blob: b74f7c3ef9d6c9ff4f3748d6b1c334d47449be65 [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;
gaolez76d2a162017-03-21 19:23:58 +08001081 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1082 (CHAN_HOP_ALL_BANDS_ENABLE ||
1083 SIR_BAND_5_GHZ == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 if (wlan_cfg_get_int(mac_ctx,
1085 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001086 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 else
1088 session->lim11hEnable = val;
1089
1090 if (session->lim11hEnable &&
1091 (eSIR_INFRA_AP_MODE ==
1092 mlm_start_req->bssType)) {
1093 cfg_get_wmi_dfs_master_param =
1094 wlan_cfg_get_int(mac_ctx,
1095 WNI_CFG_DFS_MASTER_ENABLED,
1096 &val);
1097 session->lim11hEnable = val;
1098 }
1099 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1100 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001101 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 }
1103
1104 if (!session->lim11hEnable) {
1105 if (cfg_set_int(mac_ctx,
1106 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1107 eSIR_SUCCESS)
1108 /*
1109 * Failed to set the CFG param
1110 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1111 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001112 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 }
1114
1115 session->limPrevSmeState = session->limSmeState;
1116 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1117 MTRACE(mac_trace
1118 (mac_ctx, TRACE_CODE_SME_STATE,
1119 session->peSessionId,
1120 session->limSmeState));
1121
1122 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1123 (uint32_t *) mlm_start_req);
1124 return;
1125 } else {
1126
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001127 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 mac_ctx->lim.gLimSmeState);
1129 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001130 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1132
1133free:
1134 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001135 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 session->pLimStartBssReq = NULL;
1137 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001138 if (NULL != sme_start_bss_req)
1139 qdf_mem_free(sme_start_bss_req);
1140 if (NULL != mlm_start_req)
1141 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 if (NULL != session) {
1143 pe_delete_session(mac_ctx, session);
1144 session = NULL;
1145 }
1146 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1147 session, sme_session_id, sme_transaction_id);
1148}
1149
1150/**
1151 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1152 *
1153 * @pMac: Global MAC context
1154 * @pMsg: Message pointer
1155 *
1156 * Wrapper for the function __lim_handle_sme_start_bss_request
1157 * This message will be defered until softmac come out of
1158 * scan mode or if we have detected radar on the current
1159 * operating channel.
1160 *
1161 * return true - If we consumed the buffer
1162 * false - If have defered the message.
1163 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001164static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1165 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166{
1167 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1168 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1169 /**
1170 * If message defered, buffer is not consumed yet.
1171 * So return false
1172 */
1173 return false;
1174 }
1175
1176 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1177 return true;
1178}
1179
1180/**
1181 * lim_get_random_bssid()
1182 *
1183 * FUNCTION:This function is called to process generate the random number for bssid
1184 * This function is called to process SME_SCAN_REQ message
1185 * from HDD or upper layer application.
1186 *
1187 * LOGIC:
1188 *
1189 * ASSUMPTIONS:
1190 *
1191 * NOTE:
1192 * 1. geneartes the unique random number for bssid in ibss
1193 *
1194 * @param pMac Pointer to Global MAC structure
1195 * @param *data Pointer to bssid buffer
1196 * @return None
1197 */
1198void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1199{
1200 uint32_t random[2];
1201 random[0] = tx_time_get();
1202 random[0] |= (random[0] << 15);
1203 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301204 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205}
1206
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301207static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 tpSirSmeScanReq pScanReq)
1209{
1210 tSirScanOffloadReq *pScanOffloadReq;
1211 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001212 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001214 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 tSirRetStatus status, rc = eSIR_SUCCESS;
1216 tDot11fIEExtCap extracted_extcap = {0};
1217 bool extcap_present = true;
1218
1219 if (pScanReq->uIEFieldLen) {
1220 status = lim_strip_extcap_update_struct(pMac,
1221 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1222 &pScanReq->uIEFieldLen, &extracted_extcap);
1223
1224 if (eSIR_SUCCESS != status) {
1225 extcap_present = false;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001226 pe_debug("Unable to Strip ExtCap IE from Scan Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 }
1228
1229 if (extcap_present) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001230 pe_debug("Extcap was part of SCAN IE - Updating FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1232 &extracted_extcap, true);
1233 }
1234 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001235 pe_debug("No IEs in the scan request from supplicant");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 }
1237
1238 /**
1239 * The tSirScanOffloadReq will reserve the space for first channel,
1240 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1241 */
1242 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001243 (pScanReq->channelList.numChannels - 1) +
1244 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001245
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301246 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 if (NULL == pScanOffloadReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001248 pe_err("AllocateMemory failed for pScanOffloadReq");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301249 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 }
1251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1253 msg.bodyptr = pScanOffloadReq;
1254 msg.bodyval = 0;
1255
Anurag Chouhanc5548422016-02-24 18:33:27 +05301256 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257
1258 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001259 pe_err("Invalid value (%d) for numSsid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301261 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301262 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 }
1264
1265 pScanOffloadReq->numSsid = pScanReq->numSsid;
1266 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1267 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301268 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 (uint8_t *) pScanReq->ssId[i].ssId,
1270 pScanOffloadReq->ssId[i].length);
1271 }
1272
1273 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301274 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 pScanOffloadReq->bssType = pScanReq->bssType;
1276 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1277 pScanOffloadReq->scanType = pScanReq->scanType;
1278 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1279 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1280 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301281 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1282 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301283 pScanOffloadReq->scan_adaptive_dwell_mode =
1284 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285
Paul Zhangd2315472017-02-22 10:02:50 +08001286 for (i = 0; i < pMac->lim.maxBssId; i++) {
1287 tpPESession session_entry =
1288 pe_find_session_by_sme_session_id(pMac, i);
1289 if (session_entry &&
1290 (eLIM_MLM_LINK_ESTABLISHED_STATE ==
1291 session_entry->limMlmState) &&
1292 (session_entry->beaconParams.beaconInterval
1293 < BEACON_INTERVAL_THRESHOLD)) {
1294 pScanOffloadReq->burst_scan_duration =
1295 STA_BURST_SCAN_DURATION;
1296 break;
1297 }
1298 }
1299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 /* for normal scan, the value for p2pScanType should be 0
1301 always */
1302 if (pScanReq->p2pSearch)
1303 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1304
1305 pScanOffloadReq->sessionId = pScanReq->sessionId;
1306 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001307 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301308 pScanOffloadReq->scan_adaptive_dwell_mode =
1309 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310
1311 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001312 pe_err("Invalid pe sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313 pScanOffloadReq->sessionId);
1314
1315 pScanOffloadReq->channelList.numChannels =
1316 pScanReq->channelList.numChannels;
1317 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1318 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1319 p[i] = pScanReq->channelList.channelNumber[i];
1320
1321 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1322 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1323 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301324 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 pScanOffloadReq->uIEFieldOffset,
1326 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1327 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001328
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 rc = wma_post_ctrl_msg(pMac, &msg);
1330 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001331 pe_err("wma_post_ctrl_msg() return failure");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301332 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301333 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 }
1335
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001336 pe_debug("Processed Offload Scan Request Successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301338 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339}
1340
1341/**
1342 * __lim_process_sme_scan_req() - Process the SME Scan Request
1343 * @mac_ctx: Global MAC Context
1344 * @msg_buf: Buffer which contains the request and pertinent parameters
1345 *
1346 * This function is called to process SME_SCAN_REQ message
1347 * from HDD or upper layer application.
1348 *
1349 * Return: None
1350 */
1351
1352static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1353 uint32_t *msg_buf)
1354{
1355 tpSirSmeScanReq scan_req;
1356 uint8_t valid_req = 0;
1357
1358#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1359 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1360 eSIR_SUCCESS, eSIR_SUCCESS);
1361#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301362 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363
1364 scan_req = (tpSirSmeScanReq) msg_buf;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001365 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 -08001366 scan_req->scan_id, scan_req->channelList.numChannels,
1367 scan_req->minChannelTime, scan_req->maxChannelTime,
1368 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1369 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301370 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1372 /*
1373 * Since scan req always requires a response, we will overwrite response
1374 * required here. This is added esp to take care of the condition where
1375 * in p2p go case, we hold the scan req and insert single NOA. We send
1376 * the held scan request to FW later on getting start NOA ind from FW so
1377 * we lose state of the gLimRspReqd flag for the scan req if any other
1378 * request comes by then. e.g. While unit testing, we found when insert
1379 * single NOA is done, we see a get stats request which turns the flag
1380 * gLimRspReqd to false; now when we actually start the saved scan req
1381 * for init scan after getting NOA started, the gLimRspReqd being a
1382 * global flag is showing false instead of true value for this saved
1383 * scan req. Since all scan reqs coming to lim require a response,
1384 * there is no harm in setting the global flag gLimRspReqd to true here.
1385 */
1386 mac_ctx->lim.gLimRspReqd = true;
1387
1388 /*
1389 * copy the Self MAC address from SmeReq to the globalplace,
1390 * used for sending probe req
1391 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001392 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1393 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1395
1396 if (!valid_req || mac_ctx->lim.scan_disabled) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001397 pe_err("Scan disabled %d, Valid Scan Req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 mac_ctx->lim.scan_disabled, valid_req);
1399
1400 if (mac_ctx->lim.gLimRspReqd) {
1401 mac_ctx->lim.gLimRspReqd = false;
1402
1403 lim_send_sme_scan_rsp(mac_ctx,
1404 eSIR_SME_INVALID_PARAMETERS,
1405 scan_req->sessionId,
1406 scan_req->transactionId,
1407 scan_req->scan_id);
1408 }
1409 return;
1410 }
1411
1412 /*
1413 * If scan request is received in idle, joinFailed
1414 * states or in link established state (in STA role)
1415 * or in normal state (in STA-in-IBSS/AP role) with
1416 * 'return fresh scan results' request from HDD or
1417 * it is periodic background scanning request,
1418 * trigger fresh scan request to MLM
1419 */
1420 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1421
1422 mac_ctx->lim.gLim24Band11dScanDone = 0;
1423 mac_ctx->lim.gLim50Band11dScanDone = 0;
1424 mac_ctx->lim.gLimReturnAfterFirstMatch =
1425 scan_req->returnAfterFirstMatch;
1426 mac_ctx->lim.gLimReturnUniqueResults =
1427 ((scan_req->returnUniqueResults) > 0 ? true : false);
1428
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301429 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 lim_send_hal_start_scan_offload_req(mac_ctx,
1431 scan_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001432 pe_err("Couldn't send Offload scan request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 lim_send_sme_scan_rsp(mac_ctx,
1434 eSIR_SME_INVALID_PARAMETERS,
1435 scan_req->sessionId,
1436 scan_req->transactionId,
1437 scan_req->scan_id);
1438 return;
1439 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301440 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 /* In all other cases return 'cached' scan results */
1442 if (mac_ctx->lim.gLimRspReqd) {
1443 mac_ctx->lim.gLimRspReqd = false;
1444 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1445 scan_req->sessionId,
1446 scan_req->transactionId, scan_req->scan_id);
1447 }
1448 }
1449}
1450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451/**
1452 * __lim_process_clear_dfs_channel_list()
1453 *
1454 ***FUNCTION:
1455 ***Clear DFS channel list when country is changed/aquired.
1456 .*This message is sent from SME.
1457 *
1458 ***LOGIC:
1459 *
1460 ***ASSUMPTIONS:
1461 *
1462 ***NOTE:
1463 *
1464 * @param pMac Pointer to Global MAC structure
1465 * @param *pMsgBuf A pointer to the SME message buffer
1466 * @return None
1467 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001468static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1469 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301471 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472}
1473
1474/**
1475 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1476 * @mac_ctx: Pointer to Global MAC structure
1477 * @msg_buf: A pointer to the SME message buffer
1478 *
1479 * This function is called to process SME_JOIN_REQ message
1480 * from HDD or upper layer application.
1481 *
1482 * Return: None
1483 */
1484static void
1485__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1486{
1487 tpSirSmeJoinReq sme_join_req = NULL;
1488 tLimMlmJoinReq *mlm_join_req;
1489 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1490 uint32_t val = 0;
1491 uint16_t n_size;
1492 uint8_t session_id;
1493 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301494 uint8_t sme_session_id = 0;
1495 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001496 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 uint16_t ie_len;
1498 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001499 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001500 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501
Arif Hussain995fcaf2016-07-18 11:28:22 -07001502 if (!mac_ctx || !msg_buf) {
1503 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1504 FL("JOIN REQ with invalid data"));
1505 return;
1506 }
1507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508/* FEATURE_WLAN_DIAG_SUPPORT */
1509#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1510 /*
1511 * Not sending any session, since it is not created yet.
1512 * The response whould have correct state.
1513 */
1514 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1515#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 /*
1518 * Expect Join request in idle state.
1519 * Reassociate request is expected in link established state.
1520 */
1521
1522 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1523 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1524 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1525 msg_buf);
1526
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301527 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001529 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301531 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301533 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 n_size);
1535
1536 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1537 /* Received invalid eWNI_SME_JOIN_REQ */
1538 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001539 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 sme_join_req->sessionId);
1541 ret_code = eSIR_SME_INVALID_PARAMETERS;
1542 goto end;
1543 }
1544
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001545 /*
1546 * Update the capability here itself as this is used in
1547 * lim_extract_ap_capability() below. If not updated issues
1548 * like not honoring power constraint on 1st association after
1549 * driver loading might occur.
1550 */
1551 lim_update_rrm_capability(mac_ctx, sme_join_req);
1552
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001553 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001555 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 &session_id);
1557
1558 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001559 pe_err("Session(%d) Already exists for BSSID: "
1560 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001562 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 session->limSmeState);
1564
1565 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1566 session->smeSessionId == sme_join_req->sessionId) {
1567 /*
1568 * Received eWNI_SME_JOIN_REQ for same
1569 * BSS as currently associated.
1570 * Log the event and send success
1571 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001572 pe_warn("SessionId: %d", session_id);
1573 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 /* Send Join success response to host */
1575 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1576 session = NULL;
1577 goto end;
1578 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001579 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 ret_code = eSIR_SME_REFUSED;
1581 session = NULL;
1582 goto end;
1583 }
1584 } else {
1585 /*
1586 * Session Entry does not exist for given BSSId
1587 * Try to Create a new session
1588 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001589 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 &session_id, mac_ctx->lim.maxStation,
1591 eSIR_INFRASTRUCTURE_MODE);
1592 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001593 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1595 goto end;
1596 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001597 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 session_id);
1599 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001600 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
1602 /*
1603 * Store Session related parameters
1604 * Store PE session Id in session Table
1605 */
1606 session->peSessionId = session_id;
1607
1608 /* store the smejoin req handle in session table */
1609 session->pLimJoinReq = sme_join_req;
1610
1611 /* Store SME session Id in sessionTable */
1612 session->smeSessionId = sme_join_req->sessionId;
1613
1614 /* Store SME transaction Id in session Table */
1615 session->transactionId = sme_join_req->transactionId;
1616
1617 /* Store beaconInterval */
1618 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001619 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301621 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 sizeof(session->htConfig));
1623
Sandeep Puligilla98917432016-06-10 13:50:28 -07001624 qdf_mem_copy(&(session->vht_config),
1625 &(sme_join_req->vht_config),
1626 sizeof(session->vht_config));
1627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 /* Copying of bssId is already done, while creating session */
1629 sir_copy_mac_addr(session->selfMacAddr,
1630 sme_join_req->selfMacAddr);
1631 session->bssType = sme_join_req->bsstype;
1632
1633 session->statypeForBss = STA_ENTRY_PEER;
1634 session->limWmeEnabled = sme_join_req->isWMEenabled;
1635 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301636 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301638 session->enable_bcast_probe_rsp =
1639 sme_join_req->enable_bcast_probe_rsp;
1640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001642 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1644
1645 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1646 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001647 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648
1649 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001650 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 session->isCiscoVendorAP = true;
1652 } else {
1653 session->isCiscoVendorAP = false;
1654 }
1655
1656 /* Copy the dot 11 mode in to the session table */
1657
1658 session->dot11mode = sme_join_req->dot11mode;
1659#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1660 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1661#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001662 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1664 session->enableHtSmps = sme_join_req->enableHtSmps;
1665 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001666 session->send_smps_action =
1667 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001668 /*
1669 * By default supported NSS 1x1 is set to true
1670 * and later on updated while determining session
1671 * supported rates which is the intersection of
1672 * self and peer rates
1673 */
1674 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301675 /*Store Persona */
1676 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001677 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 -08001678 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001679 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001680 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301681 session->supported_nss_1x1,
1682 session->pePersona,
1683 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001684
1685 /*Store Persona */
1686 session->pePersona = sme_join_req->staPersona;
1687 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001688 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d"),
1689 session->pePersona, sme_join_req->cbMode,
1690 session->nwType, session->dot11mode);
1691
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001692 /* Copy The channel Id to the session Table */
1693 session->currentOperChannel = bss_desc->channelId;
1694 if (IS_5G_CH(session->currentOperChannel))
1695 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001697 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1698 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1699 session->vdev_nss = vdev_type_nss->p2p_cli;
1700 else
1701 session->vdev_nss = vdev_type_nss->sta;
1702 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 session->vhtCapability =
1704 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301706 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001707 session->vht_config.su_beam_formee =
1708 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001710 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 session->enableVhtpAid =
1713 sme_join_req->enableVhtpAid;
1714 session->enableVhtGid =
1715 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001716 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001717 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 }
Krunal Soni53993f72016-07-08 18:20:03 -07001719
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001720 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1721 lim_update_session_he_capable(mac_ctx, session);
1722 lim_copy_join_req_he_cap(session, sme_join_req);
1723 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001724
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001725 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301726 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001727 session->vht_config.su_beam_formee,
1728 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001729 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001731 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 /* cbMode is already merged value of peer and self -
1734 * done by csr in csr_get_cb_mode_from_ies */
1735 session->htSupportedChannelWidthSet =
1736 (sme_join_req->cbMode) ? 1 : 0;
1737 session->htRecommendedTxWidthSet =
1738 session->htSupportedChannelWidthSet;
1739 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1740
1741 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1742 session->ch_center_freq_seg0 =
1743 session->currentOperChannel - 2;
1744 session->ch_width = CH_WIDTH_40MHZ;
1745 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1746 sme_join_req->cbMode) {
1747 session->ch_center_freq_seg0 =
1748 session->currentOperChannel + 2;
1749 session->ch_width = CH_WIDTH_40MHZ;
1750 } else {
1751 session->ch_center_freq_seg0 = 0;
1752 session->ch_width = CH_WIDTH_20MHZ;
1753 }
1754
1755 /* Record if management frames need to be protected */
1756#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001757 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001759 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761#endif
1762
1763#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001764 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765#endif
1766
1767 /* Copy the SSID from smejoinreq to session entry */
1768 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301769 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 session->ssId.length);
1771
1772 /*
1773 * Determin 11r or ESE connection based on input from SME
1774 * which inturn is dependent on the profile the user wants
1775 * to connect to, So input is coming from supplicant
1776 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778#ifdef FEATURE_WLAN_ESE
1779 session->isESEconnection = sme_join_req->isESEconnection;
1780#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 session->isFastTransitionEnabled =
1782 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 session->isFastRoamIniFeatureEnabled =
1785 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 session->txLdpcIniFeatureEnabled =
1787 sme_join_req->txLdpcIniFeatureEnabled;
1788
1789 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1790 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 } else {
1792 /*
1793 * Throw an error and return and make
1794 * sure to delete the session.
1795 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001796 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 session->bssType);
1798 ret_code = eSIR_SME_INVALID_PARAMETERS;
1799 goto end;
1800 }
1801
1802 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301803 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 &sme_join_req->addIEScan, sizeof(tSirAddie));
1805
1806 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301807 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1809
1810 val = sizeof(tLimMlmJoinReq) +
1811 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301812 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001814 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301815 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1816 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818
1819 /* PE SessionId is stored as a part of JoinReq */
1820 mlm_join_req->sessionId = session->peSessionId;
1821
1822 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1823 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1824 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001825 pe_err("couldn't retrieve JoinFailureTimer value"
1826 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 mlm_join_req->joinFailureTimeout =
1828 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1829 }
1830
1831 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301832 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 (void *)&sme_join_req->operationalRateSet,
1834 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301835 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 (void *)&sme_join_req->extendedRateSet,
1837 sizeof(tSirMacRateSet));
1838 /*
1839 * this may not be needed anymore now, as rateSet is now
1840 * included in the session entry and MLM has session context.
1841 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301842 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 (void *)&session->rateSet,
1844 sizeof(tSirMacRateSet));
1845
1846 session->encryptType = sme_join_req->UCEncryptionType;
1847
1848 mlm_join_req->bssDescription.length =
1849 session->pLimJoinReq->bssDescription.length;
1850
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301851 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 (uint8_t *)
1853 &session->pLimJoinReq->bssDescription.bssId,
1854 session->pLimJoinReq->bssDescription.length + 2);
1855
1856 session->limCurrentBssCaps =
1857 session->pLimJoinReq->bssDescription.capabilityInfo;
1858
1859 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1860 session->currentOperChannel);
1861 local_power_constraint = reg_max;
1862
1863 lim_extract_ap_capability(mac_ctx,
1864 (uint8_t *)
1865 session->pLimJoinReq->bssDescription.ieFields,
1866 lim_get_ielen_from_bss_description(
1867 &session->pLimJoinReq->bssDescription),
1868 &session->limCurrentBssQosCaps,
1869 &session->limCurrentBssPropCap,
1870 &session->gLimCurrentBssUapsd,
1871 &local_power_constraint, session);
1872
Krunal Soni53993f72016-07-08 18:20:03 -07001873 /*
1874 * Once the AP capabilities are available then set the
1875 * beam forming capabilities accordingly.
1876 */
1877 if (session->nss == 1) {
1878 session->vht_config.su_beam_former = 0;
1879 session->vht_config.tx_stbc = 0;
1880 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301881 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001882 }
1883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 session->maxTxPower = lim_get_max_tx_power(reg_max,
1885 local_power_constraint,
1886 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301887
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001888 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301889 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301891 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1892 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1893 pe_debug("Update MaxTxPower in join Req to %d",
1894 sme_join_req->powerCap.maxTxPower);
1895 }
1896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 if (session->gLimCurrentBssUapsd) {
1898 session->gUapsdPerAcBitmask =
1899 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001900 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 session->gUapsdPerAcBitmask);
1902
1903 /* resetting the dynamic uapsd mask */
1904 session->gUapsdPerAcDeliveryEnableMask = 0;
1905 session->gUapsdPerAcTriggerEnableMask = 0;
1906 }
1907
1908 session->limRFBand =
1909 lim_get_rf_band(session->currentOperChannel);
1910
1911 /* Initialize 11h Enable Flag */
1912 if (SIR_BAND_5_GHZ == session->limRFBand) {
1913 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1914 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001915 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 session->lim11hEnable =
1917 WNI_CFG_11H_ENABLED_STADEF;
1918 } else {
1919 session->lim11hEnable = val;
1920 }
1921 } else {
1922 session->lim11hEnable = 0;
1923 }
1924
1925 /*
1926 * To care of the scenario when STA transitions from
1927 * IBSS to Infrastructure mode.
1928 */
1929 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1930
1931 session->limPrevSmeState = session->limSmeState;
1932 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1933 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1934 session->peSessionId,
1935 session->limSmeState));
1936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 /* Indicate whether spectrum management is enabled */
1938 session->spectrumMgtEnabled =
1939 sme_join_req->spectrumMgtIndicator;
1940
1941 /* Enable the spectrum management if this is a DFS channel */
1942 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001943 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 session->currentOperChannel))
1945 session->spectrumMgtEnabled = true;
1946
1947 session->isOSENConnection = sme_join_req->isOSENConnection;
1948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 /* Issue LIM_MLM_JOIN_REQ to MLM */
1950 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1951 (uint32_t *) mlm_join_req);
1952 return;
1953
1954 } else {
1955 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001956 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 mac_ctx->lim.gLimSmeState);
1958 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1959 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1960 session = NULL;
1961 goto end;
1962 }
1963
1964end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301965 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1966 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967
1968 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301969 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 sme_join_req = NULL;
1971 if (NULL != session)
1972 session->pLimJoinReq = NULL;
1973 }
1974 if (ret_code != eSIR_SME_SUCCESS) {
1975 if (NULL != session) {
1976 pe_delete_session(mac_ctx, session);
1977 session = NULL;
1978 }
1979 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001980 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 sme_session_id, ret_code);
1982 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1983 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1984 sme_transaction_id);
1985}
1986
Amar Singhala297bfa2015-10-15 15:07:29 -07001987uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 uint8_t iniTxPower)
1989{
1990 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301991 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
1992 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1994 maxTxPower = txPower;
1995 else if (txPower < MIN_TX_PWR_CAP)
1996 maxTxPower = MIN_TX_PWR_CAP;
1997 else
1998 maxTxPower = MAX_TX_PWR_CAP;
1999
2000 return maxTxPower;
2001}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002
2003/**
2004 * __lim_process_sme_reassoc_req() - process reassoc req
2005 *
2006 * @mac_ctx: Pointer to Global MAC structure
2007 * @msg_buf: pointer to the SME message buffer
2008 *
2009 * This function is called to process SME_REASSOC_REQ message
2010 * from HDD or upper layer application.
2011 *
2012 * Return: None
2013 */
2014
2015static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2016 uint32_t *msg_buf)
2017{
2018 uint16_t caps;
2019 uint32_t val;
2020 tpSirSmeJoinReq reassoc_req = NULL;
2021 tLimMlmReassocReq *mlm_reassoc_req;
2022 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2023 tpPESession session_entry = NULL;
2024 uint8_t session_id;
2025 uint8_t sme_session_id;
2026 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002027 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 uint32_t tele_bcn_en = 0;
2029 uint16_t size;
2030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302032 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002034 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035
2036 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2037 goto end;
2038 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302039 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040
2041 if (!lim_is_sme_join_req_valid(mac_ctx,
2042 (tpSirSmeJoinReq)reassoc_req)) {
2043 /*
2044 * Received invalid eWNI_SME_REASSOC_REQ
2045 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002046 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047
2048 ret_code = eSIR_SME_INVALID_PARAMETERS;
2049 goto end;
2050 }
2051
2052 session_entry = pe_find_session_by_bssid(mac_ctx,
2053 reassoc_req->bssDescription.bssId,
2054 &session_id);
2055 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002056 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002057 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2058 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002060 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2061 &sme_session_id, &transaction_id);
2062 session_entry =
2063 pe_find_session_by_sme_session_id(mac_ctx,
2064 sme_session_id);
2065 if (session_entry != NULL)
2066 lim_handle_sme_join_result(mac_ctx,
2067 eSIR_SME_INVALID_PARAMETERS,
2068 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2069 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 goto end;
2071 }
2072#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2073 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2074 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2075#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2076 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2077
2078 /* Store the reassoc handle in the session Table */
2079 session_entry->pLimReAssocReq = reassoc_req;
2080
2081 session_entry->dot11mode = reassoc_req->dot11mode;
2082 session_entry->vhtCapability =
2083 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002084
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302085 if (session_entry->vhtCapability) {
2086 if (session_entry->pePersona == QDF_STA_MODE) {
2087 session_entry->vht_config.su_beam_formee =
2088 reassoc_req->vht_config.su_beam_formee;
2089 } else {
2090 reassoc_req->vht_config.su_beam_formee = 0;
2091 }
2092 session_entry->enableVhtpAid =
2093 reassoc_req->enableVhtpAid;
2094 session_entry->enableVhtGid =
2095 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002096 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302097 }
2098
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002099 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302100 session_entry->vhtCapability,
2101 session_entry->vht_config.su_beam_formee,
2102 session_entry->vht_config.su_beam_former);
2103
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002104 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2105 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002106 session_entry->send_smps_action =
2107 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002108 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002109 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002110 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002111 session_entry->send_smps_action,
2112 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 /*
2114 * Reassociate request is expected
2115 * in link established state only.
2116 */
2117
2118 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2120 /*
2121 * May be from 11r FT pre-auth. So lets check it
2122 * before we bail out
2123 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002124 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 session_entry->peSessionId);
2126
2127 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302128 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 session_entry->limReAssocbssId,
2130 6)) {
2131 lim_print_mac_addr(mac_ctx,
2132 reassoc_req->bssDescription.
2133 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002134 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 ret_code = eSIR_SME_INVALID_PARAMETERS;
2136 goto end;
2137 }
2138
2139 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2140 session_entry);
2141 return;
2142 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 /*
2144 * Should not have received eWNI_SME_REASSOC_REQ
2145 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002146 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 session_entry->limSmeState);
2148 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2149
2150 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2151 goto end;
2152 }
2153
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302154 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 session_entry->pLimReAssocReq->bssDescription.bssId,
2156 sizeof(tSirMacAddr));
2157
2158 session_entry->limReassocChannelId =
2159 session_entry->pLimReAssocReq->bssDescription.channelId;
2160
2161 session_entry->reAssocHtSupportedChannelWidthSet =
2162 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2163 session_entry->reAssocHtRecommendedTxWidthSet =
2164 session_entry->reAssocHtSupportedChannelWidthSet;
2165 session_entry->reAssocHtSecondaryChannelOffset =
2166 session_entry->pLimReAssocReq->cbMode;
2167
2168 session_entry->limReassocBssCaps =
2169 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2170 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2171 session_entry->currentOperChannel);
2172 local_pwr_constraint = reg_max;
2173
2174 lim_extract_ap_capability(mac_ctx,
2175 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2176 lim_get_ielen_from_bss_description(
2177 &session_entry->pLimReAssocReq->bssDescription),
2178 &session_entry->limReassocBssQosCaps,
2179 &session_entry->limReassocBssPropCap,
2180 &session_entry->gLimCurrentBssUapsd,
2181 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302182 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002183 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302184 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 /* Copy the SSID from session entry to local variable */
2186 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 reassoc_req->ssId.ssId,
2189 session_entry->limReassocSSID.length);
2190 if (session_entry->gLimCurrentBssUapsd) {
2191 session_entry->gUapsdPerAcBitmask =
2192 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002193 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 session_entry->gUapsdPerAcBitmask);
2195 }
2196
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302197 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002199 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200
2201 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2202 goto end;
2203 }
2204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302205 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2207
2208 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2209 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002210 eSIR_SUCCESS)
2211 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212
2213 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002214 eSIR_SUCCESS)
2215 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302216
2217 lim_update_caps_info_for_bss(mac_ctx, &caps,
2218 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002219 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 mlm_reassoc_req->capabilityInfo = caps;
2222
2223 /* Update PE session_id */
2224 mlm_reassoc_req->sessionId = session_id;
2225
2226 /*
2227 * If telescopic beaconing is enabled, set listen interval to
2228 * WNI_CFG_TELE_BCN_MAX_LI
2229 */
2230 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2231 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002232 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233
2234 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2235
2236 if (tele_bcn_en) {
2237 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2238 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002239 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 } else {
2241 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2242 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002243 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 }
2245
2246 mlm_reassoc_req->listenInterval = (uint16_t) val;
2247
2248 /* Indicate whether spectrum management is enabled */
2249 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2250
2251 /* Enable the spectrum management if this is a DFS channel */
2252 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002253 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 session_entry->currentOperChannel))
2255 session_entry->spectrumMgtEnabled = true;
2256
2257 session_entry->limPrevSmeState = session_entry->limSmeState;
2258 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2259
2260 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2261 session_entry->peSessionId,
2262 session_entry->limSmeState));
2263
2264 lim_post_mlm_message(mac_ctx,
2265 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2266 return;
2267end:
2268 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302269 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 if (session_entry)
2271 session_entry->pLimReAssocReq = NULL;
2272 }
2273
2274 if (session_entry) {
2275 /*
2276 * error occurred after we determined the session so extract
2277 * session and transaction info from there
2278 */
2279 sme_session_id = session_entry->smeSessionId;
2280 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002281 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 /*
2283 * error occurred before or during the time we determined
2284 * the session so extract the session and transaction info
2285 * from the message
2286 */
2287 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2288 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002289 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 /*
2291 * Send Reassoc failure response to host
2292 * (note session_entry may be NULL, but that's OK)
2293 */
2294 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2295 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2296 session_entry, sme_session_id,
2297 transaction_id);
2298}
2299
2300bool send_disassoc_frame = 1;
2301/**
2302 * __lim_process_sme_disassoc_req()
2303 *
2304 ***FUNCTION:
2305 * This function is called to process SME_DISASSOC_REQ message
2306 * from HDD or upper layer application.
2307 *
2308 ***LOGIC:
2309 *
2310 ***ASSUMPTIONS:
2311 *
2312 ***NOTE:
2313 *
2314 * @param pMac Pointer to Global MAC structure
2315 * @param *pMsgBuf A pointer to the SME message buffer
2316 * @return None
2317 */
2318
2319static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2320{
2321 uint16_t disassocTrigger, reasonCode;
2322 tLimMlmDisassocReq *pMlmDisassocReq;
2323 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2324 tSirSmeDisassocReq smeDisassocReq;
2325 tpPESession psessionEntry = NULL;
2326 uint8_t sessionId;
2327 uint8_t smesessionId;
2328 uint16_t smetransactionId;
2329
2330 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002331 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 return;
2333 }
2334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302335 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 smesessionId = smeDisassocReq.sessionId;
2337 smetransactionId = smeDisassocReq.transactionId;
2338 if (!lim_is_sme_disassoc_req_valid(pMac,
2339 &smeDisassocReq,
2340 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002341 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 if (pMac->lim.gLimRspReqd) {
2343 pMac->lim.gLimRspReqd = false;
2344
2345 retCode = eSIR_SME_INVALID_PARAMETERS;
2346 disassocTrigger = eLIM_HOST_DISASSOC;
2347 goto sendDisassoc;
2348 }
2349
2350 return;
2351 }
2352
2353 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002354 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 &sessionId);
2356 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002357 pe_err("session does not exist for given bssId "
2358 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002359 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 retCode = eSIR_SME_INVALID_PARAMETERS;
2361 disassocTrigger = eLIM_HOST_DISASSOC;
2362 goto sendDisassoc;
2363 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002364 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2365 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2367 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002368 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369
2370#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2371 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2372 0, smeDisassocReq.reasonCode);
2373#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2374
2375 /* Update SME session Id and SME transaction ID */
2376
2377 psessionEntry->smeSessionId = smesessionId;
2378 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002379 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002380 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381
2382 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2383 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 switch (psessionEntry->limSmeState) {
2385 case eLIM_SME_ASSOCIATED_STATE:
2386 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002387 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002388 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 psessionEntry->limPrevSmeState =
2390 psessionEntry->limSmeState;
2391 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 /* Delete all TDLS peers connected before leaving BSS */
2393 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002394 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2395 psessionEntry->peSessionId,
2396 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 break;
2398
2399 case eLIM_SME_WT_DEAUTH_STATE:
2400 /* PE shall still process the DISASSOC_REQ and proceed with
2401 * link tear down even if it had already sent a DEAUTH_IND to
2402 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2403 * its been set when PE entered WT_DEAUTH_STATE.
2404 */
2405 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2406 MTRACE(mac_trace
2407 (pMac, TRACE_CODE_SME_STATE,
2408 psessionEntry->peSessionId,
2409 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002410 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 break;
2412
2413 case eLIM_SME_WT_DISASSOC_STATE:
2414 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2415 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2416 * PE can continue processing DISASSOC_REQ and send the response instead
2417 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2418 * for disassoc frame.
2419 *
2420 * It will send a disassoc, which is ok. However, we can use the global flag
2421 * sendDisassoc to not send disassoc frame.
2422 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002423 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 break;
2425
2426 case eLIM_SME_JOIN_FAILURE_STATE: {
2427 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002428 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 if (pMac->lim.gLimRspReqd) {
2430 retCode = eSIR_SME_SUCCESS;
2431 disassocTrigger = eLIM_HOST_DISASSOC;
2432 goto sendDisassoc;
2433 }
2434 }
2435 break;
2436 default:
2437 /**
2438 * STA is not currently associated.
2439 * Log error and send response to host
2440 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002441 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 psessionEntry->limSmeState);
2443 lim_print_sme_state(pMac, LOGE,
2444 psessionEntry->limSmeState);
2445
2446 if (pMac->lim.gLimRspReqd) {
2447 if (psessionEntry->limSmeState !=
2448 eLIM_SME_WT_ASSOC_STATE)
2449 pMac->lim.gLimRspReqd = false;
2450
2451 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2452 disassocTrigger = eLIM_HOST_DISASSOC;
2453 goto sendDisassoc;
2454 }
2455
2456 return;
2457 }
2458
2459 break;
2460
2461 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 /* Fall through */
2463 break;
2464
2465 case eLIM_STA_IN_IBSS_ROLE:
2466 default:
2467 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002468 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 GET_LIM_SYSTEM_ROLE(psessionEntry));
2470
2471 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2472 disassocTrigger = eLIM_HOST_DISASSOC;
2473 goto sendDisassoc;
2474 } /* end switch (pMac->lim.gLimSystemRole) */
2475
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302476 disassocTrigger = eLIM_HOST_DISASSOC;
2477 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478
2479 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002480 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 send_disassoc_frame = 0;
2482 }
2483 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002484 pe_debug("Sending Disasscoc with disassoc Trigger"
2485 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 disassocTrigger, reasonCode);
2487
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302488 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002490 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 return;
2492 }
2493
Anurag Chouhanc5548422016-02-24 18:33:27 +05302494 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002495 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496
2497 pMlmDisassocReq->reasonCode = reasonCode;
2498 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2499
2500 /* Update PE session ID */
2501 pMlmDisassocReq->sessionId = sessionId;
2502
2503 lim_post_mlm_message(pMac,
2504 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2505 return;
2506
2507sendDisassoc:
2508 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002509 lim_send_sme_disassoc_ntf(pMac,
2510 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 retCode,
2512 disassocTrigger,
2513 1, smesessionId, smetransactionId,
2514 psessionEntry);
2515 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002516 lim_send_sme_disassoc_ntf(pMac,
2517 smeDisassocReq.peer_macaddr.bytes,
2518 retCode, disassocTrigger, 1,
2519 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520
2521} /*** end __lim_process_sme_disassoc_req() ***/
2522
2523/** -----------------------------------------------------------------
2524 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2525
2526 This function is called to process SME_DISASSOC_CNF message
2527 from HDD or upper layer application.
2528
2529 \param pMac - global mac structure
2530 \param pStaDs - station dph hash node
2531 \return none
2532 \sa
2533 ----------------------------------------------------------------- */
2534static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2535{
2536 tSirSmeDisassocCnf smeDisassocCnf;
2537 uint16_t aid;
2538 tpDphHashNode pStaDs;
2539 tpPESession psessionEntry;
2540 uint8_t sessionId;
2541
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302542 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 sizeof(struct sSirSmeDisassocCnf));
2544
2545 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002546 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 &sessionId);
2548 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002549 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 return;
2551 }
2552
2553 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002554 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 return;
2556 }
2557#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2558 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2559 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2560 psessionEntry,
2561 (uint16_t) smeDisassocCnf.statusCode, 0);
2562 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2563 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2564 psessionEntry,
2565 (uint16_t) smeDisassocCnf.statusCode, 0);
2566#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2567
2568 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2569 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2571 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2572 && (psessionEntry->limSmeState !=
2573 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002574 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 psessionEntry->limSmeState);
2576 lim_print_sme_state(pMac, LOGE,
2577 psessionEntry->limSmeState);
2578 return;
2579 }
2580 break;
2581
2582 case eLIM_AP_ROLE:
2583 /* Fall through */
2584 break;
2585
2586 case eLIM_STA_IN_IBSS_ROLE:
2587 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002588 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 GET_LIM_SYSTEM_ROLE(psessionEntry));
2590
2591 return;
2592 }
2593
2594 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2595 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2596 LIM_IS_AP_ROLE(psessionEntry)) {
2597 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002598 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 &psessionEntry->dph.dphHashTable);
2600 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002601 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2602 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002603 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 return;
2605 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302606
2607 if ((pStaDs->mlmStaContext.mlmState ==
2608 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2609 (pStaDs->mlmStaContext.mlmState ==
2610 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002611 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002612 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302613 pStaDs->mlmStaContext.mlmState);
2614 return;
2615 }
2616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 /* Delete FT session if there exists one */
2618 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2620
2621 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002622 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 }
2624
2625 return;
2626}
2627
2628/**
2629 * __lim_process_sme_deauth_req() - process sme deauth req
2630 * @mac_ctx: Pointer to Global MAC structure
2631 * @msg_buf: pointer to the SME message buffer
2632 *
2633 * This function is called to process SME_DEAUTH_REQ message
2634 * from HDD or upper layer application.
2635 *
2636 * Return: None
2637 */
2638
2639static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2640 uint32_t *msg_buf)
2641{
2642 uint16_t deauth_trigger, reason_code;
2643 tLimMlmDeauthReq *mlm_deauth_req;
2644 tSirSmeDeauthReq sme_deauth_req;
2645 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2646 tpPESession session_entry;
2647 uint8_t session_id; /* PE sessionId */
2648 uint8_t sme_session_id;
2649 uint16_t sme_transaction_id;
2650
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302651 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 sme_session_id = sme_deauth_req.sessionId;
2653 sme_transaction_id = sme_deauth_req.transactionId;
2654
2655 /*
2656 * We need to get a session first but we don't even know
2657 * if the message is correct.
2658 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002659 session_entry = pe_find_session_by_bssid(mac_ctx,
2660 sme_deauth_req.bssid.bytes,
2661 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002663 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 ret_code = eSIR_SME_INVALID_PARAMETERS;
2665 deauth_trigger = eLIM_HOST_DEAUTH;
2666 goto send_deauth;
2667 }
2668
2669 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2670 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002671 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 mac_ctx->lim.gLimRspReqd = false;
2673
2674 ret_code = eSIR_SME_INVALID_PARAMETERS;
2675 deauth_trigger = eLIM_HOST_DEAUTH;
2676 goto send_deauth;
2677 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002678 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2679 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2681 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002682 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2684 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2685 session_entry, 0, sme_deauth_req.reasonCode);
2686#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2687
2688 /* Update SME session ID and Transaction ID */
2689 session_entry->smeSessionId = sme_session_id;
2690 session_entry->transactionId = sme_transaction_id;
2691
2692 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2693 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 switch (session_entry->limSmeState) {
2695 case eLIM_SME_ASSOCIATED_STATE:
2696 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302697 /* Delete all TDLS peers connected before leaving BSS */
2698 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 case eLIM_SME_WT_ASSOC_STATE:
2700 case eLIM_SME_JOIN_FAILURE_STATE:
2701 case eLIM_SME_IDLE_STATE:
2702 session_entry->limPrevSmeState =
2703 session_entry->limSmeState;
2704 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2705 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2706 session_entry->peSessionId,
2707 session_entry->limSmeState));
2708 /* Send Deauthentication request to MLM below */
2709 break;
2710 case eLIM_SME_WT_DEAUTH_STATE:
2711 case eLIM_SME_WT_DISASSOC_STATE:
2712 /*
2713 * PE Recieved a Deauth/Disassoc frame. Normally it get
2714 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2715 * Which means host is also trying to disconnect.
2716 * PE can continue processing DEAUTH_REQ and send
2717 * the response instead of failing the request.
2718 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2719 * was sent for deauth/disassoc frame.
2720 */
2721 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002722 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 break;
2724 default:
2725 /*
2726 * STA is not in a state to deauthenticate with
2727 * peer. Log error and send response to host.
2728 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002729 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 session_entry->limSmeState);
2731 lim_print_sme_state(mac_ctx, LOGE,
2732 session_entry->limSmeState);
2733
2734 if (mac_ctx->lim.gLimRspReqd) {
2735 mac_ctx->lim.gLimRspReqd = false;
2736
2737 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2738 deauth_trigger = eLIM_HOST_DEAUTH;
2739
wadesong42968e92017-06-08 14:11:21 +08002740 /*
2741 * here we received deauth request from AP so
2742 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2743 * have ISSUED delSta then mlm state should be
2744 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2745 * delBSS rsp then mlm state should be
2746 * eLIM_MLM_IDLE_STATE so the below condition
2747 * captures the state where delSta not done
2748 * and firmware still in connected state.
2749 */
2750 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 eLIM_SME_WT_DEAUTH_STATE &&
2752 session_entry->limMlmState !=
2753 eLIM_MLM_IDLE_STATE &&
2754 session_entry->limMlmState !=
2755 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002756 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 goto send_deauth;
2758 }
2759 return;
2760 }
2761 break;
2762
2763 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002764 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 if (mac_ctx->lim.gLimRspReqd) {
2766 mac_ctx->lim.gLimRspReqd = false;
2767 ret_code = eSIR_SME_INVALID_PARAMETERS;
2768 deauth_trigger = eLIM_HOST_DEAUTH;
2769 goto send_deauth;
2770 }
2771 return;
2772 case eLIM_AP_ROLE:
2773 break;
2774 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002775 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 GET_LIM_SYSTEM_ROLE(session_entry));
2777 if (mac_ctx->lim.gLimRspReqd) {
2778 mac_ctx->lim.gLimRspReqd = false;
2779 ret_code = eSIR_SME_INVALID_PARAMETERS;
2780 deauth_trigger = eLIM_HOST_DEAUTH;
2781 goto send_deauth;
2782 }
2783 return;
2784 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2785
2786 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2787 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002788 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2790 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2791 } else {
2792 deauth_trigger = eLIM_HOST_DEAUTH;
2793 reason_code = sme_deauth_req.reasonCode;
2794 }
2795
2796 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302797 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002799 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 if (mac_ctx->lim.gLimRspReqd) {
2801 mac_ctx->lim.gLimRspReqd = false;
2802 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2803 deauth_trigger = eLIM_HOST_DEAUTH;
2804 goto send_deauth;
2805 }
2806 return;
2807 }
2808
Anurag Chouhanc5548422016-02-24 18:33:27 +05302809 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002810 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811
2812 mlm_deauth_req->reasonCode = reason_code;
2813 mlm_deauth_req->deauthTrigger = deauth_trigger;
2814
2815 /* Update PE session Id */
2816 mlm_deauth_req->sessionId = session_id;
2817
2818 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2819 (uint32_t *)mlm_deauth_req);
2820 return;
2821
2822send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002823 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2824 ret_code, deauth_trigger, 1,
2825 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826}
2827
2828/**
2829 * __lim_process_sme_set_context_req()
2830 *
2831 * @mac_ctx: Pointer to Global MAC structure
2832 * @msg_buf: pointer to the SME message buffer
2833 *
2834 * This function is called to process SME_SETCONTEXT_REQ message
2835 * from HDD or upper layer application.
2836 *
2837 * Return: None
2838 */
2839
2840static void
2841__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2842{
2843 tpSirSmeSetContextReq set_context_req;
2844 tLimMlmSetKeysReq *mlm_set_key_req;
2845 tpPESession session_entry;
2846 uint8_t session_id; /* PE sessionID */
2847 uint8_t sme_session_id;
2848 uint16_t sme_transaction_id;
2849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002851 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 return;
2853 }
2854
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302855 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002857 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 return;
2859 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302860 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 sizeof(struct sSirSmeSetContextReq));
2862 sme_session_id = set_context_req->sessionId;
2863 sme_transaction_id = set_context_req->transactionId;
2864
2865 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002866 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 goto end;
2868 }
2869
2870 if (set_context_req->keyMaterial.numKeys >
2871 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002872 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 set_context_req->keyMaterial.numKeys);
2874 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002875 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 eSIR_SME_INVALID_PARAMETERS, NULL,
2877 sme_session_id, sme_transaction_id);
2878 goto end;
2879 }
2880
2881 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002882 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002884 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002886 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 eSIR_SME_INVALID_PARAMETERS, NULL,
2888 sme_session_id, sme_transaction_id);
2889 goto end;
2890 }
2891#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2892 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2893 session_entry, 0, 0);
2894#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2895
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002896 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2898 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002899 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2901 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302902 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002904 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 goto end;
2906 }
2907 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2908 mlm_set_key_req->numKeys =
2909 set_context_req->keyMaterial.numKeys;
2910 if (mlm_set_key_req->numKeys >
2911 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002912 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 goto end;
2914 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302915 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002916 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302918 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 (uint8_t *) &set_context_req->keyMaterial.key,
2920 sizeof(tSirKeys) *
2921 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2922 numKeys : 1));
2923
2924 mlm_set_key_req->sessionId = session_id;
2925 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002926 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928
2929 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2930 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2931 LIM_IS_AP_ROLE(session_entry)) {
2932 if (set_context_req->keyMaterial.key[0].keyLength) {
2933 uint8_t key_id;
2934 key_id =
2935 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302936 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 &session_entry->WEPKeyMaterial[key_id],
2938 (uint8_t *) &set_context_req->keyMaterial,
2939 sizeof(tSirKeyMaterial));
2940 } else {
2941 uint32_t i;
2942 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2943 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302944 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 &mlm_set_key_req->key[i],
2946 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2947 sizeof(tSirKeys));
2948 }
2949 }
2950 }
2951 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2952 (uint32_t *) mlm_set_key_req);
2953 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002954 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 GET_LIM_SYSTEM_ROLE(session_entry),
2956 session_entry->limSmeState);
2957 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2958
2959 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002960 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2962 session_entry, sme_session_id,
2963 sme_transaction_id);
2964 }
2965end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302966 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 return;
2968}
2969
2970/**
2971 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2972 *
2973 * @mac_ctx: Pointer to Global MAC structure
2974 * @msg_buf: pointer to the SME message buffer
2975 *
2976 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2977 * from HDD or upper layer application.
2978 *
2979 * Return: None
2980 */
2981
Jeff Johnson801f1532016-10-07 07:54:50 -07002982static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2983 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984{
2985 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2986 tpDphHashNode sta_ds = NULL;
2987 tpPESession session_entry = NULL;
2988 tSap_Event sap_event;
2989 tpWLAN_SAPEventCB sap_event_cb = NULL;
2990 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2991 uint8_t session_id = CSR_SESSION_ID_INVALID;
2992 uint8_t assoc_id = 0;
2993 uint8_t sta_cnt = 0;
2994
2995 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002996 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 return;
2998 }
2999
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303000 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 sizeof(struct sSirSmeGetAssocSTAsReq));
3002 /*
3003 * Get Associated stations from PE.
3004 * Find PE session Entry
3005 */
3006 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003007 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 &session_id);
3009 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003010 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 goto lim_assoc_sta_end;
3012 }
3013
3014 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003015 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 session_entry->limSmeState,
3017 GET_LIM_SYSTEM_ROLE(session_entry));
3018 goto lim_assoc_sta_end;
3019 }
3020 /* Retrieve values obtained in the request message */
3021 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3022 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3023
3024 if (NULL == assoc_sta_tmp)
3025 goto lim_assoc_sta_end;
3026 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3027 assoc_id++) {
3028 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3029 &session_entry->dph.dphHashTable);
3030 if (NULL == sta_ds)
3031 continue;
3032 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303033 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303035 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3037 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3038
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303039 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 (uint8_t *)&sta_ds->supportedRates,
3041 sizeof(tSirSupportedRates));
3042 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3043 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3044 assoc_sta_tmp->Support40Mhz =
3045 sta_ds->htDsssCckRate40MHzSupport;
3046
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003047 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003049 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003051 pe_debug("Association Id: %d Station Index: %d",
3052 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 assoc_sta_tmp++;
3054 sta_cnt++;
3055 }
3056 }
3057lim_assoc_sta_end:
3058 /*
3059 * Call hdd callback with sap event to send the list of
3060 * associated stations from PE
3061 */
3062 if (sap_event_cb != NULL) {
3063 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3064 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303065 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3067 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3068 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3069 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3070 }
3071}
3072
3073/**
3074 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3075 *
3076 * @mac_ctx: Pointer to Global MAC structure
3077 * @msg_buf: pointer to WPS PBC overlap query message
3078 *
3079 * This function parses get WPS PBC overlap information
3080 * message and call callback to pass WPS PBC overlap
3081 * information back to hdd.
3082 *
3083 * Return: None
3084 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003085static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3086 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087{
3088 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3089 tpPESession session_entry = NULL;
3090 tSap_Event sap_event;
3091 tpWLAN_SAPEventCB sap_event_cb = NULL;
3092 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3094
3095 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003096 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 return;
3098 }
3099
3100 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303101 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303103 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3105 /*
3106 * Get Associated stations from PE
3107 * Find PE session Entry
3108 */
3109 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003110 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003112 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 goto lim_get_wpspbc_sessions_end;
3114 }
3115
3116 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003117 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 GET_LIM_SYSTEM_ROLE(session_entry));
3119 goto lim_get_wpspbc_sessions_end;
3120 }
3121 /*
3122 * Call hdd callback with sap event to send the
3123 * WPS PBC overlap information
3124 */
3125 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303126 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127
Anurag Chouhanc5548422016-02-24 18:33:27 +05303128 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003130 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 sap_get_wpspbc_event->UUID_E,
3132 &sap_get_wpspbc_event->wpsPBCOverlap,
3133 session_entry);
3134 } else {
3135 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003136 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137 session_entry);
3138 /* don't have to inform the HDD/Host */
3139 return;
3140 }
3141
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003142 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 lim_print_mac_addr(mac_ctx,
3144 sap_get_wpspbc_event->addr.bytes, LOG4);
3145
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303146 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147
3148lim_get_wpspbc_sessions_end:
3149 sap_event_cb =
3150 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3151 if (NULL != sap_event_cb)
3152 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3153}
3154
3155/**
3156 * __lim_counter_measures()
3157 *
3158 * FUNCTION:
3159 * This function is called to "implement" MIC counter measure
3160 * and is *temporary* only
3161 *
3162 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3163 * we don't do the proper STA disassoc sequence since the
3164 * BSS will be stoped anyway
3165 *
3166 ***ASSUMPTIONS:
3167 *
3168 ***NOTE:
3169 *
3170 * @param pMac Pointer to Global MAC structure
3171 * @return None
3172 */
3173
3174static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3175{
3176 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003177 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3179 mac, psessionEntry, false);
3180};
3181
Jeff Johnson801f1532016-10-07 07:54:50 -07003182static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3183 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184{
3185 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3186 tpPESession psessionEntry;
3187 uint8_t sessionId; /* PE sessionId */
3188
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303189 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 sizeof(struct sSirSmeTkipCntrMeasReq));
3191
3192 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003193 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 if (NULL == psessionEntry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003195 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 return;
3197 }
3198
3199 if (tkipCntrMeasReq.bEnable)
3200 __lim_counter_measures(pMac, psessionEntry);
3201
3202 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3203}
3204
3205static void
3206__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3207{
3208 tSirSmeStopBssReq stopBssReq;
3209 tSirRetStatus status;
3210 tLimSmeStates prevState;
3211 tpPESession psessionEntry;
3212 uint8_t smesessionId;
3213 uint8_t sessionId;
3214 uint16_t smetransactionId;
3215 uint8_t i = 0;
3216 tpDphHashNode pStaDs = NULL;
3217
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303218 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 smesessionId = stopBssReq.sessionId;
3220 smetransactionId = stopBssReq.transactionId;
3221
3222 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003223 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 /* Send Stop BSS response to host */
3225 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3226 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3227 smetransactionId);
3228 return;
3229 }
3230
3231 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003232 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 &sessionId);
3234 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003235 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3237 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3238 smetransactionId);
3239 return;
3240 }
3241#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3242 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3243 0, 0);
3244#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3245
3246 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3247 LIM_IS_STA_ROLE(psessionEntry)) {
3248 /**
3249 * Should not have received STOP_BSS_REQ in states
3250 * other than 'normal' state or on STA in Infrastructure
3251 * mode. Log error and return response to host.
3252 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003253 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 psessionEntry->limSmeState,
3255 GET_LIM_SYSTEM_ROLE(psessionEntry));
3256 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3257 /* / Send Stop BSS response to host */
3258 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3259 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3260 smetransactionId);
3261 return;
3262 }
3263
3264 if (LIM_IS_AP_ROLE(psessionEntry))
3265 lim_wpspbc_close(pMac, psessionEntry);
3266
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003267 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 stopBssReq.reasonCode);
3269
3270 prevState = psessionEntry->limSmeState;
3271
3272 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3273 MTRACE(mac_trace
3274 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3275 psessionEntry->limSmeState));
3276
3277 /* Update SME session Id and Transaction Id */
3278 psessionEntry->smeSessionId = smesessionId;
3279 psessionEntry->transactionId = smetransactionId;
3280
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003281 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3282 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3283 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3285 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3286 /* Send disassoc all stations associated thru TKIP */
3287 __lim_counter_measures(pMac, psessionEntry);
3288 else
3289 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003290 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3291 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 }
3293
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003294 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3295 /* Free the buffer allocated in START_BSS_REQ */
3296 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3297 psessionEntry->addIeParams.probeRespDataLen = 0;
3298 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003300 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3301 psessionEntry->addIeParams.assocRespDataLen = 0;
3302 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003304 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3305 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3306 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003308 /*
3309 * lim_del_bss is also called as part of coalescing,
3310 * when we send DEL BSS followed by Add Bss msg.
3311 */
3312 pMac->lim.gLimIbssCoalescingHappened = false;
3313 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3315 pStaDs =
3316 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3317 if (NULL == pStaDs)
3318 continue;
3319 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3320 if (eSIR_SUCCESS == status) {
3321 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3322 pStaDs->assocId, psessionEntry);
3323 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3324 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003325 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303326 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 }
3328 }
3329 /* send a delBss to HAL and wait for a response */
3330 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3331
3332 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003333 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 psessionEntry->limSmeState = prevState;
3335
3336 MTRACE(mac_trace
3337 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3338 psessionEntry->limSmeState));
3339
3340 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3341 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3342 smetransactionId);
3343 }
3344}
3345
3346/**
3347 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3348 * @pMac: Global MAC context
3349 * @pMsg: Message from SME
3350 *
3351 * Wrapper for the function __lim_handle_sme_stop_bss_request
3352 * This message will be defered until softmac come out of
3353 * scan mode. Message should be handled even if we have
3354 * detected radar in the current operating channel.
3355 *
3356 * Return: true - If we consumed the buffer
3357 * false - If have defered the message.
3358 */
3359
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003360static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3361 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362{
3363 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3364 /**
3365 * If message defered, buffer is not consumed yet.
3366 * So return false
3367 */
3368 return false;
3369 }
3370 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3371 return true;
3372} /*** end __lim_process_sme_stop_bss_req() ***/
3373
3374void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3375 uint32_t body, tpPESession psessionEntry)
3376{
3377
3378 (void)body;
3379 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3380 lim_ibss_delete(pMac, psessionEntry);
3381 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3382 lim_delete_pre_auth_list(pMac);
3383 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3384 psessionEntry->smeSessionId,
3385 psessionEntry->transactionId);
3386 return;
3387}
3388
3389/**
3390 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3391 *
3392 * @mac_ctx: pointer to mac context
3393 * @msg_type: message type
3394 * @msg_buf: pointer to the SME message buffer
3395 *
3396 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3397 * in BTAMP AP.
3398 *
3399 * Return: None
3400 */
3401
3402void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3403 uint32_t *msg_buf)
3404{
3405 tSirSmeAssocCnf assoc_cnf;
3406 tpDphHashNode sta_ds = NULL;
3407 tpPESession session_entry = NULL;
3408 uint8_t session_id;
3409 tpSirAssocReq assoc_req;
3410
3411 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003412 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 goto end;
3414 }
3415
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303416 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003418 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 goto end;
3420 }
3421
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003422 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 &session_id);
3424 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003425 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 goto end;
3427 }
3428
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003429 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3431 (session_entry->limSmeState !=
3432 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 msg_type, session_entry->limSmeState,
3435 GET_LIM_SYSTEM_ROLE(session_entry));
3436 goto end;
3437 }
3438 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3439 &session_entry->dph.dphHashTable);
3440 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003441 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003443 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444
3445 /*
3446 * send a DISASSOC_IND message to WSM to make sure
3447 * the state in WSM and LIM is the same
3448 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003449 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 eSIR_SME_STA_NOT_ASSOCIATED,
3451 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3452 session_entry->smeSessionId,
3453 session_entry->transactionId,
3454 session_entry);
3455 goto end;
3456 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303457 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003458 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303459 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003460 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003462 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 goto end;
3464 }
3465
3466 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3467 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3468 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3469 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3470 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003471 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3472 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003474 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 goto end;
3476 }
3477 /*
3478 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3479 * has been received
3480 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003481 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3483 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3484
3485 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3486 /*
3487 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3488 * when it had received Assoc Request frame. Now, PE just needs
3489 * to send association rsp frame to the requesting BTAMP-STA.
3490 */
3491 sta_ds->mlmStaContext.mlmState =
3492 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003493 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 sta_ds->assocId);
3495 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3496 sta_ds->assocId, sta_ds->staAddr,
3497 sta_ds->mlmStaContext.subType, sta_ds,
3498 session_entry);
3499 goto end;
3500 } else {
3501 /*
3502 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3503 * to be associated since the HAL sta entry is created for
3504 * denied STA we need to remove this HAL entry.
3505 * So to do that set updateContext to 1
3506 */
3507 if (!sta_ds->mlmStaContext.updateContext)
3508 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003509 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 assoc_cnf.statusCode, sta_ds->assocId);
3511 lim_reject_association(mac_ctx, sta_ds->staAddr,
3512 sta_ds->mlmStaContext.subType,
3513 true, sta_ds->mlmStaContext.authType,
3514 sta_ds->assocId, true,
Varun Reddy Yeturu8c68b472017-06-15 16:05:38 -07003515 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 session_entry);
3517 }
3518end:
3519 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3520 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3521 assoc_req = (tpSirAssocReq)
3522 session_entry->parsedAssocReq[sta_ds->assocId];
3523 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303524 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 assoc_req->assocReqFrame = NULL;
3526 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303527 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3529 }
3530}
3531
3532static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3533{
3534 tpDphHashNode pStaDs;
3535 tSirMacAddr peerMac;
3536 tpSirAddtsReq pSirAddts;
3537 uint32_t timeout;
3538 tpPESession psessionEntry;
3539 uint8_t sessionId; /* PE sessionId */
3540 uint8_t smesessionId;
3541 uint16_t smetransactionId;
3542
3543 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003544 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 return;
3546 }
3547
3548 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3549 &smetransactionId);
3550
3551 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3552
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003553 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3554 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003556 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303557 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3558 NULL, pSirAddts->req.tspec,
3559 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 return;
3561 }
3562#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3563 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3564 0);
3565#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3566
3567 /* if sta
3568 * - verify assoc state
3569 * - send addts request to ap
3570 * - wait for addts response from ap
3571 * if ap, just ignore with error log
3572 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003573 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3574 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3575 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003577 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003578 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303579 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581
3582 pStaDs =
3583 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3584 &psessionEntry->dph.dphHashTable);
3585
3586 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003587 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303588 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 }
3590
3591 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3592 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003593 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303594 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 }
3596
3597 pSirAddts->req.wsmTspecPresent = 0;
3598 pSirAddts->req.wmeTspecPresent = 0;
3599 pSirAddts->req.lleTspecPresent = 0;
3600
3601 if ((pStaDs->wsmEnabled) &&
3602 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3603 SIR_MAC_ACCESSPOLICY_EDCA))
3604 pSirAddts->req.wsmTspecPresent = 1;
3605 else if (pStaDs->wmeEnabled)
3606 pSirAddts->req.wmeTspecPresent = 1;
3607 else if (pStaDs->lleEnabled)
3608 pSirAddts->req.lleTspecPresent = 1;
3609 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003610 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303611 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 }
3613
3614 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3615 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003616 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303618 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 }
3620
3621 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003622 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 pMac->lim.gLimAddtsReq.req.dialogToken,
3624 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3625 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3626 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303627 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629
3630 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3631
3632 /* save the addts request */
3633 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303634 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3636
3637 /* ship out the message now */
3638 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3639 psessionEntry);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003640 pe_debug("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 /* start a timer to wait for the response */
3642 if (pSirAddts->timeout)
3643 timeout = pSirAddts->timeout;
3644 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3645 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003646 pe_err("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303648 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 }
3650
3651 timeout = SYS_MS_TO_TICKS(timeout);
3652 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3653 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003654 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303655 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 }
3657 pMac->lim.gLimAddtsRspTimerCount++;
3658 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3659 pMac->lim.gLimAddtsRspTimerCount) !=
3660 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003661 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303662 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 }
3664 MTRACE(mac_trace
3665 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3666 eLIM_ADDTS_RSP_TIMER));
3667
3668 /* add the sessionId to the timer object */
3669 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3670 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3671 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003672 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303673 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674 }
3675 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303676
3677send_failure_addts_rsp:
3678 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3679 psessionEntry, pSirAddts->req.tspec,
3680 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681}
3682
3683static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3684{
3685 tSirMacAddr peerMacAddr;
3686 uint8_t ac;
3687 tSirMacTSInfo *pTsinfo;
3688 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3689 tpDphHashNode pStaDs = NULL;
3690 tpPESession psessionEntry;
3691 uint8_t sessionId;
3692 uint32_t status = eSIR_SUCCESS;
3693 uint8_t smesessionId;
3694 uint16_t smetransactionId;
3695
3696 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3697 &smetransactionId);
3698
3699 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003700 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 &sessionId);
3702 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003703 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704 status = eSIR_FAILURE;
3705 goto end;
3706 }
3707#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3708 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3709 0);
3710#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3711
3712 if (eSIR_SUCCESS !=
3713 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003714 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 status = eSIR_FAILURE;
3716 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3717 smesessionId, smetransactionId);
3718 return;
3719 }
3720
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003721 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3722 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3724
3725 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3726 pDeltsReq->req.wmeTspecPresent,
3727 &pDeltsReq->req.tsinfo,
3728 &pDeltsReq->req.tspec, psessionEntry);
3729
3730 pTsinfo =
3731 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3732 tsinfo : &pDeltsReq->req.tsinfo;
3733
3734 /* We've successfully send DELTS frame to AP. Update the
3735 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3736 * is no longer trigger enabled or delivery enabled
3737 */
3738 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3739 pTsinfo, CLEAR_UAPSD_MASK);
3740
3741 /* We're deleting the TSPEC, so this particular AC is no longer
3742 * admitted. PE needs to downgrade the EDCA
3743 * parameters(for the AC for which TS is being deleted) to the
3744 * next best AC for which ACM is not enabled, and send the
3745 * updated values to HAL.
3746 */
3747 ac = upToAc(pTsinfo->traffic.userPrio);
3748
3749 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3750 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3751 ~(1 << ac);
3752 } else if (pTsinfo->traffic.direction ==
3753 SIR_MAC_DIRECTION_DNLINK) {
3754 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3755 ~(1 << ac);
3756 } else if (pTsinfo->traffic.direction ==
3757 SIR_MAC_DIRECTION_BIDIR) {
3758 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3759 ~(1 << ac);
3760 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3761 ~(1 << ac);
3762 }
3763
3764 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3765 psessionEntry);
3766
3767 pStaDs =
3768 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3769 &psessionEntry->dph.dphHashTable);
3770 if (pStaDs != NULL) {
3771 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3772 pStaDs->bssId);
3773 status = eSIR_SUCCESS;
3774 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003775 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776 status = eSIR_FAILURE;
3777 }
3778#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780#endif
3781
3782 /* send an sme response back */
3783end:
3784 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3785 smesessionId, smetransactionId);
3786}
3787
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303788void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789{
3790 /* fetch the sessionEntry based on the sessionId */
3791 tpPESession psessionEntry;
3792 psessionEntry = pe_find_session_by_session_id(pMac,
3793 pMac->lim.limTimers.gLimAddtsRspTimer.
3794 sessionId);
3795 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003796 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 return;
3798 }
3799
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003800 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003801 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802 GET_LIM_SYSTEM_ROLE(psessionEntry));
3803 pMac->lim.gLimAddtsSent = false;
3804 return;
3805 }
3806
3807 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003808 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 return;
3810 }
3811
3812 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003813 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 pMac->lim.gLimAddtsRspTimerCount);
3815 return;
3816 }
3817 /* this a real response timeout */
3818 pMac->lim.gLimAddtsSent = false;
3819 pMac->lim.gLimAddtsRspTimerCount++;
3820
3821 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3822 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3823 psessionEntry->smeSessionId,
3824 psessionEntry->transactionId);
3825}
3826
3827/**
3828 * __lim_process_sme_get_statistics_request()
3829 *
3830 ***FUNCTION:
3831 *
3832 *
3833 ***NOTE:
3834 *
3835 * @param pMac Pointer to Global MAC structure
3836 * @param *pMsgBuf A pointer to the SME message buffer
3837 * @return None
3838 */
3839static void
3840__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3841{
3842 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003843 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844
3845 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3846
3847 msgQ.type = WMA_GET_STATISTICS_REQ;
3848
3849 msgQ.reserved = 0;
3850 msgQ.bodyptr = pMsgBuf;
3851 msgQ.bodyval = 0;
3852 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3853
3854 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303855 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003857 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 return;
3859 }
3860
3861 return;
3862}
3863
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003864#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003866 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003868 * @pMac: Pointer to Global MAC structure
3869 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003871 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 */
3873static void
3874__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3875{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003876 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877
3878 msgQ.type = WMA_TSM_STATS_REQ;
3879 msgQ.reserved = 0;
3880 msgQ.bodyptr = pMsgBuf;
3881 msgQ.bodyval = 0;
3882 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3883
3884 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303885 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003887 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 return;
3889 }
3890}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003891#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892
3893static void
3894__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3895{
3896 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
3897 tpPESession psessionEntry;
3898 uint8_t sessionId; /* PE sessionID */
3899
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003900 pe_debug("received UPDATE_APWPSIEs_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901
3902 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003903 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904 return;
3905 }
3906
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303907 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 if (NULL == pUpdateAPWPSIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003909 pe_err("call to AllocateMemory failed for pUpdateAPWPSIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 return;
3911 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303912 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 sizeof(struct sSirUpdateAPWPSIEsReq));
3914
3915 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08003916 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 &sessionId);
3918 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003919 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 goto end;
3921 }
3922
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303923 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 sizeof(tSirAPWPSIEs));
3925
3926 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3927 lim_send_beacon_ind(pMac, psessionEntry);
3928
3929end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303930 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 return;
3932}
3933
Naveen Rawat8029a402017-06-01 10:54:19 -07003934static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3935 struct update_config *msg)
3936{
3937 tpPESession pe_session;
3938
3939 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3940 if (msg == NULL) {
3941 pe_err("Buffer is Pointing to NULL");
3942 return;
3943 }
3944
3945 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3946 msg->sme_session_id);
3947 if (pe_session == NULL) {
3948 pe_warn("Session does not exist for given BSSID");
3949 return;
3950 }
3951
3952 switch (msg->capab) {
3953 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3954 pe_session->htConfig.ht_rx_ldpc = msg->value;
3955 break;
3956 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3957 pe_session->htConfig.ht_tx_stbc = msg->value;
3958 break;
3959 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3960 pe_session->htConfig.ht_rx_stbc = msg->value;
3961 break;
3962 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3963 pe_session->htConfig.ht_sgi20 = msg->value;
3964 break;
3965 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3966 pe_session->htConfig.ht_sgi40 = msg->value;
3967 break;
3968 }
3969
3970 if (LIM_IS_AP_ROLE(pe_session)) {
3971 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3972 lim_send_beacon_ind(mac_ctx, pe_session);
3973 }
3974}
3975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976void
3977lim_send_vdev_restart(tpAniSirGlobal pMac,
3978 tpPESession psessionEntry, uint8_t sessionId)
3979{
3980 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003981 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 tSirRetStatus retCode = eSIR_SUCCESS;
3983
3984 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003985 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 return;
3987 }
3988
3989 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303990 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003992 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 return;
3994 }
3995
3996 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3997 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003998 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999
4000 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4001 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4002 msgQ.bodyval = 0;
4003
4004 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4005 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004006 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304007 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 }
4009}
4010
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304011/**
4012 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4013 * @mac_ctx: Pointer to Global MAC structure
4014 * @msg_buf: Pointer to SME message buffer
4015 *
4016 * Return: None
4017 */
4018static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4019 uint32_t *msg_buf)
4020{
4021 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004022 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304023 tSirRetStatus status;
4024 tSirRoamOffloadScanReq *req_buffer;
4025 uint16_t local_ie_len;
4026 uint8_t *local_ie_buf;
4027
4028 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4029 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4030 req_buffer->sessionId);
4031
4032 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4033 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004034 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304035 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304036 return;
4037 }
4038
4039 local_ie_len = req_buffer->assoc_ie.length;
4040 /* Update ext cap IE if present */
4041 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004042 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4043 local_ie_buf, &local_ie_len)) {
4044 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004045 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4046 req_buffer->assoc_ie.length = local_ie_len;
4047 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4048 local_ie_buf, local_ie_len);
4049 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304050 }
4051 qdf_mem_free(local_ie_buf);
4052
4053 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4054 wma_msg.bodyptr = req_buffer;
4055
4056 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4057 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004058 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304059 qdf_mem_free(req_buffer);
4060 }
4061}
4062
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304063/*
4064 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4065 * @mac_ctx: Pointer to global mac context
4066 * @session: Pointer to PE session
4067 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4068 * 1 - Disable broadcast SSID
4069 *
4070 * Return: None
4071 */
4072static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4073 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004075 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004076 session->ssidHidden, ssid_hidden);
4077
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004078 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304079 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004080 } else {
4081 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304082 return;
4083 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084
4085 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304086 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304089}
4090
4091/**
4092 * __lim_process_sme_session_update - process SME session update msg
4093 *
4094 * @mac_ctx: Pointer to global mac context
4095 * @msg_buf: Pointer to the received message buffer
4096 *
4097 * Return: None
4098 */
4099static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4100 uint32_t *msg_buf)
4101{
4102 struct sir_update_session_param *msg;
4103 tpPESession session;
4104
4105 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004106 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304107 return;
4108 }
4109
4110 msg = (struct sir_update_session_param *) msg_buf;
4111
4112 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4113 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004114 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304115 msg->session_id);
4116 return;
4117 }
4118
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004119 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304120 msg->param_type, msg->param_val);
4121 switch (msg->param_type) {
4122 case SIR_PARAM_SSID_HIDDEN:
4123 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4124 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304125 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4126 session->ignore_assoc_disallowed = msg->param_val;
4127 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304128 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004129 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304130 break;
4131 }
4132}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133
4134static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4135{
4136 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4137 tpPESession psessionEntry;
4138 uint8_t sessionId; /* PE sessionID */
4139
4140 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004141 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 return;
4143 }
4144
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304145 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 if (NULL == pUpdateAPWPARSNIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004147 pe_err("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 return;
4149 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304150 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4152
4153 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004154 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 &sessionId);
4156 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004157 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 goto end;
4159 }
4160
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304161 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4163
4164 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4165 &psessionEntry->
4166 pLimStartBssReq->rsnIE,
4167 psessionEntry);
4168
4169 psessionEntry->pLimStartBssReq->privacy = 1;
4170 psessionEntry->privacy = 1;
4171
4172 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4173 lim_send_beacon_ind(pMac, psessionEntry);
4174
4175end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304176 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 return;
4178} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4179
4180/*
4181 Update the beacon Interval dynamically if beaconInterval is different in MCC
4182 */
4183static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4184{
4185 tpSirChangeBIParams pChangeBIParams;
4186 tpPESession psessionEntry;
4187 uint8_t sessionId = 0;
4188 tUpdateBeaconParams beaconParams;
4189
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004190 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191
4192 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004193 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 return;
4195 }
4196
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304197 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4199
4200 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004201 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 &sessionId);
4203 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004204 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 return;
4206 }
4207
4208 /*Update sessionEntry Beacon Interval */
4209 if (psessionEntry->beaconParams.beaconInterval !=
4210 pChangeBIParams->beaconInterval) {
4211 psessionEntry->beaconParams.beaconInterval =
4212 pChangeBIParams->beaconInterval;
4213 }
4214
4215 /*Update sch beaconInterval */
4216 if (pMac->sch.schObject.gSchBeaconInterval !=
4217 pChangeBIParams->beaconInterval) {
4218 pMac->sch.schObject.gSchBeaconInterval =
4219 pChangeBIParams->beaconInterval;
4220
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004221 pe_debug("LIM send update BeaconInterval Indication: %d",
4222 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223
4224 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4225 /* Update beacon */
4226 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4227
4228 beaconParams.bssIdx = psessionEntry->bssIdx;
4229 /* Set change in beacon Interval */
4230 beaconParams.beaconInterval =
4231 pChangeBIParams->beaconInterval;
4232 beaconParams.paramChangeBitmap =
4233 PARAM_BCN_INTERVAL_CHANGED;
4234 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4235 }
4236 }
4237
4238 return;
4239} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4240
4241#ifdef QCA_HT_2040_COEX
4242static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4243 uint32_t *pMsgBuf)
4244{
4245 tpSirSetHT2040Mode pSetHT2040Mode;
4246 tpPESession psessionEntry;
4247 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004248 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 tUpdateVHTOpMode *pHtOpMode = NULL;
4250 uint16_t staId = 0;
4251 tpDphHashNode pStaDs = NULL;
4252
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004253 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004255 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 return;
4257 }
4258
4259 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4260
4261 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004262 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 &sessionId);
4264 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004265 pe_debug("Session does not exist for given BSSID");
4266 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 return;
4268 }
4269
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004270 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 pSetHT2040Mode->cbMode);
4272 /*Update sessionEntry HT related fields */
4273 switch (pSetHT2040Mode->cbMode) {
4274 case PHY_SINGLE_CHANNEL_CENTERED:
4275 psessionEntry->htSecondaryChannelOffset =
4276 PHY_SINGLE_CHANNEL_CENTERED;
4277 psessionEntry->htRecommendedTxWidthSet = 0;
4278 if (pSetHT2040Mode->obssEnabled)
4279 psessionEntry->htSupportedChannelWidthSet
4280 = eHT_CHANNEL_WIDTH_40MHZ;
4281 else
4282 psessionEntry->htSupportedChannelWidthSet
4283 = eHT_CHANNEL_WIDTH_20MHZ;
4284 break;
4285 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4286 psessionEntry->htSecondaryChannelOffset =
4287 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4288 psessionEntry->htRecommendedTxWidthSet = 1;
4289 break;
4290 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4291 psessionEntry->htSecondaryChannelOffset =
4292 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4293 psessionEntry->htRecommendedTxWidthSet = 1;
4294 break;
4295 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004296 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 return;
4298 }
4299
4300 /* Update beacon */
4301 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4302 lim_send_beacon_ind(pMac, psessionEntry);
4303
4304 /* update OP Mode for each associated peer */
4305 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4306 pStaDs = dph_get_hash_entry(pMac, staId,
4307 &psessionEntry->dph.dphHashTable);
4308 if (NULL == pStaDs)
4309 continue;
4310
4311 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304312 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004314 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 return;
4316 }
4317 pHtOpMode->opMode =
4318 (psessionEntry->htSecondaryChannelOffset ==
4319 PHY_SINGLE_CHANNEL_CENTERED) ?
4320 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4321 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304322 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 sizeof(tSirMacAddr));
4324 pHtOpMode->smesessionId = sessionId;
4325
4326 msg.type = WMA_UPDATE_OP_MODE;
4327 msg.reserved = 0;
4328 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004329 if (!QDF_IS_STATUS_SUCCESS
4330 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4331 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304332 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 return;
4334 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004335 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4336 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337
4338 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004339 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 }
4341
4342 return;
4343}
4344#endif
4345
4346/* -------------------------------------------------------------------- */
4347/**
4348 * __lim_process_report_message
4349 *
4350 * FUNCTION: Processes the next received Radio Resource Management message
4351 *
4352 * LOGIC:
4353 *
4354 * ASSUMPTIONS:
4355 *
4356 * NOTE:
4357 *
4358 * @param None
4359 * @return None
4360 */
4361
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004362static void __lim_process_report_message(tpAniSirGlobal pMac,
4363 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 switch (pMsg->type) {
4366 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4367 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4368 break;
4369 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004371 break;
4372 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004373 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375}
4376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377/* -------------------------------------------------------------------- */
4378/**
4379 * lim_send_set_max_tx_power_req
4380 *
4381 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4382 *
4383 * LOGIC:
4384 *
4385 * ASSUMPTIONS:
4386 *
4387 * NOTE:
4388 *
4389 * @param txPower txPower to be set.
4390 * @param pSessionEntry session entry.
4391 * @return None
4392 */
4393tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004394lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 tpPESession pSessionEntry)
4396{
4397 tpMaxTxPowerParams pMaxTxParams = NULL;
4398 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004399 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400
4401 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004402 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 return eSIR_FAILURE;
4404 }
4405
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304406 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004408 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 return eSIR_MEM_ALLOC_FAILED;
4410
4411 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304413 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304414 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304415 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004416 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304417 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418
4419 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4420 msgQ.bodyptr = pMaxTxParams;
4421 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004422 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4424 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4425 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004426 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304427 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 }
4429 return retCode;
4430}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431
4432/**
4433 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4434 *
4435 * @mac_ctx: Pointer to Global MAC structure
4436 * @msg_buf: pointer to the SME message buffer
4437 *
4438 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4439 * from SME. It Register this information within PE.
4440 *
4441 * Return: None
4442 */
4443static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4444 uint32_t *msg_buf)
4445{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304446 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4448 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4449 struct mgmt_frm_reg_info *next = NULL;
4450 bool match = false;
4451
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004452 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 sme_req->registerFrame, sme_req->frameType,
4454 sme_req->matchLen);
4455 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304456 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304457 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4458 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304459 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460
4461 while (lim_mgmt_regn != NULL) {
4462 if (lim_mgmt_regn->frameType != sme_req->frameType)
4463 goto skip_match;
4464 if (sme_req->matchLen) {
4465 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304466 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 sme_req->matchData,
4468 lim_mgmt_regn->matchLen))) {
4469 /* found match! */
4470 match = true;
4471 break;
4472 }
4473 } else {
4474 /* found match! */
4475 match = true;
4476 break;
4477 }
4478skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304479 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304480 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304482 (qdf_list_node_t *)lim_mgmt_regn,
4483 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304484 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 lim_mgmt_regn = next;
4486 next = NULL;
4487 }
4488 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304489 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004490 if (QDF_STATUS_SUCCESS ==
4491 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004493 (qdf_list_node_t *)lim_mgmt_regn))
4494 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304495 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 }
4497
4498 if (sme_req->registerFrame) {
4499 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304500 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 sme_req->matchLen);
4502 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 lim_mgmt_regn->frameType = sme_req->frameType;
4504 lim_mgmt_regn->matchLen = sme_req->matchLen;
4505 lim_mgmt_regn->sessionId = sme_req->sessionId;
4506 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304507 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 sme_req->matchData,
4509 sme_req->matchLen);
4510 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304511 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304513 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 gLimMgmtFrameRegistratinQueue,
4515 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304516 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 &mac_ctx->lim.lim_frame_register_lock);
4518 }
4519 }
4520 return;
4521}
4522
4523static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4524{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004525 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526 pMac->lim.gDeferMsgTypeForNOA = 0;
4527 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4528 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304529 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4531 }
4532}
4533
4534/**
4535 * lim_process_regd_defd_sme_req_after_noa_start()
4536 *
4537 * mac_ctx: Pointer to Global MAC structure
4538 *
4539 * This function is called to process deferred sme req message
4540 * after noa start.
4541 *
4542 * Return: None
4543 */
4544void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4545{
4546 bool buf_consumed = true;
4547
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004548 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 mac_ctx->lim.gDeferMsgTypeForNOA);
4550
4551 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4552 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004553 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4554 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 return;
4556 }
4557 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4558 case eWNI_SME_SCAN_REQ:
4559 __lim_process_sme_scan_req(mac_ctx,
4560 mac_ctx->lim.gpDefdSmeMsgForNOA);
4561 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4563 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4564 mac_ctx->lim.gpDefdSmeMsgForNOA);
4565 /*
4566 * lim_process_remain_on_chnl_req doesnt want us to free
4567 * the buffer since it is freed in lim_remain_on_chn_rsp.
4568 * this change is to avoid "double free"
4569 */
4570 if (false == buf_consumed)
4571 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4572 break;
4573 case eWNI_SME_JOIN_REQ:
4574 __lim_process_sme_join_req(mac_ctx,
4575 mac_ctx->lim.gpDefdSmeMsgForNOA);
4576 break;
4577 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004578 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 mac_ctx->lim.gDeferMsgTypeForNOA);
4580 break;
4581 }
4582 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4583}
4584
4585static void
4586__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4587{
4588 tpSirResetAPCapsChange pResetCapsChange;
4589 tpPESession psessionEntry;
4590 uint8_t sessionId = 0;
4591 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004592 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 return;
4594 }
4595
4596 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4597 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004598 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4599 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004601 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 return;
4603 }
4604
4605 psessionEntry->limSentCapsChangeNtf = false;
4606 return;
4607}
4608
4609/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304610 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4611 * @mac_ctx: Mac pointer
4612 * @msg_buf: Msg pointer containing the callback
4613 *
4614 * This function is used to save the p2p ack indication callback in PE.
4615 *
4616 * Return: None
4617 */
4618static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4619 uint32_t *msg_buf)
4620{
4621 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4622 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4623
4624 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004625 pe_err("msg_buf is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304626 return;
4627 }
4628 if (sme_req->callback)
4629 mac_ctx->p2p_ack_ind_cb =
4630 sme_req->callback;
4631 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004632 pe_err("sme_req->callback is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304633}
4634
4635/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304636 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4637 * indication callback in PE.
4638 * @mac_ptr: Mac pointer
4639 * @msg_buf: Msg pointer containing the callback
4640 *
4641 * This function is used save the Management frame
4642 * indication callback in PE.
4643 *
4644 * Return: None
4645 */
4646static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4647 uint32_t *msg_buf)
4648{
4649 struct sir_sme_mgmt_frame_cb_req *sme_req =
4650 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4651
4652 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004653 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304654 return;
4655 }
4656 if (sme_req->callback)
4657 mac_ctx->mgmt_frame_ind_cb =
4658 (sir_mgmt_frame_ind_callback)sme_req->callback;
4659 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004660 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304661}
4662
4663/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304664 *__lim_process_send_disassoc_frame: function processes disassoc frame
4665 * @mac_ctx: pointer to mac context
4666 * @msg_buf: message buffer
4667 *
4668 * function processes disassoc request received from SME
4669 *
4670 * return: none
4671 */
4672static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4673 uint32_t *msg_buf)
4674{
4675 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4676 tSirRetStatus status;
4677 tpPESession session_entry = NULL;
4678 uint8_t sme_session_id;
4679 uint16_t sme_trans_id;
4680
4681 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004682 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304683 return;
4684 }
4685
4686 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4687 &sme_trans_id);
4688
4689 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4690 &sme_send_disassoc_frame_req,
4691 (uint8_t *)msg_buf);
4692
4693 if ((eSIR_FAILURE == status) ||
4694 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4695 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004696 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304697 return;
4698 }
4699
4700 session_entry = pe_find_session_by_sme_session_id(
4701 mac_ctx, sme_session_id);
4702 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004703 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304704 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4705 return;
4706 }
4707
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004708 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 +05304709 sme_send_disassoc_frame_req.msg_type,
4710 sme_send_disassoc_frame_req.length,
4711 sme_send_disassoc_frame_req.session_id,
4712 sme_send_disassoc_frame_req.trans_id,
4713 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4714 sme_send_disassoc_frame_req.reason,
4715 sme_send_disassoc_frame_req.wait_for_ack);
4716
4717 lim_send_disassoc_mgmt_frame(mac_ctx,
4718 sme_send_disassoc_frame_req.reason,
4719 sme_send_disassoc_frame_req.peer_mac,
4720 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4721}
4722
4723/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004724 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4725 * @mac_ctx: Pointer to Global MAC structure
4726 * @pdev_id: pdev id to set the IE.
4727 * @nss: Nss values to prepare the HT IE.
4728 *
4729 * Prepares the HT IE with self capabilities for different
4730 * Nss values and sends the set HT IE req to FW.
4731 *
4732 * Return: None
4733 */
4734static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4735 uint8_t nss)
4736{
4737 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004738 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004739 tSirRetStatus rc = eSIR_SUCCESS;
4740 uint8_t *p_ie = NULL;
4741 tHtCaps *p_ht_cap;
4742 int i;
4743
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004744 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004745 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4746 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004747 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004748 return;
4749 }
4750 ie_params->nss = i;
4751 ie_params->pdev_id = pdev_id;
4752 ie_params->ie_type = DOT11_HT_IE;
4753 /* 2 for IE len and EID */
4754 ie_params->ie_len = 2 + sizeof(tHtCaps);
4755 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4756 if (NULL == ie_params->ie_ptr) {
4757 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004758 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004759 return;
4760 }
4761 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4762 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4763 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4764 ie_params->ie_len);
4765
4766 if (NSS_1x1_MODE == i) {
4767 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4768 ie_params->ie_len,
4769 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004770 if (NULL == p_ie) {
4771 qdf_mem_free(ie_params->ie_ptr);
4772 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004773 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004774 return;
4775 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004776 p_ht_cap = (tHtCaps *)&p_ie[2];
4777 p_ht_cap->supportedMCSSet[1] = 0;
4778 p_ht_cap->txSTBC = 0;
4779 }
4780
4781 msg.type = WMA_SET_PDEV_IE_REQ;
4782 msg.bodyptr = ie_params;
4783 msg.bodyval = 0;
4784
4785 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4786 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004787 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004788 qdf_mem_free(ie_params->ie_ptr);
4789 qdf_mem_free(ie_params);
4790 return;
4791 }
4792 }
4793}
4794
4795/**
4796 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4797 * @mac_ctx: Pointer to Global MAC structure
4798 * @pdev_id: pdev id to set the IE.
4799 * @nss: Nss values to prepare the VHT IE.
4800 *
4801 * Prepares the VHT IE with self capabilities for different
4802 * Nss values and sends the set VHT IE req to FW.
4803 *
4804 * Return: None
4805 */
4806static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4807 uint8_t nss)
4808{
4809 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004810 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004811 tSirRetStatus rc = eSIR_SUCCESS;
4812 uint8_t *p_ie = NULL;
4813 tSirMacVHTCapabilityInfo *vht_cap;
4814 int i;
4815 tSirVhtMcsInfo *vht_mcs;
4816
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004817 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004818 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4819 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004820 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004821 return;
4822 }
4823 ie_params->nss = i;
4824 ie_params->pdev_id = pdev_id;
4825 ie_params->ie_type = DOT11_VHT_IE;
4826 /* 2 for IE len and EID */
4827 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4828 sizeof(tSirVhtMcsInfo);
4829 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4830 if (NULL == ie_params->ie_ptr) {
4831 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004832 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004833 return;
4834 }
4835 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4836 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4837 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4838 ie_params->ie_len);
4839
4840 if (NSS_1x1_MODE == i) {
4841 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4842 ie_params->ie_len,
4843 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004844 if (NULL == p_ie) {
4845 qdf_mem_free(ie_params->ie_ptr);
4846 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004847 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004848 return;
4849 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004850 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4851 vht_cap->txSTBC = 0;
4852 vht_mcs =
4853 (tSirVhtMcsInfo *)&p_ie[2 +
4854 sizeof(tSirMacVHTCapabilityInfo)];
4855 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4856 vht_mcs->rxHighest =
4857 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4858 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4859 vht_mcs->txHighest =
4860 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4861 }
4862 msg.type = WMA_SET_PDEV_IE_REQ;
4863 msg.bodyptr = ie_params;
4864 msg.bodyval = 0;
4865
4866 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4867 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004868 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004869 qdf_mem_free(ie_params->ie_ptr);
4870 qdf_mem_free(ie_params);
4871 return;
4872 }
4873 }
4874}
4875
4876/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004877 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4878 * @mac_ctx: Pointer to Global MAC structure
4879 * @msg_buf: Pointer to the SME message buffer
4880 *
4881 * This function is called by limProcessMessageQueue(). This function sets the
4882 * VDEV IEs to the FW.
4883 *
4884 * Return: None
4885 */
4886static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4887 uint32_t *msg_buf)
4888{
4889 struct sir_set_vdev_ies_per_band *p_msg =
4890 (struct sir_set_vdev_ies_per_band *)msg_buf;
4891
4892 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004893 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004894 return;
4895 }
4896
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004897 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004898 p_msg->vdev_id);
4899 /* intentionally using NULL here so that self capabilty are sent */
4900 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4901 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004902 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004903}
4904
4905/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004906 * lim_process_set_pdev_IEs() - process the set pdev IE req
4907 * @mac_ctx: Pointer to Global MAC structure
4908 * @msg_buf: Pointer to the SME message buffer
4909 *
4910 * This function is called by limProcessMessageQueue(). This
4911 * function sets the PDEV IEs to the FW.
4912 *
4913 * Return: None
4914 */
4915static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4916{
4917 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4918
4919 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4920
4921 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004922 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004923 return;
4924 }
4925
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004926 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004927 ht_vht_cfg->nss);
4928 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4929
4930 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4931 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4932 ht_vht_cfg->nss);
4933}
4934
4935/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304936 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4937 *
4938 * access policy
4939 * @mac_ctx: pointer to mac context
4940 * @msg: message buffer
4941 *
4942 * function processes vendor IE and access policy from SME and updates PE
4943 *
4944 * session entry
4945 *
4946 * return: none
4947*/
4948static void lim_process_sme_update_access_policy_vendor_ie(
4949 tpAniSirGlobal mac_ctx,
4950 uint32_t *msg)
4951{
4952 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4953 struct sPESession *pe_session_entry;
4954 uint8_t num_bytes;
4955
4956 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004957 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304958 return;
4959 }
4960 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4961 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4962 update_vendor_ie->sme_session_id);
4963
4964 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004965 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304966 update_vendor_ie->sme_session_id);
4967 return;
4968 }
4969 if (pe_session_entry->access_policy_vendor_ie)
4970 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4971
4972 num_bytes = update_vendor_ie->ie[1] + 2;
4973 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4974
4975 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004976 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304977 return;
4978 }
4979 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4980 &update_vendor_ie->ie[0], num_bytes);
4981
4982 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4983}
4984
4985/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986 * lim_process_sme_req_messages()
4987 *
4988 ***FUNCTION:
4989 * This function is called by limProcessMessageQueue(). This
4990 * function processes SME request messages from HDD or upper layer
4991 * application.
4992 *
4993 ***LOGIC:
4994 *
4995 ***ASSUMPTIONS:
4996 *
4997 ***NOTE:
4998 *
4999 * @param pMac Pointer to Global MAC structure
5000 * @param msgType Indicates the SME message type
5001 * @param *pMsgBuf A pointer to the SME message buffer
5002 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5003 * false - if pMsgBuf is not to be freed.
5004 */
5005
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005006bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5007 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008{
5009 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5010 uint32_t *pMsgBuf = pMsg->bodyptr;
5011 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005012
5013 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 lim_msg_str(pMsg->type), pMsg->type,
5015 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5016 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017
5018 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5019 /* If no insert NOA required then execute the code below */
5020
5021 switch (pMsg->type) {
5022 case eWNI_SME_SYS_READY_IND:
5023 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5024 break;
5025
5026 case eWNI_SME_START_BSS_REQ:
5027 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5028 break;
5029
5030 case eWNI_SME_SCAN_REQ:
5031 __lim_process_sme_scan_req(pMac, pMsgBuf);
5032 break;
5033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5035 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5036 break;
5037
5038 case eWNI_SME_UPDATE_NOA:
5039 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5040 break;
5041 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5042 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5043 break;
5044 case eWNI_SME_JOIN_REQ:
5045 __lim_process_sme_join_req(pMac, pMsgBuf);
5046 break;
5047
5048 case eWNI_SME_REASSOC_REQ:
5049 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5050 break;
5051
5052 case eWNI_SME_DISASSOC_REQ:
5053 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5054 break;
5055
5056 case eWNI_SME_DISASSOC_CNF:
5057 case eWNI_SME_DEAUTH_CNF:
5058 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5059 break;
5060
5061 case eWNI_SME_DEAUTH_REQ:
5062 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5063 break;
5064
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305065 case eWNI_SME_SEND_DISASSOC_FRAME:
5066 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5067 break;
5068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 case eWNI_SME_SETCONTEXT_REQ:
5070 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5071 break;
5072
5073 case eWNI_SME_STOP_BSS_REQ:
5074 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5075 break;
5076
5077 case eWNI_SME_ASSOC_CNF:
5078 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005079 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5081 pMsgBuf);
5082 break;
5083
5084 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005085 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 __lim_process_sme_addts_req(pMac, pMsgBuf);
5087 break;
5088
5089 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005090 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 __lim_process_sme_delts_req(pMac, pMsgBuf);
5092 break;
5093
5094 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005095 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5097 break;
5098
5099 case eWNI_SME_GET_STATISTICS_REQ:
5100 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5101 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5102 bufConsumed = false;
5103 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005104#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 case eWNI_SME_GET_TSM_STATS_REQ:
5106 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5107 bufConsumed = false;
5108 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005109#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110 case eWNI_SME_GET_ASSOC_STAS_REQ:
5111 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5112 break;
5113 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5114 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5115 break;
5116
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305117 case eWNI_SME_SESSION_UPDATE_PARAM:
5118 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305120 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5121 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5122 bufConsumed = false;
5123 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005124 case eWNI_SME_UPDATE_APWPSIE_REQ:
5125 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5126 break;
5127 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5128 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5129 break;
5130
5131 case eWNI_SME_SET_APWPARSNIEs_REQ:
5132 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5133 break;
5134
5135 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5136 /* Update the beaconInterval */
5137 __lim_process_sme_change_bi(pMac, pMsgBuf);
5138 break;
5139
5140#ifdef QCA_HT_2040_COEX
5141 case eWNI_SME_SET_HT_2040_MODE:
5142 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5143 break;
5144#endif
5145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5147 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5148 __lim_process_report_message(pMac, pMsg);
5149 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 case eWNI_SME_FT_PRE_AUTH_REQ:
5152 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5153 break;
5154 case eWNI_SME_FT_UPDATE_KEY:
5155 lim_process_ft_update_key(pMac, pMsgBuf);
5156 break;
5157
5158 case eWNI_SME_FT_AGGR_QOS_REQ:
5159 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5160 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161
5162 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5163 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5164 break;
5165#ifdef FEATURE_WLAN_TDLS
5166 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5167 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5168 break;
5169 case eWNI_SME_TDLS_ADD_STA_REQ:
5170 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5171 break;
5172 case eWNI_SME_TDLS_DEL_STA_REQ:
5173 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5174 break;
5175 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5176 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5177 break;
5178#endif
5179 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5180 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5181 break;
5182
5183 case eWNI_SME_CHANNEL_CHANGE_REQ:
5184 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5185 break;
5186
5187 case eWNI_SME_START_BEACON_REQ:
5188 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5189 break;
5190
5191 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5192 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5193 break;
5194
5195 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5196 lim_process_update_add_ies(pMac, pMsgBuf);
5197 break;
5198
5199 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5200 lim_process_modify_add_ies(pMac, pMsgBuf);
5201 break;
5202 case eWNI_SME_SET_HW_MODE_REQ:
5203 lim_process_set_hw_mode(pMac, pMsgBuf);
5204 break;
5205 case eWNI_SME_NSS_UPDATE_REQ:
5206 lim_process_nss_update_request(pMac, pMsgBuf);
5207 break;
5208 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5209 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5210 break;
5211 case eWNI_SME_SET_IE_REQ:
5212 lim_process_set_ie_req(pMac, pMsgBuf);
5213 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305214 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5215 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5216 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305217 case eWNI_SME_EXT_CHANGE_CHANNEL:
5218 lim_process_ext_change_channel(pMac, pMsgBuf);
5219 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005220 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5221 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5222 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005223 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5224 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005225 break;
5226 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5227 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5228 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005229 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005230 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005231 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005232 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005233 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305234 case eWNI_SME_REGISTER_P2P_ACK_CB:
5235 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5236 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305237 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5238 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5239 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005240 case eWNI_SME_UPDATE_CONFIG:
5241 lim_process_sme_update_config(pMac,
5242 (struct update_config *)pMsgBuf);
5243 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305245 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 pMsg->bodyptr = NULL;
5247 break;
5248 } /* switch (msgType) */
5249
5250 return bufConsumed;
5251} /*** end lim_process_sme_req_messages() ***/
5252
5253/**
5254 * lim_process_sme_start_beacon_req()
5255 *
5256 ***FUNCTION:
5257 * This function is called by limProcessMessageQueue(). This
5258 * function processes SME request messages from HDD or upper layer
5259 * application.
5260 *
5261 ***LOGIC:
5262 *
5263 ***ASSUMPTIONS:
5264 *
5265 ***NOTE:
5266 *
5267 * @param pMac Pointer to Global MAC structure
5268 * @param msgType Indicates the SME message type
5269 * @param *pMsgBuf A pointer to the SME message buffer
5270 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5271 * false - if pMsgBuf is not to be freed.
5272 */
5273static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5274{
5275 tpSirStartBeaconIndication pBeaconStartInd;
5276 tpPESession psessionEntry;
5277 uint8_t sessionId; /* PE sessionID */
5278
5279 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005280 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 return;
5282 }
5283
5284 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5285 psessionEntry = pe_find_session_by_bssid(pMac,
5286 pBeaconStartInd->bssid,
5287 &sessionId);
5288 if (psessionEntry == NULL) {
5289 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005290 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 return;
5292 }
5293
5294 if (pBeaconStartInd->beaconStartStatus == true) {
5295 /*
5296 * Currently this Indication comes from SAP
5297 * to start Beacon Tx on a DFS channel
5298 * since beaconing has to be done on DFS
5299 * channel only after CAC WAIT is completed.
5300 * On a DFS Channel LIM does not start beacon
5301 * Tx right after the WMA_ADD_BSS_RSP.
5302 */
5303 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305304 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 FL("Start Beacon with ssid %s Ch %d"),
5306 psessionEntry->ssId.ssId,
5307 psessionEntry->currentOperChannel);
5308 lim_send_beacon_ind(pMac, psessionEntry);
5309 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005310 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 return;
5312 }
5313}
5314
5315/**
5316 * lim_process_sme_channel_change_request() - process sme ch change req
5317 *
5318 * @mac_ctx: Pointer to Global MAC structure
5319 * @msg_buf: pointer to the SME message buffer
5320 *
5321 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5322 *
5323 * Return: None
5324 */
5325static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5326 uint32_t *msg_buf)
5327{
5328 tpSirChanChangeRequest ch_change_req;
5329 tpPESession session_entry;
5330 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005331 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 uint32_t val = 0;
5333
5334 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005335 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 return;
5337 }
5338 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5339
5340 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5341 ch_change_req->targetChannel);
5342
5343 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5344 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005345 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346 return;
5347 }
5348
5349 session_entry = pe_find_session_by_bssid(mac_ctx,
5350 ch_change_req->bssid, &session_id);
5351 if (session_entry == NULL) {
5352 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005353 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 return;
5355 }
5356
5357 if (session_entry->currentOperChannel ==
5358 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005359 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 return;
5361 }
5362
5363 if (LIM_IS_AP_ROLE(session_entry))
5364 session_entry->channelChangeReasonCode =
5365 LIM_SWITCH_CHANNEL_SAP_DFS;
5366 else
5367 session_entry->channelChangeReasonCode =
5368 LIM_SWITCH_CHANNEL_OPERATION;
5369
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005370 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371 session_entry->currentOperChannel,
5372 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005373 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374
5375 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005376 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 session_entry->ch_center_freq_seg0 =
5378 ch_change_req->center_freq_seg_0;
5379 session_entry->ch_center_freq_seg1 =
5380 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005381 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005383 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 session_entry->htRecommendedTxWidthSet =
5385 session_entry->htSupportedChannelWidthSet;
5386 session_entry->currentOperChannel =
5387 ch_change_req->targetChannel;
5388 session_entry->limRFBand =
5389 lim_get_rf_band(session_entry->currentOperChannel);
5390 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005391 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5392 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5394 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005395 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396 }
5397
5398 session_entry->lim11hEnable = val;
5399 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305400 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 &ch_change_req->operational_rateset,
5402 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305403 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 &ch_change_req->extended_rateset,
5405 sizeof(session_entry->extRateSet));
5406 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5407 session_entry->ch_center_freq_seg0,
5408 session_entry->ch_center_freq_seg1,
5409 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005410 max_tx_pwr, session_entry->peSessionId,
5411 ch_change_req->cac_duration_ms,
5412 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413}
5414
5415/******************************************************************************
5416* lim_start_bss_update_add_ie_buffer()
5417*
5418***FUNCTION:
5419* This function checks the src buffer and its length and then malloc for
5420* dst buffer update the same
5421*
5422***LOGIC:
5423*
5424***ASSUMPTIONS:
5425*
5426***NOTE:
5427*
5428* @param pMac Pointer to Global MAC structure
5429* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5430* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5431* @param *pSrcData_buff A pointer of uint8_t src buffer
5432* @param srcDataLen src buffer length
5433******************************************************************************/
5434
5435static void
5436lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5437 uint8_t **pDstData_buff,
5438 uint16_t *pDstDataLen,
5439 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5440{
5441
5442 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5443 *pDstDataLen = srcDataLen;
5444
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305445 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446
5447 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005448 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449 return;
5450 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305451 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 } else {
5453 *pDstData_buff = NULL;
5454 *pDstDataLen = 0;
5455 }
5456}
5457
5458/******************************************************************************
5459* lim_update_add_ie_buffer()
5460*
5461***FUNCTION:
5462* This function checks the src buffer and length if src buffer length more
5463* than dst buffer length then free the dst buffer and malloc for the new src
5464* length, and update the dst buffer and length. But if dst buffer is bigger
5465* than src buffer length then it just update the dst buffer and length
5466*
5467***LOGIC:
5468*
5469***ASSUMPTIONS:
5470*
5471***NOTE:
5472*
5473* @param pMac Pointer to Global MAC structure
5474* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5475* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5476* @param *pSrcData_buff A pointer of uint8_t src buffer
5477* @param srcDataLen src buffer length
5478******************************************************************************/
5479
5480static void
5481lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5482 uint8_t **pDstData_buff,
5483 uint16_t *pDstDataLen,
5484 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5485{
5486
5487 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005488 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 return;
5490 }
5491
5492 if (srcDataLen > *pDstDataLen) {
5493 *pDstDataLen = srcDataLen;
5494 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305495 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305497 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498
5499 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005500 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501 *pDstDataLen = 0;
5502 return;
5503 }
5504 }
5505
5506 /* copy the content of buffer into dst buffer
5507 */
5508 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305509 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510
5511}
5512
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005513/**
5514 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5515 * @pMac : Pointer to Global MAC structure
5516 * @pDstData_buff : A pointer to pointer of dst buffer
5517 * @pDstDataLen : A pointer to pointer of dst buffer length
5518 * @pModifyIE : A pointer to tSirModifyIE
5519 *
5520 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5521 *
5522 * Return:
5523 * True or false depending upon whether IE is updated or not
5524 */
5525static bool
5526lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5527 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5528{
Hong Shi1553d692016-09-28 12:16:19 +08005529 int32_t oui_length;
5530 uint8_t *ibss_ie = NULL;
5531 uint8_t *vendor_ie;
5532#define MAC_VENDOR_OUI "\x00\x16\x32"
5533#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005534
5535 ibss_ie = pModifyIE->pIEBuffer;
5536 oui_length = pModifyIE->oui_length;
5537
5538 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005539 pe_err("Invalid set IBSS vendor IE command length %d",
5540 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005541 return false;
5542 }
5543
Hong Shi1553d692016-09-28 12:16:19 +08005544 /*
5545 * Why replace only beacon OUI data here:
5546 * 1. other ie (such as wpa) shall not be overwritten here.
5547 * 2. per spec, beacon oui ie might be set twice and original one
5548 * shall be updated.
5549 */
5550 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5551 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5552 if (vendor_ie) {
5553 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5554 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5555 pModifyIE->ieBufferlength);
5556 } else {
5557 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5558 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005559
Hong Shi1553d692016-09-28 12:16:19 +08005560 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005561 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005562 return false;
5563 }
5564 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5565 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5566 pModifyIE->ieBufferlength);
5567 qdf_mem_free(*pDstData_buff);
5568 *pDstDataLen = new_length;
5569 *pDstData_buff = new_ptr;
5570 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005571 return true;
5572}
5573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574/*
5575* lim_process_modify_add_ies() - process modify additional IE req.
5576*
5577* @mac_ctx: Pointer to Global MAC structure
5578* @msg_buf: pointer to the SME message buffer
5579*
5580* This function update the PE buffers for additional IEs.
5581*
5582* Return: None
5583*/
5584static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5585 uint32_t *msg_buf)
5586{
5587 tpSirModifyIEsInd modify_add_ies;
5588 tpPESession session_entry;
5589 uint8_t session_id;
5590 bool ret = false;
5591 tSirAddIeParams *add_ie_params;
5592
5593 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005594 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 return;
5596 }
5597
5598 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5599 /* Incoming message has smeSession, use BSSID to find PE session */
5600 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005601 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602
5603 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005604 pe_err("Session not found for given bssid"
5605 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005606 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 goto end;
5608 }
5609 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5610 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5611 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005612 pe_err("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 modify_add_ies->modifyIE.pIEBuffer,
5614 modify_add_ies->modifyIE.ieBufferlength,
5615 modify_add_ies->modifyIE.ieID,
5616 modify_add_ies->modifyIE.ieIDLen,
5617 modify_add_ies->updateType);
5618 goto end;
5619 }
5620 add_ie_params = &session_entry->addIeParams;
5621 switch (modify_add_ies->updateType) {
5622 case eUPDATE_IE_PROBE_RESP:
5623 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005624 if (LIM_IS_IBSS_ROLE(session_entry)) {
5625 lim_update_ibss_prop_add_ies(mac_ctx,
5626 &add_ie_params->probeRespData_buff,
5627 &add_ie_params->probeRespDataLen,
5628 &modify_add_ies->modifyIE);
5629 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 break;
5631 case eUPDATE_IE_ASSOC_RESP:
5632 /* assoc resp IE */
5633 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305634 QDF_TRACE(QDF_MODULE_ID_PE,
5635 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 "assoc resp add ie not present %d"),
5637 add_ie_params->assocRespDataLen);
5638 }
5639 /* search through the buffer and modify the IE */
5640 break;
5641 case eUPDATE_IE_PROBE_BCN:
5642 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005643 if (LIM_IS_IBSS_ROLE(session_entry)) {
5644 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5645 &add_ie_params->probeRespBCNData_buff,
5646 &add_ie_params->probeRespBCNDataLen,
5647 &modify_add_ies->modifyIE);
5648 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 if (ret == true && modify_add_ies->modifyIE.notify) {
5650 lim_handle_param_update(mac_ctx,
5651 modify_add_ies->updateType);
5652 }
5653 break;
5654 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005655 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 modify_add_ies->updateType);
5657 break;
5658 }
5659end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305660 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 modify_add_ies->modifyIE.pIEBuffer = NULL;
5662}
5663
5664/*
5665* lim_process_update_add_ies() - process additional IE update req
5666*
5667* @mac_ctx: Pointer to Global MAC structure
5668* @msg_buf: pointer to the SME message buffer
5669*
5670* This function update the PE buffers for additional IEs.
5671*
5672* Return: None
5673*/
5674static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5675 uint32_t *msg_buf)
5676{
5677 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5678 uint8_t session_id;
5679 tpPESession session_entry;
5680 tSirAddIeParams *addn_ie;
5681 uint16_t new_length = 0;
5682 uint8_t *new_ptr = NULL;
5683 tSirUpdateIE *update_ie;
5684
5685 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005686 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687 return;
5688 }
5689 update_ie = &update_add_ies->updateIE;
5690 /* incoming message has smeSession, use BSSID to find PE session */
5691 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005692 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693
5694 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005695 pe_err("Session not found for given bssid"
5696 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005697 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 goto end;
5699 }
5700 addn_ie = &session_entry->addIeParams;
5701 /* if len is 0, upper layer requested freeing of buffer */
5702 if (0 == update_ie->ieBufferlength) {
5703 switch (update_add_ies->updateType) {
5704 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305705 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 addn_ie->probeRespData_buff = NULL;
5707 addn_ie->probeRespDataLen = 0;
5708 break;
5709 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305710 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 addn_ie->assocRespData_buff = NULL;
5712 addn_ie->assocRespDataLen = 0;
5713 break;
5714 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305715 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 addn_ie->probeRespBCNData_buff = NULL;
5717 addn_ie->probeRespBCNDataLen = 0;
5718
5719 if (update_ie->notify)
5720 lim_handle_param_update(mac_ctx,
5721 update_add_ies->updateType);
5722 break;
5723 default:
5724 break;
5725 }
5726 return;
5727 }
5728 switch (update_add_ies->updateType) {
5729 case eUPDATE_IE_PROBE_RESP:
5730 if (update_ie->append) {
5731 /*
5732 * In case of append, allocate new memory
5733 * with combined length
5734 */
5735 new_length = update_ie->ieBufferlength +
5736 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305737 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005739 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 goto end;
5741 }
5742 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305743 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305745 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746 update_ie->pAdditionIEBuffer,
5747 update_ie->ieBufferlength);
5748 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305749 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 /* adjust length accordingly */
5751 addn_ie->probeRespDataLen = new_length;
5752 /* save refernece of local buffer in PE session */
5753 addn_ie->probeRespData_buff = new_ptr;
5754 goto end;
5755 }
5756 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5757 &addn_ie->probeRespDataLen,
5758 update_ie->pAdditionIEBuffer,
5759 update_ie->ieBufferlength);
5760 break;
5761 case eUPDATE_IE_ASSOC_RESP:
5762 /* assoc resp IE */
5763 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5764 &addn_ie->assocRespDataLen,
5765 update_ie->pAdditionIEBuffer,
5766 update_ie->ieBufferlength);
5767 break;
5768 case eUPDATE_IE_PROBE_BCN:
5769 /* probe resp Bcn IE */
5770 lim_update_add_ie_buffer(mac_ctx,
5771 &addn_ie->probeRespBCNData_buff,
5772 &addn_ie->probeRespBCNDataLen,
5773 update_ie->pAdditionIEBuffer,
5774 update_ie->ieBufferlength);
5775 if (update_ie->notify)
5776 lim_handle_param_update(mac_ctx,
5777 update_add_ies->updateType);
5778 break;
5779 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005780 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 break;
5782 }
5783end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305784 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 update_ie->pAdditionIEBuffer = NULL;
5786}
5787
5788/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305789 * send_extended_chan_switch_action_frame()- function to send ECSA
5790 * action frame for each sta connected to SAP/GO and AP in case of
5791 * STA .
5792 * @mac_ctx: pointer to global mac structure
5793 * @new_channel: new channel to switch to.
5794 * @ch_bandwidth: BW of channel to calculate op_class
5795 * @session_entry: pe session
5796 *
5797 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5798 *
5799 * Return: void
5800 */
5801
5802static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5803 uint16_t new_channel, uint8_t ch_bandwidth,
5804 tpPESession session_entry)
5805{
5806 uint16_t op_class;
5807 uint8_t switch_mode = 0, i;
5808 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005809 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305810
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005811 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305812 mac_ctx->scan.countryCodeCurrent,
5813 new_channel,
5814 ch_bandwidth);
5815
5816 if (LIM_IS_AP_ROLE(session_entry) &&
5817 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005818 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305819
gaoleze2920bd2017-03-21 17:38:42 +08005820 switch_count = session_entry->gLimChannelSwitch.switchCount;
5821
Abhishek Singh518323d2015-10-19 17:42:01 +05305822 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005823 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305824 psta =
5825 session_entry->dph.dphHashTable.pDphNodeArray + i;
5826 if (psta && psta->added)
5827 lim_send_extended_chan_switch_action_frame(
5828 mac_ctx,
5829 psta->staAddr,
5830 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005831 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305832 }
5833 } else if (LIM_IS_STA_ROLE(session_entry)) {
5834 lim_send_extended_chan_switch_action_frame(mac_ctx,
5835 session_entry->bssId,
5836 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005837 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305838 }
5839
5840}
5841
5842/**
gaolez76d2a162017-03-21 19:23:58 +08005843 * lim_send_chan_switch_action_frame()- Send an action frame
5844 * containing CSA IE or ECSA IE depending on the connected
5845 * sta capability.
5846 *
5847 * @mac_ctx: pointer to global mac structure
5848 * @new_channel: new channel to switch to.
5849 * @ch_bandwidth: BW of channel to calculate op_class
5850 * @session_entry: pe session
5851 *
5852 * Return: void
5853 */
5854static
5855void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5856 uint16_t new_channel,
5857 uint8_t ch_bandwidth,
5858 tpPESession session_entry)
5859{
5860 uint16_t op_class;
5861 uint8_t switch_mode = 0, i;
5862 uint8_t switch_count;
5863 tpDphHashNode psta;
5864 tpDphHashNode dph_node_array_ptr;
5865
5866 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5867
5868 op_class = wlan_reg_dmn_get_opclass_from_channel(
5869 mac_ctx->scan.countryCodeCurrent,
5870 new_channel, ch_bandwidth);
5871
5872 if (LIM_IS_AP_ROLE(session_entry) &&
5873 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5874 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5875
5876 switch_count = session_entry->gLimChannelSwitch.switchCount;
5877
5878 if (LIM_IS_AP_ROLE(session_entry)) {
5879 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5880 psta = dph_node_array_ptr + i;
5881 if (!(psta && psta->added))
5882 continue;
5883 if (session_entry->lim_non_ecsa_cap_num == 0)
5884 lim_send_extended_chan_switch_action_frame
5885 (mac_ctx, psta->staAddr, switch_mode,
5886 op_class, new_channel, switch_count,
5887 session_entry);
5888 else
5889 lim_send_channel_switch_mgmt_frame
5890 (mac_ctx, psta->staAddr, switch_mode,
5891 new_channel, switch_count,
5892 session_entry);
5893 }
5894 } else if (LIM_IS_STA_ROLE(session_entry)) {
5895 lim_send_extended_chan_switch_action_frame
5896 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5897 new_channel, switch_count, session_entry);
5898 }
5899}
5900
5901/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5903 *
5904 * @mac_ctx: Pointer to Global MAC structure
5905 * @msg_buf: pointer to the SME message buffer
5906 *
5907 * This function processes SME request messages from HDD or upper layer
5908 * application.
5909 *
5910 * Return: None
5911 */
5912static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5913 uint32_t *msg_buf)
5914{
5915 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5916 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 uint8_t session_id;
5918 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005919 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920
5921 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005922 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 return;
5924 }
5925
5926 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5927 session_entry = pe_find_session_by_bssid(mac_ctx,
5928 dfs_csa_ie_req->bssid, &session_id);
5929 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005930 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5932 return;
5933 }
5934
5935 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005936 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 GET_LIM_SYSTEM_ROLE(session_entry));
5938 return;
5939 }
5940
5941 /* target channel */
5942 session_entry->gLimChannelSwitch.primaryChannel =
5943 dfs_csa_ie_req->targetChannel;
5944
5945 /* Channel switch announcement needs to be included in beacon */
5946 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005947 session_entry->gLimChannelSwitch.switchCount =
5948 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005950 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305951 session_entry->gLimChannelSwitch.sec_ch_offset =
5952 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005954 session_entry->gLimChannelSwitch.switchMode =
5955 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956
5957 /*
5958 * Validate if SAP is operating HT or VHT mode and set the Channel
5959 * Switch Wrapper element with the Wide Band Switch subelement.
5960 */
5961 if (true != session_entry->vhtCapability)
5962 goto skip_vht;
5963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 /* Now encode the Wider Ch BW element depending on the ch width */
5965 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005966 switch (dfs_csa_ie_req->ch_params.ch_width) {
5967 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968 /*
5969 * Wide channel BW sublement in channel wrapper element is not
5970 * required in case of 20 Mhz operation. Currently It is set
5971 * only set in case of 40/80 Mhz Operation.
5972 */
5973 session_entry->dfsIncludeChanWrapperIe = false;
5974 wider_bw_ch_switch->newChanWidth =
5975 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5976 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005977 case CH_WIDTH_40MHZ:
5978 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 wider_bw_ch_switch->newChanWidth =
5980 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5981 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005982 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 session_entry->dfsIncludeChanWrapperIe = true;
5984 wider_bw_ch_switch->newChanWidth =
5985 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5986 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005987 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005988 session_entry->dfsIncludeChanWrapperIe = true;
5989 wider_bw_ch_switch->newChanWidth =
5990 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5991 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005992 case CH_WIDTH_80P80MHZ:
5993 session_entry->dfsIncludeChanWrapperIe = true;
5994 wider_bw_ch_switch->newChanWidth =
5995 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005996 /*
5997 * This is not applicable for 20/40/80 Mhz.
5998 * Only used when we support 80+80 Mhz operation.
5999 * In case of 80+80 Mhz, this parameter indicates
6000 * center channel frequency index of 80 Mhz channel of
6001 * frequency segment 1.
6002 */
6003 wider_bw_ch_switch->newCenterChanFreq1 =
6004 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006005 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 default:
6007 session_entry->dfsIncludeChanWrapperIe = false;
6008 /*
6009 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6010 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6011 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006012 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 break;
6014 }
6015 /* Fetch the center channel based on the channel width */
6016 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006017 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018skip_vht:
6019 /* Send CSA IE request from here */
6020 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6021 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006022 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 return;
6024 }
6025
6026 /*
6027 * First beacon update request is sent here, the remaining updates are
6028 * done when the FW responds back after sending the first beacon after
6029 * the template update
6030 */
6031 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306032
6033 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6034 ch_offset = BW80;
6035 else
6036 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6037
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006038 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306039 session_entry->gLimChannelSwitch.switchCount,
6040 session_entry->gLimChannelSwitch.primaryChannel,
6041 session_entry->gLimChannelSwitch.ch_width,
6042 session_entry->dfsIncludeChanWrapperIe,
6043 ch_offset);
6044
gaolez76d2a162017-03-21 19:23:58 +08006045 /* Send ECSA/CSA Action frame after updating the beacon */
6046 if (CHAN_HOP_ALL_BANDS_ENABLE)
6047 lim_send_chan_switch_action_frame(mac_ctx,
6048 session_entry->gLimChannelSwitch.primaryChannel,
6049 ch_offset, session_entry);
6050 else
6051 send_extended_chan_switch_action_frame(mac_ctx,
6052 session_entry->gLimChannelSwitch.primaryChannel,
6053 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006054 session_entry->gLimChannelSwitch.switchCount--;
6055}
6056
6057/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306058 * lim_process_ext_change_channel()- function to send ECSA
6059 * action frame for STA/CLI .
6060 * @mac_ctx: pointer to global mac structure
6061 * @msg: params from sme for new channel.
6062 *
6063 * This function is called to send ECSA frame for STA/CLI.
6064 *
6065 * Return: void
6066 */
6067
6068static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6069 uint32_t *msg)
6070{
6071 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6072 (struct sir_sme_ext_cng_chan_req *) msg;
6073 tpPESession session_entry = NULL;
6074
6075 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006076 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05306077 return;
6078 }
6079 session_entry =
6080 pe_find_session_by_sme_session_id(mac_ctx,
6081 ext_chng_channel->session_id);
6082 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006083 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05306084 ext_chng_channel->session_id);
6085 return;
6086 }
6087 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006088 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05306089 return;
6090 }
6091 send_extended_chan_switch_action_frame(mac_ctx,
6092 ext_chng_channel->new_channel,
6093 0, session_entry);
6094}
6095
6096/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 * lim_process_nss_update_request() - process sme nss update req
6098 *
6099 * @mac_ctx: Pointer to Global MAC structure
6100 * @msg_buf: pointer to the SME message buffer
6101 *
6102 * This function processes SME request messages from HDD or upper layer
6103 * application.
6104 *
6105 * Return: None
6106 */
6107static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6108 uint32_t *msg_buf)
6109{
6110 struct sir_nss_update_request *nss_update_req_ptr;
6111 tpPESession session_entry = NULL;
6112
6113 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006114 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006115 return;
6116 }
6117
6118 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306119 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 nss_update_req_ptr->vdev_id);
6121 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006122 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 nss_update_req_ptr->vdev_id);
6124 return;
6125 }
6126
6127 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006128 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129 GET_LIM_SYSTEM_ROLE(session_entry));
6130 return;
6131 }
6132
6133 /* populate nss field in the beacon */
6134 session_entry->gLimOperatingMode.present = 1;
6135 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306136 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6137
6138 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6139 (session_entry->ch_width > CH_WIDTH_80MHZ))
6140 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6141
6142 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 /* Send nss update request from here */
6145 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6146 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006147 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006148 return;
6149 }
6150
6151 lim_send_beacon_ind(mac_ctx, session_entry);
6152}
6153
6154/**
6155 * lim_process_set_ie_req() - process sme set IE request
6156 *
6157 * @mac_ctx: Pointer to Global MAC structure
6158 * @msg_buf: pointer to the SME message buffer
6159 *
6160 * This function processes SME request messages from HDD or upper layer
6161 * application.
6162 *
6163 * Return: None
6164 */
6165static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6166{
6167 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306168 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169
6170 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006171 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006172 return;
6173 }
6174
6175 msg = (struct send_extcap_ie *)msg_buf;
6176 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306177 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006178 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006179
6180}