blob: 1d7cd4f880b04269f5345174a95c382059cdb89d [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
68/*
69 * This overhead is time for sending NOA start to host in case of GO/sending
70 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
71 * with init scan req/rsp plus in case of concurrency, taking care of sending
72 * null data and receiving ACK to/from AP/Also SetChannel with calibration
73 * is taking around 7ms .
74 */
75#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
76#define JOIN_NOA_DURATION 2000 /* in msecs */
77#define OEM_DATA_NOA_DURATION 60 /* in msecs */
78#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
79
80#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
81
Paul Zhangd2315472017-02-22 10:02:50 +080082#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
83#define STA_BURST_SCAN_DURATION 120 /* in msecs */
84
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085/* SME REQ processing function templates */
86static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080087static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
88 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
93static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
94static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
95static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080096static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
97 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053098static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
99 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
101 uint32_t *pMsg);
102static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
103static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
104static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
105static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
106
107static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
108 uint8_t **pDstData_buff,
109 uint16_t *pDstDataLen,
110 uint8_t *pSrcData_buff,
111 uint16_t srcDataLen);
112
113static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
114 uint8_t **pDstData_buff,
115 uint16_t *pDstDataLen,
116 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800117static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
118 uint8_t **pDstData_buff,
119 uint16_t *pDstDataLen,
120 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
122
123static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
124
Abhishek Singh518323d2015-10-19 17:42:01 +0530125static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
126 uint32_t *msg);
127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128/**
129 * lim_process_set_hw_mode() - Send set HW mode command to WMA
130 * @mac: Globacl MAC pointer
131 * @msg: Message containing the hw mode index
132 *
133 * Send the set HW mode command to WMA
134 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530135 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530137static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530139 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700140 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800141 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 uint32_t len;
143 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700144 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145 struct sir_set_hw_mode_resp *param;
146
147 buf = (struct s_sir_set_hw_mode *) msg;
148 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700149 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 /* To free the active command list */
151 goto fail;
152 }
153
154 len = sizeof(*req_msg);
155
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530156 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700158 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 /* Free the active command list
160 * Probably the malloc is going to fail there as well?!
161 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530162 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 }
164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530166 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 /* Other parameters are not needed for WMA */
168
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800169 message.bodyptr = req_msg;
170 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700172 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800173 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530174 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700175 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 goto fail;
179 }
180 return status;
181fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530182 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700184 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530185 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 }
187 param->status = SET_HW_MODE_STATUS_ECANCELED;
188 param->cfgd_hw_mode_index = 0;
189 param->num_vdev_mac_entries = 0;
190 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
191 resp_msg.bodyptr = param;
192 resp_msg.bodyval = 0;
193 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530194 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195}
196
197/**
198 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
199 * @mac: Global MAC pointer
200 * @msg: Message containing the dual mac config parameter
201 *
202 * Send the set dual mac config command to WMA
203 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530206static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 uint32_t *msg)
208{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530209 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700210 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 struct sir_dual_mac_config *req_msg;
212 uint32_t len;
213 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700214 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215 struct sir_dual_mac_config_resp *param;
216
217 buf = (struct sir_set_dual_mac_cfg *) msg;
218 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700219 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 /* To free the active command list */
221 goto fail;
222 }
223
224 len = sizeof(*req_msg);
225
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530226 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700228 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* Free the active command list
230 * Probably the malloc is going to fail there as well?!
231 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530232 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 }
234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 req_msg->scan_config = buf->set_dual_mac.scan_config;
236 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
237 /* Other parameters are not needed for WMA */
238
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800239 message.bodyptr = req_msg;
240 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700242 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800244 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530245 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700246 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530248 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 goto fail;
250 }
251 return status;
252fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530253 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700255 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530256 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 }
258 param->status = SET_HW_MODE_STATUS_ECANCELED;
259 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
260 resp_msg.bodyptr = param;
261 resp_msg.bodyval = 0;
262 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530263 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264}
265
266/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800267 * lim_process_set_antenna_mode_req() - Set antenna mode command
268 * to WMA
269 * @mac: Global MAC pointer
270 * @msg: Message containing the antenna mode parameter
271 *
272 * Send the set antenna mode command to WMA
273 *
274 * Return: QDF_STATUS_SUCCESS if message posting is successful
275 */
276static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
277 uint32_t *msg)
278{
279 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700280 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 struct sir_antenna_mode_param *req_msg;
282 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700283 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800284 struct sir_antenna_mode_resp *param;
285
286 buf = (struct sir_set_antenna_mode *) msg;
287 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700288 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800289 /* To free the active command list */
290 goto fail;
291 }
292
293 req_msg = qdf_mem_malloc(sizeof(*req_msg));
294 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700295 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800296 return QDF_STATUS_E_NOMEM;
297 }
298
299 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
300 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
301
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800302 message.bodyptr = req_msg;
303 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800304
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700305 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800306 req_msg->num_rx_chains,
307 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800308 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800309 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700310 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 status);
312 qdf_mem_free(req_msg);
313 goto fail;
314 }
315 return status;
316fail:
317 param = qdf_mem_malloc(sizeof(*param));
318 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700319 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800320 return QDF_STATUS_E_NOMEM;
321 }
322 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
323 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
324 resp_msg.bodyptr = param;
325 resp_msg.bodyval = 0;
326 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
327 return QDF_STATUS_SUCCESS;
328}
329
330/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
332 * @mac_ctx: Pointer to Global MAC structure
333 * @return_fresh_results: Trigger fresh scan.
334 *
335 * PE will do fresh scan, if all of the active sessions are in
336 * good state (Link Est or BSS Started). If one of the sessions
337 * is not in one of the above states, then PE does not do fresh
338 * scan. If no session exists (scanning very first time),
339 * then PE will always do fresh scan if SME asks it to do that.
340 *
341 * Return: true for fresh scan results, false if in invalid state.
342 */
343static uint8_t
344__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
345{
346 uint8_t valid_state = true;
347 int i;
348
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700349
350 pe_debug("gLimSmeState: %d, returnFreshResults 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 mac_ctx->lim.gLimSmeState, return_fresh_results);
352
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700353 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355
356 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700357
358 if (mac_ctx->lim.gpSession[i].valid == false)
359 continue;
360
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700361 pe_debug("session %d, bsstype %d, limSystemRole %d, limSmeState %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 i, mac_ctx->lim.gpSession[i].bssType,
363 mac_ctx->lim.gpSession[i].limSystemRole,
364 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700365
366 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
367 continue;
368
369 if (mac_ctx->lim.gpSession[i].bssType ==
370 eSIR_INFRASTRUCTURE_MODE &&
371 mac_ctx->lim.gpSession[i].limSmeState ==
372 eLIM_SME_LINK_EST_STATE)
373 continue;
374
375 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
376 mac_ctx->lim.gpSession[i].limSmeState ==
377 eLIM_SME_NORMAL_STATE)
378 continue;
379
380 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
381 mac_ctx->lim.gpSession[i].pePersona ==
382 QDF_P2P_GO_MODE &&
383 mac_ctx->lim.gpSession[i].limSmeState ==
384 eLIM_SME_NORMAL_STATE)
385 continue;
386
387 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
388 mac_ctx->lim.gpSession[i].limSmeState ==
389 eLIM_SME_NORMAL_STATE)
390 continue;
391
392 valid_state = false;
393 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 }
395
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700396 pe_debug("valid_state: %d", valid_state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397
398 if ((valid_state) &&
399 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
400 return true;
401 else
402 return false;
403}
404
405/**
406 * __lim_is_sme_assoc_cnf_valid()
407 *
408 ***FUNCTION:
409 * This function is called by __lim_process_sme_assoc_cnf_new() upon
410 * receiving SME_ASSOC_CNF.
411 *
412 ***LOGIC:
413 * Message validity checks are performed in this function
414 *
415 ***ASSUMPTIONS:
416 *
417 ***NOTE:
418 *
419 * @param pMeasReq Pointer to Received ASSOC_CNF message
420 * @return true When received SME_ASSOC_CNF is formatted
421 * correctly
422 * false otherwise
423 */
424
425static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
426{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530427 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 return false;
429 else
430 return true;
431} /*** end __lim_is_sme_assoc_cnf_valid() ***/
432
433/**
434 * __lim_get_sme_join_req_size_for_alloc()
435 *
436 ***FUNCTION:
437 * This function is called in various places to get IE length
438 * from tSirBssDescription structure
439 * number being scanned.
440 *
441 ***PARAMS:
442 *
443 ***LOGIC:
444 *
445 ***ASSUMPTIONS:
446 * NA
447 *
448 ***NOTE:
449 * NA
450 *
451 * @param pBssDescr
452 * @return Total IE length
453 */
454
455static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
456{
457 uint16_t len = 0;
458
459 if (!pBuf)
460 return len;
461
462 pBuf += sizeof(uint16_t);
463 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700464 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465}
466
467/**
468 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
469 * @pMac: Global MAC context
470 * @pMsg: Pointer to message posted from SME to LIM.
471 *
472 * Has role only if 11h is enabled. Not used on STA side.
473 * Defers the message if SME is in learn state and brings
474 * the LIM back to normal mode.
475 *
476 * Return: true - If defered false - Otherwise
477 */
478
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800479static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
480 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481{
482 if (lim_is_system_in_scan_state(pMac)) {
483 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700484 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 return false;
486 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700487 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 pMsg->type);
489 return true;
490 }
491 return false;
492}
493
494/**
495 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
496 * @mac_ctx: Pointer to Global MAC structure
497 * @message: Pointer to message posted from SME to LIM.
498 *
499 * Has role only if 11h is enabled. Not used on STA side.
500 * Defers the message if radar is detected.
501 *
502 * Return: true, if defered otherwise return false.
503 */
504static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800505__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
506 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507{
508 /*
509 * fRadarDetCurOperChan will be set only if we
510 * detect radar in current operating channel and
511 * System Role == AP ROLE
512 *
513 * TODO: Need to take care radar detection.
514 *
515 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
516 */
517 if (0) {
518 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700519 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520 return false;
521 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700522 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 message->type);
524 return true;
525 }
526 return false;
527}
528
529/**
530 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
531 * @pMac: Global MAC context
532 * @pMsgBuf: Message from WMA
533 *
534 * handles the notification from HDD. PE just forwards this message to HAL.
535 *
536 * Return: true-Posting to HAL failed, so PE will consume the buffer.
537 * false-Posting to HAL successful, so HAL will consume the buffer.
538 */
539
540static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
541{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700542 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
544
545 msg.type = WMA_SYS_READY_IND;
546 msg.reserved = 0;
547 msg.bodyptr = pMsgBuf;
548 msg.bodyval = 0;
549
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700550 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800551 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530552 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700553 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
555 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700556
557 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
559
560 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700561 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 return true;
563 }
564 return false;
565}
566
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567/**
568 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
569 *@mac_ctx: Pointer to Global MAC structure
570 *@session: A pointer to session entry
571 *@sme_start_bss_req: Start BSS Request from upper layers.
572 *
573 * This function is used to configure the start bss parameters
574 * in to the session.
575 *
576 * Return: None.
577 */
578static void
579lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
580 tpSirSmeStartBssReq sme_start_bss_req)
581{
582 session->limSystemRole = eLIM_AP_ROLE;
583 session->privacy = sme_start_bss_req->privacy;
584 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
585 session->authType = sme_start_bss_req->authType;
586 /* Store the DTIM period */
587 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
588 /* Enable/disable UAPSD */
589 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530590 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 session->proxyProbeRspEn = 0;
592 } else {
593 /*
594 * To detect PBC overlap in SAP WPS mode,
595 * Host handles Probe Requests.
596 */
597 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
598 session->proxyProbeRspEn = 1;
599 else
600 session->proxyProbeRspEn = 0;
601 }
602 session->ssidHidden = sme_start_bss_req->ssidHidden;
603 session->wps_state = sme_start_bss_req->wps_state;
604 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530605 session->vendor_vht_sap =
606 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
608 &session->shortSlotTimeSupported);
609 session->isCoalesingInIBSSAllowed =
610 sme_start_bss_req->isCoalesingInIBSSAllowed;
611
612}
613
614/**
615 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
616 *@mac_ctx: Pointer to Global MAC structure
617 *@msg_buf: A pointer to the SME message buffer
618 *
619 * This function is called to process SME_START_BSS_REQ message
620 * from HDD or upper layer application.
621 *
622 * Return: None
623 */
624static void
625__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
626{
627 uint16_t size;
628 uint32_t val = 0;
629 tSirRetStatus ret_status;
630 tSirMacChanNum channel_number;
631 tLimMlmStartReq *mlm_start_req = NULL;
632 tpSirSmeStartBssReq sme_start_bss_req = NULL;
633 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
634 /* Flag Used in case of IBSS to Auto generate BSSID. */
635 uint32_t auto_gen_bssid = false;
636 uint8_t session_id;
637 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800638 uint8_t sme_session_id = 0xFF;
639 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700641 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
643
644/* FEATURE_WLAN_DIAG_SUPPORT */
645#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
646 /*
647 * Since the session is not created yet, sending NULL.
648 * The response should have the correct state.
649 */
650 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
651 NULL, 0, 0);
652#endif /* FEATURE_WLAN_DIAG_SUPPORT */
653
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700654 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800655 size = sizeof(tSirSmeStartBssReq);
656 sme_start_bss_req = qdf_mem_malloc(size);
657 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700658 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800659 /* Send failure response to host */
660 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
661 goto free;
662 }
663 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
664 sme_session_id = sme_start_bss_req->sessionId;
665 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
668 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
670 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700671 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 ret_code = eSIR_SME_INVALID_PARAMETERS;
673 goto free;
674 }
675
676 /*
677 * This is the place where PE is going to create a session.
678 * If session is not existed, then create a new session
679 */
680 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800681 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700683 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
685 session = NULL;
686 goto free;
687 } else {
688 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800689 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690 &session_id, mac_ctx->lim.maxStation,
691 sme_start_bss_req->bssType);
692 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700693 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
695 goto free;
696 }
697 }
698
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700699 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
700 /* Probe resp add ie */
701 lim_start_bss_update_add_ie_buffer(mac_ctx,
702 &session->addIeParams.probeRespData_buff,
703 &session->addIeParams.probeRespDataLen,
704 sme_start_bss_req->addIeParams.
705 probeRespData_buff,
706 sme_start_bss_req->addIeParams.
707 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700709 /* Probe Beacon add ie */
710 lim_start_bss_update_add_ie_buffer(mac_ctx,
711 &session->addIeParams.probeRespBCNData_buff,
712 &session->addIeParams.probeRespBCNDataLen,
713 sme_start_bss_req->addIeParams.
714 probeRespBCNData_buff,
715 sme_start_bss_req->addIeParams.
716 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700718 /* Assoc resp IE */
719 lim_start_bss_update_add_ie_buffer(mac_ctx,
720 &session->addIeParams.assocRespData_buff,
721 &session->addIeParams.assocRespDataLen,
722 sme_start_bss_req->addIeParams.
723 assocRespData_buff,
724 sme_start_bss_req->addIeParams.
725 assocRespDataLen);
726 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 /* Store the session related params in newly created session */
728 session->pLimStartBssReq = sme_start_bss_req;
729
730 /* Store PE session_id in session Table */
731 session->peSessionId = session_id;
732
733 /* Store SME session Id in sessionTable */
734 session->smeSessionId = sme_start_bss_req->sessionId;
735
736 session->transactionId = sme_start_bss_req->transactionId;
737
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530738 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 &(sme_start_bss_req->htConfig),
740 sizeof(session->htConfig));
741
Sandeep Puligilla98917432016-06-10 13:50:28 -0700742 qdf_mem_copy(&(session->vht_config),
743 &(sme_start_bss_req->vht_config),
744 sizeof(session->vht_config));
745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800747 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748
749 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530750 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 (uint8_t *) &sme_start_bss_req->ssId,
752 (sme_start_bss_req->ssId.length + 1));
753
754 session->bssType = sme_start_bss_req->bssType;
755
756 session->nwType = sme_start_bss_req->nwType;
757
758 session->beaconParams.beaconInterval =
759 sme_start_bss_req->beaconInterval;
760
761 /* Store the channel number in session Table */
762 session->currentOperChannel =
763 sme_start_bss_req->channelId;
764
765 /* Store Persona */
766 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530767 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 FL("PE PERSONA=%d"), session->pePersona);
769
770 /* Update the phymode */
771 session->gLimPhyMode = sme_start_bss_req->nwType;
772
773 session->maxTxPower =
774 cfg_get_regulatory_max_transmit_power(mac_ctx,
775 session->currentOperChannel);
776 /* Store the dot 11 mode in to the session Table */
777 session->dot11mode = sme_start_bss_req->dot11mode;
778#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
779 session->cc_switch_mode =
780 sme_start_bss_req->cc_switch_mode;
781#endif
782 session->htCapability =
783 IS_DOT11_MODE_HT(session->dot11mode);
784 session->vhtCapability =
785 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800786
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700787 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800788 session->htCapability, session->vhtCapability);
789
790 if (IS_DOT11_MODE_HE(session->dot11mode)) {
791 lim_update_session_he_capable(mac_ctx, session);
792 lim_copy_bss_he_cap(session, sme_start_bss_req);
793 }
794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 session->txLdpcIniFeatureEnabled =
796 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797#ifdef WLAN_FEATURE_11W
798 session->limRmfEnabled =
799 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700800 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801#endif
802
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530803 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 (void *)&sme_start_bss_req->operationalRateSet,
805 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530806 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 (void *)&sme_start_bss_req->extendedRateSet,
808 sizeof(tSirMacRateSet));
809
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700810 if (IS_5G_CH(session->currentOperChannel))
811 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
812 else
813 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 switch (sme_start_bss_req->bssType) {
816 case eSIR_INFRA_AP_MODE:
817 lim_configure_ap_start_bss_session(mac_ctx, session,
818 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700819 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700820 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700821 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700822 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 break;
824 case eSIR_IBSS_MODE:
825 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
826 lim_get_short_slot_from_phy_mode(mac_ctx, session,
827 session->gLimPhyMode,
828 &session->shortSlotTimeSupported);
829
830 /*
831 * initialize to "OPEN".
832 * will be updated upon key installation
833 */
834 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700835 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836
837 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700838 case eSIR_NDI_MODE:
839 session->limSystemRole = eLIM_NDI_ROLE;
840 break;
841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 /*
844 * There is one more mode called auto mode.
845 * which is used no where
846 */
847
848 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
849
850 default:
851 /* not used anywhere...used in scan function */
852 break;
853 }
854
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700855 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700856 session->pePersona, session->vdev_nss);
857 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700859 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 * parsed (Re)Assoc request structure
861 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700862 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530864 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700865 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700867 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
869 goto free;
870 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 }
872
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700873 if (!sme_start_bss_req->channelId &&
874 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700875 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 ret_code = eSIR_SME_INVALID_PARAMETERS;
877 goto free;
878 }
879 channel_number = sme_start_bss_req->channelId;
880#ifdef QCA_HT_2040_COEX
881 if (sme_start_bss_req->obssEnabled)
882 session->htSupportedChannelWidthSet =
883 session->htCapability;
884 else
885#endif
886 session->htSupportedChannelWidthSet =
887 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
888 session->htSecondaryChannelOffset =
889 sme_start_bss_req->sec_ch_offset;
890 session->htRecommendedTxWidthSet =
891 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530892 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800894 if (lim_is_session_he_capable(session) ||
895 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700897 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800898 sme_start_bss_req->vht_channel_width,
899 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 session->ch_width = chanwidth;
901 if (session->htSupportedChannelWidthSet) {
902 session->ch_center_freq_seg0 =
903 sme_start_bss_req->center_freq_seg0;
904 session->ch_center_freq_seg1 =
905 sme_start_bss_req->center_freq_seg1;
906 } else {
907 session->ch_center_freq_seg0 = 0;
908 session->ch_center_freq_seg1 = 0;
909 }
910 }
911
912 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800913 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700915 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700917 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700918 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919
920 /* Delete pre-auth list if any */
921 lim_delete_pre_auth_list(mac_ctx);
922
Krunal Soni53993f72016-07-08 18:20:03 -0700923 if (session->nss == 1) {
924 session->vht_config.su_beam_former = 0;
925 session->vht_config.tx_stbc = 0;
926 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530927 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700928 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 /*
930 * keep the RSN/WPA IE information in PE Session Entry
931 * later will be using this to check when received (Re)Assoc req
932 */
933 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
934 &sme_start_bss_req->rsnIE, session);
935
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700936 if (LIM_IS_AP_ROLE(session) ||
937 LIM_IS_IBSS_ROLE(session) ||
938 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 session->gLimProtectionControl =
940 sme_start_bss_req->protEnabled;
941 /*
942 * each byte will have the following info
943 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
944 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
945 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530946 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 (void *)&sme_start_bss_req->ht_capab,
948 sizeof(uint16_t));
949 /* Initialize WPS PBC session link list */
950 session->pAPWPSPBCSession = NULL;
951 }
952 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530953 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700955 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
957 goto free;
958 }
959
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530961 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 (uint8_t *) &sme_start_bss_req->ssId,
963 sme_start_bss_req->ssId.length + 1);
964 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
965 mlm_start_req->obssProtEnabled =
966 sme_start_bss_req->obssProtEnabled;
967
968 mlm_start_req->bssType = session->bssType;
969
970 /* Fill PE session Id from the session Table */
971 mlm_start_req->sessionId = session->peSessionId;
972
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700973 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
974 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 /*
976 * Copy the BSSId from sessionTable to
977 * mlmStartReq struct
978 */
979 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
980 } else {
981 /* ibss mode */
982 mac_ctx->lim.gLimIbssCoalescingHappened = false;
983
984 ret_status = wlan_cfg_get_int(mac_ctx,
985 WNI_CFG_IBSS_AUTO_BSSID,
986 &auto_gen_bssid);
987 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700988 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 ret_status);
990 ret_code = eSIR_LOGP_EXCEPTION;
991 goto free;
992 }
993
994 if (!auto_gen_bssid) {
995 /*
996 * We're not auto generating BSSID.
997 * Instead, get it from session entry
998 */
999 sir_copy_mac_addr(mlm_start_req->bssId,
1000 session->bssId);
1001 /*
1002 * Start IBSS group BSSID
1003 * Auto Generating BSSID.
1004 */
1005 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1006 0x01) ? true : false);
1007 }
1008
1009 if (auto_gen_bssid) {
1010 /*
1011 * if BSSID is not any uc id.
1012 * then use locally generated BSSID.
1013 * Autogenerate the BSSID
1014 */
1015 lim_get_random_bssid(mac_ctx,
1016 mlm_start_req->bssId);
1017 mlm_start_req->bssId[0] = 0x02;
1018
1019 /*
1020 * Copy randomly generated BSSID
1021 * to the session Table
1022 */
1023 sir_copy_mac_addr(session->bssId,
1024 mlm_start_req->bssId);
1025 }
1026 }
1027 /* store the channel num in mlmstart req structure */
1028 mlm_start_req->channelNumber = session->currentOperChannel;
1029 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1030 mlm_start_req->beaconPeriod =
1031 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -07001032 mlm_start_req->cac_duration_ms =
1033 sme_start_bss_req->cac_duration_ms;
1034 mlm_start_req->dfs_regdomain =
1035 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 if (LIM_IS_AP_ROLE(session)) {
1037 mlm_start_req->dtimPeriod = session->dtimPeriod;
1038 mlm_start_req->wps_state = session->wps_state;
1039
1040 } else {
1041 if (wlan_cfg_get_int(mac_ctx,
1042 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001043 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 mlm_start_req->dtimPeriod = (uint8_t) val;
1045 }
1046
1047 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1048 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001049 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1051
1052 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1053 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001054 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1056
1057 /*
1058 * this may not be needed anymore now,
1059 * as rateSet is now included in the
1060 * session entry and MLM has session context.
1061 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301062 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 (void *)&session->rateSet,
1064 sizeof(tSirMacRateSet));
1065
1066 /* Now populate the 11n related parameters */
1067 mlm_start_req->nwType = session->nwType;
1068 mlm_start_req->htCapable = session->htCapability;
1069
1070 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1071 /* Unused */
1072 mlm_start_req->dualCTSProtection =
1073 mac_ctx->lim.gHTDualCTSProtection;
1074 mlm_start_req->txChannelWidthSet =
1075 session->htRecommendedTxWidthSet;
1076
1077 session->limRFBand = lim_get_rf_band(channel_number);
1078
1079 /* Initialize 11h Enable Flag */
1080 session->lim11hEnable = 0;
1081 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1082 (SIR_BAND_5_GHZ == session->limRFBand)) {
1083 if (wlan_cfg_get_int(mac_ctx,
1084 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001085 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 else
1087 session->lim11hEnable = val;
1088
1089 if (session->lim11hEnable &&
1090 (eSIR_INFRA_AP_MODE ==
1091 mlm_start_req->bssType)) {
1092 cfg_get_wmi_dfs_master_param =
1093 wlan_cfg_get_int(mac_ctx,
1094 WNI_CFG_DFS_MASTER_ENABLED,
1095 &val);
1096 session->lim11hEnable = val;
1097 }
1098 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1099 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001100 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 }
1102
1103 if (!session->lim11hEnable) {
1104 if (cfg_set_int(mac_ctx,
1105 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1106 eSIR_SUCCESS)
1107 /*
1108 * Failed to set the CFG param
1109 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1110 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001111 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 }
1113
1114 session->limPrevSmeState = session->limSmeState;
1115 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1116 MTRACE(mac_trace
1117 (mac_ctx, TRACE_CODE_SME_STATE,
1118 session->peSessionId,
1119 session->limSmeState));
1120
1121 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1122 (uint32_t *) mlm_start_req);
1123 return;
1124 } else {
1125
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001126 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 mac_ctx->lim.gLimSmeState);
1128 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001129 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1131
1132free:
1133 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001134 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 session->pLimStartBssReq = NULL;
1136 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001137 if (NULL != sme_start_bss_req)
1138 qdf_mem_free(sme_start_bss_req);
1139 if (NULL != mlm_start_req)
1140 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141 if (NULL != session) {
1142 pe_delete_session(mac_ctx, session);
1143 session = NULL;
1144 }
1145 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1146 session, sme_session_id, sme_transaction_id);
1147}
1148
1149/**
1150 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1151 *
1152 * @pMac: Global MAC context
1153 * @pMsg: Message pointer
1154 *
1155 * Wrapper for the function __lim_handle_sme_start_bss_request
1156 * This message will be defered until softmac come out of
1157 * scan mode or if we have detected radar on the current
1158 * operating channel.
1159 *
1160 * return true - If we consumed the buffer
1161 * false - If have defered the message.
1162 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001163static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1164 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165{
1166 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1167 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1168 /**
1169 * If message defered, buffer is not consumed yet.
1170 * So return false
1171 */
1172 return false;
1173 }
1174
1175 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1176 return true;
1177}
1178
1179/**
1180 * lim_get_random_bssid()
1181 *
1182 * FUNCTION:This function is called to process generate the random number for bssid
1183 * This function is called to process SME_SCAN_REQ message
1184 * from HDD or upper layer application.
1185 *
1186 * LOGIC:
1187 *
1188 * ASSUMPTIONS:
1189 *
1190 * NOTE:
1191 * 1. geneartes the unique random number for bssid in ibss
1192 *
1193 * @param pMac Pointer to Global MAC structure
1194 * @param *data Pointer to bssid buffer
1195 * @return None
1196 */
1197void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1198{
1199 uint32_t random[2];
1200 random[0] = tx_time_get();
1201 random[0] |= (random[0] << 15);
1202 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301203 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204}
1205
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301206static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 tpSirSmeScanReq pScanReq)
1208{
1209 tSirScanOffloadReq *pScanOffloadReq;
1210 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001211 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001213 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 tSirRetStatus status, rc = eSIR_SUCCESS;
1215 tDot11fIEExtCap extracted_extcap = {0};
1216 bool extcap_present = true;
1217
1218 if (pScanReq->uIEFieldLen) {
1219 status = lim_strip_extcap_update_struct(pMac,
1220 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1221 &pScanReq->uIEFieldLen, &extracted_extcap);
1222
1223 if (eSIR_SUCCESS != status) {
1224 extcap_present = false;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001225 pe_debug("Unable to Strip ExtCap IE from Scan Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 }
1227
1228 if (extcap_present) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001229 pe_debug("Extcap was part of SCAN IE - Updating FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1231 &extracted_extcap, true);
1232 }
1233 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001234 pe_debug("No IEs in the scan request from supplicant");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 }
1236
1237 /**
1238 * The tSirScanOffloadReq will reserve the space for first channel,
1239 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1240 */
1241 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001242 (pScanReq->channelList.numChannels - 1) +
1243 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001244
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301245 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 if (NULL == pScanOffloadReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001247 pe_err("AllocateMemory failed for pScanOffloadReq");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301248 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 }
1250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1252 msg.bodyptr = pScanOffloadReq;
1253 msg.bodyval = 0;
1254
Anurag Chouhanc5548422016-02-24 18:33:27 +05301255 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256
1257 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001258 pe_err("Invalid value (%d) for numSsid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301260 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301261 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 }
1263
1264 pScanOffloadReq->numSsid = pScanReq->numSsid;
1265 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1266 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301267 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 (uint8_t *) pScanReq->ssId[i].ssId,
1269 pScanOffloadReq->ssId[i].length);
1270 }
1271
1272 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301273 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 pScanOffloadReq->bssType = pScanReq->bssType;
1275 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1276 pScanOffloadReq->scanType = pScanReq->scanType;
1277 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1278 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1279 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301280 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1281 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301282 pScanOffloadReq->scan_adaptive_dwell_mode =
1283 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284
Paul Zhangd2315472017-02-22 10:02:50 +08001285 for (i = 0; i < pMac->lim.maxBssId; i++) {
1286 tpPESession session_entry =
1287 pe_find_session_by_sme_session_id(pMac, i);
1288 if (session_entry &&
1289 (eLIM_MLM_LINK_ESTABLISHED_STATE ==
1290 session_entry->limMlmState) &&
1291 (session_entry->beaconParams.beaconInterval
1292 < BEACON_INTERVAL_THRESHOLD)) {
1293 pScanOffloadReq->burst_scan_duration =
1294 STA_BURST_SCAN_DURATION;
1295 break;
1296 }
1297 }
1298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 /* for normal scan, the value for p2pScanType should be 0
1300 always */
1301 if (pScanReq->p2pSearch)
1302 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1303
1304 pScanOffloadReq->sessionId = pScanReq->sessionId;
1305 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001306 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301307 pScanOffloadReq->scan_adaptive_dwell_mode =
1308 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309
1310 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001311 pe_err("Invalid pe sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 pScanOffloadReq->sessionId);
1313
1314 pScanOffloadReq->channelList.numChannels =
1315 pScanReq->channelList.numChannels;
1316 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1317 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1318 p[i] = pScanReq->channelList.channelNumber[i];
1319
1320 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1321 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1322 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301323 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 pScanOffloadReq->uIEFieldOffset,
1325 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1326 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001327
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 rc = wma_post_ctrl_msg(pMac, &msg);
1329 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001330 pe_err("wma_post_ctrl_msg() return failure");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301331 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301332 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 }
1334
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001335 pe_debug("Processed Offload Scan Request Successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301337 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338}
1339
1340/**
1341 * __lim_process_sme_scan_req() - Process the SME Scan Request
1342 * @mac_ctx: Global MAC Context
1343 * @msg_buf: Buffer which contains the request and pertinent parameters
1344 *
1345 * This function is called to process SME_SCAN_REQ message
1346 * from HDD or upper layer application.
1347 *
1348 * Return: None
1349 */
1350
1351static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1352 uint32_t *msg_buf)
1353{
1354 tpSirSmeScanReq scan_req;
1355 uint8_t valid_req = 0;
1356
1357#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1358 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1359 eSIR_SUCCESS, eSIR_SUCCESS);
1360#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301361 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362
1363 scan_req = (tpSirSmeScanReq) msg_buf;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001364 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 -08001365 scan_req->scan_id, scan_req->channelList.numChannels,
1366 scan_req->minChannelTime, scan_req->maxChannelTime,
1367 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1368 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301369 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1371 /*
1372 * Since scan req always requires a response, we will overwrite response
1373 * required here. This is added esp to take care of the condition where
1374 * in p2p go case, we hold the scan req and insert single NOA. We send
1375 * the held scan request to FW later on getting start NOA ind from FW so
1376 * we lose state of the gLimRspReqd flag for the scan req if any other
1377 * request comes by then. e.g. While unit testing, we found when insert
1378 * single NOA is done, we see a get stats request which turns the flag
1379 * gLimRspReqd to false; now when we actually start the saved scan req
1380 * for init scan after getting NOA started, the gLimRspReqd being a
1381 * global flag is showing false instead of true value for this saved
1382 * scan req. Since all scan reqs coming to lim require a response,
1383 * there is no harm in setting the global flag gLimRspReqd to true here.
1384 */
1385 mac_ctx->lim.gLimRspReqd = true;
1386
1387 /*
1388 * copy the Self MAC address from SmeReq to the globalplace,
1389 * used for sending probe req
1390 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001391 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1392 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1394
1395 if (!valid_req || mac_ctx->lim.scan_disabled) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001396 pe_err("Scan disabled %d, Valid Scan Req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 mac_ctx->lim.scan_disabled, valid_req);
1398
1399 if (mac_ctx->lim.gLimRspReqd) {
1400 mac_ctx->lim.gLimRspReqd = false;
1401
1402 lim_send_sme_scan_rsp(mac_ctx,
1403 eSIR_SME_INVALID_PARAMETERS,
1404 scan_req->sessionId,
1405 scan_req->transactionId,
1406 scan_req->scan_id);
1407 }
1408 return;
1409 }
1410
1411 /*
1412 * If scan request is received in idle, joinFailed
1413 * states or in link established state (in STA role)
1414 * or in normal state (in STA-in-IBSS/AP role) with
1415 * 'return fresh scan results' request from HDD or
1416 * it is periodic background scanning request,
1417 * trigger fresh scan request to MLM
1418 */
1419 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1420
1421 mac_ctx->lim.gLim24Band11dScanDone = 0;
1422 mac_ctx->lim.gLim50Band11dScanDone = 0;
1423 mac_ctx->lim.gLimReturnAfterFirstMatch =
1424 scan_req->returnAfterFirstMatch;
1425 mac_ctx->lim.gLimReturnUniqueResults =
1426 ((scan_req->returnUniqueResults) > 0 ? true : false);
1427
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301428 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 lim_send_hal_start_scan_offload_req(mac_ctx,
1430 scan_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001431 pe_err("Couldn't send Offload scan request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 lim_send_sme_scan_rsp(mac_ctx,
1433 eSIR_SME_INVALID_PARAMETERS,
1434 scan_req->sessionId,
1435 scan_req->transactionId,
1436 scan_req->scan_id);
1437 return;
1438 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301439 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 /* In all other cases return 'cached' scan results */
1441 if (mac_ctx->lim.gLimRspReqd) {
1442 mac_ctx->lim.gLimRspReqd = false;
1443 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1444 scan_req->sessionId,
1445 scan_req->transactionId, scan_req->scan_id);
1446 }
1447 }
1448}
1449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450/**
1451 * __lim_process_clear_dfs_channel_list()
1452 *
1453 ***FUNCTION:
1454 ***Clear DFS channel list when country is changed/aquired.
1455 .*This message is sent from SME.
1456 *
1457 ***LOGIC:
1458 *
1459 ***ASSUMPTIONS:
1460 *
1461 ***NOTE:
1462 *
1463 * @param pMac Pointer to Global MAC structure
1464 * @param *pMsgBuf A pointer to the SME message buffer
1465 * @return None
1466 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001467static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1468 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301470 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471}
1472
1473/**
1474 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1475 * @mac_ctx: Pointer to Global MAC structure
1476 * @msg_buf: A pointer to the SME message buffer
1477 *
1478 * This function is called to process SME_JOIN_REQ message
1479 * from HDD or upper layer application.
1480 *
1481 * Return: None
1482 */
1483static void
1484__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1485{
1486 tpSirSmeJoinReq sme_join_req = NULL;
1487 tLimMlmJoinReq *mlm_join_req;
1488 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1489 uint32_t val = 0;
1490 uint16_t n_size;
1491 uint8_t session_id;
1492 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301493 uint8_t sme_session_id = 0;
1494 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001495 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 uint16_t ie_len;
1497 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001498 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001499 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500
Arif Hussain995fcaf2016-07-18 11:28:22 -07001501 if (!mac_ctx || !msg_buf) {
1502 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1503 FL("JOIN REQ with invalid data"));
1504 return;
1505 }
1506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507/* FEATURE_WLAN_DIAG_SUPPORT */
1508#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1509 /*
1510 * Not sending any session, since it is not created yet.
1511 * The response whould have correct state.
1512 */
1513 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1514#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 /*
1517 * Expect Join request in idle state.
1518 * Reassociate request is expected in link established state.
1519 */
1520
1521 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1522 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1523 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1524 msg_buf);
1525
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301526 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001528 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301530 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301532 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 n_size);
1534
1535 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1536 /* Received invalid eWNI_SME_JOIN_REQ */
1537 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001538 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 sme_join_req->sessionId);
1540 ret_code = eSIR_SME_INVALID_PARAMETERS;
1541 goto end;
1542 }
1543
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001544 /*
1545 * Update the capability here itself as this is used in
1546 * lim_extract_ap_capability() below. If not updated issues
1547 * like not honoring power constraint on 1st association after
1548 * driver loading might occur.
1549 */
1550 lim_update_rrm_capability(mac_ctx, sme_join_req);
1551
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001552 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001554 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 &session_id);
1556
1557 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001558 pe_err("Session(%d) Already exists for BSSID: "
1559 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001561 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 session->limSmeState);
1563
1564 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1565 session->smeSessionId == sme_join_req->sessionId) {
1566 /*
1567 * Received eWNI_SME_JOIN_REQ for same
1568 * BSS as currently associated.
1569 * Log the event and send success
1570 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001571 pe_warn("SessionId: %d", session_id);
1572 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 /* Send Join success response to host */
1574 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1575 session = NULL;
1576 goto end;
1577 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001578 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 ret_code = eSIR_SME_REFUSED;
1580 session = NULL;
1581 goto end;
1582 }
1583 } else {
1584 /*
1585 * Session Entry does not exist for given BSSId
1586 * Try to Create a new session
1587 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001588 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 &session_id, mac_ctx->lim.maxStation,
1590 eSIR_INFRASTRUCTURE_MODE);
1591 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001592 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1594 goto end;
1595 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001596 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 session_id);
1598 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001599 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600
1601 /*
1602 * Store Session related parameters
1603 * Store PE session Id in session Table
1604 */
1605 session->peSessionId = session_id;
1606
1607 /* store the smejoin req handle in session table */
1608 session->pLimJoinReq = sme_join_req;
1609
1610 /* Store SME session Id in sessionTable */
1611 session->smeSessionId = sme_join_req->sessionId;
1612
1613 /* Store SME transaction Id in session Table */
1614 session->transactionId = sme_join_req->transactionId;
1615
1616 /* Store beaconInterval */
1617 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001618 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301620 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 sizeof(session->htConfig));
1622
Sandeep Puligilla98917432016-06-10 13:50:28 -07001623 qdf_mem_copy(&(session->vht_config),
1624 &(sme_join_req->vht_config),
1625 sizeof(session->vht_config));
1626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 /* Copying of bssId is already done, while creating session */
1628 sir_copy_mac_addr(session->selfMacAddr,
1629 sme_join_req->selfMacAddr);
1630 session->bssType = sme_join_req->bsstype;
1631
1632 session->statypeForBss = STA_ENTRY_PEER;
1633 session->limWmeEnabled = sme_join_req->isWMEenabled;
1634 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301635 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301637 session->enable_bcast_probe_rsp =
1638 sme_join_req->enable_bcast_probe_rsp;
1639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001641 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1643
1644 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1645 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001646 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647
1648 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001649 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 session->isCiscoVendorAP = true;
1651 } else {
1652 session->isCiscoVendorAP = false;
1653 }
1654
1655 /* Copy the dot 11 mode in to the session table */
1656
1657 session->dot11mode = sme_join_req->dot11mode;
1658#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1659 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1660#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001661 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1663 session->enableHtSmps = sme_join_req->enableHtSmps;
1664 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001665 session->send_smps_action =
1666 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001667 /*
1668 * By default supported NSS 1x1 is set to true
1669 * and later on updated while determining session
1670 * supported rates which is the intersection of
1671 * self and peer rates
1672 */
1673 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301674 /*Store Persona */
1675 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001676 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 -08001677 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001678 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001679 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301680 session->supported_nss_1x1,
1681 session->pePersona,
1682 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001683
1684 /*Store Persona */
1685 session->pePersona = sme_join_req->staPersona;
1686 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001687 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d"),
1688 session->pePersona, sme_join_req->cbMode,
1689 session->nwType, session->dot11mode);
1690
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001691 /* Copy The channel Id to the session Table */
1692 session->currentOperChannel = bss_desc->channelId;
1693 if (IS_5G_CH(session->currentOperChannel))
1694 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001696 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1697 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1698 session->vdev_nss = vdev_type_nss->p2p_cli;
1699 else
1700 session->vdev_nss = vdev_type_nss->sta;
1701 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 session->vhtCapability =
1703 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301705 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001706 session->vht_config.su_beam_formee =
1707 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001709 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 session->enableVhtpAid =
1712 sme_join_req->enableVhtpAid;
1713 session->enableVhtGid =
1714 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001715 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001716 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 }
Krunal Soni53993f72016-07-08 18:20:03 -07001718
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001719 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1720 lim_update_session_he_capable(mac_ctx, session);
1721 lim_copy_join_req_he_cap(session, sme_join_req);
1722 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001723
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001724 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301725 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001726 session->vht_config.su_beam_formee,
1727 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001728 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001730 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 /* cbMode is already merged value of peer and self -
1733 * done by csr in csr_get_cb_mode_from_ies */
1734 session->htSupportedChannelWidthSet =
1735 (sme_join_req->cbMode) ? 1 : 0;
1736 session->htRecommendedTxWidthSet =
1737 session->htSupportedChannelWidthSet;
1738 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1739
1740 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1741 session->ch_center_freq_seg0 =
1742 session->currentOperChannel - 2;
1743 session->ch_width = CH_WIDTH_40MHZ;
1744 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1745 sme_join_req->cbMode) {
1746 session->ch_center_freq_seg0 =
1747 session->currentOperChannel + 2;
1748 session->ch_width = CH_WIDTH_40MHZ;
1749 } else {
1750 session->ch_center_freq_seg0 = 0;
1751 session->ch_width = CH_WIDTH_20MHZ;
1752 }
1753
1754 /* Record if management frames need to be protected */
1755#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001756 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001758 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760#endif
1761
1762#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001763 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764#endif
1765
1766 /* Copy the SSID from smejoinreq to session entry */
1767 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301768 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 session->ssId.length);
1770
1771 /*
1772 * Determin 11r or ESE connection based on input from SME
1773 * which inturn is dependent on the profile the user wants
1774 * to connect to, So input is coming from supplicant
1775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777#ifdef FEATURE_WLAN_ESE
1778 session->isESEconnection = sme_join_req->isESEconnection;
1779#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 session->isFastTransitionEnabled =
1781 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 session->isFastRoamIniFeatureEnabled =
1784 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 session->txLdpcIniFeatureEnabled =
1786 sme_join_req->txLdpcIniFeatureEnabled;
1787
1788 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1789 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 } else {
1791 /*
1792 * Throw an error and return and make
1793 * sure to delete the session.
1794 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001795 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 session->bssType);
1797 ret_code = eSIR_SME_INVALID_PARAMETERS;
1798 goto end;
1799 }
1800
1801 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301802 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 &sme_join_req->addIEScan, sizeof(tSirAddie));
1804
1805 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301806 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1808
1809 val = sizeof(tLimMlmJoinReq) +
1810 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301811 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001813 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301814 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1815 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001816 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817
1818 /* PE SessionId is stored as a part of JoinReq */
1819 mlm_join_req->sessionId = session->peSessionId;
1820
1821 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1822 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1823 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001824 pe_err("couldn't retrieve JoinFailureTimer value"
1825 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 mlm_join_req->joinFailureTimeout =
1827 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1828 }
1829
1830 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301831 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 (void *)&sme_join_req->operationalRateSet,
1833 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301834 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 (void *)&sme_join_req->extendedRateSet,
1836 sizeof(tSirMacRateSet));
1837 /*
1838 * this may not be needed anymore now, as rateSet is now
1839 * included in the session entry and MLM has session context.
1840 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301841 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 (void *)&session->rateSet,
1843 sizeof(tSirMacRateSet));
1844
1845 session->encryptType = sme_join_req->UCEncryptionType;
1846
1847 mlm_join_req->bssDescription.length =
1848 session->pLimJoinReq->bssDescription.length;
1849
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301850 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 (uint8_t *)
1852 &session->pLimJoinReq->bssDescription.bssId,
1853 session->pLimJoinReq->bssDescription.length + 2);
1854
1855 session->limCurrentBssCaps =
1856 session->pLimJoinReq->bssDescription.capabilityInfo;
1857
1858 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1859 session->currentOperChannel);
1860 local_power_constraint = reg_max;
1861
1862 lim_extract_ap_capability(mac_ctx,
1863 (uint8_t *)
1864 session->pLimJoinReq->bssDescription.ieFields,
1865 lim_get_ielen_from_bss_description(
1866 &session->pLimJoinReq->bssDescription),
1867 &session->limCurrentBssQosCaps,
1868 &session->limCurrentBssPropCap,
1869 &session->gLimCurrentBssUapsd,
1870 &local_power_constraint, session);
1871
Krunal Soni53993f72016-07-08 18:20:03 -07001872 /*
1873 * Once the AP capabilities are available then set the
1874 * beam forming capabilities accordingly.
1875 */
1876 if (session->nss == 1) {
1877 session->vht_config.su_beam_former = 0;
1878 session->vht_config.tx_stbc = 0;
1879 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301880 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001881 }
1882
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 session->maxTxPower = lim_get_max_tx_power(reg_max,
1884 local_power_constraint,
1885 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301886
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001887 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301888 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301890 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1891 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1892 pe_debug("Update MaxTxPower in join Req to %d",
1893 sme_join_req->powerCap.maxTxPower);
1894 }
1895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 if (session->gLimCurrentBssUapsd) {
1897 session->gUapsdPerAcBitmask =
1898 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001899 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 session->gUapsdPerAcBitmask);
1901
1902 /* resetting the dynamic uapsd mask */
1903 session->gUapsdPerAcDeliveryEnableMask = 0;
1904 session->gUapsdPerAcTriggerEnableMask = 0;
1905 }
1906
1907 session->limRFBand =
1908 lim_get_rf_band(session->currentOperChannel);
1909
1910 /* Initialize 11h Enable Flag */
1911 if (SIR_BAND_5_GHZ == session->limRFBand) {
1912 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1913 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001914 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 session->lim11hEnable =
1916 WNI_CFG_11H_ENABLED_STADEF;
1917 } else {
1918 session->lim11hEnable = val;
1919 }
1920 } else {
1921 session->lim11hEnable = 0;
1922 }
1923
1924 /*
1925 * To care of the scenario when STA transitions from
1926 * IBSS to Infrastructure mode.
1927 */
1928 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1929
1930 session->limPrevSmeState = session->limSmeState;
1931 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1932 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1933 session->peSessionId,
1934 session->limSmeState));
1935
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 /* Indicate whether spectrum management is enabled */
1937 session->spectrumMgtEnabled =
1938 sme_join_req->spectrumMgtIndicator;
1939
1940 /* Enable the spectrum management if this is a DFS channel */
1941 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001942 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 session->currentOperChannel))
1944 session->spectrumMgtEnabled = true;
1945
1946 session->isOSENConnection = sme_join_req->isOSENConnection;
1947
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 /* Issue LIM_MLM_JOIN_REQ to MLM */
1949 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1950 (uint32_t *) mlm_join_req);
1951 return;
1952
1953 } else {
1954 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001955 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 mac_ctx->lim.gLimSmeState);
1957 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1958 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1959 session = NULL;
1960 goto end;
1961 }
1962
1963end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301964 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1965 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966
1967 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301968 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 sme_join_req = NULL;
1970 if (NULL != session)
1971 session->pLimJoinReq = NULL;
1972 }
1973 if (ret_code != eSIR_SME_SUCCESS) {
1974 if (NULL != session) {
1975 pe_delete_session(mac_ctx, session);
1976 session = NULL;
1977 }
1978 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001979 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 sme_session_id, ret_code);
1981 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1982 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1983 sme_transaction_id);
1984}
1985
Amar Singhala297bfa2015-10-15 15:07:29 -07001986uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 uint8_t iniTxPower)
1988{
1989 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301990 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
1991 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1993 maxTxPower = txPower;
1994 else if (txPower < MIN_TX_PWR_CAP)
1995 maxTxPower = MIN_TX_PWR_CAP;
1996 else
1997 maxTxPower = MAX_TX_PWR_CAP;
1998
1999 return maxTxPower;
2000}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
2002/**
2003 * __lim_process_sme_reassoc_req() - process reassoc req
2004 *
2005 * @mac_ctx: Pointer to Global MAC structure
2006 * @msg_buf: pointer to the SME message buffer
2007 *
2008 * This function is called to process SME_REASSOC_REQ message
2009 * from HDD or upper layer application.
2010 *
2011 * Return: None
2012 */
2013
2014static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2015 uint32_t *msg_buf)
2016{
2017 uint16_t caps;
2018 uint32_t val;
2019 tpSirSmeJoinReq reassoc_req = NULL;
2020 tLimMlmReassocReq *mlm_reassoc_req;
2021 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2022 tpPESession session_entry = NULL;
2023 uint8_t session_id;
2024 uint8_t sme_session_id;
2025 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002026 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 uint32_t tele_bcn_en = 0;
2028 uint16_t size;
2029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302031 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002033 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034
2035 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2036 goto end;
2037 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302038 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039
2040 if (!lim_is_sme_join_req_valid(mac_ctx,
2041 (tpSirSmeJoinReq)reassoc_req)) {
2042 /*
2043 * Received invalid eWNI_SME_REASSOC_REQ
2044 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002045 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046
2047 ret_code = eSIR_SME_INVALID_PARAMETERS;
2048 goto end;
2049 }
2050
2051 session_entry = pe_find_session_by_bssid(mac_ctx,
2052 reassoc_req->bssDescription.bssId,
2053 &session_id);
2054 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002055 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002056 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2057 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002059 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2060 &sme_session_id, &transaction_id);
2061 session_entry =
2062 pe_find_session_by_sme_session_id(mac_ctx,
2063 sme_session_id);
2064 if (session_entry != NULL)
2065 lim_handle_sme_join_result(mac_ctx,
2066 eSIR_SME_INVALID_PARAMETERS,
2067 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2068 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 goto end;
2070 }
2071#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2072 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2073 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2074#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2075 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2076
2077 /* Store the reassoc handle in the session Table */
2078 session_entry->pLimReAssocReq = reassoc_req;
2079
2080 session_entry->dot11mode = reassoc_req->dot11mode;
2081 session_entry->vhtCapability =
2082 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002083
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302084 if (session_entry->vhtCapability) {
2085 if (session_entry->pePersona == QDF_STA_MODE) {
2086 session_entry->vht_config.su_beam_formee =
2087 reassoc_req->vht_config.su_beam_formee;
2088 } else {
2089 reassoc_req->vht_config.su_beam_formee = 0;
2090 }
2091 session_entry->enableVhtpAid =
2092 reassoc_req->enableVhtpAid;
2093 session_entry->enableVhtGid =
2094 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002095 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302096 }
2097
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002098 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302099 session_entry->vhtCapability,
2100 session_entry->vht_config.su_beam_formee,
2101 session_entry->vht_config.su_beam_former);
2102
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002103 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2104 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002105 session_entry->send_smps_action =
2106 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002107 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002108 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002109 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002110 session_entry->send_smps_action,
2111 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 /*
2113 * Reassociate request is expected
2114 * in link established state only.
2115 */
2116
2117 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2119 /*
2120 * May be from 11r FT pre-auth. So lets check it
2121 * before we bail out
2122 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002123 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 session_entry->peSessionId);
2125
2126 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302127 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 session_entry->limReAssocbssId,
2129 6)) {
2130 lim_print_mac_addr(mac_ctx,
2131 reassoc_req->bssDescription.
2132 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002133 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 ret_code = eSIR_SME_INVALID_PARAMETERS;
2135 goto end;
2136 }
2137
2138 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2139 session_entry);
2140 return;
2141 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 /*
2143 * Should not have received eWNI_SME_REASSOC_REQ
2144 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002145 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 session_entry->limSmeState);
2147 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2148
2149 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2150 goto end;
2151 }
2152
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302153 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 session_entry->pLimReAssocReq->bssDescription.bssId,
2155 sizeof(tSirMacAddr));
2156
2157 session_entry->limReassocChannelId =
2158 session_entry->pLimReAssocReq->bssDescription.channelId;
2159
2160 session_entry->reAssocHtSupportedChannelWidthSet =
2161 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2162 session_entry->reAssocHtRecommendedTxWidthSet =
2163 session_entry->reAssocHtSupportedChannelWidthSet;
2164 session_entry->reAssocHtSecondaryChannelOffset =
2165 session_entry->pLimReAssocReq->cbMode;
2166
2167 session_entry->limReassocBssCaps =
2168 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2169 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2170 session_entry->currentOperChannel);
2171 local_pwr_constraint = reg_max;
2172
2173 lim_extract_ap_capability(mac_ctx,
2174 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2175 lim_get_ielen_from_bss_description(
2176 &session_entry->pLimReAssocReq->bssDescription),
2177 &session_entry->limReassocBssQosCaps,
2178 &session_entry->limReassocBssPropCap,
2179 &session_entry->gLimCurrentBssUapsd,
2180 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302181 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002182 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302183 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 /* Copy the SSID from session entry to local variable */
2185 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302186 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 reassoc_req->ssId.ssId,
2188 session_entry->limReassocSSID.length);
2189 if (session_entry->gLimCurrentBssUapsd) {
2190 session_entry->gUapsdPerAcBitmask =
2191 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002192 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 session_entry->gUapsdPerAcBitmask);
2194 }
2195
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302196 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002198 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199
2200 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2201 goto end;
2202 }
2203
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302204 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2206
2207 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2208 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002209 eSIR_SUCCESS)
2210 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211
2212 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002213 eSIR_SUCCESS)
2214 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302215
2216 lim_update_caps_info_for_bss(mac_ctx, &caps,
2217 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002218 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 mlm_reassoc_req->capabilityInfo = caps;
2221
2222 /* Update PE session_id */
2223 mlm_reassoc_req->sessionId = session_id;
2224
2225 /*
2226 * If telescopic beaconing is enabled, set listen interval to
2227 * WNI_CFG_TELE_BCN_MAX_LI
2228 */
2229 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2230 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002231 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232
2233 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2234
2235 if (tele_bcn_en) {
2236 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2237 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002238 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 } else {
2240 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2241 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002242 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 }
2244
2245 mlm_reassoc_req->listenInterval = (uint16_t) val;
2246
2247 /* Indicate whether spectrum management is enabled */
2248 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2249
2250 /* Enable the spectrum management if this is a DFS channel */
2251 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002252 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 session_entry->currentOperChannel))
2254 session_entry->spectrumMgtEnabled = true;
2255
2256 session_entry->limPrevSmeState = session_entry->limSmeState;
2257 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2258
2259 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2260 session_entry->peSessionId,
2261 session_entry->limSmeState));
2262
2263 lim_post_mlm_message(mac_ctx,
2264 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2265 return;
2266end:
2267 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302268 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 if (session_entry)
2270 session_entry->pLimReAssocReq = NULL;
2271 }
2272
2273 if (session_entry) {
2274 /*
2275 * error occurred after we determined the session so extract
2276 * session and transaction info from there
2277 */
2278 sme_session_id = session_entry->smeSessionId;
2279 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002280 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 /*
2282 * error occurred before or during the time we determined
2283 * the session so extract the session and transaction info
2284 * from the message
2285 */
2286 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2287 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002288 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 /*
2290 * Send Reassoc failure response to host
2291 * (note session_entry may be NULL, but that's OK)
2292 */
2293 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2294 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2295 session_entry, sme_session_id,
2296 transaction_id);
2297}
2298
2299bool send_disassoc_frame = 1;
2300/**
2301 * __lim_process_sme_disassoc_req()
2302 *
2303 ***FUNCTION:
2304 * This function is called to process SME_DISASSOC_REQ message
2305 * from HDD or upper layer application.
2306 *
2307 ***LOGIC:
2308 *
2309 ***ASSUMPTIONS:
2310 *
2311 ***NOTE:
2312 *
2313 * @param pMac Pointer to Global MAC structure
2314 * @param *pMsgBuf A pointer to the SME message buffer
2315 * @return None
2316 */
2317
2318static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2319{
2320 uint16_t disassocTrigger, reasonCode;
2321 tLimMlmDisassocReq *pMlmDisassocReq;
2322 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2323 tSirSmeDisassocReq smeDisassocReq;
2324 tpPESession psessionEntry = NULL;
2325 uint8_t sessionId;
2326 uint8_t smesessionId;
2327 uint16_t smetransactionId;
2328
2329 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002330 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 return;
2332 }
2333
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302334 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 smesessionId = smeDisassocReq.sessionId;
2336 smetransactionId = smeDisassocReq.transactionId;
2337 if (!lim_is_sme_disassoc_req_valid(pMac,
2338 &smeDisassocReq,
2339 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002340 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 if (pMac->lim.gLimRspReqd) {
2342 pMac->lim.gLimRspReqd = false;
2343
2344 retCode = eSIR_SME_INVALID_PARAMETERS;
2345 disassocTrigger = eLIM_HOST_DISASSOC;
2346 goto sendDisassoc;
2347 }
2348
2349 return;
2350 }
2351
2352 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002353 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 &sessionId);
2355 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002356 pe_err("session does not exist for given bssId "
2357 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002358 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 retCode = eSIR_SME_INVALID_PARAMETERS;
2360 disassocTrigger = eLIM_HOST_DISASSOC;
2361 goto sendDisassoc;
2362 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002363 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2364 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2366 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002367 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368
2369#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2370 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2371 0, smeDisassocReq.reasonCode);
2372#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2373
2374 /* Update SME session Id and SME transaction ID */
2375
2376 psessionEntry->smeSessionId = smesessionId;
2377 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002378 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002379 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380
2381 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2382 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 switch (psessionEntry->limSmeState) {
2384 case eLIM_SME_ASSOCIATED_STATE:
2385 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002386 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002387 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 psessionEntry->limPrevSmeState =
2389 psessionEntry->limSmeState;
2390 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 /* Delete all TDLS peers connected before leaving BSS */
2392 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002393 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2394 psessionEntry->peSessionId,
2395 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 break;
2397
2398 case eLIM_SME_WT_DEAUTH_STATE:
2399 /* PE shall still process the DISASSOC_REQ and proceed with
2400 * link tear down even if it had already sent a DEAUTH_IND to
2401 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2402 * its been set when PE entered WT_DEAUTH_STATE.
2403 */
2404 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2405 MTRACE(mac_trace
2406 (pMac, TRACE_CODE_SME_STATE,
2407 psessionEntry->peSessionId,
2408 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002409 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 break;
2411
2412 case eLIM_SME_WT_DISASSOC_STATE:
2413 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2414 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2415 * PE can continue processing DISASSOC_REQ and send the response instead
2416 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2417 * for disassoc frame.
2418 *
2419 * It will send a disassoc, which is ok. However, we can use the global flag
2420 * sendDisassoc to not send disassoc frame.
2421 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002422 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 break;
2424
2425 case eLIM_SME_JOIN_FAILURE_STATE: {
2426 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002427 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 if (pMac->lim.gLimRspReqd) {
2429 retCode = eSIR_SME_SUCCESS;
2430 disassocTrigger = eLIM_HOST_DISASSOC;
2431 goto sendDisassoc;
2432 }
2433 }
2434 break;
2435 default:
2436 /**
2437 * STA is not currently associated.
2438 * Log error and send response to host
2439 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002440 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 psessionEntry->limSmeState);
2442 lim_print_sme_state(pMac, LOGE,
2443 psessionEntry->limSmeState);
2444
2445 if (pMac->lim.gLimRspReqd) {
2446 if (psessionEntry->limSmeState !=
2447 eLIM_SME_WT_ASSOC_STATE)
2448 pMac->lim.gLimRspReqd = false;
2449
2450 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2451 disassocTrigger = eLIM_HOST_DISASSOC;
2452 goto sendDisassoc;
2453 }
2454
2455 return;
2456 }
2457
2458 break;
2459
2460 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 /* Fall through */
2462 break;
2463
2464 case eLIM_STA_IN_IBSS_ROLE:
2465 default:
2466 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002467 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 GET_LIM_SYSTEM_ROLE(psessionEntry));
2469
2470 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2471 disassocTrigger = eLIM_HOST_DISASSOC;
2472 goto sendDisassoc;
2473 } /* end switch (pMac->lim.gLimSystemRole) */
2474
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302475 disassocTrigger = eLIM_HOST_DISASSOC;
2476 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477
2478 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002479 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 send_disassoc_frame = 0;
2481 }
2482 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002483 pe_debug("Sending Disasscoc with disassoc Trigger"
2484 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 disassocTrigger, reasonCode);
2486
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302487 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002489 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490 return;
2491 }
2492
Anurag Chouhanc5548422016-02-24 18:33:27 +05302493 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002494 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495
2496 pMlmDisassocReq->reasonCode = reasonCode;
2497 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2498
2499 /* Update PE session ID */
2500 pMlmDisassocReq->sessionId = sessionId;
2501
2502 lim_post_mlm_message(pMac,
2503 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2504 return;
2505
2506sendDisassoc:
2507 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002508 lim_send_sme_disassoc_ntf(pMac,
2509 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 retCode,
2511 disassocTrigger,
2512 1, smesessionId, smetransactionId,
2513 psessionEntry);
2514 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002515 lim_send_sme_disassoc_ntf(pMac,
2516 smeDisassocReq.peer_macaddr.bytes,
2517 retCode, disassocTrigger, 1,
2518 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519
2520} /*** end __lim_process_sme_disassoc_req() ***/
2521
2522/** -----------------------------------------------------------------
2523 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2524
2525 This function is called to process SME_DISASSOC_CNF message
2526 from HDD or upper layer application.
2527
2528 \param pMac - global mac structure
2529 \param pStaDs - station dph hash node
2530 \return none
2531 \sa
2532 ----------------------------------------------------------------- */
2533static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2534{
2535 tSirSmeDisassocCnf smeDisassocCnf;
2536 uint16_t aid;
2537 tpDphHashNode pStaDs;
2538 tpPESession psessionEntry;
2539 uint8_t sessionId;
2540
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302541 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 sizeof(struct sSirSmeDisassocCnf));
2543
2544 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002545 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 &sessionId);
2547 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002548 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 return;
2550 }
2551
2552 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002553 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 return;
2555 }
2556#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2557 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2558 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2559 psessionEntry,
2560 (uint16_t) smeDisassocCnf.statusCode, 0);
2561 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2562 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2563 psessionEntry,
2564 (uint16_t) smeDisassocCnf.statusCode, 0);
2565#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2566
2567 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2568 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2570 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2571 && (psessionEntry->limSmeState !=
2572 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002573 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 psessionEntry->limSmeState);
2575 lim_print_sme_state(pMac, LOGE,
2576 psessionEntry->limSmeState);
2577 return;
2578 }
2579 break;
2580
2581 case eLIM_AP_ROLE:
2582 /* Fall through */
2583 break;
2584
2585 case eLIM_STA_IN_IBSS_ROLE:
2586 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002587 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 GET_LIM_SYSTEM_ROLE(psessionEntry));
2589
2590 return;
2591 }
2592
2593 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2594 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2595 LIM_IS_AP_ROLE(psessionEntry)) {
2596 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002597 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 &psessionEntry->dph.dphHashTable);
2599 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002600 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2601 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002602 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 return;
2604 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302605
2606 if ((pStaDs->mlmStaContext.mlmState ==
2607 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2608 (pStaDs->mlmStaContext.mlmState ==
2609 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002610 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002611 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302612 pStaDs->mlmStaContext.mlmState);
2613 return;
2614 }
2615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 /* Delete FT session if there exists one */
2617 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2619
2620 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002621 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 }
2623
2624 return;
2625}
2626
2627/**
2628 * __lim_process_sme_deauth_req() - process sme deauth req
2629 * @mac_ctx: Pointer to Global MAC structure
2630 * @msg_buf: pointer to the SME message buffer
2631 *
2632 * This function is called to process SME_DEAUTH_REQ message
2633 * from HDD or upper layer application.
2634 *
2635 * Return: None
2636 */
2637
2638static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2639 uint32_t *msg_buf)
2640{
2641 uint16_t deauth_trigger, reason_code;
2642 tLimMlmDeauthReq *mlm_deauth_req;
2643 tSirSmeDeauthReq sme_deauth_req;
2644 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2645 tpPESession session_entry;
2646 uint8_t session_id; /* PE sessionId */
2647 uint8_t sme_session_id;
2648 uint16_t sme_transaction_id;
2649
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302650 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 sme_session_id = sme_deauth_req.sessionId;
2652 sme_transaction_id = sme_deauth_req.transactionId;
2653
2654 /*
2655 * We need to get a session first but we don't even know
2656 * if the message is correct.
2657 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002658 session_entry = pe_find_session_by_bssid(mac_ctx,
2659 sme_deauth_req.bssid.bytes,
2660 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002662 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 ret_code = eSIR_SME_INVALID_PARAMETERS;
2664 deauth_trigger = eLIM_HOST_DEAUTH;
2665 goto send_deauth;
2666 }
2667
2668 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2669 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002670 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 mac_ctx->lim.gLimRspReqd = false;
2672
2673 ret_code = eSIR_SME_INVALID_PARAMETERS;
2674 deauth_trigger = eLIM_HOST_DEAUTH;
2675 goto send_deauth;
2676 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002677 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2678 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2680 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002681 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2683 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2684 session_entry, 0, sme_deauth_req.reasonCode);
2685#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2686
2687 /* Update SME session ID and Transaction ID */
2688 session_entry->smeSessionId = sme_session_id;
2689 session_entry->transactionId = sme_transaction_id;
2690
2691 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2692 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 switch (session_entry->limSmeState) {
2694 case eLIM_SME_ASSOCIATED_STATE:
2695 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302696 /* Delete all TDLS peers connected before leaving BSS */
2697 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 case eLIM_SME_WT_ASSOC_STATE:
2699 case eLIM_SME_JOIN_FAILURE_STATE:
2700 case eLIM_SME_IDLE_STATE:
2701 session_entry->limPrevSmeState =
2702 session_entry->limSmeState;
2703 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2704 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2705 session_entry->peSessionId,
2706 session_entry->limSmeState));
2707 /* Send Deauthentication request to MLM below */
2708 break;
2709 case eLIM_SME_WT_DEAUTH_STATE:
2710 case eLIM_SME_WT_DISASSOC_STATE:
2711 /*
2712 * PE Recieved a Deauth/Disassoc frame. Normally it get
2713 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2714 * Which means host is also trying to disconnect.
2715 * PE can continue processing DEAUTH_REQ and send
2716 * the response instead of failing the request.
2717 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2718 * was sent for deauth/disassoc frame.
2719 */
2720 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002721 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 break;
2723 default:
2724 /*
2725 * STA is not in a state to deauthenticate with
2726 * peer. Log error and send response to host.
2727 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002728 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 session_entry->limSmeState);
2730 lim_print_sme_state(mac_ctx, LOGE,
2731 session_entry->limSmeState);
2732
2733 if (mac_ctx->lim.gLimRspReqd) {
2734 mac_ctx->lim.gLimRspReqd = false;
2735
2736 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2737 deauth_trigger = eLIM_HOST_DEAUTH;
2738
wadesong42968e92017-06-08 14:11:21 +08002739 /*
2740 * here we received deauth request from AP so
2741 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2742 * have ISSUED delSta then mlm state should be
2743 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2744 * delBSS rsp then mlm state should be
2745 * eLIM_MLM_IDLE_STATE so the below condition
2746 * captures the state where delSta not done
2747 * and firmware still in connected state.
2748 */
2749 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 eLIM_SME_WT_DEAUTH_STATE &&
2751 session_entry->limMlmState !=
2752 eLIM_MLM_IDLE_STATE &&
2753 session_entry->limMlmState !=
2754 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002755 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 goto send_deauth;
2757 }
2758 return;
2759 }
2760 break;
2761
2762 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002763 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 if (mac_ctx->lim.gLimRspReqd) {
2765 mac_ctx->lim.gLimRspReqd = false;
2766 ret_code = eSIR_SME_INVALID_PARAMETERS;
2767 deauth_trigger = eLIM_HOST_DEAUTH;
2768 goto send_deauth;
2769 }
2770 return;
2771 case eLIM_AP_ROLE:
2772 break;
2773 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002774 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 GET_LIM_SYSTEM_ROLE(session_entry));
2776 if (mac_ctx->lim.gLimRspReqd) {
2777 mac_ctx->lim.gLimRspReqd = false;
2778 ret_code = eSIR_SME_INVALID_PARAMETERS;
2779 deauth_trigger = eLIM_HOST_DEAUTH;
2780 goto send_deauth;
2781 }
2782 return;
2783 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2784
2785 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2786 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002787 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2789 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2790 } else {
2791 deauth_trigger = eLIM_HOST_DEAUTH;
2792 reason_code = sme_deauth_req.reasonCode;
2793 }
2794
2795 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302796 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002798 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 if (mac_ctx->lim.gLimRspReqd) {
2800 mac_ctx->lim.gLimRspReqd = false;
2801 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2802 deauth_trigger = eLIM_HOST_DEAUTH;
2803 goto send_deauth;
2804 }
2805 return;
2806 }
2807
Anurag Chouhanc5548422016-02-24 18:33:27 +05302808 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002809 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810
2811 mlm_deauth_req->reasonCode = reason_code;
2812 mlm_deauth_req->deauthTrigger = deauth_trigger;
2813
2814 /* Update PE session Id */
2815 mlm_deauth_req->sessionId = session_id;
2816
2817 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2818 (uint32_t *)mlm_deauth_req);
2819 return;
2820
2821send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002822 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2823 ret_code, deauth_trigger, 1,
2824 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825}
2826
2827/**
2828 * __lim_process_sme_set_context_req()
2829 *
2830 * @mac_ctx: Pointer to Global MAC structure
2831 * @msg_buf: pointer to the SME message buffer
2832 *
2833 * This function is called to process SME_SETCONTEXT_REQ message
2834 * from HDD or upper layer application.
2835 *
2836 * Return: None
2837 */
2838
2839static void
2840__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2841{
2842 tpSirSmeSetContextReq set_context_req;
2843 tLimMlmSetKeysReq *mlm_set_key_req;
2844 tpPESession session_entry;
2845 uint8_t session_id; /* PE sessionID */
2846 uint8_t sme_session_id;
2847 uint16_t sme_transaction_id;
2848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002850 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 return;
2852 }
2853
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302854 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002856 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 return;
2858 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302859 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 sizeof(struct sSirSmeSetContextReq));
2861 sme_session_id = set_context_req->sessionId;
2862 sme_transaction_id = set_context_req->transactionId;
2863
2864 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002865 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 goto end;
2867 }
2868
2869 if (set_context_req->keyMaterial.numKeys >
2870 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002871 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 set_context_req->keyMaterial.numKeys);
2873 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002874 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 eSIR_SME_INVALID_PARAMETERS, NULL,
2876 sme_session_id, sme_transaction_id);
2877 goto end;
2878 }
2879
2880 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002881 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002883 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002885 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 eSIR_SME_INVALID_PARAMETERS, NULL,
2887 sme_session_id, sme_transaction_id);
2888 goto end;
2889 }
2890#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2891 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2892 session_entry, 0, 0);
2893#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2894
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002895 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2897 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002898 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2900 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302901 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002903 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 goto end;
2905 }
2906 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2907 mlm_set_key_req->numKeys =
2908 set_context_req->keyMaterial.numKeys;
2909 if (mlm_set_key_req->numKeys >
2910 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002911 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 goto end;
2913 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302914 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002915 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302917 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 (uint8_t *) &set_context_req->keyMaterial.key,
2919 sizeof(tSirKeys) *
2920 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2921 numKeys : 1));
2922
2923 mlm_set_key_req->sessionId = session_id;
2924 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002925 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927
2928 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2929 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2930 LIM_IS_AP_ROLE(session_entry)) {
2931 if (set_context_req->keyMaterial.key[0].keyLength) {
2932 uint8_t key_id;
2933 key_id =
2934 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302935 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 &session_entry->WEPKeyMaterial[key_id],
2937 (uint8_t *) &set_context_req->keyMaterial,
2938 sizeof(tSirKeyMaterial));
2939 } else {
2940 uint32_t i;
2941 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2942 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302943 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944 &mlm_set_key_req->key[i],
2945 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2946 sizeof(tSirKeys));
2947 }
2948 }
2949 }
2950 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2951 (uint32_t *) mlm_set_key_req);
2952 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002953 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 GET_LIM_SYSTEM_ROLE(session_entry),
2955 session_entry->limSmeState);
2956 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2957
2958 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002959 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2961 session_entry, sme_session_id,
2962 sme_transaction_id);
2963 }
2964end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302965 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 return;
2967}
2968
2969/**
2970 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2971 *
2972 * @mac_ctx: Pointer to Global MAC structure
2973 * @msg_buf: pointer to the SME message buffer
2974 *
2975 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2976 * from HDD or upper layer application.
2977 *
2978 * Return: None
2979 */
2980
Jeff Johnson801f1532016-10-07 07:54:50 -07002981static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2982 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983{
2984 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2985 tpDphHashNode sta_ds = NULL;
2986 tpPESession session_entry = NULL;
2987 tSap_Event sap_event;
2988 tpWLAN_SAPEventCB sap_event_cb = NULL;
2989 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2990 uint8_t session_id = CSR_SESSION_ID_INVALID;
2991 uint8_t assoc_id = 0;
2992 uint8_t sta_cnt = 0;
2993
2994 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002995 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 return;
2997 }
2998
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302999 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 sizeof(struct sSirSmeGetAssocSTAsReq));
3001 /*
3002 * Get Associated stations from PE.
3003 * Find PE session Entry
3004 */
3005 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003006 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 &session_id);
3008 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003009 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 goto lim_assoc_sta_end;
3011 }
3012
3013 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003014 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 session_entry->limSmeState,
3016 GET_LIM_SYSTEM_ROLE(session_entry));
3017 goto lim_assoc_sta_end;
3018 }
3019 /* Retrieve values obtained in the request message */
3020 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3021 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3022
3023 if (NULL == assoc_sta_tmp)
3024 goto lim_assoc_sta_end;
3025 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3026 assoc_id++) {
3027 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3028 &session_entry->dph.dphHashTable);
3029 if (NULL == sta_ds)
3030 continue;
3031 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303032 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303034 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3036 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3037
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303038 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 (uint8_t *)&sta_ds->supportedRates,
3040 sizeof(tSirSupportedRates));
3041 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3042 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3043 assoc_sta_tmp->Support40Mhz =
3044 sta_ds->htDsssCckRate40MHzSupport;
3045
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003046 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003048 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003050 pe_debug("Association Id: %d Station Index: %d",
3051 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 assoc_sta_tmp++;
3053 sta_cnt++;
3054 }
3055 }
3056lim_assoc_sta_end:
3057 /*
3058 * Call hdd callback with sap event to send the list of
3059 * associated stations from PE
3060 */
3061 if (sap_event_cb != NULL) {
3062 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3063 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303064 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3066 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3067 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3068 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3069 }
3070}
3071
3072/**
3073 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3074 *
3075 * @mac_ctx: Pointer to Global MAC structure
3076 * @msg_buf: pointer to WPS PBC overlap query message
3077 *
3078 * This function parses get WPS PBC overlap information
3079 * message and call callback to pass WPS PBC overlap
3080 * information back to hdd.
3081 *
3082 * Return: None
3083 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003084static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3085 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086{
3087 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3088 tpPESession session_entry = NULL;
3089 tSap_Event sap_event;
3090 tpWLAN_SAPEventCB sap_event_cb = NULL;
3091 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3093
3094 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003095 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 return;
3097 }
3098
3099 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303100 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303102 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3104 /*
3105 * Get Associated stations from PE
3106 * Find PE session Entry
3107 */
3108 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003109 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003111 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 goto lim_get_wpspbc_sessions_end;
3113 }
3114
3115 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003116 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 GET_LIM_SYSTEM_ROLE(session_entry));
3118 goto lim_get_wpspbc_sessions_end;
3119 }
3120 /*
3121 * Call hdd callback with sap event to send the
3122 * WPS PBC overlap information
3123 */
3124 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303125 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126
Anurag Chouhanc5548422016-02-24 18:33:27 +05303127 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003129 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 sap_get_wpspbc_event->UUID_E,
3131 &sap_get_wpspbc_event->wpsPBCOverlap,
3132 session_entry);
3133 } else {
3134 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003135 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 session_entry);
3137 /* don't have to inform the HDD/Host */
3138 return;
3139 }
3140
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003141 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 lim_print_mac_addr(mac_ctx,
3143 sap_get_wpspbc_event->addr.bytes, LOG4);
3144
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303145 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146
3147lim_get_wpspbc_sessions_end:
3148 sap_event_cb =
3149 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3150 if (NULL != sap_event_cb)
3151 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3152}
3153
3154/**
3155 * __lim_counter_measures()
3156 *
3157 * FUNCTION:
3158 * This function is called to "implement" MIC counter measure
3159 * and is *temporary* only
3160 *
3161 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3162 * we don't do the proper STA disassoc sequence since the
3163 * BSS will be stoped anyway
3164 *
3165 ***ASSUMPTIONS:
3166 *
3167 ***NOTE:
3168 *
3169 * @param pMac Pointer to Global MAC structure
3170 * @return None
3171 */
3172
3173static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3174{
3175 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003176 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3178 mac, psessionEntry, false);
3179};
3180
Jeff Johnson801f1532016-10-07 07:54:50 -07003181static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3182 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183{
3184 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3185 tpPESession psessionEntry;
3186 uint8_t sessionId; /* PE sessionId */
3187
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303188 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 sizeof(struct sSirSmeTkipCntrMeasReq));
3190
3191 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003192 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 if (NULL == psessionEntry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003194 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 return;
3196 }
3197
3198 if (tkipCntrMeasReq.bEnable)
3199 __lim_counter_measures(pMac, psessionEntry);
3200
3201 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3202}
3203
3204static void
3205__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3206{
3207 tSirSmeStopBssReq stopBssReq;
3208 tSirRetStatus status;
3209 tLimSmeStates prevState;
3210 tpPESession psessionEntry;
3211 uint8_t smesessionId;
3212 uint8_t sessionId;
3213 uint16_t smetransactionId;
3214 uint8_t i = 0;
3215 tpDphHashNode pStaDs = NULL;
3216
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303217 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 smesessionId = stopBssReq.sessionId;
3219 smetransactionId = stopBssReq.transactionId;
3220
3221 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003222 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 /* Send Stop BSS response to host */
3224 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3225 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3226 smetransactionId);
3227 return;
3228 }
3229
3230 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003231 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 &sessionId);
3233 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003234 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3236 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3237 smetransactionId);
3238 return;
3239 }
3240#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3241 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3242 0, 0);
3243#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3244
3245 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3246 LIM_IS_STA_ROLE(psessionEntry)) {
3247 /**
3248 * Should not have received STOP_BSS_REQ in states
3249 * other than 'normal' state or on STA in Infrastructure
3250 * mode. Log error and return response to host.
3251 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003252 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 psessionEntry->limSmeState,
3254 GET_LIM_SYSTEM_ROLE(psessionEntry));
3255 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3256 /* / Send Stop BSS response to host */
3257 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3258 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3259 smetransactionId);
3260 return;
3261 }
3262
3263 if (LIM_IS_AP_ROLE(psessionEntry))
3264 lim_wpspbc_close(pMac, psessionEntry);
3265
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003266 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 stopBssReq.reasonCode);
3268
3269 prevState = psessionEntry->limSmeState;
3270
3271 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3272 MTRACE(mac_trace
3273 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3274 psessionEntry->limSmeState));
3275
3276 /* Update SME session Id and Transaction Id */
3277 psessionEntry->smeSessionId = smesessionId;
3278 psessionEntry->transactionId = smetransactionId;
3279
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003280 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3281 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3282 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3284 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3285 /* Send disassoc all stations associated thru TKIP */
3286 __lim_counter_measures(pMac, psessionEntry);
3287 else
3288 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003289 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3290 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 }
3292
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003293 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3294 /* Free the buffer allocated in START_BSS_REQ */
3295 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3296 psessionEntry->addIeParams.probeRespDataLen = 0;
3297 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003299 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3300 psessionEntry->addIeParams.assocRespDataLen = 0;
3301 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003303 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3304 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3305 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003307 /*
3308 * lim_del_bss is also called as part of coalescing,
3309 * when we send DEL BSS followed by Add Bss msg.
3310 */
3311 pMac->lim.gLimIbssCoalescingHappened = false;
3312 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3314 pStaDs =
3315 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3316 if (NULL == pStaDs)
3317 continue;
3318 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3319 if (eSIR_SUCCESS == status) {
3320 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3321 pStaDs->assocId, psessionEntry);
3322 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3323 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003324 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303325 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 }
3327 }
3328 /* send a delBss to HAL and wait for a response */
3329 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3330
3331 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003332 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 psessionEntry->limSmeState = prevState;
3334
3335 MTRACE(mac_trace
3336 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3337 psessionEntry->limSmeState));
3338
3339 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3340 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3341 smetransactionId);
3342 }
3343}
3344
3345/**
3346 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3347 * @pMac: Global MAC context
3348 * @pMsg: Message from SME
3349 *
3350 * Wrapper for the function __lim_handle_sme_stop_bss_request
3351 * This message will be defered until softmac come out of
3352 * scan mode. Message should be handled even if we have
3353 * detected radar in the current operating channel.
3354 *
3355 * Return: true - If we consumed the buffer
3356 * false - If have defered the message.
3357 */
3358
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003359static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3360 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361{
3362 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3363 /**
3364 * If message defered, buffer is not consumed yet.
3365 * So return false
3366 */
3367 return false;
3368 }
3369 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3370 return true;
3371} /*** end __lim_process_sme_stop_bss_req() ***/
3372
3373void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3374 uint32_t body, tpPESession psessionEntry)
3375{
3376
3377 (void)body;
3378 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3379 lim_ibss_delete(pMac, psessionEntry);
3380 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3381 lim_delete_pre_auth_list(pMac);
3382 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3383 psessionEntry->smeSessionId,
3384 psessionEntry->transactionId);
3385 return;
3386}
3387
3388/**
3389 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3390 *
3391 * @mac_ctx: pointer to mac context
3392 * @msg_type: message type
3393 * @msg_buf: pointer to the SME message buffer
3394 *
3395 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3396 * in BTAMP AP.
3397 *
3398 * Return: None
3399 */
3400
3401void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3402 uint32_t *msg_buf)
3403{
3404 tSirSmeAssocCnf assoc_cnf;
3405 tpDphHashNode sta_ds = NULL;
3406 tpPESession session_entry = NULL;
3407 uint8_t session_id;
3408 tpSirAssocReq assoc_req;
3409
3410 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003411 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412 goto end;
3413 }
3414
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303415 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003417 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 goto end;
3419 }
3420
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003421 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 &session_id);
3423 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003424 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 goto end;
3426 }
3427
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003428 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3430 (session_entry->limSmeState !=
3431 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003432 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 msg_type, session_entry->limSmeState,
3434 GET_LIM_SYSTEM_ROLE(session_entry));
3435 goto end;
3436 }
3437 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3438 &session_entry->dph.dphHashTable);
3439 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003440 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003442 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443
3444 /*
3445 * send a DISASSOC_IND message to WSM to make sure
3446 * the state in WSM and LIM is the same
3447 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003448 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 eSIR_SME_STA_NOT_ASSOCIATED,
3450 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3451 session_entry->smeSessionId,
3452 session_entry->transactionId,
3453 session_entry);
3454 goto end;
3455 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303456 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003457 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303458 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003459 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003461 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 goto end;
3463 }
3464
3465 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3466 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3467 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3468 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3469 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003470 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3471 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003473 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 goto end;
3475 }
3476 /*
3477 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3478 * has been received
3479 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003480 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3482 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3483
3484 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3485 /*
3486 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3487 * when it had received Assoc Request frame. Now, PE just needs
3488 * to send association rsp frame to the requesting BTAMP-STA.
3489 */
3490 sta_ds->mlmStaContext.mlmState =
3491 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003492 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 sta_ds->assocId);
3494 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3495 sta_ds->assocId, sta_ds->staAddr,
3496 sta_ds->mlmStaContext.subType, sta_ds,
3497 session_entry);
3498 goto end;
3499 } else {
3500 /*
3501 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3502 * to be associated since the HAL sta entry is created for
3503 * denied STA we need to remove this HAL entry.
3504 * So to do that set updateContext to 1
3505 */
3506 if (!sta_ds->mlmStaContext.updateContext)
3507 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003508 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 assoc_cnf.statusCode, sta_ds->assocId);
3510 lim_reject_association(mac_ctx, sta_ds->staAddr,
3511 sta_ds->mlmStaContext.subType,
3512 true, sta_ds->mlmStaContext.authType,
3513 sta_ds->assocId, true,
Varun Reddy Yeturu8c68b472017-06-15 16:05:38 -07003514 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 session_entry);
3516 }
3517end:
3518 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3519 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3520 assoc_req = (tpSirAssocReq)
3521 session_entry->parsedAssocReq[sta_ds->assocId];
3522 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303523 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 assoc_req->assocReqFrame = NULL;
3525 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303526 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3528 }
3529}
3530
3531static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3532{
3533 tpDphHashNode pStaDs;
3534 tSirMacAddr peerMac;
3535 tpSirAddtsReq pSirAddts;
3536 uint32_t timeout;
3537 tpPESession psessionEntry;
3538 uint8_t sessionId; /* PE sessionId */
3539 uint8_t smesessionId;
3540 uint16_t smetransactionId;
3541
3542 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003543 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 return;
3545 }
3546
3547 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3548 &smetransactionId);
3549
3550 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3551
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003552 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3553 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003555 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303556 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3557 NULL, pSirAddts->req.tspec,
3558 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 return;
3560 }
3561#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3562 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3563 0);
3564#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3565
3566 /* if sta
3567 * - verify assoc state
3568 * - send addts request to ap
3569 * - wait for addts response from ap
3570 * if ap, just ignore with error log
3571 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003572 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3573 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3574 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003576 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003577 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303578 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580
3581 pStaDs =
3582 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3583 &psessionEntry->dph.dphHashTable);
3584
3585 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003586 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303587 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 }
3589
3590 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3591 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003592 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303593 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 }
3595
3596 pSirAddts->req.wsmTspecPresent = 0;
3597 pSirAddts->req.wmeTspecPresent = 0;
3598 pSirAddts->req.lleTspecPresent = 0;
3599
3600 if ((pStaDs->wsmEnabled) &&
3601 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3602 SIR_MAC_ACCESSPOLICY_EDCA))
3603 pSirAddts->req.wsmTspecPresent = 1;
3604 else if (pStaDs->wmeEnabled)
3605 pSirAddts->req.wmeTspecPresent = 1;
3606 else if (pStaDs->lleEnabled)
3607 pSirAddts->req.lleTspecPresent = 1;
3608 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003609 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303610 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 }
3612
3613 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3614 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003615 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303617 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 }
3619
3620 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003621 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 pMac->lim.gLimAddtsReq.req.dialogToken,
3623 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3624 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3625 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303626 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 }
3628
3629 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3630
3631 /* save the addts request */
3632 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303633 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3635
3636 /* ship out the message now */
3637 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3638 psessionEntry);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003639 pe_debug("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 /* start a timer to wait for the response */
3641 if (pSirAddts->timeout)
3642 timeout = pSirAddts->timeout;
3643 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3644 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003645 pe_err("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303647 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 }
3649
3650 timeout = SYS_MS_TO_TICKS(timeout);
3651 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3652 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003653 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303654 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 }
3656 pMac->lim.gLimAddtsRspTimerCount++;
3657 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3658 pMac->lim.gLimAddtsRspTimerCount) !=
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 MTRACE(mac_trace
3664 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3665 eLIM_ADDTS_RSP_TIMER));
3666
3667 /* add the sessionId to the timer object */
3668 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3669 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3670 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003671 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303672 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 }
3674 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303675
3676send_failure_addts_rsp:
3677 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3678 psessionEntry, pSirAddts->req.tspec,
3679 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680}
3681
3682static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3683{
3684 tSirMacAddr peerMacAddr;
3685 uint8_t ac;
3686 tSirMacTSInfo *pTsinfo;
3687 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3688 tpDphHashNode pStaDs = NULL;
3689 tpPESession psessionEntry;
3690 uint8_t sessionId;
3691 uint32_t status = eSIR_SUCCESS;
3692 uint8_t smesessionId;
3693 uint16_t smetransactionId;
3694
3695 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3696 &smetransactionId);
3697
3698 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003699 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 &sessionId);
3701 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003702 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 status = eSIR_FAILURE;
3704 goto end;
3705 }
3706#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3707 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3708 0);
3709#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3710
3711 if (eSIR_SUCCESS !=
3712 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003713 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 status = eSIR_FAILURE;
3715 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3716 smesessionId, smetransactionId);
3717 return;
3718 }
3719
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003720 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3721 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3723
3724 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3725 pDeltsReq->req.wmeTspecPresent,
3726 &pDeltsReq->req.tsinfo,
3727 &pDeltsReq->req.tspec, psessionEntry);
3728
3729 pTsinfo =
3730 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3731 tsinfo : &pDeltsReq->req.tsinfo;
3732
3733 /* We've successfully send DELTS frame to AP. Update the
3734 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3735 * is no longer trigger enabled or delivery enabled
3736 */
3737 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3738 pTsinfo, CLEAR_UAPSD_MASK);
3739
3740 /* We're deleting the TSPEC, so this particular AC is no longer
3741 * admitted. PE needs to downgrade the EDCA
3742 * parameters(for the AC for which TS is being deleted) to the
3743 * next best AC for which ACM is not enabled, and send the
3744 * updated values to HAL.
3745 */
3746 ac = upToAc(pTsinfo->traffic.userPrio);
3747
3748 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3749 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3750 ~(1 << ac);
3751 } else if (pTsinfo->traffic.direction ==
3752 SIR_MAC_DIRECTION_DNLINK) {
3753 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3754 ~(1 << ac);
3755 } else if (pTsinfo->traffic.direction ==
3756 SIR_MAC_DIRECTION_BIDIR) {
3757 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3758 ~(1 << ac);
3759 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3760 ~(1 << ac);
3761 }
3762
3763 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3764 psessionEntry);
3765
3766 pStaDs =
3767 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3768 &psessionEntry->dph.dphHashTable);
3769 if (pStaDs != NULL) {
3770 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3771 pStaDs->bssId);
3772 status = eSIR_SUCCESS;
3773 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003774 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 status = eSIR_FAILURE;
3776 }
3777#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779#endif
3780
3781 /* send an sme response back */
3782end:
3783 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3784 smesessionId, smetransactionId);
3785}
3786
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303787void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788{
3789 /* fetch the sessionEntry based on the sessionId */
3790 tpPESession psessionEntry;
3791 psessionEntry = pe_find_session_by_session_id(pMac,
3792 pMac->lim.limTimers.gLimAddtsRspTimer.
3793 sessionId);
3794 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003795 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 return;
3797 }
3798
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003799 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003800 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 GET_LIM_SYSTEM_ROLE(psessionEntry));
3802 pMac->lim.gLimAddtsSent = false;
3803 return;
3804 }
3805
3806 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003807 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 return;
3809 }
3810
3811 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003812 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813 pMac->lim.gLimAddtsRspTimerCount);
3814 return;
3815 }
3816 /* this a real response timeout */
3817 pMac->lim.gLimAddtsSent = false;
3818 pMac->lim.gLimAddtsRspTimerCount++;
3819
3820 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3821 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3822 psessionEntry->smeSessionId,
3823 psessionEntry->transactionId);
3824}
3825
3826/**
3827 * __lim_process_sme_get_statistics_request()
3828 *
3829 ***FUNCTION:
3830 *
3831 *
3832 ***NOTE:
3833 *
3834 * @param pMac Pointer to Global MAC structure
3835 * @param *pMsgBuf A pointer to the SME message buffer
3836 * @return None
3837 */
3838static void
3839__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3840{
3841 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003842 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843
3844 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3845
3846 msgQ.type = WMA_GET_STATISTICS_REQ;
3847
3848 msgQ.reserved = 0;
3849 msgQ.bodyptr = pMsgBuf;
3850 msgQ.bodyval = 0;
3851 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3852
3853 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303854 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003856 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 return;
3858 }
3859
3860 return;
3861}
3862
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003863#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003865 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003867 * @pMac: Pointer to Global MAC structure
3868 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003870 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 */
3872static void
3873__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3874{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003875 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
3877 msgQ.type = WMA_TSM_STATS_REQ;
3878 msgQ.reserved = 0;
3879 msgQ.bodyptr = pMsgBuf;
3880 msgQ.bodyval = 0;
3881 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3882
3883 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303884 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003886 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 return;
3888 }
3889}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003890#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891
3892static void
3893__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3894{
3895 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
3896 tpPESession psessionEntry;
3897 uint8_t sessionId; /* PE sessionID */
3898
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003899 pe_debug("received UPDATE_APWPSIEs_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003900
3901 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003902 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 return;
3904 }
3905
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303906 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 if (NULL == pUpdateAPWPSIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003908 pe_err("call to AllocateMemory failed for pUpdateAPWPSIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 return;
3910 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303911 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 sizeof(struct sSirUpdateAPWPSIEsReq));
3913
3914 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08003915 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 &sessionId);
3917 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003918 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 goto end;
3920 }
3921
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303922 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 sizeof(tSirAPWPSIEs));
3924
3925 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3926 lim_send_beacon_ind(pMac, psessionEntry);
3927
3928end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303929 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 return;
3931}
3932
Naveen Rawat8029a402017-06-01 10:54:19 -07003933static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3934 struct update_config *msg)
3935{
3936 tpPESession pe_session;
3937
3938 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3939 if (msg == NULL) {
3940 pe_err("Buffer is Pointing to NULL");
3941 return;
3942 }
3943
3944 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3945 msg->sme_session_id);
3946 if (pe_session == NULL) {
3947 pe_warn("Session does not exist for given BSSID");
3948 return;
3949 }
3950
3951 switch (msg->capab) {
3952 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3953 pe_session->htConfig.ht_rx_ldpc = msg->value;
3954 break;
3955 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3956 pe_session->htConfig.ht_tx_stbc = msg->value;
3957 break;
3958 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3959 pe_session->htConfig.ht_rx_stbc = msg->value;
3960 break;
3961 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3962 pe_session->htConfig.ht_sgi20 = msg->value;
3963 break;
3964 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3965 pe_session->htConfig.ht_sgi40 = msg->value;
3966 break;
3967 }
3968
3969 if (LIM_IS_AP_ROLE(pe_session)) {
3970 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3971 lim_send_beacon_ind(mac_ctx, pe_session);
3972 }
3973}
3974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975void
3976lim_send_vdev_restart(tpAniSirGlobal pMac,
3977 tpPESession psessionEntry, uint8_t sessionId)
3978{
3979 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003980 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981 tSirRetStatus retCode = eSIR_SUCCESS;
3982
3983 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003984 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 return;
3986 }
3987
3988 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303989 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003991 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 return;
3993 }
3994
3995 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3996 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003997 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998
3999 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4000 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4001 msgQ.bodyval = 0;
4002
4003 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4004 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004005 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304006 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 }
4008}
4009
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304010/**
4011 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4012 * @mac_ctx: Pointer to Global MAC structure
4013 * @msg_buf: Pointer to SME message buffer
4014 *
4015 * Return: None
4016 */
4017static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4018 uint32_t *msg_buf)
4019{
4020 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004021 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304022 tSirRetStatus status;
4023 tSirRoamOffloadScanReq *req_buffer;
4024 uint16_t local_ie_len;
4025 uint8_t *local_ie_buf;
4026
4027 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4028 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4029 req_buffer->sessionId);
4030
4031 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4032 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004033 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304034 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304035 return;
4036 }
4037
4038 local_ie_len = req_buffer->assoc_ie.length;
4039 /* Update ext cap IE if present */
4040 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004041 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4042 local_ie_buf, &local_ie_len)) {
4043 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004044 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4045 req_buffer->assoc_ie.length = local_ie_len;
4046 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4047 local_ie_buf, local_ie_len);
4048 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304049 }
4050 qdf_mem_free(local_ie_buf);
4051
4052 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4053 wma_msg.bodyptr = req_buffer;
4054
4055 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4056 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004057 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304058 qdf_mem_free(req_buffer);
4059 }
4060}
4061
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304062/*
4063 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4064 * @mac_ctx: Pointer to global mac context
4065 * @session: Pointer to PE session
4066 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4067 * 1 - Disable broadcast SSID
4068 *
4069 * Return: None
4070 */
4071static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4072 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004074 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004075 session->ssidHidden, ssid_hidden);
4076
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004077 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304078 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004079 } else {
4080 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304081 return;
4082 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083
4084 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304085 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304088}
4089
4090/**
4091 * __lim_process_sme_session_update - process SME session update msg
4092 *
4093 * @mac_ctx: Pointer to global mac context
4094 * @msg_buf: Pointer to the received message buffer
4095 *
4096 * Return: None
4097 */
4098static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4099 uint32_t *msg_buf)
4100{
4101 struct sir_update_session_param *msg;
4102 tpPESession session;
4103
4104 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004105 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304106 return;
4107 }
4108
4109 msg = (struct sir_update_session_param *) msg_buf;
4110
4111 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4112 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004113 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304114 msg->session_id);
4115 return;
4116 }
4117
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004118 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304119 msg->param_type, msg->param_val);
4120 switch (msg->param_type) {
4121 case SIR_PARAM_SSID_HIDDEN:
4122 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4123 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304124 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4125 session->ignore_assoc_disallowed = msg->param_val;
4126 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304127 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004128 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304129 break;
4130 }
4131}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132
4133static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4134{
4135 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4136 tpPESession psessionEntry;
4137 uint8_t sessionId; /* PE sessionID */
4138
4139 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004140 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 return;
4142 }
4143
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304144 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 if (NULL == pUpdateAPWPARSNIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004146 pe_err("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 return;
4148 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304149 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4151
4152 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004153 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 &sessionId);
4155 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004156 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 goto end;
4158 }
4159
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304160 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4162
4163 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4164 &psessionEntry->
4165 pLimStartBssReq->rsnIE,
4166 psessionEntry);
4167
4168 psessionEntry->pLimStartBssReq->privacy = 1;
4169 psessionEntry->privacy = 1;
4170
4171 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4172 lim_send_beacon_ind(pMac, psessionEntry);
4173
4174end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304175 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 return;
4177} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4178
4179/*
4180 Update the beacon Interval dynamically if beaconInterval is different in MCC
4181 */
4182static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4183{
4184 tpSirChangeBIParams pChangeBIParams;
4185 tpPESession psessionEntry;
4186 uint8_t sessionId = 0;
4187 tUpdateBeaconParams beaconParams;
4188
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004189 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190
4191 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004192 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 return;
4194 }
4195
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304196 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4198
4199 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004200 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 &sessionId);
4202 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004203 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 return;
4205 }
4206
4207 /*Update sessionEntry Beacon Interval */
4208 if (psessionEntry->beaconParams.beaconInterval !=
4209 pChangeBIParams->beaconInterval) {
4210 psessionEntry->beaconParams.beaconInterval =
4211 pChangeBIParams->beaconInterval;
4212 }
4213
4214 /*Update sch beaconInterval */
4215 if (pMac->sch.schObject.gSchBeaconInterval !=
4216 pChangeBIParams->beaconInterval) {
4217 pMac->sch.schObject.gSchBeaconInterval =
4218 pChangeBIParams->beaconInterval;
4219
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004220 pe_debug("LIM send update BeaconInterval Indication: %d",
4221 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222
4223 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4224 /* Update beacon */
4225 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4226
4227 beaconParams.bssIdx = psessionEntry->bssIdx;
4228 /* Set change in beacon Interval */
4229 beaconParams.beaconInterval =
4230 pChangeBIParams->beaconInterval;
4231 beaconParams.paramChangeBitmap =
4232 PARAM_BCN_INTERVAL_CHANGED;
4233 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4234 }
4235 }
4236
4237 return;
4238} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4239
4240#ifdef QCA_HT_2040_COEX
4241static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4242 uint32_t *pMsgBuf)
4243{
4244 tpSirSetHT2040Mode pSetHT2040Mode;
4245 tpPESession psessionEntry;
4246 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004247 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 tUpdateVHTOpMode *pHtOpMode = NULL;
4249 uint16_t staId = 0;
4250 tpDphHashNode pStaDs = NULL;
4251
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004252 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004254 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 return;
4256 }
4257
4258 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4259
4260 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004261 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 &sessionId);
4263 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004264 pe_debug("Session does not exist for given BSSID");
4265 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 return;
4267 }
4268
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004269 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 pSetHT2040Mode->cbMode);
4271 /*Update sessionEntry HT related fields */
4272 switch (pSetHT2040Mode->cbMode) {
4273 case PHY_SINGLE_CHANNEL_CENTERED:
4274 psessionEntry->htSecondaryChannelOffset =
4275 PHY_SINGLE_CHANNEL_CENTERED;
4276 psessionEntry->htRecommendedTxWidthSet = 0;
4277 if (pSetHT2040Mode->obssEnabled)
4278 psessionEntry->htSupportedChannelWidthSet
4279 = eHT_CHANNEL_WIDTH_40MHZ;
4280 else
4281 psessionEntry->htSupportedChannelWidthSet
4282 = eHT_CHANNEL_WIDTH_20MHZ;
4283 break;
4284 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4285 psessionEntry->htSecondaryChannelOffset =
4286 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4287 psessionEntry->htRecommendedTxWidthSet = 1;
4288 break;
4289 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4290 psessionEntry->htSecondaryChannelOffset =
4291 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4292 psessionEntry->htRecommendedTxWidthSet = 1;
4293 break;
4294 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004295 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 return;
4297 }
4298
4299 /* Update beacon */
4300 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4301 lim_send_beacon_ind(pMac, psessionEntry);
4302
4303 /* update OP Mode for each associated peer */
4304 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4305 pStaDs = dph_get_hash_entry(pMac, staId,
4306 &psessionEntry->dph.dphHashTable);
4307 if (NULL == pStaDs)
4308 continue;
4309
4310 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304311 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004313 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 return;
4315 }
4316 pHtOpMode->opMode =
4317 (psessionEntry->htSecondaryChannelOffset ==
4318 PHY_SINGLE_CHANNEL_CENTERED) ?
4319 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4320 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304321 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 sizeof(tSirMacAddr));
4323 pHtOpMode->smesessionId = sessionId;
4324
4325 msg.type = WMA_UPDATE_OP_MODE;
4326 msg.reserved = 0;
4327 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004328 if (!QDF_IS_STATUS_SUCCESS
4329 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4330 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304331 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 return;
4333 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004334 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4335 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336
4337 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004338 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 }
4340
4341 return;
4342}
4343#endif
4344
4345/* -------------------------------------------------------------------- */
4346/**
4347 * __lim_process_report_message
4348 *
4349 * FUNCTION: Processes the next received Radio Resource Management message
4350 *
4351 * LOGIC:
4352 *
4353 * ASSUMPTIONS:
4354 *
4355 * NOTE:
4356 *
4357 * @param None
4358 * @return None
4359 */
4360
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004361static void __lim_process_report_message(tpAniSirGlobal pMac,
4362 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 switch (pMsg->type) {
4365 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4366 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4367 break;
4368 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004370 break;
4371 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004372 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374}
4375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376/* -------------------------------------------------------------------- */
4377/**
4378 * lim_send_set_max_tx_power_req
4379 *
4380 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4381 *
4382 * LOGIC:
4383 *
4384 * ASSUMPTIONS:
4385 *
4386 * NOTE:
4387 *
4388 * @param txPower txPower to be set.
4389 * @param pSessionEntry session entry.
4390 * @return None
4391 */
4392tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004393lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 tpPESession pSessionEntry)
4395{
4396 tpMaxTxPowerParams pMaxTxParams = NULL;
4397 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004398 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399
4400 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004401 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 return eSIR_FAILURE;
4403 }
4404
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304405 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004407 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 return eSIR_MEM_ALLOC_FAILED;
4409
4410 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304412 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304413 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304414 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004415 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304416 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417
4418 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4419 msgQ.bodyptr = pMaxTxParams;
4420 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004421 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4423 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4424 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004425 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304426 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427 }
4428 return retCode;
4429}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430
4431/**
4432 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4433 *
4434 * @mac_ctx: Pointer to Global MAC structure
4435 * @msg_buf: pointer to the SME message buffer
4436 *
4437 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4438 * from SME. It Register this information within PE.
4439 *
4440 * Return: None
4441 */
4442static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4443 uint32_t *msg_buf)
4444{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304445 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4447 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4448 struct mgmt_frm_reg_info *next = NULL;
4449 bool match = false;
4450
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004451 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 sme_req->registerFrame, sme_req->frameType,
4453 sme_req->matchLen);
4454 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304455 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304456 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4457 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304458 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459
4460 while (lim_mgmt_regn != NULL) {
4461 if (lim_mgmt_regn->frameType != sme_req->frameType)
4462 goto skip_match;
4463 if (sme_req->matchLen) {
4464 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304465 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 sme_req->matchData,
4467 lim_mgmt_regn->matchLen))) {
4468 /* found match! */
4469 match = true;
4470 break;
4471 }
4472 } else {
4473 /* found match! */
4474 match = true;
4475 break;
4476 }
4477skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304478 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304479 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304481 (qdf_list_node_t *)lim_mgmt_regn,
4482 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304483 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484 lim_mgmt_regn = next;
4485 next = NULL;
4486 }
4487 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304488 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004489 if (QDF_STATUS_SUCCESS ==
4490 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004492 (qdf_list_node_t *)lim_mgmt_regn))
4493 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304494 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 }
4496
4497 if (sme_req->registerFrame) {
4498 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304499 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 sme_req->matchLen);
4501 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 lim_mgmt_regn->frameType = sme_req->frameType;
4503 lim_mgmt_regn->matchLen = sme_req->matchLen;
4504 lim_mgmt_regn->sessionId = sme_req->sessionId;
4505 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304506 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 sme_req->matchData,
4508 sme_req->matchLen);
4509 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304510 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304512 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 gLimMgmtFrameRegistratinQueue,
4514 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304515 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 &mac_ctx->lim.lim_frame_register_lock);
4517 }
4518 }
4519 return;
4520}
4521
4522static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4523{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004524 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 pMac->lim.gDeferMsgTypeForNOA = 0;
4526 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4527 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304528 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4530 }
4531}
4532
4533/**
4534 * lim_process_regd_defd_sme_req_after_noa_start()
4535 *
4536 * mac_ctx: Pointer to Global MAC structure
4537 *
4538 * This function is called to process deferred sme req message
4539 * after noa start.
4540 *
4541 * Return: None
4542 */
4543void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4544{
4545 bool buf_consumed = true;
4546
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004547 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 mac_ctx->lim.gDeferMsgTypeForNOA);
4549
4550 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4551 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004552 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4553 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 return;
4555 }
4556 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4557 case eWNI_SME_SCAN_REQ:
4558 __lim_process_sme_scan_req(mac_ctx,
4559 mac_ctx->lim.gpDefdSmeMsgForNOA);
4560 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4562 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4563 mac_ctx->lim.gpDefdSmeMsgForNOA);
4564 /*
4565 * lim_process_remain_on_chnl_req doesnt want us to free
4566 * the buffer since it is freed in lim_remain_on_chn_rsp.
4567 * this change is to avoid "double free"
4568 */
4569 if (false == buf_consumed)
4570 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4571 break;
4572 case eWNI_SME_JOIN_REQ:
4573 __lim_process_sme_join_req(mac_ctx,
4574 mac_ctx->lim.gpDefdSmeMsgForNOA);
4575 break;
4576 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004577 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 mac_ctx->lim.gDeferMsgTypeForNOA);
4579 break;
4580 }
4581 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4582}
4583
4584static void
4585__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4586{
4587 tpSirResetAPCapsChange pResetCapsChange;
4588 tpPESession psessionEntry;
4589 uint8_t sessionId = 0;
4590 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004591 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 return;
4593 }
4594
4595 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4596 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004597 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4598 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004600 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 return;
4602 }
4603
4604 psessionEntry->limSentCapsChangeNtf = false;
4605 return;
4606}
4607
4608/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304609 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4610 * @mac_ctx: Mac pointer
4611 * @msg_buf: Msg pointer containing the callback
4612 *
4613 * This function is used to save the p2p ack indication callback in PE.
4614 *
4615 * Return: None
4616 */
4617static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4618 uint32_t *msg_buf)
4619{
4620 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4621 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4622
4623 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004624 pe_err("msg_buf is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304625 return;
4626 }
4627 if (sme_req->callback)
4628 mac_ctx->p2p_ack_ind_cb =
4629 sme_req->callback;
4630 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004631 pe_err("sme_req->callback is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304632}
4633
4634/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304635 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4636 * indication callback in PE.
4637 * @mac_ptr: Mac pointer
4638 * @msg_buf: Msg pointer containing the callback
4639 *
4640 * This function is used save the Management frame
4641 * indication callback in PE.
4642 *
4643 * Return: None
4644 */
4645static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4646 uint32_t *msg_buf)
4647{
4648 struct sir_sme_mgmt_frame_cb_req *sme_req =
4649 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4650
4651 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004652 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304653 return;
4654 }
4655 if (sme_req->callback)
4656 mac_ctx->mgmt_frame_ind_cb =
4657 (sir_mgmt_frame_ind_callback)sme_req->callback;
4658 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004659 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304660}
4661
4662/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304663 *__lim_process_send_disassoc_frame: function processes disassoc frame
4664 * @mac_ctx: pointer to mac context
4665 * @msg_buf: message buffer
4666 *
4667 * function processes disassoc request received from SME
4668 *
4669 * return: none
4670 */
4671static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4672 uint32_t *msg_buf)
4673{
4674 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4675 tSirRetStatus status;
4676 tpPESession session_entry = NULL;
4677 uint8_t sme_session_id;
4678 uint16_t sme_trans_id;
4679
4680 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004681 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304682 return;
4683 }
4684
4685 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4686 &sme_trans_id);
4687
4688 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4689 &sme_send_disassoc_frame_req,
4690 (uint8_t *)msg_buf);
4691
4692 if ((eSIR_FAILURE == status) ||
4693 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4694 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004695 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304696 return;
4697 }
4698
4699 session_entry = pe_find_session_by_sme_session_id(
4700 mac_ctx, sme_session_id);
4701 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004702 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304703 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4704 return;
4705 }
4706
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004707 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 +05304708 sme_send_disassoc_frame_req.msg_type,
4709 sme_send_disassoc_frame_req.length,
4710 sme_send_disassoc_frame_req.session_id,
4711 sme_send_disassoc_frame_req.trans_id,
4712 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4713 sme_send_disassoc_frame_req.reason,
4714 sme_send_disassoc_frame_req.wait_for_ack);
4715
4716 lim_send_disassoc_mgmt_frame(mac_ctx,
4717 sme_send_disassoc_frame_req.reason,
4718 sme_send_disassoc_frame_req.peer_mac,
4719 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4720}
4721
4722/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004723 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4724 * @mac_ctx: Pointer to Global MAC structure
4725 * @pdev_id: pdev id to set the IE.
4726 * @nss: Nss values to prepare the HT IE.
4727 *
4728 * Prepares the HT IE with self capabilities for different
4729 * Nss values and sends the set HT IE req to FW.
4730 *
4731 * Return: None
4732 */
4733static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4734 uint8_t nss)
4735{
4736 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004737 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004738 tSirRetStatus rc = eSIR_SUCCESS;
4739 uint8_t *p_ie = NULL;
4740 tHtCaps *p_ht_cap;
4741 int i;
4742
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004743 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004744 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4745 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004746 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004747 return;
4748 }
4749 ie_params->nss = i;
4750 ie_params->pdev_id = pdev_id;
4751 ie_params->ie_type = DOT11_HT_IE;
4752 /* 2 for IE len and EID */
4753 ie_params->ie_len = 2 + sizeof(tHtCaps);
4754 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4755 if (NULL == ie_params->ie_ptr) {
4756 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004757 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004758 return;
4759 }
4760 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4761 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4762 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4763 ie_params->ie_len);
4764
4765 if (NSS_1x1_MODE == i) {
4766 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4767 ie_params->ie_len,
4768 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004769 if (NULL == p_ie) {
4770 qdf_mem_free(ie_params->ie_ptr);
4771 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004772 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004773 return;
4774 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004775 p_ht_cap = (tHtCaps *)&p_ie[2];
4776 p_ht_cap->supportedMCSSet[1] = 0;
4777 p_ht_cap->txSTBC = 0;
4778 }
4779
4780 msg.type = WMA_SET_PDEV_IE_REQ;
4781 msg.bodyptr = ie_params;
4782 msg.bodyval = 0;
4783
4784 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4785 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004786 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004787 qdf_mem_free(ie_params->ie_ptr);
4788 qdf_mem_free(ie_params);
4789 return;
4790 }
4791 }
4792}
4793
4794/**
4795 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4796 * @mac_ctx: Pointer to Global MAC structure
4797 * @pdev_id: pdev id to set the IE.
4798 * @nss: Nss values to prepare the VHT IE.
4799 *
4800 * Prepares the VHT IE with self capabilities for different
4801 * Nss values and sends the set VHT IE req to FW.
4802 *
4803 * Return: None
4804 */
4805static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4806 uint8_t nss)
4807{
4808 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004809 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004810 tSirRetStatus rc = eSIR_SUCCESS;
4811 uint8_t *p_ie = NULL;
4812 tSirMacVHTCapabilityInfo *vht_cap;
4813 int i;
4814 tSirVhtMcsInfo *vht_mcs;
4815
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004816 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004817 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4818 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004819 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004820 return;
4821 }
4822 ie_params->nss = i;
4823 ie_params->pdev_id = pdev_id;
4824 ie_params->ie_type = DOT11_VHT_IE;
4825 /* 2 for IE len and EID */
4826 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4827 sizeof(tSirVhtMcsInfo);
4828 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4829 if (NULL == ie_params->ie_ptr) {
4830 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004831 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004832 return;
4833 }
4834 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4835 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4836 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4837 ie_params->ie_len);
4838
4839 if (NSS_1x1_MODE == i) {
4840 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4841 ie_params->ie_len,
4842 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004843 if (NULL == p_ie) {
4844 qdf_mem_free(ie_params->ie_ptr);
4845 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004846 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004847 return;
4848 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004849 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4850 vht_cap->txSTBC = 0;
4851 vht_mcs =
4852 (tSirVhtMcsInfo *)&p_ie[2 +
4853 sizeof(tSirMacVHTCapabilityInfo)];
4854 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4855 vht_mcs->rxHighest =
4856 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4857 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4858 vht_mcs->txHighest =
4859 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4860 }
4861 msg.type = WMA_SET_PDEV_IE_REQ;
4862 msg.bodyptr = ie_params;
4863 msg.bodyval = 0;
4864
4865 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4866 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004867 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004868 qdf_mem_free(ie_params->ie_ptr);
4869 qdf_mem_free(ie_params);
4870 return;
4871 }
4872 }
4873}
4874
4875/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004876 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4877 * @mac_ctx: Pointer to Global MAC structure
4878 * @msg_buf: Pointer to the SME message buffer
4879 *
4880 * This function is called by limProcessMessageQueue(). This function sets the
4881 * VDEV IEs to the FW.
4882 *
4883 * Return: None
4884 */
4885static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4886 uint32_t *msg_buf)
4887{
4888 struct sir_set_vdev_ies_per_band *p_msg =
4889 (struct sir_set_vdev_ies_per_band *)msg_buf;
4890
4891 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004892 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004893 return;
4894 }
4895
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004896 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004897 p_msg->vdev_id);
4898 /* intentionally using NULL here so that self capabilty are sent */
4899 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4900 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004901 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004902}
4903
4904/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004905 * lim_process_set_pdev_IEs() - process the set pdev IE req
4906 * @mac_ctx: Pointer to Global MAC structure
4907 * @msg_buf: Pointer to the SME message buffer
4908 *
4909 * This function is called by limProcessMessageQueue(). This
4910 * function sets the PDEV IEs to the FW.
4911 *
4912 * Return: None
4913 */
4914static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4915{
4916 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4917
4918 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4919
4920 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004921 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004922 return;
4923 }
4924
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004925 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004926 ht_vht_cfg->nss);
4927 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4928
4929 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4930 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4931 ht_vht_cfg->nss);
4932}
4933
4934/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304935 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4936 *
4937 * access policy
4938 * @mac_ctx: pointer to mac context
4939 * @msg: message buffer
4940 *
4941 * function processes vendor IE and access policy from SME and updates PE
4942 *
4943 * session entry
4944 *
4945 * return: none
4946*/
4947static void lim_process_sme_update_access_policy_vendor_ie(
4948 tpAniSirGlobal mac_ctx,
4949 uint32_t *msg)
4950{
4951 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4952 struct sPESession *pe_session_entry;
4953 uint8_t num_bytes;
4954
4955 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004956 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304957 return;
4958 }
4959 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4960 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4961 update_vendor_ie->sme_session_id);
4962
4963 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004964 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304965 update_vendor_ie->sme_session_id);
4966 return;
4967 }
4968 if (pe_session_entry->access_policy_vendor_ie)
4969 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4970
4971 num_bytes = update_vendor_ie->ie[1] + 2;
4972 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4973
4974 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004975 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304976 return;
4977 }
4978 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4979 &update_vendor_ie->ie[0], num_bytes);
4980
4981 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4982}
4983
4984/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 * lim_process_sme_req_messages()
4986 *
4987 ***FUNCTION:
4988 * This function is called by limProcessMessageQueue(). This
4989 * function processes SME request messages from HDD or upper layer
4990 * application.
4991 *
4992 ***LOGIC:
4993 *
4994 ***ASSUMPTIONS:
4995 *
4996 ***NOTE:
4997 *
4998 * @param pMac Pointer to Global MAC structure
4999 * @param msgType Indicates the SME message type
5000 * @param *pMsgBuf A pointer to the SME message buffer
5001 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5002 * false - if pMsgBuf is not to be freed.
5003 */
5004
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005005bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5006 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007{
5008 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5009 uint32_t *pMsgBuf = pMsg->bodyptr;
5010 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005011
5012 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013 lim_msg_str(pMsg->type), pMsg->type,
5014 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5015 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016
5017 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5018 /* If no insert NOA required then execute the code below */
5019
5020 switch (pMsg->type) {
5021 case eWNI_SME_SYS_READY_IND:
5022 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5023 break;
5024
5025 case eWNI_SME_START_BSS_REQ:
5026 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5027 break;
5028
5029 case eWNI_SME_SCAN_REQ:
5030 __lim_process_sme_scan_req(pMac, pMsgBuf);
5031 break;
5032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5034 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5035 break;
5036
5037 case eWNI_SME_UPDATE_NOA:
5038 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5039 break;
5040 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5041 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5042 break;
5043 case eWNI_SME_JOIN_REQ:
5044 __lim_process_sme_join_req(pMac, pMsgBuf);
5045 break;
5046
5047 case eWNI_SME_REASSOC_REQ:
5048 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5049 break;
5050
5051 case eWNI_SME_DISASSOC_REQ:
5052 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5053 break;
5054
5055 case eWNI_SME_DISASSOC_CNF:
5056 case eWNI_SME_DEAUTH_CNF:
5057 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5058 break;
5059
5060 case eWNI_SME_DEAUTH_REQ:
5061 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5062 break;
5063
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305064 case eWNI_SME_SEND_DISASSOC_FRAME:
5065 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5066 break;
5067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068 case eWNI_SME_SETCONTEXT_REQ:
5069 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5070 break;
5071
5072 case eWNI_SME_STOP_BSS_REQ:
5073 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5074 break;
5075
5076 case eWNI_SME_ASSOC_CNF:
5077 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005078 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5080 pMsgBuf);
5081 break;
5082
5083 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005084 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 __lim_process_sme_addts_req(pMac, pMsgBuf);
5086 break;
5087
5088 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005089 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 __lim_process_sme_delts_req(pMac, pMsgBuf);
5091 break;
5092
5093 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005094 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5096 break;
5097
5098 case eWNI_SME_GET_STATISTICS_REQ:
5099 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5100 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5101 bufConsumed = false;
5102 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005103#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 case eWNI_SME_GET_TSM_STATS_REQ:
5105 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5106 bufConsumed = false;
5107 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005108#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 case eWNI_SME_GET_ASSOC_STAS_REQ:
5110 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5111 break;
5112 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5113 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5114 break;
5115
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305116 case eWNI_SME_SESSION_UPDATE_PARAM:
5117 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305119 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5120 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5121 bufConsumed = false;
5122 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 case eWNI_SME_UPDATE_APWPSIE_REQ:
5124 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5125 break;
5126 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5127 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5128 break;
5129
5130 case eWNI_SME_SET_APWPARSNIEs_REQ:
5131 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5132 break;
5133
5134 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5135 /* Update the beaconInterval */
5136 __lim_process_sme_change_bi(pMac, pMsgBuf);
5137 break;
5138
5139#ifdef QCA_HT_2040_COEX
5140 case eWNI_SME_SET_HT_2040_MODE:
5141 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5142 break;
5143#endif
5144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005145 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5146 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5147 __lim_process_report_message(pMac, pMsg);
5148 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 case eWNI_SME_FT_PRE_AUTH_REQ:
5151 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5152 break;
5153 case eWNI_SME_FT_UPDATE_KEY:
5154 lim_process_ft_update_key(pMac, pMsgBuf);
5155 break;
5156
5157 case eWNI_SME_FT_AGGR_QOS_REQ:
5158 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5159 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160
5161 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5162 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5163 break;
5164#ifdef FEATURE_WLAN_TDLS
5165 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5166 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5167 break;
5168 case eWNI_SME_TDLS_ADD_STA_REQ:
5169 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5170 break;
5171 case eWNI_SME_TDLS_DEL_STA_REQ:
5172 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5173 break;
5174 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5175 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5176 break;
5177#endif
5178 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5179 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5180 break;
5181
5182 case eWNI_SME_CHANNEL_CHANGE_REQ:
5183 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5184 break;
5185
5186 case eWNI_SME_START_BEACON_REQ:
5187 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5188 break;
5189
5190 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5191 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5192 break;
5193
5194 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5195 lim_process_update_add_ies(pMac, pMsgBuf);
5196 break;
5197
5198 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5199 lim_process_modify_add_ies(pMac, pMsgBuf);
5200 break;
5201 case eWNI_SME_SET_HW_MODE_REQ:
5202 lim_process_set_hw_mode(pMac, pMsgBuf);
5203 break;
5204 case eWNI_SME_NSS_UPDATE_REQ:
5205 lim_process_nss_update_request(pMac, pMsgBuf);
5206 break;
5207 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5208 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5209 break;
5210 case eWNI_SME_SET_IE_REQ:
5211 lim_process_set_ie_req(pMac, pMsgBuf);
5212 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305213 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5214 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5215 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305216 case eWNI_SME_EXT_CHANGE_CHANNEL:
5217 lim_process_ext_change_channel(pMac, pMsgBuf);
5218 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005219 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5220 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5221 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005222 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5223 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005224 break;
5225 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5226 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5227 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005228 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005229 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005230 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005231 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005232 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305233 case eWNI_SME_REGISTER_P2P_ACK_CB:
5234 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5235 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305236 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5237 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5238 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005239 case eWNI_SME_UPDATE_CONFIG:
5240 lim_process_sme_update_config(pMac,
5241 (struct update_config *)pMsgBuf);
5242 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305244 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 pMsg->bodyptr = NULL;
5246 break;
5247 } /* switch (msgType) */
5248
5249 return bufConsumed;
5250} /*** end lim_process_sme_req_messages() ***/
5251
5252/**
5253 * lim_process_sme_start_beacon_req()
5254 *
5255 ***FUNCTION:
5256 * This function is called by limProcessMessageQueue(). This
5257 * function processes SME request messages from HDD or upper layer
5258 * application.
5259 *
5260 ***LOGIC:
5261 *
5262 ***ASSUMPTIONS:
5263 *
5264 ***NOTE:
5265 *
5266 * @param pMac Pointer to Global MAC structure
5267 * @param msgType Indicates the SME message type
5268 * @param *pMsgBuf A pointer to the SME message buffer
5269 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5270 * false - if pMsgBuf is not to be freed.
5271 */
5272static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5273{
5274 tpSirStartBeaconIndication pBeaconStartInd;
5275 tpPESession psessionEntry;
5276 uint8_t sessionId; /* PE sessionID */
5277
5278 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005279 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 return;
5281 }
5282
5283 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5284 psessionEntry = pe_find_session_by_bssid(pMac,
5285 pBeaconStartInd->bssid,
5286 &sessionId);
5287 if (psessionEntry == NULL) {
5288 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005289 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 return;
5291 }
5292
5293 if (pBeaconStartInd->beaconStartStatus == true) {
5294 /*
5295 * Currently this Indication comes from SAP
5296 * to start Beacon Tx on a DFS channel
5297 * since beaconing has to be done on DFS
5298 * channel only after CAC WAIT is completed.
5299 * On a DFS Channel LIM does not start beacon
5300 * Tx right after the WMA_ADD_BSS_RSP.
5301 */
5302 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305303 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 FL("Start Beacon with ssid %s Ch %d"),
5305 psessionEntry->ssId.ssId,
5306 psessionEntry->currentOperChannel);
5307 lim_send_beacon_ind(pMac, psessionEntry);
5308 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005309 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 return;
5311 }
5312}
5313
5314/**
5315 * lim_process_sme_channel_change_request() - process sme ch change req
5316 *
5317 * @mac_ctx: Pointer to Global MAC structure
5318 * @msg_buf: pointer to the SME message buffer
5319 *
5320 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5321 *
5322 * Return: None
5323 */
5324static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5325 uint32_t *msg_buf)
5326{
5327 tpSirChanChangeRequest ch_change_req;
5328 tpPESession session_entry;
5329 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005330 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 uint32_t val = 0;
5332
5333 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005334 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335 return;
5336 }
5337 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5338
5339 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5340 ch_change_req->targetChannel);
5341
5342 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5343 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005344 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 return;
5346 }
5347
5348 session_entry = pe_find_session_by_bssid(mac_ctx,
5349 ch_change_req->bssid, &session_id);
5350 if (session_entry == NULL) {
5351 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005352 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 return;
5354 }
5355
5356 if (session_entry->currentOperChannel ==
5357 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005358 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359 return;
5360 }
5361
5362 if (LIM_IS_AP_ROLE(session_entry))
5363 session_entry->channelChangeReasonCode =
5364 LIM_SWITCH_CHANNEL_SAP_DFS;
5365 else
5366 session_entry->channelChangeReasonCode =
5367 LIM_SWITCH_CHANNEL_OPERATION;
5368
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005369 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 session_entry->currentOperChannel,
5371 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005372 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005373
5374 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005375 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 session_entry->ch_center_freq_seg0 =
5377 ch_change_req->center_freq_seg_0;
5378 session_entry->ch_center_freq_seg1 =
5379 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005380 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005382 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 session_entry->htRecommendedTxWidthSet =
5384 session_entry->htSupportedChannelWidthSet;
5385 session_entry->currentOperChannel =
5386 ch_change_req->targetChannel;
5387 session_entry->limRFBand =
5388 lim_get_rf_band(session_entry->currentOperChannel);
5389 /* Initialize 11h Enable Flag */
5390 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5391 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5392 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005393 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 }
5395
5396 session_entry->lim11hEnable = val;
5397 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305398 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 &ch_change_req->operational_rateset,
5400 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305401 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 &ch_change_req->extended_rateset,
5403 sizeof(session_entry->extRateSet));
5404 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5405 session_entry->ch_center_freq_seg0,
5406 session_entry->ch_center_freq_seg1,
5407 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005408 max_tx_pwr, session_entry->peSessionId,
5409 ch_change_req->cac_duration_ms,
5410 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411}
5412
5413/******************************************************************************
5414* lim_start_bss_update_add_ie_buffer()
5415*
5416***FUNCTION:
5417* This function checks the src buffer and its length and then malloc for
5418* dst buffer update the same
5419*
5420***LOGIC:
5421*
5422***ASSUMPTIONS:
5423*
5424***NOTE:
5425*
5426* @param pMac Pointer to Global MAC structure
5427* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5428* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5429* @param *pSrcData_buff A pointer of uint8_t src buffer
5430* @param srcDataLen src buffer length
5431******************************************************************************/
5432
5433static void
5434lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5435 uint8_t **pDstData_buff,
5436 uint16_t *pDstDataLen,
5437 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5438{
5439
5440 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5441 *pDstDataLen = srcDataLen;
5442
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305443 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005444
5445 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005446 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 return;
5448 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305449 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 } else {
5451 *pDstData_buff = NULL;
5452 *pDstDataLen = 0;
5453 }
5454}
5455
5456/******************************************************************************
5457* lim_update_add_ie_buffer()
5458*
5459***FUNCTION:
5460* This function checks the src buffer and length if src buffer length more
5461* than dst buffer length then free the dst buffer and malloc for the new src
5462* length, and update the dst buffer and length. But if dst buffer is bigger
5463* than src buffer length then it just update the dst buffer and length
5464*
5465***LOGIC:
5466*
5467***ASSUMPTIONS:
5468*
5469***NOTE:
5470*
5471* @param pMac Pointer to Global MAC structure
5472* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5473* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5474* @param *pSrcData_buff A pointer of uint8_t src buffer
5475* @param srcDataLen src buffer length
5476******************************************************************************/
5477
5478static void
5479lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5480 uint8_t **pDstData_buff,
5481 uint16_t *pDstDataLen,
5482 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5483{
5484
5485 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005486 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487 return;
5488 }
5489
5490 if (srcDataLen > *pDstDataLen) {
5491 *pDstDataLen = srcDataLen;
5492 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305493 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305495 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496
5497 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005498 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499 *pDstDataLen = 0;
5500 return;
5501 }
5502 }
5503
5504 /* copy the content of buffer into dst buffer
5505 */
5506 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305507 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508
5509}
5510
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005511/**
5512 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5513 * @pMac : Pointer to Global MAC structure
5514 * @pDstData_buff : A pointer to pointer of dst buffer
5515 * @pDstDataLen : A pointer to pointer of dst buffer length
5516 * @pModifyIE : A pointer to tSirModifyIE
5517 *
5518 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5519 *
5520 * Return:
5521 * True or false depending upon whether IE is updated or not
5522 */
5523static bool
5524lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5525 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5526{
Hong Shi1553d692016-09-28 12:16:19 +08005527 int32_t oui_length;
5528 uint8_t *ibss_ie = NULL;
5529 uint8_t *vendor_ie;
5530#define MAC_VENDOR_OUI "\x00\x16\x32"
5531#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005532
5533 ibss_ie = pModifyIE->pIEBuffer;
5534 oui_length = pModifyIE->oui_length;
5535
5536 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005537 pe_err("Invalid set IBSS vendor IE command length %d",
5538 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005539 return false;
5540 }
5541
Hong Shi1553d692016-09-28 12:16:19 +08005542 /*
5543 * Why replace only beacon OUI data here:
5544 * 1. other ie (such as wpa) shall not be overwritten here.
5545 * 2. per spec, beacon oui ie might be set twice and original one
5546 * shall be updated.
5547 */
5548 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5549 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5550 if (vendor_ie) {
5551 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5552 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5553 pModifyIE->ieBufferlength);
5554 } else {
5555 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5556 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005557
Hong Shi1553d692016-09-28 12:16:19 +08005558 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005559 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005560 return false;
5561 }
5562 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5563 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5564 pModifyIE->ieBufferlength);
5565 qdf_mem_free(*pDstData_buff);
5566 *pDstDataLen = new_length;
5567 *pDstData_buff = new_ptr;
5568 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005569 return true;
5570}
5571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572/*
5573* lim_process_modify_add_ies() - process modify additional IE req.
5574*
5575* @mac_ctx: Pointer to Global MAC structure
5576* @msg_buf: pointer to the SME message buffer
5577*
5578* This function update the PE buffers for additional IEs.
5579*
5580* Return: None
5581*/
5582static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5583 uint32_t *msg_buf)
5584{
5585 tpSirModifyIEsInd modify_add_ies;
5586 tpPESession session_entry;
5587 uint8_t session_id;
5588 bool ret = false;
5589 tSirAddIeParams *add_ie_params;
5590
5591 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005592 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593 return;
5594 }
5595
5596 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5597 /* Incoming message has smeSession, use BSSID to find PE session */
5598 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005599 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600
5601 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005602 pe_err("Session not found for given bssid"
5603 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005604 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 goto end;
5606 }
5607 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5608 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5609 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005610 pe_err("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 modify_add_ies->modifyIE.pIEBuffer,
5612 modify_add_ies->modifyIE.ieBufferlength,
5613 modify_add_ies->modifyIE.ieID,
5614 modify_add_ies->modifyIE.ieIDLen,
5615 modify_add_ies->updateType);
5616 goto end;
5617 }
5618 add_ie_params = &session_entry->addIeParams;
5619 switch (modify_add_ies->updateType) {
5620 case eUPDATE_IE_PROBE_RESP:
5621 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005622 if (LIM_IS_IBSS_ROLE(session_entry)) {
5623 lim_update_ibss_prop_add_ies(mac_ctx,
5624 &add_ie_params->probeRespData_buff,
5625 &add_ie_params->probeRespDataLen,
5626 &modify_add_ies->modifyIE);
5627 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 break;
5629 case eUPDATE_IE_ASSOC_RESP:
5630 /* assoc resp IE */
5631 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305632 QDF_TRACE(QDF_MODULE_ID_PE,
5633 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 "assoc resp add ie not present %d"),
5635 add_ie_params->assocRespDataLen);
5636 }
5637 /* search through the buffer and modify the IE */
5638 break;
5639 case eUPDATE_IE_PROBE_BCN:
5640 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005641 if (LIM_IS_IBSS_ROLE(session_entry)) {
5642 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5643 &add_ie_params->probeRespBCNData_buff,
5644 &add_ie_params->probeRespBCNDataLen,
5645 &modify_add_ies->modifyIE);
5646 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 if (ret == true && modify_add_ies->modifyIE.notify) {
5648 lim_handle_param_update(mac_ctx,
5649 modify_add_ies->updateType);
5650 }
5651 break;
5652 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005653 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 modify_add_ies->updateType);
5655 break;
5656 }
5657end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305658 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 modify_add_ies->modifyIE.pIEBuffer = NULL;
5660}
5661
5662/*
5663* lim_process_update_add_ies() - process additional IE update req
5664*
5665* @mac_ctx: Pointer to Global MAC structure
5666* @msg_buf: pointer to the SME message buffer
5667*
5668* This function update the PE buffers for additional IEs.
5669*
5670* Return: None
5671*/
5672static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5673 uint32_t *msg_buf)
5674{
5675 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5676 uint8_t session_id;
5677 tpPESession session_entry;
5678 tSirAddIeParams *addn_ie;
5679 uint16_t new_length = 0;
5680 uint8_t *new_ptr = NULL;
5681 tSirUpdateIE *update_ie;
5682
5683 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005684 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685 return;
5686 }
5687 update_ie = &update_add_ies->updateIE;
5688 /* incoming message has smeSession, use BSSID to find PE session */
5689 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005690 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691
5692 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005693 pe_err("Session not found for given bssid"
5694 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005695 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 goto end;
5697 }
5698 addn_ie = &session_entry->addIeParams;
5699 /* if len is 0, upper layer requested freeing of buffer */
5700 if (0 == update_ie->ieBufferlength) {
5701 switch (update_add_ies->updateType) {
5702 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305703 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005704 addn_ie->probeRespData_buff = NULL;
5705 addn_ie->probeRespDataLen = 0;
5706 break;
5707 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305708 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 addn_ie->assocRespData_buff = NULL;
5710 addn_ie->assocRespDataLen = 0;
5711 break;
5712 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305713 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 addn_ie->probeRespBCNData_buff = NULL;
5715 addn_ie->probeRespBCNDataLen = 0;
5716
5717 if (update_ie->notify)
5718 lim_handle_param_update(mac_ctx,
5719 update_add_ies->updateType);
5720 break;
5721 default:
5722 break;
5723 }
5724 return;
5725 }
5726 switch (update_add_ies->updateType) {
5727 case eUPDATE_IE_PROBE_RESP:
5728 if (update_ie->append) {
5729 /*
5730 * In case of append, allocate new memory
5731 * with combined length
5732 */
5733 new_length = update_ie->ieBufferlength +
5734 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305735 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005737 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738 goto end;
5739 }
5740 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305741 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305743 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 update_ie->pAdditionIEBuffer,
5745 update_ie->ieBufferlength);
5746 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305747 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 /* adjust length accordingly */
5749 addn_ie->probeRespDataLen = new_length;
5750 /* save refernece of local buffer in PE session */
5751 addn_ie->probeRespData_buff = new_ptr;
5752 goto end;
5753 }
5754 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5755 &addn_ie->probeRespDataLen,
5756 update_ie->pAdditionIEBuffer,
5757 update_ie->ieBufferlength);
5758 break;
5759 case eUPDATE_IE_ASSOC_RESP:
5760 /* assoc resp IE */
5761 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5762 &addn_ie->assocRespDataLen,
5763 update_ie->pAdditionIEBuffer,
5764 update_ie->ieBufferlength);
5765 break;
5766 case eUPDATE_IE_PROBE_BCN:
5767 /* probe resp Bcn IE */
5768 lim_update_add_ie_buffer(mac_ctx,
5769 &addn_ie->probeRespBCNData_buff,
5770 &addn_ie->probeRespBCNDataLen,
5771 update_ie->pAdditionIEBuffer,
5772 update_ie->ieBufferlength);
5773 if (update_ie->notify)
5774 lim_handle_param_update(mac_ctx,
5775 update_add_ies->updateType);
5776 break;
5777 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005778 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 break;
5780 }
5781end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305782 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 update_ie->pAdditionIEBuffer = NULL;
5784}
5785
5786/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305787 * send_extended_chan_switch_action_frame()- function to send ECSA
5788 * action frame for each sta connected to SAP/GO and AP in case of
5789 * STA .
5790 * @mac_ctx: pointer to global mac structure
5791 * @new_channel: new channel to switch to.
5792 * @ch_bandwidth: BW of channel to calculate op_class
5793 * @session_entry: pe session
5794 *
5795 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5796 *
5797 * Return: void
5798 */
5799
5800static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5801 uint16_t new_channel, uint8_t ch_bandwidth,
5802 tpPESession session_entry)
5803{
5804 uint16_t op_class;
5805 uint8_t switch_mode = 0, i;
5806 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005807 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305808
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005809 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305810 mac_ctx->scan.countryCodeCurrent,
5811 new_channel,
5812 ch_bandwidth);
5813
5814 if (LIM_IS_AP_ROLE(session_entry) &&
5815 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5816 switch_mode = 1;
5817
gaoleze2920bd2017-03-21 17:38:42 +08005818 switch_count = session_entry->gLimChannelSwitch.switchCount;
5819
Abhishek Singh518323d2015-10-19 17:42:01 +05305820 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005821 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305822 psta =
5823 session_entry->dph.dphHashTable.pDphNodeArray + i;
5824 if (psta && psta->added)
5825 lim_send_extended_chan_switch_action_frame(
5826 mac_ctx,
5827 psta->staAddr,
5828 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005829 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305830 }
5831 } else if (LIM_IS_STA_ROLE(session_entry)) {
5832 lim_send_extended_chan_switch_action_frame(mac_ctx,
5833 session_entry->bssId,
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
5838}
5839
5840/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5842 *
5843 * @mac_ctx: Pointer to Global MAC structure
5844 * @msg_buf: pointer to the SME message buffer
5845 *
5846 * This function processes SME request messages from HDD or upper layer
5847 * application.
5848 *
5849 * Return: None
5850 */
5851static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5852 uint32_t *msg_buf)
5853{
5854 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5855 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 uint8_t session_id;
5857 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005858 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859
5860 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005861 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 return;
5863 }
5864
5865 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5866 session_entry = pe_find_session_by_bssid(mac_ctx,
5867 dfs_csa_ie_req->bssid, &session_id);
5868 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005869 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5871 return;
5872 }
5873
5874 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005875 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 GET_LIM_SYSTEM_ROLE(session_entry));
5877 return;
5878 }
5879
5880 /* target channel */
5881 session_entry->gLimChannelSwitch.primaryChannel =
5882 dfs_csa_ie_req->targetChannel;
5883
5884 /* Channel switch announcement needs to be included in beacon */
5885 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005886 session_entry->gLimChannelSwitch.switchCount =
5887 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005889 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305890 session_entry->gLimChannelSwitch.sec_ch_offset =
5891 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5893 session_entry->gLimChannelSwitch.switchMode = 1;
5894
5895 /*
5896 * Validate if SAP is operating HT or VHT mode and set the Channel
5897 * Switch Wrapper element with the Wide Band Switch subelement.
5898 */
5899 if (true != session_entry->vhtCapability)
5900 goto skip_vht;
5901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 /* Now encode the Wider Ch BW element depending on the ch width */
5903 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005904 switch (dfs_csa_ie_req->ch_params.ch_width) {
5905 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 /*
5907 * Wide channel BW sublement in channel wrapper element is not
5908 * required in case of 20 Mhz operation. Currently It is set
5909 * only set in case of 40/80 Mhz Operation.
5910 */
5911 session_entry->dfsIncludeChanWrapperIe = false;
5912 wider_bw_ch_switch->newChanWidth =
5913 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5914 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005915 case CH_WIDTH_40MHZ:
5916 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 wider_bw_ch_switch->newChanWidth =
5918 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5919 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005920 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 session_entry->dfsIncludeChanWrapperIe = true;
5922 wider_bw_ch_switch->newChanWidth =
5923 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5924 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005925 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 session_entry->dfsIncludeChanWrapperIe = true;
5927 wider_bw_ch_switch->newChanWidth =
5928 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5929 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005930 case CH_WIDTH_80P80MHZ:
5931 session_entry->dfsIncludeChanWrapperIe = true;
5932 wider_bw_ch_switch->newChanWidth =
5933 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005934 /*
5935 * This is not applicable for 20/40/80 Mhz.
5936 * Only used when we support 80+80 Mhz operation.
5937 * In case of 80+80 Mhz, this parameter indicates
5938 * center channel frequency index of 80 Mhz channel of
5939 * frequency segment 1.
5940 */
5941 wider_bw_ch_switch->newCenterChanFreq1 =
5942 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005943 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 default:
5945 session_entry->dfsIncludeChanWrapperIe = false;
5946 /*
5947 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5948 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5949 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005950 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 break;
5952 }
5953 /* Fetch the center channel based on the channel width */
5954 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005955 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956skip_vht:
5957 /* Send CSA IE request from here */
5958 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5959 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005960 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 return;
5962 }
5963
5964 /*
5965 * First beacon update request is sent here, the remaining updates are
5966 * done when the FW responds back after sending the first beacon after
5967 * the template update
5968 */
5969 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305970
5971 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5972 ch_offset = BW80;
5973 else
5974 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5975
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005976 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305977 session_entry->gLimChannelSwitch.switchCount,
5978 session_entry->gLimChannelSwitch.primaryChannel,
5979 session_entry->gLimChannelSwitch.ch_width,
5980 session_entry->dfsIncludeChanWrapperIe,
5981 ch_offset);
5982
Abhishek Singh518323d2015-10-19 17:42:01 +05305983 /* Send ECSA Action frame after updating the beacon */
5984 send_extended_chan_switch_action_frame(mac_ctx,
5985 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305986 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 session_entry->gLimChannelSwitch.switchCount--;
5988}
5989
5990/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305991 * lim_process_ext_change_channel()- function to send ECSA
5992 * action frame for STA/CLI .
5993 * @mac_ctx: pointer to global mac structure
5994 * @msg: params from sme for new channel.
5995 *
5996 * This function is called to send ECSA frame for STA/CLI.
5997 *
5998 * Return: void
5999 */
6000
6001static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6002 uint32_t *msg)
6003{
6004 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6005 (struct sir_sme_ext_cng_chan_req *) msg;
6006 tpPESession session_entry = NULL;
6007
6008 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006009 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05306010 return;
6011 }
6012 session_entry =
6013 pe_find_session_by_sme_session_id(mac_ctx,
6014 ext_chng_channel->session_id);
6015 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006016 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05306017 ext_chng_channel->session_id);
6018 return;
6019 }
6020 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006021 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05306022 return;
6023 }
6024 send_extended_chan_switch_action_frame(mac_ctx,
6025 ext_chng_channel->new_channel,
6026 0, session_entry);
6027}
6028
6029/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006030 * lim_process_nss_update_request() - process sme nss update req
6031 *
6032 * @mac_ctx: Pointer to Global MAC structure
6033 * @msg_buf: pointer to the SME message buffer
6034 *
6035 * This function processes SME request messages from HDD or upper layer
6036 * application.
6037 *
6038 * Return: None
6039 */
6040static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6041 uint32_t *msg_buf)
6042{
6043 struct sir_nss_update_request *nss_update_req_ptr;
6044 tpPESession session_entry = NULL;
6045
6046 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006047 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 return;
6049 }
6050
6051 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306052 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053 nss_update_req_ptr->vdev_id);
6054 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006055 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 nss_update_req_ptr->vdev_id);
6057 return;
6058 }
6059
6060 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006061 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 GET_LIM_SYSTEM_ROLE(session_entry));
6063 return;
6064 }
6065
6066 /* populate nss field in the beacon */
6067 session_entry->gLimOperatingMode.present = 1;
6068 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306069 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6070
6071 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6072 (session_entry->ch_width > CH_WIDTH_80MHZ))
6073 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6074
6075 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 /* Send nss update request from here */
6078 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6079 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006080 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 return;
6082 }
6083
6084 lim_send_beacon_ind(mac_ctx, session_entry);
6085}
6086
6087/**
6088 * lim_process_set_ie_req() - process sme set IE request
6089 *
6090 * @mac_ctx: Pointer to Global MAC structure
6091 * @msg_buf: pointer to the SME message buffer
6092 *
6093 * This function processes SME request messages from HDD or upper layer
6094 * application.
6095 *
6096 * Return: None
6097 */
6098static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6099{
6100 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306101 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102
6103 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006104 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 return;
6106 }
6107
6108 msg = (struct send_extcap_ie *)msg_buf;
6109 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306110 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006111 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112
6113}