blob: 08cd54d98cce315d1ce9340a6c0839c33c3a18dc [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
82/* SME REQ processing function templates */
83static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080084static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
85 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080093static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
94 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053095static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
96 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
98 uint32_t *pMsg);
99static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
100static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
101static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
102static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
103
104static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
105 uint8_t **pDstData_buff,
106 uint16_t *pDstDataLen,
107 uint8_t *pSrcData_buff,
108 uint16_t srcDataLen);
109
110static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
111 uint8_t **pDstData_buff,
112 uint16_t *pDstDataLen,
113 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800114static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
115 uint8_t **pDstData_buff,
116 uint16_t *pDstDataLen,
117 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
119
120static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
121
Abhishek Singh518323d2015-10-19 17:42:01 +0530122static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
123 uint32_t *msg);
124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125/**
126 * lim_process_set_hw_mode() - Send set HW mode command to WMA
127 * @mac: Globacl MAC pointer
128 * @msg: Message containing the hw mode index
129 *
130 * Send the set HW mode command to WMA
131 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530134static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530136 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700137 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800138 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 uint32_t len;
140 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700141 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 struct sir_set_hw_mode_resp *param;
143
144 buf = (struct s_sir_set_hw_mode *) msg;
145 if (!buf) {
146 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
147 /* To free the active command list */
148 goto fail;
149 }
150
151 len = sizeof(*req_msg);
152
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530155 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 /* Free the active command list
157 * Probably the malloc is going to fail there as well?!
158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530159 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 }
161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530163 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 /* Other parameters are not needed for WMA */
165
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800166 message.bodyptr = req_msg;
167 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
169 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800170 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530171 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 lim_log(mac, LOGE,
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800173 FL("scheduler_post_msg failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 goto fail;
177 }
178 return status;
179fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530180 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 if (!param) {
182 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530183 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 }
185 param->status = SET_HW_MODE_STATUS_ECANCELED;
186 param->cfgd_hw_mode_index = 0;
187 param->num_vdev_mac_entries = 0;
188 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
189 resp_msg.bodyptr = param;
190 resp_msg.bodyval = 0;
191 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193}
194
195/**
196 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
197 * @mac: Global MAC pointer
198 * @msg: Message containing the dual mac config parameter
199 *
200 * Send the set dual mac config command to WMA
201 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 uint32_t *msg)
206{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700208 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 struct sir_dual_mac_config *req_msg;
210 uint32_t len;
211 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700212 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 struct sir_dual_mac_config_resp *param;
214
215 buf = (struct sir_set_dual_mac_cfg *) msg;
216 if (!buf) {
217 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
218 /* To free the active command list */
219 goto fail;
220 }
221
222 len = sizeof(*req_msg);
223
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530224 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700226 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 /* Free the active command list
228 * Probably the malloc is going to fail there as well?!
229 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530230 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 }
232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 req_msg->scan_config = buf->set_dual_mac.scan_config;
234 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
235 /* Other parameters are not needed for WMA */
236
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800237 message.bodyptr = req_msg;
238 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239
240 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530241 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800243 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 lim_log(mac, LOGE,
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800246 FL("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) {
255 lim_log(mac, LOGE, FL("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) {
288 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
289 /* To free the active command list */
290 goto fail;
291 }
292
293 req_msg = qdf_mem_malloc(sizeof(*req_msg));
294 if (!req_msg) {
295 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
296 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
305 lim_log(mac, LOG1,
306 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
307 req_msg->num_rx_chains,
308 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800309 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800310 if (!QDF_IS_STATUS_SUCCESS(status)) {
311 lim_log(mac, LOGE,
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800312 FL("scheduler_post_msg failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800313 status);
314 qdf_mem_free(req_msg);
315 goto fail;
316 }
317 return status;
318fail:
319 param = qdf_mem_malloc(sizeof(*param));
320 if (!param) {
321 lim_log(mac, LOGE, FL("antenna mode resp failed"));
322 return QDF_STATUS_E_NOMEM;
323 }
324 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
325 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
326 resp_msg.bodyptr = param;
327 resp_msg.bodyval = 0;
328 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
329 return QDF_STATUS_SUCCESS;
330}
331
332/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
334 * @mac_ctx: Pointer to Global MAC structure
335 * @return_fresh_results: Trigger fresh scan.
336 *
337 * PE will do fresh scan, if all of the active sessions are in
338 * good state (Link Est or BSS Started). If one of the sessions
339 * is not in one of the above states, then PE does not do fresh
340 * scan. If no session exists (scanning very first time),
341 * then PE will always do fresh scan if SME asks it to do that.
342 *
343 * Return: true for fresh scan results, false if in invalid state.
344 */
345static uint8_t
346__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
347{
348 uint8_t valid_state = true;
349 int i;
350
351 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
352 mac_ctx->lim.gLimSmeState, return_fresh_results);
353
354 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
355 lim_log(mac_ctx, LOG1, FL("return FALSE"));
356 return false;
357 }
358
359 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700360
361 if (mac_ctx->lim.gpSession[i].valid == false)
362 continue;
363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 lim_log(mac_ctx, LOG1,
365 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
366 i, mac_ctx->lim.gpSession[i].bssType,
367 mac_ctx->lim.gpSession[i].limSystemRole,
368 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700369
370 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
371 continue;
372
373 if (mac_ctx->lim.gpSession[i].bssType ==
374 eSIR_INFRASTRUCTURE_MODE &&
375 mac_ctx->lim.gpSession[i].limSmeState ==
376 eLIM_SME_LINK_EST_STATE)
377 continue;
378
379 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
380 mac_ctx->lim.gpSession[i].limSmeState ==
381 eLIM_SME_NORMAL_STATE)
382 continue;
383
384 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
385 mac_ctx->lim.gpSession[i].pePersona ==
386 QDF_P2P_GO_MODE &&
387 mac_ctx->lim.gpSession[i].limSmeState ==
388 eLIM_SME_NORMAL_STATE)
389 continue;
390
391 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
392 mac_ctx->lim.gpSession[i].limSmeState ==
393 eLIM_SME_NORMAL_STATE)
394 continue;
395
396 valid_state = false;
397 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 }
399
400 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
401
402 if ((valid_state) &&
403 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
404 return true;
405 else
406 return false;
407}
408
409/**
410 * __lim_is_sme_assoc_cnf_valid()
411 *
412 ***FUNCTION:
413 * This function is called by __lim_process_sme_assoc_cnf_new() upon
414 * receiving SME_ASSOC_CNF.
415 *
416 ***LOGIC:
417 * Message validity checks are performed in this function
418 *
419 ***ASSUMPTIONS:
420 *
421 ***NOTE:
422 *
423 * @param pMeasReq Pointer to Received ASSOC_CNF message
424 * @return true When received SME_ASSOC_CNF is formatted
425 * correctly
426 * false otherwise
427 */
428
429static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
430{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530431 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 return false;
433 else
434 return true;
435} /*** end __lim_is_sme_assoc_cnf_valid() ***/
436
437/**
438 * __lim_get_sme_join_req_size_for_alloc()
439 *
440 ***FUNCTION:
441 * This function is called in various places to get IE length
442 * from tSirBssDescription structure
443 * number being scanned.
444 *
445 ***PARAMS:
446 *
447 ***LOGIC:
448 *
449 ***ASSUMPTIONS:
450 * NA
451 *
452 ***NOTE:
453 * NA
454 *
455 * @param pBssDescr
456 * @return Total IE length
457 */
458
459static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
460{
461 uint16_t len = 0;
462
463 if (!pBuf)
464 return len;
465
466 pBuf += sizeof(uint16_t);
467 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700468 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469}
470
471/**
472 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
473 * @pMac: Global MAC context
474 * @pMsg: Pointer to message posted from SME to LIM.
475 *
476 * Has role only if 11h is enabled. Not used on STA side.
477 * Defers the message if SME is in learn state and brings
478 * the LIM back to normal mode.
479 *
480 * Return: true - If defered false - Otherwise
481 */
482
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800483static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
484 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485{
486 if (lim_is_system_in_scan_state(pMac)) {
487 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
488 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
489 pMsg->type);
490 return false;
491 }
492 lim_log(pMac, LOG1,
493 FL("Defer the message, in learn mode type = %d"),
494 pMsg->type);
495 return true;
496 }
497 return false;
498}
499
500/**
501 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
502 * @mac_ctx: Pointer to Global MAC structure
503 * @message: Pointer to message posted from SME to LIM.
504 *
505 * Has role only if 11h is enabled. Not used on STA side.
506 * Defers the message if radar is detected.
507 *
508 * Return: true, if defered otherwise return false.
509 */
510static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800511__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
512 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513{
514 /*
515 * fRadarDetCurOperChan will be set only if we
516 * detect radar in current operating channel and
517 * System Role == AP ROLE
518 *
519 * TODO: Need to take care radar detection.
520 *
521 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
522 */
523 if (0) {
524 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
525 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
526 message->type);
527 return false;
528 }
529 lim_log(mac_ctx, LOG1,
530 FL("Defer the message, in learn mode type = %d"),
531 message->type);
532 return true;
533 }
534 return false;
535}
536
537/**
538 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
539 * @pMac: Global MAC context
540 * @pMsgBuf: Message from WMA
541 *
542 * handles the notification from HDD. PE just forwards this message to HAL.
543 *
544 * Return: true-Posting to HAL failed, so PE will consume the buffer.
545 * false-Posting to HAL successful, so HAL will consume the buffer.
546 */
547
548static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
549{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700550 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
552
553 msg.type = WMA_SYS_READY_IND;
554 msg.reserved = 0;
555 msg.bodyptr = pMsgBuf;
556 msg.bodyval = 0;
557
558 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800559 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530560 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700561 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
563 }
564 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
565 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
566
567 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
568 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
569 return true;
570 }
571 return false;
572}
573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574/**
575 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
576 *@mac_ctx: Pointer to Global MAC structure
577 *@session: A pointer to session entry
578 *@sme_start_bss_req: Start BSS Request from upper layers.
579 *
580 * This function is used to configure the start bss parameters
581 * in to the session.
582 *
583 * Return: None.
584 */
585static void
586lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
587 tpSirSmeStartBssReq sme_start_bss_req)
588{
589 session->limSystemRole = eLIM_AP_ROLE;
590 session->privacy = sme_start_bss_req->privacy;
591 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
592 session->authType = sme_start_bss_req->authType;
593 /* Store the DTIM period */
594 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
595 /* Enable/disable UAPSD */
596 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530597 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 session->proxyProbeRspEn = 0;
599 } else {
600 /*
601 * To detect PBC overlap in SAP WPS mode,
602 * Host handles Probe Requests.
603 */
604 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
605 session->proxyProbeRspEn = 1;
606 else
607 session->proxyProbeRspEn = 0;
608 }
609 session->ssidHidden = sme_start_bss_req->ssidHidden;
610 session->wps_state = sme_start_bss_req->wps_state;
611 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530612 session->vendor_vht_sap =
613 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
615 &session->shortSlotTimeSupported);
616 session->isCoalesingInIBSSAllowed =
617 sme_start_bss_req->isCoalesingInIBSSAllowed;
618
619}
620
621/**
622 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
623 *@mac_ctx: Pointer to Global MAC structure
624 *@msg_buf: A pointer to the SME message buffer
625 *
626 * This function is called to process SME_START_BSS_REQ message
627 * from HDD or upper layer application.
628 *
629 * Return: None
630 */
631static void
632__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
633{
634 uint16_t size;
635 uint32_t val = 0;
636 tSirRetStatus ret_status;
637 tSirMacChanNum channel_number;
638 tLimMlmStartReq *mlm_start_req = NULL;
639 tpSirSmeStartBssReq sme_start_bss_req = NULL;
640 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
641 /* Flag Used in case of IBSS to Auto generate BSSID. */
642 uint32_t auto_gen_bssid = false;
643 uint8_t session_id;
644 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800645 uint8_t sme_session_id = 0xFF;
646 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700648 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
650
651/* FEATURE_WLAN_DIAG_SUPPORT */
652#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
653 /*
654 * Since the session is not created yet, sending NULL.
655 * The response should have the correct state.
656 */
657 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
658 NULL, 0, 0);
659#endif /* FEATURE_WLAN_DIAG_SUPPORT */
660
661 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
Krunal Sonib37bb352016-12-20 14:12:21 -0800662 size = sizeof(tSirSmeStartBssReq);
663 sme_start_bss_req = qdf_mem_malloc(size);
664 if (NULL == sme_start_bss_req) {
665 lim_log(mac_ctx, LOGE,
666 FL("Allocate Memory fail for LimStartBssReq"));
667 /* Send failure response to host */
668 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
669 goto free;
670 }
671 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
672 sme_session_id = sme_start_bss_req->sessionId;
673 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
676 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
678 sme_start_bss_req)) {
679 lim_log(mac_ctx, LOGW,
680 FL("Received invalid eWNI_SME_START_BSS_REQ"));
681 ret_code = eSIR_SME_INVALID_PARAMETERS;
682 goto free;
683 }
684
685 /*
686 * This is the place where PE is going to create a session.
687 * If session is not existed, then create a new session
688 */
689 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800690 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 if (session != NULL) {
692 lim_log(mac_ctx, LOGW,
693 FL("Session Already exists for given BSSID"));
694 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
695 session = NULL;
696 goto free;
697 } else {
698 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800699 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 &session_id, mac_ctx->lim.maxStation,
701 sme_start_bss_req->bssType);
702 if (session == NULL) {
703 lim_log(mac_ctx, LOGW,
704 FL("Session Can not be created "));
705 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
706 goto free;
707 }
708 }
709
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700710 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
711 /* Probe resp add ie */
712 lim_start_bss_update_add_ie_buffer(mac_ctx,
713 &session->addIeParams.probeRespData_buff,
714 &session->addIeParams.probeRespDataLen,
715 sme_start_bss_req->addIeParams.
716 probeRespData_buff,
717 sme_start_bss_req->addIeParams.
718 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700720 /* Probe Beacon add ie */
721 lim_start_bss_update_add_ie_buffer(mac_ctx,
722 &session->addIeParams.probeRespBCNData_buff,
723 &session->addIeParams.probeRespBCNDataLen,
724 sme_start_bss_req->addIeParams.
725 probeRespBCNData_buff,
726 sme_start_bss_req->addIeParams.
727 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700729 /* Assoc resp IE */
730 lim_start_bss_update_add_ie_buffer(mac_ctx,
731 &session->addIeParams.assocRespData_buff,
732 &session->addIeParams.assocRespDataLen,
733 sme_start_bss_req->addIeParams.
734 assocRespData_buff,
735 sme_start_bss_req->addIeParams.
736 assocRespDataLen);
737 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 /* Store the session related params in newly created session */
739 session->pLimStartBssReq = sme_start_bss_req;
740
741 /* Store PE session_id in session Table */
742 session->peSessionId = session_id;
743
744 /* Store SME session Id in sessionTable */
745 session->smeSessionId = sme_start_bss_req->sessionId;
746
747 session->transactionId = sme_start_bss_req->transactionId;
748
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530749 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 &(sme_start_bss_req->htConfig),
751 sizeof(session->htConfig));
752
Sandeep Puligilla98917432016-06-10 13:50:28 -0700753 qdf_mem_copy(&(session->vht_config),
754 &(sme_start_bss_req->vht_config),
755 sizeof(session->vht_config));
756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800758 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
760 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530761 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 (uint8_t *) &sme_start_bss_req->ssId,
763 (sme_start_bss_req->ssId.length + 1));
764
765 session->bssType = sme_start_bss_req->bssType;
766
767 session->nwType = sme_start_bss_req->nwType;
768
769 session->beaconParams.beaconInterval =
770 sme_start_bss_req->beaconInterval;
771
772 /* Store the channel number in session Table */
773 session->currentOperChannel =
774 sme_start_bss_req->channelId;
775
776 /* Store Persona */
777 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530778 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 FL("PE PERSONA=%d"), session->pePersona);
780
781 /* Update the phymode */
782 session->gLimPhyMode = sme_start_bss_req->nwType;
783
784 session->maxTxPower =
785 cfg_get_regulatory_max_transmit_power(mac_ctx,
786 session->currentOperChannel);
787 /* Store the dot 11 mode in to the session Table */
788 session->dot11mode = sme_start_bss_req->dot11mode;
789#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
790 session->cc_switch_mode =
791 sme_start_bss_req->cc_switch_mode;
792#endif
793 session->htCapability =
794 IS_DOT11_MODE_HT(session->dot11mode);
795 session->vhtCapability =
796 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800797
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800798 lim_log(mac_ctx, LOG1, FL("HT[%d], VHT[%d]"),
799 session->htCapability, session->vhtCapability);
800
801 if (IS_DOT11_MODE_HE(session->dot11mode)) {
802 lim_update_session_he_capable(mac_ctx, session);
803 lim_copy_bss_he_cap(session, sme_start_bss_req);
804 }
805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 session->txLdpcIniFeatureEnabled =
807 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808#ifdef WLAN_FEATURE_11W
809 session->limRmfEnabled =
810 sme_start_bss_req->pmfCapable ? 1 : 0;
811 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
812 session->limRmfEnabled);
813#endif
814
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530815 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 (void *)&sme_start_bss_req->operationalRateSet,
817 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530818 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819 (void *)&sme_start_bss_req->extendedRateSet,
820 sizeof(tSirMacRateSet));
821
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700822 if (IS_5G_CH(session->currentOperChannel))
823 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
824 else
825 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 switch (sme_start_bss_req->bssType) {
828 case eSIR_INFRA_AP_MODE:
829 lim_configure_ap_start_bss_session(mac_ctx, session,
830 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700831 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700832 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700833 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700834 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 break;
836 case eSIR_IBSS_MODE:
837 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
838 lim_get_short_slot_from_phy_mode(mac_ctx, session,
839 session->gLimPhyMode,
840 &session->shortSlotTimeSupported);
841
842 /*
843 * initialize to "OPEN".
844 * will be updated upon key installation
845 */
846 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700847 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
849 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700850 case eSIR_NDI_MODE:
851 session->limSystemRole = eLIM_NDI_ROLE;
852 break;
853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 /*
856 * There is one more mode called auto mode.
857 * which is used no where
858 */
859
860 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
861
862 default:
863 /* not used anywhere...used in scan function */
864 break;
865 }
866
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700867 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
868 session->pePersona, session->vdev_nss);
869 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700871 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 * parsed (Re)Assoc request structure
873 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700874 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530876 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700877 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 if (NULL == session->parsedAssocReq) {
879 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700880 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
882 goto free;
883 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 }
885
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700886 if (!sme_start_bss_req->channelId &&
887 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 lim_log(mac_ctx, LOGE,
889 FL("Received invalid eWNI_SME_START_BSS_REQ"));
890 ret_code = eSIR_SME_INVALID_PARAMETERS;
891 goto free;
892 }
893 channel_number = sme_start_bss_req->channelId;
894#ifdef QCA_HT_2040_COEX
895 if (sme_start_bss_req->obssEnabled)
896 session->htSupportedChannelWidthSet =
897 session->htCapability;
898 else
899#endif
900 session->htSupportedChannelWidthSet =
901 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
902 session->htSecondaryChannelOffset =
903 sme_start_bss_req->sec_ch_offset;
904 session->htRecommendedTxWidthSet =
905 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530906 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800908 if (lim_is_session_he_capable(session) ||
909 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800911 lim_log(mac_ctx, LOG1,
912 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
913 sme_start_bss_req->vht_channel_width,
914 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 session->ch_width = chanwidth;
916 if (session->htSupportedChannelWidthSet) {
917 session->ch_center_freq_seg0 =
918 sme_start_bss_req->center_freq_seg0;
919 session->ch_center_freq_seg1 =
920 sme_start_bss_req->center_freq_seg1;
921 } else {
922 session->ch_center_freq_seg0 = 0;
923 session->ch_center_freq_seg1 = 0;
924 }
925 }
926
927 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800928 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700930 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
931 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 }
Krunal Soni53993f72016-07-08 18:20:03 -0700933 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
934 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935
936 /* Delete pre-auth list if any */
937 lim_delete_pre_auth_list(mac_ctx);
938
Krunal Soni53993f72016-07-08 18:20:03 -0700939 if (session->nss == 1) {
940 session->vht_config.su_beam_former = 0;
941 session->vht_config.tx_stbc = 0;
942 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530943 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700944 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 /*
946 * keep the RSN/WPA IE information in PE Session Entry
947 * later will be using this to check when received (Re)Assoc req
948 */
949 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
950 &sme_start_bss_req->rsnIE, session);
951
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700952 if (LIM_IS_AP_ROLE(session) ||
953 LIM_IS_IBSS_ROLE(session) ||
954 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 session->gLimProtectionControl =
956 sme_start_bss_req->protEnabled;
957 /*
958 * each byte will have the following info
959 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
960 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
961 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530962 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 (void *)&sme_start_bss_req->ht_capab,
964 sizeof(uint16_t));
965 /* Initialize WPS PBC session link list */
966 session->pAPWPSPBCSession = NULL;
967 }
968 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530969 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 if (NULL == mlm_start_req) {
971 lim_log(mac_ctx, LOGP,
972 FL("Allocate Memory failed for mlmStartReq"));
973 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
974 goto free;
975 }
976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530978 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 (uint8_t *) &sme_start_bss_req->ssId,
980 sme_start_bss_req->ssId.length + 1);
981 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
982 mlm_start_req->obssProtEnabled =
983 sme_start_bss_req->obssProtEnabled;
984
985 mlm_start_req->bssType = session->bssType;
986
987 /* Fill PE session Id from the session Table */
988 mlm_start_req->sessionId = session->peSessionId;
989
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700990 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
991 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 /*
993 * Copy the BSSId from sessionTable to
994 * mlmStartReq struct
995 */
996 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
997 } else {
998 /* ibss mode */
999 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1000
1001 ret_status = wlan_cfg_get_int(mac_ctx,
1002 WNI_CFG_IBSS_AUTO_BSSID,
1003 &auto_gen_bssid);
1004 if (ret_status != eSIR_SUCCESS) {
1005 lim_log(mac_ctx, LOGP,
1006 FL("Get Auto Gen BSSID fail,Status=%d"),
1007 ret_status);
1008 ret_code = eSIR_LOGP_EXCEPTION;
1009 goto free;
1010 }
1011
1012 if (!auto_gen_bssid) {
1013 /*
1014 * We're not auto generating BSSID.
1015 * Instead, get it from session entry
1016 */
1017 sir_copy_mac_addr(mlm_start_req->bssId,
1018 session->bssId);
1019 /*
1020 * Start IBSS group BSSID
1021 * Auto Generating BSSID.
1022 */
1023 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1024 0x01) ? true : false);
1025 }
1026
1027 if (auto_gen_bssid) {
1028 /*
1029 * if BSSID is not any uc id.
1030 * then use locally generated BSSID.
1031 * Autogenerate the BSSID
1032 */
1033 lim_get_random_bssid(mac_ctx,
1034 mlm_start_req->bssId);
1035 mlm_start_req->bssId[0] = 0x02;
1036
1037 /*
1038 * Copy randomly generated BSSID
1039 * to the session Table
1040 */
1041 sir_copy_mac_addr(session->bssId,
1042 mlm_start_req->bssId);
1043 }
1044 }
1045 /* store the channel num in mlmstart req structure */
1046 mlm_start_req->channelNumber = session->currentOperChannel;
1047 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1048 mlm_start_req->beaconPeriod =
1049 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -07001050 mlm_start_req->cac_duration_ms =
1051 sme_start_bss_req->cac_duration_ms;
1052 mlm_start_req->dfs_regdomain =
1053 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 if (LIM_IS_AP_ROLE(session)) {
1055 mlm_start_req->dtimPeriod = session->dtimPeriod;
1056 mlm_start_req->wps_state = session->wps_state;
1057
1058 } else {
1059 if (wlan_cfg_get_int(mac_ctx,
1060 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1061 lim_log(mac_ctx, LOGP,
1062 FL("could not retrieve DTIM Period"));
1063 mlm_start_req->dtimPeriod = (uint8_t) val;
1064 }
1065
1066 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1067 eSIR_SUCCESS)
1068 lim_log(mac_ctx, LOGP,
1069 FL("could not retrieve Beacon interval"));
1070 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1071
1072 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1073 eSIR_SUCCESS)
1074 lim_log(mac_ctx, LOGP,
1075 FL("could not retrieve CFPMaxDuration"));
1076 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1077
1078 /*
1079 * this may not be needed anymore now,
1080 * as rateSet is now included in the
1081 * session entry and MLM has session context.
1082 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301083 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 (void *)&session->rateSet,
1085 sizeof(tSirMacRateSet));
1086
1087 /* Now populate the 11n related parameters */
1088 mlm_start_req->nwType = session->nwType;
1089 mlm_start_req->htCapable = session->htCapability;
1090
1091 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1092 /* Unused */
1093 mlm_start_req->dualCTSProtection =
1094 mac_ctx->lim.gHTDualCTSProtection;
1095 mlm_start_req->txChannelWidthSet =
1096 session->htRecommendedTxWidthSet;
1097
1098 session->limRFBand = lim_get_rf_band(channel_number);
1099
1100 /* Initialize 11h Enable Flag */
1101 session->lim11hEnable = 0;
1102 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1103 (SIR_BAND_5_GHZ == session->limRFBand)) {
1104 if (wlan_cfg_get_int(mac_ctx,
1105 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1106 lim_log(mac_ctx, LOGP,
1107 FL("Fail to get WNI_CFG_11H_ENABLED "));
1108 else
1109 session->lim11hEnable = val;
1110
1111 if (session->lim11hEnable &&
1112 (eSIR_INFRA_AP_MODE ==
1113 mlm_start_req->bssType)) {
1114 cfg_get_wmi_dfs_master_param =
1115 wlan_cfg_get_int(mac_ctx,
1116 WNI_CFG_DFS_MASTER_ENABLED,
1117 &val);
1118 session->lim11hEnable = val;
1119 }
1120 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1121 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1122 lim_log(mac_ctx, LOGE,
1123 FL("Get Fail, CFG DFS ENABLE"));
1124 }
1125
1126 if (!session->lim11hEnable) {
1127 if (cfg_set_int(mac_ctx,
1128 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1129 eSIR_SUCCESS)
1130 /*
1131 * Failed to set the CFG param
1132 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1133 */
1134 lim_log(mac_ctx, LOGE,
1135 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1136 }
1137
1138 session->limPrevSmeState = session->limSmeState;
1139 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1140 MTRACE(mac_trace
1141 (mac_ctx, TRACE_CODE_SME_STATE,
1142 session->peSessionId,
1143 session->limSmeState));
1144
1145 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1146 (uint32_t *) mlm_start_req);
1147 return;
1148 } else {
1149
1150 lim_log(mac_ctx, LOGE,
1151 FL("Received unexpected START_BSS_REQ, in state %X"),
1152 mac_ctx->lim.gLimSmeState);
1153 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001154 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1156
1157free:
1158 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001159 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 session->pLimStartBssReq = NULL;
1161 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001162 if (NULL != sme_start_bss_req)
1163 qdf_mem_free(sme_start_bss_req);
1164 if (NULL != mlm_start_req)
1165 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 if (NULL != session) {
1167 pe_delete_session(mac_ctx, session);
1168 session = NULL;
1169 }
1170 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1171 session, sme_session_id, sme_transaction_id);
1172}
1173
1174/**
1175 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1176 *
1177 * @pMac: Global MAC context
1178 * @pMsg: Message pointer
1179 *
1180 * Wrapper for the function __lim_handle_sme_start_bss_request
1181 * This message will be defered until softmac come out of
1182 * scan mode or if we have detected radar on the current
1183 * operating channel.
1184 *
1185 * return true - If we consumed the buffer
1186 * false - If have defered the message.
1187 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001188static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1189 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190{
1191 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1192 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1193 /**
1194 * If message defered, buffer is not consumed yet.
1195 * So return false
1196 */
1197 return false;
1198 }
1199
1200 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1201 return true;
1202}
1203
1204/**
1205 * lim_get_random_bssid()
1206 *
1207 * FUNCTION:This function is called to process generate the random number for bssid
1208 * This function is called to process SME_SCAN_REQ message
1209 * from HDD or upper layer application.
1210 *
1211 * LOGIC:
1212 *
1213 * ASSUMPTIONS:
1214 *
1215 * NOTE:
1216 * 1. geneartes the unique random number for bssid in ibss
1217 *
1218 * @param pMac Pointer to Global MAC structure
1219 * @param *data Pointer to bssid buffer
1220 * @return None
1221 */
1222void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1223{
1224 uint32_t random[2];
1225 random[0] = tx_time_get();
1226 random[0] |= (random[0] << 15);
1227 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301228 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229}
1230
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301231static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 tpSirSmeScanReq pScanReq)
1233{
1234 tSirScanOffloadReq *pScanOffloadReq;
1235 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001236 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001238 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 tSirRetStatus status, rc = eSIR_SUCCESS;
1240 tDot11fIEExtCap extracted_extcap = {0};
1241 bool extcap_present = true;
1242
1243 if (pScanReq->uIEFieldLen) {
1244 status = lim_strip_extcap_update_struct(pMac,
1245 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1246 &pScanReq->uIEFieldLen, &extracted_extcap);
1247
1248 if (eSIR_SUCCESS != status) {
1249 extcap_present = false;
1250 lim_log(pMac, LOG1,
1251 FL("Unable to Strip ExtCap IE from Scan Req"));
1252 }
1253
1254 if (extcap_present) {
1255 lim_log(pMac, LOG1,
1256 FL("Extcap was part of SCAN IE - Updating FW"));
1257 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1258 &extracted_extcap, true);
1259 }
1260 } else {
1261 lim_log(pMac, LOG1,
1262 FL("No IEs in the scan request from supplicant"));
1263 }
1264
1265 /**
1266 * The tSirScanOffloadReq will reserve the space for first channel,
1267 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1268 */
1269 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001270 (pScanReq->channelList.numChannels - 1) +
1271 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001272
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301273 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 if (NULL == pScanOffloadReq) {
1275 lim_log(pMac, LOGE,
1276 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301277 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 }
1279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1281 msg.bodyptr = pScanOffloadReq;
1282 msg.bodyval = 0;
1283
Anurag Chouhanc5548422016-02-24 18:33:27 +05301284 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285
1286 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1287 lim_log(pMac, LOGE,
1288 FL("Invalid value (%d) for numSsid"),
1289 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301290 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301291 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 }
1293
1294 pScanOffloadReq->numSsid = pScanReq->numSsid;
1295 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1296 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301297 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298 (uint8_t *) pScanReq->ssId[i].ssId,
1299 pScanOffloadReq->ssId[i].length);
1300 }
1301
1302 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301303 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 pScanOffloadReq->bssType = pScanReq->bssType;
1305 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1306 pScanOffloadReq->scanType = pScanReq->scanType;
1307 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1308 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1309 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301310 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1311 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301312 pScanOffloadReq->scan_adaptive_dwell_mode =
1313 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314
1315 /* for normal scan, the value for p2pScanType should be 0
1316 always */
1317 if (pScanReq->p2pSearch)
1318 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1319
1320 pScanOffloadReq->sessionId = pScanReq->sessionId;
1321 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001322 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301323 pScanOffloadReq->scan_adaptive_dwell_mode =
1324 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325
1326 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1327 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1328 pScanOffloadReq->sessionId);
1329
1330 pScanOffloadReq->channelList.numChannels =
1331 pScanReq->channelList.numChannels;
1332 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1333 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1334 p[i] = pScanReq->channelList.channelNumber[i];
1335
1336 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1337 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1338 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301339 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 pScanOffloadReq->uIEFieldOffset,
1341 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1342 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001343
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 rc = wma_post_ctrl_msg(pMac, &msg);
1345 if (rc != eSIR_SUCCESS) {
1346 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301347 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301348 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 }
1350
1351 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1352
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301353 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354}
1355
1356/**
1357 * __lim_process_sme_scan_req() - Process the SME Scan Request
1358 * @mac_ctx: Global MAC Context
1359 * @msg_buf: Buffer which contains the request and pertinent parameters
1360 *
1361 * This function is called to process SME_SCAN_REQ message
1362 * from HDD or upper layer application.
1363 *
1364 * Return: None
1365 */
1366
1367static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1368 uint32_t *msg_buf)
1369{
1370 tpSirSmeScanReq scan_req;
1371 uint8_t valid_req = 0;
1372
1373#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1374 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1375 eSIR_SUCCESS, eSIR_SUCCESS);
1376#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301377 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378
1379 scan_req = (tpSirSmeScanReq) msg_buf;
1380 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301381 FL("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 -08001382 scan_req->scan_id, scan_req->channelList.numChannels,
1383 scan_req->minChannelTime, scan_req->maxChannelTime,
1384 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1385 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301386 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1388 /*
1389 * Since scan req always requires a response, we will overwrite response
1390 * required here. This is added esp to take care of the condition where
1391 * in p2p go case, we hold the scan req and insert single NOA. We send
1392 * the held scan request to FW later on getting start NOA ind from FW so
1393 * we lose state of the gLimRspReqd flag for the scan req if any other
1394 * request comes by then. e.g. While unit testing, we found when insert
1395 * single NOA is done, we see a get stats request which turns the flag
1396 * gLimRspReqd to false; now when we actually start the saved scan req
1397 * for init scan after getting NOA started, the gLimRspReqd being a
1398 * global flag is showing false instead of true value for this saved
1399 * scan req. Since all scan reqs coming to lim require a response,
1400 * there is no harm in setting the global flag gLimRspReqd to true here.
1401 */
1402 mac_ctx->lim.gLimRspReqd = true;
1403
1404 /*
1405 * copy the Self MAC address from SmeReq to the globalplace,
1406 * used for sending probe req
1407 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001408 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1409 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1411
1412 if (!valid_req || mac_ctx->lim.scan_disabled) {
1413 lim_log(mac_ctx, LOGE,
1414 FL("Scan disabled %d, Valid Scan Req %d"),
1415 mac_ctx->lim.scan_disabled, valid_req);
1416
1417 if (mac_ctx->lim.gLimRspReqd) {
1418 mac_ctx->lim.gLimRspReqd = false;
1419
1420 lim_send_sme_scan_rsp(mac_ctx,
1421 eSIR_SME_INVALID_PARAMETERS,
1422 scan_req->sessionId,
1423 scan_req->transactionId,
1424 scan_req->scan_id);
1425 }
1426 return;
1427 }
1428
1429 /*
1430 * If scan request is received in idle, joinFailed
1431 * states or in link established state (in STA role)
1432 * or in normal state (in STA-in-IBSS/AP role) with
1433 * 'return fresh scan results' request from HDD or
1434 * it is periodic background scanning request,
1435 * trigger fresh scan request to MLM
1436 */
1437 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1438
1439 mac_ctx->lim.gLim24Band11dScanDone = 0;
1440 mac_ctx->lim.gLim50Band11dScanDone = 0;
1441 mac_ctx->lim.gLimReturnAfterFirstMatch =
1442 scan_req->returnAfterFirstMatch;
1443 mac_ctx->lim.gLimReturnUniqueResults =
1444 ((scan_req->returnUniqueResults) > 0 ? true : false);
1445
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301446 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 lim_send_hal_start_scan_offload_req(mac_ctx,
1448 scan_req)) {
1449 lim_log(mac_ctx, LOGE, FL(
1450 "Couldn't send Offload scan request"));
1451 lim_send_sme_scan_rsp(mac_ctx,
1452 eSIR_SME_INVALID_PARAMETERS,
1453 scan_req->sessionId,
1454 scan_req->transactionId,
1455 scan_req->scan_id);
1456 return;
1457 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301458 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 /* In all other cases return 'cached' scan results */
1460 if (mac_ctx->lim.gLimRspReqd) {
1461 mac_ctx->lim.gLimRspReqd = false;
1462 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1463 scan_req->sessionId,
1464 scan_req->transactionId, scan_req->scan_id);
1465 }
1466 }
1467}
1468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469/**
1470 * __lim_process_clear_dfs_channel_list()
1471 *
1472 ***FUNCTION:
1473 ***Clear DFS channel list when country is changed/aquired.
1474 .*This message is sent from SME.
1475 *
1476 ***LOGIC:
1477 *
1478 ***ASSUMPTIONS:
1479 *
1480 ***NOTE:
1481 *
1482 * @param pMac Pointer to Global MAC structure
1483 * @param *pMsgBuf A pointer to the SME message buffer
1484 * @return None
1485 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001486static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1487 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301489 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490}
1491
1492/**
1493 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1494 * @mac_ctx: Pointer to Global MAC structure
1495 * @msg_buf: A pointer to the SME message buffer
1496 *
1497 * This function is called to process SME_JOIN_REQ message
1498 * from HDD or upper layer application.
1499 *
1500 * Return: None
1501 */
1502static void
1503__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1504{
1505 tpSirSmeJoinReq sme_join_req = NULL;
1506 tLimMlmJoinReq *mlm_join_req;
1507 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1508 uint32_t val = 0;
1509 uint16_t n_size;
1510 uint8_t session_id;
1511 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301512 uint8_t sme_session_id = 0;
1513 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001514 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 uint16_t ie_len;
1516 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001517 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001518 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519
Arif Hussain995fcaf2016-07-18 11:28:22 -07001520 if (!mac_ctx || !msg_buf) {
1521 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1522 FL("JOIN REQ with invalid data"));
1523 return;
1524 }
1525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526/* FEATURE_WLAN_DIAG_SUPPORT */
1527#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1528 /*
1529 * Not sending any session, since it is not created yet.
1530 * The response whould have correct state.
1531 */
1532 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1533#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 /*
1536 * Expect Join request in idle state.
1537 * Reassociate request is expected in link established state.
1538 */
1539
1540 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1541 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1542 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1543 msg_buf);
1544
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301545 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 if (NULL == sme_join_req) {
1547 lim_log(mac_ctx, LOGP,
1548 FL("AllocateMemory failed for sme_join_req"));
1549 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301550 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301552 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 n_size);
1554
1555 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1556 /* Received invalid eWNI_SME_JOIN_REQ */
1557 /* Log the event */
1558 lim_log(mac_ctx, LOGW,
1559 FL("SessionId:%d JOIN REQ with invalid data"),
1560 sme_join_req->sessionId);
1561 ret_code = eSIR_SME_INVALID_PARAMETERS;
1562 goto end;
1563 }
1564
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001565 /*
1566 * Update the capability here itself as this is used in
1567 * lim_extract_ap_capability() below. If not updated issues
1568 * like not honoring power constraint on 1st association after
1569 * driver loading might occur.
1570 */
1571 lim_update_rrm_capability(mac_ctx, sme_join_req);
1572
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001573 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001575 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 &session_id);
1577
1578 if (session != NULL) {
1579 lim_log(mac_ctx, LOGE,
1580 FL("Session(%d) Already exists for BSSID: "
1581 MAC_ADDRESS_STR " in limSmeState = %X"),
1582 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001583 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 session->limSmeState);
1585
1586 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1587 session->smeSessionId == sme_join_req->sessionId) {
1588 /*
1589 * Received eWNI_SME_JOIN_REQ for same
1590 * BSS as currently associated.
1591 * Log the event and send success
1592 */
1593 lim_log(mac_ctx, LOGW,
1594 FL("SessionId: %d"), session_id);
1595 lim_log(mac_ctx, LOGW,
1596 FL("JOIN_REQ for current joined BSS"));
1597 /* Send Join success response to host */
1598 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1599 session = NULL;
1600 goto end;
1601 } else {
1602 lim_log(mac_ctx, LOGE,
1603 FL("JOIN_REQ not for current joined BSS"));
1604 ret_code = eSIR_SME_REFUSED;
1605 session = NULL;
1606 goto end;
1607 }
1608 } else {
1609 /*
1610 * Session Entry does not exist for given BSSId
1611 * Try to Create a new session
1612 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001613 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 &session_id, mac_ctx->lim.maxStation,
1615 eSIR_INFRASTRUCTURE_MODE);
1616 if (session == NULL) {
1617 lim_log(mac_ctx, LOGE,
1618 FL("Session Can not be created "));
1619 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1620 goto end;
1621 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301622 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 FL("SessionId:%d New session created"),
1624 session_id);
1625 }
1626 session->isAmsduSupportInAMPDU =
1627 sme_join_req->isAmsduSupportInAMPDU;
1628
1629 /*
1630 * Store Session related parameters
1631 * Store PE session Id in session Table
1632 */
1633 session->peSessionId = session_id;
1634
1635 /* store the smejoin req handle in session table */
1636 session->pLimJoinReq = sme_join_req;
1637
1638 /* Store SME session Id in sessionTable */
1639 session->smeSessionId = sme_join_req->sessionId;
1640
1641 /* Store SME transaction Id in session Table */
1642 session->transactionId = sme_join_req->transactionId;
1643
1644 /* Store beaconInterval */
1645 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001646 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301648 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 sizeof(session->htConfig));
1650
Sandeep Puligilla98917432016-06-10 13:50:28 -07001651 qdf_mem_copy(&(session->vht_config),
1652 &(sme_join_req->vht_config),
1653 sizeof(session->vht_config));
1654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 /* Copying of bssId is already done, while creating session */
1656 sir_copy_mac_addr(session->selfMacAddr,
1657 sme_join_req->selfMacAddr);
1658 session->bssType = sme_join_req->bsstype;
1659
1660 session->statypeForBss = STA_ENTRY_PEER;
1661 session->limWmeEnabled = sme_join_req->isWMEenabled;
1662 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301663 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664
1665 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001666 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1668
1669 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1670 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001671 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672
1673 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001674 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 session->isCiscoVendorAP = true;
1676 } else {
1677 session->isCiscoVendorAP = false;
1678 }
1679
1680 /* Copy the dot 11 mode in to the session table */
1681
1682 session->dot11mode = sme_join_req->dot11mode;
1683#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1684 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1685#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001686 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1688 session->enableHtSmps = sme_join_req->enableHtSmps;
1689 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001690 session->send_smps_action =
1691 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001692 /*
1693 * By default supported NSS 1x1 is set to true
1694 * and later on updated while determining session
1695 * supported rates which is the intersection of
1696 * self and peer rates
1697 */
1698 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301699 /*Store Persona */
1700 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001701 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301702 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001703 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001704 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001705 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301706 session->supported_nss_1x1,
1707 session->pePersona,
1708 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001709
1710 /*Store Persona */
1711 session->pePersona = sme_join_req->staPersona;
1712 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001713 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d"),
1714 session->pePersona, sme_join_req->cbMode,
1715 session->nwType, session->dot11mode);
1716
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001717 /* Copy The channel Id to the session Table */
1718 session->currentOperChannel = bss_desc->channelId;
1719 if (IS_5G_CH(session->currentOperChannel))
1720 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001722 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1723 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1724 session->vdev_nss = vdev_type_nss->p2p_cli;
1725 else
1726 session->vdev_nss = vdev_type_nss->sta;
1727 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 session->vhtCapability =
1729 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301731 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001732 session->vht_config.su_beam_formee =
1733 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001735 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 session->enableVhtpAid =
1738 sme_join_req->enableVhtpAid;
1739 session->enableVhtGid =
1740 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001741 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1742 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 }
Krunal Soni53993f72016-07-08 18:20:03 -07001744
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001745 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1746 lim_update_session_he_capable(mac_ctx, session);
1747 lim_copy_join_req_he_cap(session, sme_join_req);
1748 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001749
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301750 lim_log(mac_ctx, LOG1,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001751 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301752 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001753 session->vht_config.su_beam_formee,
1754 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001755 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001757 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 /* cbMode is already merged value of peer and self -
1760 * done by csr in csr_get_cb_mode_from_ies */
1761 session->htSupportedChannelWidthSet =
1762 (sme_join_req->cbMode) ? 1 : 0;
1763 session->htRecommendedTxWidthSet =
1764 session->htSupportedChannelWidthSet;
1765 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1766
1767 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1768 session->ch_center_freq_seg0 =
1769 session->currentOperChannel - 2;
1770 session->ch_width = CH_WIDTH_40MHZ;
1771 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1772 sme_join_req->cbMode) {
1773 session->ch_center_freq_seg0 =
1774 session->currentOperChannel + 2;
1775 session->ch_width = CH_WIDTH_40MHZ;
1776 } else {
1777 session->ch_center_freq_seg0 = 0;
1778 session->ch_width = CH_WIDTH_20MHZ;
1779 }
1780
1781 /* Record if management frames need to be protected */
1782#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001783 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001785 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787#endif
1788
1789#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001790 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791#endif
1792
1793 /* Copy the SSID from smejoinreq to session entry */
1794 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301795 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 session->ssId.length);
1797
1798 /*
1799 * Determin 11r or ESE connection based on input from SME
1800 * which inturn is dependent on the profile the user wants
1801 * to connect to, So input is coming from supplicant
1802 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804#ifdef FEATURE_WLAN_ESE
1805 session->isESEconnection = sme_join_req->isESEconnection;
1806#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 session->isFastTransitionEnabled =
1808 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 session->isFastRoamIniFeatureEnabled =
1811 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 session->txLdpcIniFeatureEnabled =
1813 sme_join_req->txLdpcIniFeatureEnabled;
1814
1815 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1816 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 } else {
1818 /*
1819 * Throw an error and return and make
1820 * sure to delete the session.
1821 */
1822 lim_log(mac_ctx, LOGE,
1823 FL("recvd JOIN_REQ with invalid bss type %d"),
1824 session->bssType);
1825 ret_code = eSIR_SME_INVALID_PARAMETERS;
1826 goto end;
1827 }
1828
1829 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301830 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 &sme_join_req->addIEScan, sizeof(tSirAddie));
1832
1833 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301834 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1836
1837 val = sizeof(tLimMlmJoinReq) +
1838 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301839 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 if (NULL == mlm_join_req) {
1841 lim_log(mac_ctx, LOGP,
1842 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301843 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1844 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846
1847 /* PE SessionId is stored as a part of JoinReq */
1848 mlm_join_req->sessionId = session->peSessionId;
1849
1850 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1851 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1852 eSIR_SUCCESS) {
1853 lim_log(mac_ctx, LOGP,
1854 FL("couldn't retrieve JoinFailureTimer value"
1855 " setting to default value"));
1856 mlm_join_req->joinFailureTimeout =
1857 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1858 }
1859
1860 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301861 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 (void *)&sme_join_req->operationalRateSet,
1863 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301864 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 (void *)&sme_join_req->extendedRateSet,
1866 sizeof(tSirMacRateSet));
1867 /*
1868 * this may not be needed anymore now, as rateSet is now
1869 * included in the session entry and MLM has session context.
1870 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301871 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 (void *)&session->rateSet,
1873 sizeof(tSirMacRateSet));
1874
1875 session->encryptType = sme_join_req->UCEncryptionType;
1876
1877 mlm_join_req->bssDescription.length =
1878 session->pLimJoinReq->bssDescription.length;
1879
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301880 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 (uint8_t *)
1882 &session->pLimJoinReq->bssDescription.bssId,
1883 session->pLimJoinReq->bssDescription.length + 2);
1884
1885 session->limCurrentBssCaps =
1886 session->pLimJoinReq->bssDescription.capabilityInfo;
1887
1888 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1889 session->currentOperChannel);
1890 local_power_constraint = reg_max;
1891
1892 lim_extract_ap_capability(mac_ctx,
1893 (uint8_t *)
1894 session->pLimJoinReq->bssDescription.ieFields,
1895 lim_get_ielen_from_bss_description(
1896 &session->pLimJoinReq->bssDescription),
1897 &session->limCurrentBssQosCaps,
1898 &session->limCurrentBssPropCap,
1899 &session->gLimCurrentBssUapsd,
1900 &local_power_constraint, session);
1901
Krunal Soni53993f72016-07-08 18:20:03 -07001902 /*
1903 * Once the AP capabilities are available then set the
1904 * beam forming capabilities accordingly.
1905 */
1906 if (session->nss == 1) {
1907 session->vht_config.su_beam_former = 0;
1908 session->vht_config.tx_stbc = 0;
1909 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301910 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001911 }
1912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 session->maxTxPower = lim_get_max_tx_power(reg_max,
1914 local_power_constraint,
1915 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301916
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301917 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301918 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301919 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920
1921 if (session->gLimCurrentBssUapsd) {
1922 session->gUapsdPerAcBitmask =
1923 session->pLimJoinReq->uapsdPerAcBitmask;
1924 lim_log(mac_ctx, LOG1,
1925 FL("UAPSD flag for all AC - 0x%2x"),
1926 session->gUapsdPerAcBitmask);
1927
1928 /* resetting the dynamic uapsd mask */
1929 session->gUapsdPerAcDeliveryEnableMask = 0;
1930 session->gUapsdPerAcTriggerEnableMask = 0;
1931 }
1932
1933 session->limRFBand =
1934 lim_get_rf_band(session->currentOperChannel);
1935
1936 /* Initialize 11h Enable Flag */
1937 if (SIR_BAND_5_GHZ == session->limRFBand) {
1938 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1939 &val) != eSIR_SUCCESS) {
1940 lim_log(mac_ctx, LOGP,
1941 FL("Fail to get WNI_CFG_11H_ENABLED "));
1942 session->lim11hEnable =
1943 WNI_CFG_11H_ENABLED_STADEF;
1944 } else {
1945 session->lim11hEnable = val;
1946 }
1947 } else {
1948 session->lim11hEnable = 0;
1949 }
1950
1951 /*
1952 * To care of the scenario when STA transitions from
1953 * IBSS to Infrastructure mode.
1954 */
1955 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1956
1957 session->limPrevSmeState = session->limSmeState;
1958 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1959 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1960 session->peSessionId,
1961 session->limSmeState));
1962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 /* Indicate whether spectrum management is enabled */
1964 session->spectrumMgtEnabled =
1965 sme_join_req->spectrumMgtIndicator;
1966
1967 /* Enable the spectrum management if this is a DFS channel */
1968 if (session->country_info_present &&
1969 lim_isconnected_on_dfs_channel(
1970 session->currentOperChannel))
1971 session->spectrumMgtEnabled = true;
1972
1973 session->isOSENConnection = sme_join_req->isOSENConnection;
1974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 /* Issue LIM_MLM_JOIN_REQ to MLM */
1976 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1977 (uint32_t *) mlm_join_req);
1978 return;
1979
1980 } else {
1981 /* Received eWNI_SME_JOIN_REQ un expected state */
1982 lim_log(mac_ctx, LOGE,
1983 FL("received unexpected SME_JOIN_REQ in state %X"),
1984 mac_ctx->lim.gLimSmeState);
1985 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1986 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1987 session = NULL;
1988 goto end;
1989 }
1990
1991end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301992 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1993 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994
1995 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301996 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 sme_join_req = NULL;
1998 if (NULL != session)
1999 session->pLimJoinReq = NULL;
2000 }
2001 if (ret_code != eSIR_SME_SUCCESS) {
2002 if (NULL != session) {
2003 pe_delete_session(mac_ctx, session);
2004 session = NULL;
2005 }
2006 }
2007 lim_log(mac_ctx, LOG1,
2008 FL("Send failure status on sessionid: %d with ret_code = %d"),
2009 sme_session_id, ret_code);
2010 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2011 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2012 sme_transaction_id);
2013}
2014
Amar Singhala297bfa2015-10-15 15:07:29 -07002015uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 uint8_t iniTxPower)
2017{
2018 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302019 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2020 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2022 maxTxPower = txPower;
2023 else if (txPower < MIN_TX_PWR_CAP)
2024 maxTxPower = MIN_TX_PWR_CAP;
2025 else
2026 maxTxPower = MAX_TX_PWR_CAP;
2027
2028 return maxTxPower;
2029}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030
2031/**
2032 * __lim_process_sme_reassoc_req() - process reassoc req
2033 *
2034 * @mac_ctx: Pointer to Global MAC structure
2035 * @msg_buf: pointer to the SME message buffer
2036 *
2037 * This function is called to process SME_REASSOC_REQ message
2038 * from HDD or upper layer application.
2039 *
2040 * Return: None
2041 */
2042
2043static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2044 uint32_t *msg_buf)
2045{
2046 uint16_t caps;
2047 uint32_t val;
2048 tpSirSmeJoinReq reassoc_req = NULL;
2049 tLimMlmReassocReq *mlm_reassoc_req;
2050 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2051 tpPESession session_entry = NULL;
2052 uint8_t session_id;
2053 uint8_t sme_session_id;
2054 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002055 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 uint32_t tele_bcn_en = 0;
2057 uint16_t size;
2058
2059 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2060
2061 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302062 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 if (NULL == reassoc_req) {
2064 lim_log(mac_ctx, LOGP,
2065 FL("call to AllocateMemory failed for reassoc_req"));
2066
2067 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2068 goto end;
2069 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302070 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071
2072 if (!lim_is_sme_join_req_valid(mac_ctx,
2073 (tpSirSmeJoinReq)reassoc_req)) {
2074 /*
2075 * Received invalid eWNI_SME_REASSOC_REQ
2076 */
2077 lim_log(mac_ctx, LOGW,
2078 FL("received SME_REASSOC_REQ with invalid data"));
2079
2080 ret_code = eSIR_SME_INVALID_PARAMETERS;
2081 goto end;
2082 }
2083
2084 session_entry = pe_find_session_by_bssid(mac_ctx,
2085 reassoc_req->bssDescription.bssId,
2086 &session_id);
2087 if (session_entry == NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 lim_log(mac_ctx, LOGE,
2089 FL("Session does not exist for given bssId"));
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002090 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2091 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002093 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2094 &sme_session_id, &transaction_id);
2095 session_entry =
2096 pe_find_session_by_sme_session_id(mac_ctx,
2097 sme_session_id);
2098 if (session_entry != NULL)
2099 lim_handle_sme_join_result(mac_ctx,
2100 eSIR_SME_INVALID_PARAMETERS,
2101 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2102 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 goto end;
2104 }
2105#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2106 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2107 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2108#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2109 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2110
2111 /* Store the reassoc handle in the session Table */
2112 session_entry->pLimReAssocReq = reassoc_req;
2113
2114 session_entry->dot11mode = reassoc_req->dot11mode;
2115 session_entry->vhtCapability =
2116 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002117
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302118 if (session_entry->vhtCapability) {
2119 if (session_entry->pePersona == QDF_STA_MODE) {
2120 session_entry->vht_config.su_beam_formee =
2121 reassoc_req->vht_config.su_beam_formee;
2122 } else {
2123 reassoc_req->vht_config.su_beam_formee = 0;
2124 }
2125 session_entry->enableVhtpAid =
2126 reassoc_req->enableVhtpAid;
2127 session_entry->enableVhtGid =
2128 reassoc_req->enableVhtGid;
2129 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2130 session_entry->vht_config.su_beam_former);
2131 }
2132
2133 lim_log(mac_ctx, LOG1,
2134 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2135 session_entry->vhtCapability,
2136 session_entry->vht_config.su_beam_formee,
2137 session_entry->vht_config.su_beam_former);
2138
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002139 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2140 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002141 session_entry->send_smps_action =
2142 reassoc_req->send_smps_action;
2143 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002144 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002145 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002146 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002147 session_entry->send_smps_action,
2148 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 /*
2150 * Reassociate request is expected
2151 * in link established state only.
2152 */
2153
2154 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2156 /*
2157 * May be from 11r FT pre-auth. So lets check it
2158 * before we bail out
2159 */
2160 lim_log(mac_ctx, LOG1, FL(
2161 "Session in reassoc state is %d"),
2162 session_entry->peSessionId);
2163
2164 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302165 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 session_entry->limReAssocbssId,
2167 6)) {
2168 lim_print_mac_addr(mac_ctx,
2169 reassoc_req->bssDescription.
2170 bssId, LOGE);
2171 lim_log(mac_ctx, LOGP,
2172 FL("Unknown bssId in reassoc state"));
2173 ret_code = eSIR_SME_INVALID_PARAMETERS;
2174 goto end;
2175 }
2176
2177 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2178 session_entry);
2179 return;
2180 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 /*
2182 * Should not have received eWNI_SME_REASSOC_REQ
2183 */
2184 lim_log(mac_ctx, LOGE,
2185 FL("received unexpected SME_REASSOC_REQ in state %X"),
2186 session_entry->limSmeState);
2187 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2188
2189 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2190 goto end;
2191 }
2192
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 session_entry->pLimReAssocReq->bssDescription.bssId,
2195 sizeof(tSirMacAddr));
2196
2197 session_entry->limReassocChannelId =
2198 session_entry->pLimReAssocReq->bssDescription.channelId;
2199
2200 session_entry->reAssocHtSupportedChannelWidthSet =
2201 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2202 session_entry->reAssocHtRecommendedTxWidthSet =
2203 session_entry->reAssocHtSupportedChannelWidthSet;
2204 session_entry->reAssocHtSecondaryChannelOffset =
2205 session_entry->pLimReAssocReq->cbMode;
2206
2207 session_entry->limReassocBssCaps =
2208 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2209 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2210 session_entry->currentOperChannel);
2211 local_pwr_constraint = reg_max;
2212
2213 lim_extract_ap_capability(mac_ctx,
2214 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2215 lim_get_ielen_from_bss_description(
2216 &session_entry->pLimReAssocReq->bssDescription),
2217 &session_entry->limReassocBssQosCaps,
2218 &session_entry->limReassocBssPropCap,
2219 &session_entry->gLimCurrentBssUapsd,
2220 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302221 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302223 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2224 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 /* Copy the SSID from session entry to local variable */
2226 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302227 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 reassoc_req->ssId.ssId,
2229 session_entry->limReassocSSID.length);
2230 if (session_entry->gLimCurrentBssUapsd) {
2231 session_entry->gUapsdPerAcBitmask =
2232 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2233 lim_log(mac_ctx, LOG1,
2234 FL("UAPSD flag for all AC - 0x%2x"),
2235 session_entry->gUapsdPerAcBitmask);
2236 }
2237
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302238 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 if (NULL == mlm_reassoc_req) {
2240 lim_log(mac_ctx, LOGP,
2241 FL("call to AllocateMemory failed for mlmReassocReq"));
2242
2243 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2244 goto end;
2245 }
2246
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302247 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2249
2250 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2251 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2252 eSIR_SUCCESS) {
2253 /*
2254 * Could not get ReassocFailureTimeout value
2255 * from CFG. Log error.
2256 */
2257 lim_log(mac_ctx, LOGP,
2258 FL("could not retrieve ReassocFailureTimeout value"));
2259 }
2260
2261 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2262 eSIR_SUCCESS) {
2263 /*
2264 * Could not get Capabilities value
2265 * from CFG. Log error.
2266 */
2267 lim_log(mac_ctx, LOGP, FL(
2268 "could not retrieve Capabilities value"));
2269 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302270
2271 lim_update_caps_info_for_bss(mac_ctx, &caps,
2272 reassoc_req->bssDescription.capabilityInfo);
2273 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 mlm_reassoc_req->capabilityInfo = caps;
2276
2277 /* Update PE session_id */
2278 mlm_reassoc_req->sessionId = session_id;
2279
2280 /*
2281 * If telescopic beaconing is enabled, set listen interval to
2282 * WNI_CFG_TELE_BCN_MAX_LI
2283 */
2284 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2285 &tele_bcn_en) != eSIR_SUCCESS)
2286 lim_log(mac_ctx, LOGP,
2287 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2288
2289 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2290
2291 if (tele_bcn_en) {
2292 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2293 eSIR_SUCCESS)
2294 /*
2295 * Could not get ListenInterval value
2296 * from CFG. Log error.
2297 */
2298 lim_log(mac_ctx, LOGP,
2299 FL("could not retrieve ListenInterval"));
2300 } else {
2301 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2302 eSIR_SUCCESS)
2303 /*
2304 * Could not get ListenInterval value
2305 * from CFG. Log error.
2306 */
2307 lim_log(mac_ctx, LOGP,
2308 FL("could not retrieve ListenInterval"));
2309 }
2310
2311 mlm_reassoc_req->listenInterval = (uint16_t) val;
2312
2313 /* Indicate whether spectrum management is enabled */
2314 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2315
2316 /* Enable the spectrum management if this is a DFS channel */
2317 if (session_entry->country_info_present &&
2318 lim_isconnected_on_dfs_channel(
2319 session_entry->currentOperChannel))
2320 session_entry->spectrumMgtEnabled = true;
2321
2322 session_entry->limPrevSmeState = session_entry->limSmeState;
2323 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2324
2325 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2326 session_entry->peSessionId,
2327 session_entry->limSmeState));
2328
2329 lim_post_mlm_message(mac_ctx,
2330 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2331 return;
2332end:
2333 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302334 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 if (session_entry)
2336 session_entry->pLimReAssocReq = NULL;
2337 }
2338
2339 if (session_entry) {
2340 /*
2341 * error occurred after we determined the session so extract
2342 * session and transaction info from there
2343 */
2344 sme_session_id = session_entry->smeSessionId;
2345 transaction_id = session_entry->transactionId;
2346 } else
2347 /*
2348 * error occurred before or during the time we determined
2349 * the session so extract the session and transaction info
2350 * from the message
2351 */
2352 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2353 &sme_session_id, &transaction_id);
2354
2355 /*
2356 * Send Reassoc failure response to host
2357 * (note session_entry may be NULL, but that's OK)
2358 */
2359 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2360 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2361 session_entry, sme_session_id,
2362 transaction_id);
2363}
2364
2365bool send_disassoc_frame = 1;
2366/**
2367 * __lim_process_sme_disassoc_req()
2368 *
2369 ***FUNCTION:
2370 * This function is called to process SME_DISASSOC_REQ message
2371 * from HDD or upper layer application.
2372 *
2373 ***LOGIC:
2374 *
2375 ***ASSUMPTIONS:
2376 *
2377 ***NOTE:
2378 *
2379 * @param pMac Pointer to Global MAC structure
2380 * @param *pMsgBuf A pointer to the SME message buffer
2381 * @return None
2382 */
2383
2384static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2385{
2386 uint16_t disassocTrigger, reasonCode;
2387 tLimMlmDisassocReq *pMlmDisassocReq;
2388 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2389 tSirSmeDisassocReq smeDisassocReq;
2390 tpPESession psessionEntry = NULL;
2391 uint8_t sessionId;
2392 uint8_t smesessionId;
2393 uint16_t smetransactionId;
2394
2395 if (pMsgBuf == NULL) {
2396 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2397 return;
2398 }
2399
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302400 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 smesessionId = smeDisassocReq.sessionId;
2402 smetransactionId = smeDisassocReq.transactionId;
2403 if (!lim_is_sme_disassoc_req_valid(pMac,
2404 &smeDisassocReq,
2405 psessionEntry)) {
2406 PELOGE(lim_log(pMac, LOGE,
2407 FL("received invalid SME_DISASSOC_REQ message"));)
2408 if (pMac->lim.gLimRspReqd) {
2409 pMac->lim.gLimRspReqd = false;
2410
2411 retCode = eSIR_SME_INVALID_PARAMETERS;
2412 disassocTrigger = eLIM_HOST_DISASSOC;
2413 goto sendDisassoc;
2414 }
2415
2416 return;
2417 }
2418
2419 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002420 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 &sessionId);
2422 if (psessionEntry == NULL) {
2423 lim_log(pMac, LOGE,
2424 FL("session does not exist for given bssId "
2425 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002426 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 retCode = eSIR_SME_INVALID_PARAMETERS;
2428 disassocTrigger = eLIM_HOST_DISASSOC;
2429 goto sendDisassoc;
2430 }
2431 lim_log(pMac, LOG1,
2432 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2433 MAC_ADDRESS_STR), smesessionId,
2434 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2435 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002436 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437
2438#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2439 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2440 0, smeDisassocReq.reasonCode);
2441#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2442
2443 /* Update SME session Id and SME transaction ID */
2444
2445 psessionEntry->smeSessionId = smesessionId;
2446 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07002447 lim_log(pMac, LOGD, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002448 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449
2450 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2451 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 switch (psessionEntry->limSmeState) {
2453 case eLIM_SME_ASSOCIATED_STATE:
2454 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002455 lim_log(pMac, LOG1,
2456 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2457 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 psessionEntry->limPrevSmeState =
2459 psessionEntry->limSmeState;
2460 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 /* Delete all TDLS peers connected before leaving BSS */
2462 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002463 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2464 psessionEntry->peSessionId,
2465 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 break;
2467
2468 case eLIM_SME_WT_DEAUTH_STATE:
2469 /* PE shall still process the DISASSOC_REQ and proceed with
2470 * link tear down even if it had already sent a DEAUTH_IND to
2471 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2472 * its been set when PE entered WT_DEAUTH_STATE.
2473 */
2474 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2475 MTRACE(mac_trace
2476 (pMac, TRACE_CODE_SME_STATE,
2477 psessionEntry->peSessionId,
2478 psessionEntry->limSmeState));
2479 lim_log(pMac, LOG1,
2480 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2481 break;
2482
2483 case eLIM_SME_WT_DISASSOC_STATE:
2484 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2485 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2486 * PE can continue processing DISASSOC_REQ and send the response instead
2487 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2488 * for disassoc frame.
2489 *
2490 * It will send a disassoc, which is ok. However, we can use the global flag
2491 * sendDisassoc to not send disassoc frame.
2492 */
2493 lim_log(pMac, LOG1,
2494 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2495 break;
2496
2497 case eLIM_SME_JOIN_FAILURE_STATE: {
2498 /* Already in Disconnected State, return success */
2499 lim_log(pMac, LOG1,
2500 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2501 if (pMac->lim.gLimRspReqd) {
2502 retCode = eSIR_SME_SUCCESS;
2503 disassocTrigger = eLIM_HOST_DISASSOC;
2504 goto sendDisassoc;
2505 }
2506 }
2507 break;
2508 default:
2509 /**
2510 * STA is not currently associated.
2511 * Log error and send response to host
2512 */
2513 lim_log(pMac, LOGE,
2514 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2515 psessionEntry->limSmeState);
2516 lim_print_sme_state(pMac, LOGE,
2517 psessionEntry->limSmeState);
2518
2519 if (pMac->lim.gLimRspReqd) {
2520 if (psessionEntry->limSmeState !=
2521 eLIM_SME_WT_ASSOC_STATE)
2522 pMac->lim.gLimRspReqd = false;
2523
2524 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2525 disassocTrigger = eLIM_HOST_DISASSOC;
2526 goto sendDisassoc;
2527 }
2528
2529 return;
2530 }
2531
2532 break;
2533
2534 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 /* Fall through */
2536 break;
2537
2538 case eLIM_STA_IN_IBSS_ROLE:
2539 default:
2540 /* eLIM_UNKNOWN_ROLE */
2541 lim_log(pMac, LOGE,
2542 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2543 GET_LIM_SYSTEM_ROLE(psessionEntry));
2544
2545 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2546 disassocTrigger = eLIM_HOST_DISASSOC;
2547 goto sendDisassoc;
2548 } /* end switch (pMac->lim.gLimSystemRole) */
2549
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302550 disassocTrigger = eLIM_HOST_DISASSOC;
2551 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552
2553 if (smeDisassocReq.doNotSendOverTheAir) {
2554 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2555 send_disassoc_frame = 0;
2556 }
2557 /* Trigger Disassociation frame to peer MAC entity */
2558 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2559 " : %d, reasonCode : %d"),
2560 disassocTrigger, reasonCode);
2561
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302562 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 if (NULL == pMlmDisassocReq) {
2564 /* Log error */
2565 lim_log(pMac, LOGP,
2566 FL("call to AllocateMemory failed for mlmDisassocReq"));
2567
2568 return;
2569 }
2570
Anurag Chouhanc5548422016-02-24 18:33:27 +05302571 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002572 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573
2574 pMlmDisassocReq->reasonCode = reasonCode;
2575 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2576
2577 /* Update PE session ID */
2578 pMlmDisassocReq->sessionId = sessionId;
2579
2580 lim_post_mlm_message(pMac,
2581 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2582 return;
2583
2584sendDisassoc:
2585 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002586 lim_send_sme_disassoc_ntf(pMac,
2587 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 retCode,
2589 disassocTrigger,
2590 1, smesessionId, smetransactionId,
2591 psessionEntry);
2592 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002593 lim_send_sme_disassoc_ntf(pMac,
2594 smeDisassocReq.peer_macaddr.bytes,
2595 retCode, disassocTrigger, 1,
2596 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597
2598} /*** end __lim_process_sme_disassoc_req() ***/
2599
2600/** -----------------------------------------------------------------
2601 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2602
2603 This function is called to process SME_DISASSOC_CNF message
2604 from HDD or upper layer application.
2605
2606 \param pMac - global mac structure
2607 \param pStaDs - station dph hash node
2608 \return none
2609 \sa
2610 ----------------------------------------------------------------- */
2611static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2612{
2613 tSirSmeDisassocCnf smeDisassocCnf;
2614 uint16_t aid;
2615 tpDphHashNode pStaDs;
2616 tpPESession psessionEntry;
2617 uint8_t sessionId;
2618
2619 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2620
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302621 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 sizeof(struct sSirSmeDisassocCnf));
2623
2624 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002625 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 &sessionId);
2627 if (psessionEntry == NULL) {
2628 lim_log(pMac, LOGE,
2629 FL("session does not exist for given bssId"));
2630 return;
2631 }
2632
2633 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2634 lim_log(pMac, LOGE,
2635 FL("received invalid SME_DISASSOC_CNF message"));
2636 return;
2637 }
2638#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2639 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2640 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2641 psessionEntry,
2642 (uint16_t) smeDisassocCnf.statusCode, 0);
2643 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2644 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2645 psessionEntry,
2646 (uint16_t) smeDisassocCnf.statusCode, 0);
2647#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2648
2649 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2650 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2652 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2653 && (psessionEntry->limSmeState !=
2654 eLIM_SME_WT_DEAUTH_STATE)) {
2655 lim_log(pMac, LOGE,
2656 FL
2657 ("received unexp SME_DISASSOC_CNF in state %X"),
2658 psessionEntry->limSmeState);
2659 lim_print_sme_state(pMac, LOGE,
2660 psessionEntry->limSmeState);
2661 return;
2662 }
2663 break;
2664
2665 case eLIM_AP_ROLE:
2666 /* Fall through */
2667 break;
2668
2669 case eLIM_STA_IN_IBSS_ROLE:
2670 default: /* eLIM_UNKNOWN_ROLE */
2671 lim_log(pMac, LOGE,
2672 FL("received unexpected SME_DISASSOC_CNF role %d"),
2673 GET_LIM_SYSTEM_ROLE(psessionEntry));
2674
2675 return;
2676 }
2677
2678 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2679 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2680 LIM_IS_AP_ROLE(psessionEntry)) {
2681 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002682 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 &psessionEntry->dph.dphHashTable);
2684 if (pStaDs == NULL) {
2685 lim_log(pMac, LOGE,
2686 FL("DISASSOC_CNF for a STA with no context, addr= "
2687 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002688 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 return;
2690 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302691
2692 if ((pStaDs->mlmStaContext.mlmState ==
2693 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2694 (pStaDs->mlmStaContext.mlmState ==
2695 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2696 lim_log(pMac, LOGE,
2697 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002698 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302699 pStaDs->mlmStaContext.mlmState);
2700 return;
2701 }
2702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 /* Delete FT session if there exists one */
2704 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2706
2707 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002708 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 }
2710
2711 return;
2712}
2713
2714/**
2715 * __lim_process_sme_deauth_req() - process sme deauth req
2716 * @mac_ctx: Pointer to Global MAC structure
2717 * @msg_buf: pointer to the SME message buffer
2718 *
2719 * This function is called to process SME_DEAUTH_REQ message
2720 * from HDD or upper layer application.
2721 *
2722 * Return: None
2723 */
2724
2725static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2726 uint32_t *msg_buf)
2727{
2728 uint16_t deauth_trigger, reason_code;
2729 tLimMlmDeauthReq *mlm_deauth_req;
2730 tSirSmeDeauthReq sme_deauth_req;
2731 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2732 tpPESession session_entry;
2733 uint8_t session_id; /* PE sessionId */
2734 uint8_t sme_session_id;
2735 uint16_t sme_transaction_id;
2736
2737 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2738
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302739 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 sme_session_id = sme_deauth_req.sessionId;
2741 sme_transaction_id = sme_deauth_req.transactionId;
2742
2743 /*
2744 * We need to get a session first but we don't even know
2745 * if the message is correct.
2746 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002747 session_entry = pe_find_session_by_bssid(mac_ctx,
2748 sme_deauth_req.bssid.bytes,
2749 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 if (session_entry == NULL) {
2751 lim_log(mac_ctx, LOGE,
2752 FL("session does not exist for given bssId"));
2753 ret_code = eSIR_SME_INVALID_PARAMETERS;
2754 deauth_trigger = eLIM_HOST_DEAUTH;
2755 goto send_deauth;
2756 }
2757
2758 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2759 session_entry)) {
2760 lim_log(mac_ctx, LOGE,
2761 FL("received invalid SME_DEAUTH_REQ message"));
2762 mac_ctx->lim.gLimRspReqd = false;
2763
2764 ret_code = eSIR_SME_INVALID_PARAMETERS;
2765 deauth_trigger = eLIM_HOST_DEAUTH;
2766 goto send_deauth;
2767 }
2768 lim_log(mac_ctx, LOG1,
2769 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2770 MAC_ADDRESS_STR), sme_session_id,
2771 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2772 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002773 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2775 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2776 session_entry, 0, sme_deauth_req.reasonCode);
2777#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2778
2779 /* Update SME session ID and Transaction ID */
2780 session_entry->smeSessionId = sme_session_id;
2781 session_entry->transactionId = sme_transaction_id;
2782
2783 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2784 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 switch (session_entry->limSmeState) {
2786 case eLIM_SME_ASSOCIATED_STATE:
2787 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302788 /* Delete all TDLS peers connected before leaving BSS */
2789 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 case eLIM_SME_WT_ASSOC_STATE:
2791 case eLIM_SME_JOIN_FAILURE_STATE:
2792 case eLIM_SME_IDLE_STATE:
2793 session_entry->limPrevSmeState =
2794 session_entry->limSmeState;
2795 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2796 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2797 session_entry->peSessionId,
2798 session_entry->limSmeState));
2799 /* Send Deauthentication request to MLM below */
2800 break;
2801 case eLIM_SME_WT_DEAUTH_STATE:
2802 case eLIM_SME_WT_DISASSOC_STATE:
2803 /*
2804 * PE Recieved a Deauth/Disassoc frame. Normally it get
2805 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2806 * Which means host is also trying to disconnect.
2807 * PE can continue processing DEAUTH_REQ and send
2808 * the response instead of failing the request.
2809 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2810 * was sent for deauth/disassoc frame.
2811 */
2812 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2813 lim_log(mac_ctx, LOG1, FL(
2814 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2815 break;
2816 default:
2817 /*
2818 * STA is not in a state to deauthenticate with
2819 * peer. Log error and send response to host.
2820 */
2821 lim_log(mac_ctx, LOGE, FL(
2822 "received unexp SME_DEAUTH_REQ in state %X"),
2823 session_entry->limSmeState);
2824 lim_print_sme_state(mac_ctx, LOGE,
2825 session_entry->limSmeState);
2826
2827 if (mac_ctx->lim.gLimRspReqd) {
2828 mac_ctx->lim.gLimRspReqd = false;
2829
2830 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2831 deauth_trigger = eLIM_HOST_DEAUTH;
2832
2833 /*
2834 * here we received deauth request from AP so sme state
2835 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2836 * delSta then mlm state should be
2837 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2838 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2839 * so the below condition captures the state where
2840 * delSta not done and firmware still in
2841 * connected state.
2842 */
2843 if (session_entry->limSmeState ==
2844 eLIM_SME_WT_DEAUTH_STATE &&
2845 session_entry->limMlmState !=
2846 eLIM_MLM_IDLE_STATE &&
2847 session_entry->limMlmState !=
2848 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2849 ret_code = eSIR_SME_DEAUTH_STATUS;
2850 goto send_deauth;
2851 }
2852 return;
2853 }
2854 break;
2855
2856 case eLIM_STA_IN_IBSS_ROLE:
2857 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2858 if (mac_ctx->lim.gLimRspReqd) {
2859 mac_ctx->lim.gLimRspReqd = false;
2860 ret_code = eSIR_SME_INVALID_PARAMETERS;
2861 deauth_trigger = eLIM_HOST_DEAUTH;
2862 goto send_deauth;
2863 }
2864 return;
2865 case eLIM_AP_ROLE:
2866 break;
2867 default:
2868 lim_log(mac_ctx, LOGE,
2869 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2870 GET_LIM_SYSTEM_ROLE(session_entry));
2871 if (mac_ctx->lim.gLimRspReqd) {
2872 mac_ctx->lim.gLimRspReqd = false;
2873 ret_code = eSIR_SME_INVALID_PARAMETERS;
2874 deauth_trigger = eLIM_HOST_DEAUTH;
2875 goto send_deauth;
2876 }
2877 return;
2878 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2879
2880 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2881 /* Deauthentication is triggered by Link Monitoring */
2882 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2883 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2884 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2885 } else {
2886 deauth_trigger = eLIM_HOST_DEAUTH;
2887 reason_code = sme_deauth_req.reasonCode;
2888 }
2889
2890 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302891 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 if (NULL == mlm_deauth_req) {
2893 lim_log(mac_ctx, LOGP,
2894 FL("call to AllocateMemory failed for mlmDeauthReq"));
2895 if (mac_ctx->lim.gLimRspReqd) {
2896 mac_ctx->lim.gLimRspReqd = false;
2897 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2898 deauth_trigger = eLIM_HOST_DEAUTH;
2899 goto send_deauth;
2900 }
2901 return;
2902 }
2903
Anurag Chouhanc5548422016-02-24 18:33:27 +05302904 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002905 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906
2907 mlm_deauth_req->reasonCode = reason_code;
2908 mlm_deauth_req->deauthTrigger = deauth_trigger;
2909
2910 /* Update PE session Id */
2911 mlm_deauth_req->sessionId = session_id;
2912
2913 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2914 (uint32_t *)mlm_deauth_req);
2915 return;
2916
2917send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002918 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2919 ret_code, deauth_trigger, 1,
2920 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921}
2922
2923/**
2924 * __lim_process_sme_set_context_req()
2925 *
2926 * @mac_ctx: Pointer to Global MAC structure
2927 * @msg_buf: pointer to the SME message buffer
2928 *
2929 * This function is called to process SME_SETCONTEXT_REQ message
2930 * from HDD or upper layer application.
2931 *
2932 * Return: None
2933 */
2934
2935static void
2936__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2937{
2938 tpSirSmeSetContextReq set_context_req;
2939 tLimMlmSetKeysReq *mlm_set_key_req;
2940 tpPESession session_entry;
2941 uint8_t session_id; /* PE sessionID */
2942 uint8_t sme_session_id;
2943 uint16_t sme_transaction_id;
2944
2945 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2946
2947 if (msg_buf == NULL) {
2948 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2949 return;
2950 }
2951
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302952 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 if (NULL == set_context_req) {
2954 lim_log(mac_ctx, LOGP, FL(
2955 "call to AllocateMemory failed for set_context_req"));
2956 return;
2957 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302958 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 sizeof(struct sSirSmeSetContextReq));
2960 sme_session_id = set_context_req->sessionId;
2961 sme_transaction_id = set_context_req->transactionId;
2962
2963 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2964 lim_log(mac_ctx, LOGW,
2965 FL("received invalid SME_SETCONTEXT_REQ message"));
2966 goto end;
2967 }
2968
2969 if (set_context_req->keyMaterial.numKeys >
2970 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2971 lim_log(mac_ctx, LOGE, FL(
2972 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2973 set_context_req->keyMaterial.numKeys);
2974 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002975 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 eSIR_SME_INVALID_PARAMETERS, NULL,
2977 sme_session_id, sme_transaction_id);
2978 goto end;
2979 }
2980
2981 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002982 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 if (session_entry == NULL) {
2984 lim_log(mac_ctx, LOGW,
2985 FL("Session does not exist for given BSSID"));
2986 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002987 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 eSIR_SME_INVALID_PARAMETERS, NULL,
2989 sme_session_id, sme_transaction_id);
2990 goto end;
2991 }
2992#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2993 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2994 session_entry, 0, 0);
2995#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2996
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002997 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2999 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003000 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3002 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303003 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 if (NULL == mlm_set_key_req) {
3005 lim_log(mac_ctx, LOGP, FL(
3006 "mem alloc failed for mlmSetKeysReq"));
3007 goto end;
3008 }
3009 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3010 mlm_set_key_req->numKeys =
3011 set_context_req->keyMaterial.numKeys;
3012 if (mlm_set_key_req->numKeys >
3013 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3014 lim_log(mac_ctx, LOGP, FL(
3015 "no.of keys exceeded max num of default keys limit"));
3016 goto end;
3017 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303018 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003019 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303021 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022 (uint8_t *) &set_context_req->keyMaterial.key,
3023 sizeof(tSirKeys) *
3024 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3025 numKeys : 1));
3026
3027 mlm_set_key_req->sessionId = session_id;
3028 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 lim_log(mac_ctx, LOG1, FL(
3030 "received SETCONTEXT_REQ message sessionId=%d"),
3031 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032
3033 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3034 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3035 LIM_IS_AP_ROLE(session_entry)) {
3036 if (set_context_req->keyMaterial.key[0].keyLength) {
3037 uint8_t key_id;
3038 key_id =
3039 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303040 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 &session_entry->WEPKeyMaterial[key_id],
3042 (uint8_t *) &set_context_req->keyMaterial,
3043 sizeof(tSirKeyMaterial));
3044 } else {
3045 uint32_t i;
3046 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3047 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303048 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 &mlm_set_key_req->key[i],
3050 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3051 sizeof(tSirKeys));
3052 }
3053 }
3054 }
3055 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3056 (uint32_t *) mlm_set_key_req);
3057 } else {
3058 lim_log(mac_ctx, LOGE, FL(
3059 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3060 GET_LIM_SYSTEM_ROLE(session_entry),
3061 session_entry->limSmeState);
3062 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3063
3064 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003065 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3067 session_entry, sme_session_id,
3068 sme_transaction_id);
3069 }
3070end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303071 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 return;
3073}
3074
3075/**
3076 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3077 *
3078 * @mac_ctx: Pointer to Global MAC structure
3079 * @msg_buf: pointer to the SME message buffer
3080 *
3081 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3082 * from HDD or upper layer application.
3083 *
3084 * Return: None
3085 */
3086
Jeff Johnson801f1532016-10-07 07:54:50 -07003087static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3088 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089{
3090 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3091 tpDphHashNode sta_ds = NULL;
3092 tpPESession session_entry = NULL;
3093 tSap_Event sap_event;
3094 tpWLAN_SAPEventCB sap_event_cb = NULL;
3095 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3096 uint8_t session_id = CSR_SESSION_ID_INVALID;
3097 uint8_t assoc_id = 0;
3098 uint8_t sta_cnt = 0;
3099
3100 if (msg_buf == NULL) {
3101 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3102 return;
3103 }
3104
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303105 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 sizeof(struct sSirSmeGetAssocSTAsReq));
3107 /*
3108 * Get Associated stations from PE.
3109 * Find PE session Entry
3110 */
3111 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003112 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 &session_id);
3114 if (session_entry == NULL) {
3115 lim_log(mac_ctx, LOGE,
3116 FL("session does not exist for given bssId"));
3117 goto lim_assoc_sta_end;
3118 }
3119
3120 if (!LIM_IS_AP_ROLE(session_entry)) {
3121 lim_log(mac_ctx, LOGE, FL(
3122 "Received unexpected message in state %X, in role %X"),
3123 session_entry->limSmeState,
3124 GET_LIM_SYSTEM_ROLE(session_entry));
3125 goto lim_assoc_sta_end;
3126 }
3127 /* Retrieve values obtained in the request message */
3128 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3129 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3130
3131 if (NULL == assoc_sta_tmp)
3132 goto lim_assoc_sta_end;
3133 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3134 assoc_id++) {
3135 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3136 &session_entry->dph.dphHashTable);
3137 if (NULL == sta_ds)
3138 continue;
3139 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303140 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303142 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3144 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3145
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303146 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 (uint8_t *)&sta_ds->supportedRates,
3148 sizeof(tSirSupportedRates));
3149 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3150 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3151 assoc_sta_tmp->Support40Mhz =
3152 sta_ds->htDsssCckRate40MHzSupport;
3153
3154 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3155 sta_cnt + 1);
3156 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3157 MAC_ADDR_ARRAY(sta_ds->staAddr));
3158 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3159 sta_ds->assocId);
3160 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3161 sta_ds->staIndex);
3162 assoc_sta_tmp++;
3163 sta_cnt++;
3164 }
3165 }
3166lim_assoc_sta_end:
3167 /*
3168 * Call hdd callback with sap event to send the list of
3169 * associated stations from PE
3170 */
3171 if (sap_event_cb != NULL) {
3172 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3173 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303174 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3176 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3177 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3178 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3179 }
3180}
3181
3182/**
3183 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3184 *
3185 * @mac_ctx: Pointer to Global MAC structure
3186 * @msg_buf: pointer to WPS PBC overlap query message
3187 *
3188 * This function parses get WPS PBC overlap information
3189 * message and call callback to pass WPS PBC overlap
3190 * information back to hdd.
3191 *
3192 * Return: None
3193 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003194static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3195 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196{
3197 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3198 tpPESession session_entry = NULL;
3199 tSap_Event sap_event;
3200 tpWLAN_SAPEventCB sap_event_cb = NULL;
3201 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3203
3204 if (msg_buf == NULL) {
3205 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3206 return;
3207 }
3208
3209 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303210 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303212 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3214 /*
3215 * Get Associated stations from PE
3216 * Find PE session Entry
3217 */
3218 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003219 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 if (session_entry == NULL) {
3221 lim_log(mac_ctx, LOGE,
3222 FL("session does not exist for given bssId"));
3223 goto lim_get_wpspbc_sessions_end;
3224 }
3225
3226 if (!LIM_IS_AP_ROLE(session_entry)) {
3227 lim_log(mac_ctx, LOGE,
3228 FL("Received unexpected message in role %X"),
3229 GET_LIM_SYSTEM_ROLE(session_entry));
3230 goto lim_get_wpspbc_sessions_end;
3231 }
3232 /*
3233 * Call hdd callback with sap event to send the
3234 * WPS PBC overlap information
3235 */
3236 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303237 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238
Anurag Chouhanc5548422016-02-24 18:33:27 +05303239 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003241 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 sap_get_wpspbc_event->UUID_E,
3243 &sap_get_wpspbc_event->wpsPBCOverlap,
3244 session_entry);
3245 } else {
3246 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003247 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 session_entry);
3249 /* don't have to inform the HDD/Host */
3250 return;
3251 }
3252
3253 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3254 sap_get_wpspbc_event->wpsPBCOverlap);
3255 lim_print_mac_addr(mac_ctx,
3256 sap_get_wpspbc_event->addr.bytes, LOG4);
3257
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303258 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259
3260lim_get_wpspbc_sessions_end:
3261 sap_event_cb =
3262 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3263 if (NULL != sap_event_cb)
3264 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3265}
3266
3267/**
3268 * __lim_counter_measures()
3269 *
3270 * FUNCTION:
3271 * This function is called to "implement" MIC counter measure
3272 * and is *temporary* only
3273 *
3274 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3275 * we don't do the proper STA disassoc sequence since the
3276 * BSS will be stoped anyway
3277 *
3278 ***ASSUMPTIONS:
3279 *
3280 ***NOTE:
3281 *
3282 * @param pMac Pointer to Global MAC structure
3283 * @return None
3284 */
3285
3286static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3287{
3288 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003289 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3291 mac, psessionEntry, false);
3292};
3293
Jeff Johnson801f1532016-10-07 07:54:50 -07003294static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3295 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296{
3297 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3298 tpPESession psessionEntry;
3299 uint8_t sessionId; /* PE sessionId */
3300
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303301 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 sizeof(struct sSirSmeTkipCntrMeasReq));
3303
3304 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003305 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 if (NULL == psessionEntry) {
3307 lim_log(pMac, LOGE,
3308 FL("session does not exist for given BSSID "));
3309 return;
3310 }
3311
3312 if (tkipCntrMeasReq.bEnable)
3313 __lim_counter_measures(pMac, psessionEntry);
3314
3315 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3316}
3317
3318static void
3319__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3320{
3321 tSirSmeStopBssReq stopBssReq;
3322 tSirRetStatus status;
3323 tLimSmeStates prevState;
3324 tpPESession psessionEntry;
3325 uint8_t smesessionId;
3326 uint8_t sessionId;
3327 uint16_t smetransactionId;
3328 uint8_t i = 0;
3329 tpDphHashNode pStaDs = NULL;
3330
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303331 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 smesessionId = stopBssReq.sessionId;
3333 smetransactionId = stopBssReq.transactionId;
3334
3335 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3336 PELOGW(lim_log(pMac, LOGW,
3337 FL("received invalid SME_STOP_BSS_REQ message"));)
3338 /* Send Stop BSS response to host */
3339 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3340 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3341 smetransactionId);
3342 return;
3343 }
3344
3345 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003346 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 &sessionId);
3348 if (psessionEntry == NULL) {
3349 lim_log(pMac, LOGW,
3350 FL("session does not exist for given BSSID "));
3351 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3352 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3353 smetransactionId);
3354 return;
3355 }
3356#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3357 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3358 0, 0);
3359#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3360
3361 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3362 LIM_IS_STA_ROLE(psessionEntry)) {
3363 /**
3364 * Should not have received STOP_BSS_REQ in states
3365 * other than 'normal' state or on STA in Infrastructure
3366 * mode. Log error and return response to host.
3367 */
3368 lim_log(pMac, LOGE,
3369 FL
3370 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3371 psessionEntry->limSmeState,
3372 GET_LIM_SYSTEM_ROLE(psessionEntry));
3373 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3374 /* / Send Stop BSS response to host */
3375 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3376 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3377 smetransactionId);
3378 return;
3379 }
3380
3381 if (LIM_IS_AP_ROLE(psessionEntry))
3382 lim_wpspbc_close(pMac, psessionEntry);
3383
3384 lim_log(pMac, LOGW,
3385 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3386 stopBssReq.reasonCode);
3387
3388 prevState = psessionEntry->limSmeState;
3389
3390 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3391 MTRACE(mac_trace
3392 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3393 psessionEntry->limSmeState));
3394
3395 /* Update SME session Id and Transaction Id */
3396 psessionEntry->smeSessionId = smesessionId;
3397 psessionEntry->transactionId = smetransactionId;
3398
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003399 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3400 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3401 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3403 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3404 /* Send disassoc all stations associated thru TKIP */
3405 __lim_counter_measures(pMac, psessionEntry);
3406 else
3407 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003408 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3409 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 }
3411
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003412 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3413 /* Free the buffer allocated in START_BSS_REQ */
3414 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3415 psessionEntry->addIeParams.probeRespDataLen = 0;
3416 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003418 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3419 psessionEntry->addIeParams.assocRespDataLen = 0;
3420 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003422 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3423 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3424 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003426 /*
3427 * lim_del_bss is also called as part of coalescing,
3428 * when we send DEL BSS followed by Add Bss msg.
3429 */
3430 pMac->lim.gLimIbssCoalescingHappened = false;
3431 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3433 pStaDs =
3434 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3435 if (NULL == pStaDs)
3436 continue;
3437 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3438 if (eSIR_SUCCESS == status) {
3439 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3440 pStaDs->assocId, psessionEntry);
3441 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3442 } else {
3443 lim_log(pMac, LOGE,
3444 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303445 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 }
3447 }
3448 /* send a delBss to HAL and wait for a response */
3449 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3450
3451 if (status != eSIR_SUCCESS) {
3452 PELOGE(lim_log
3453 (pMac, LOGE, FL("delBss failed for bss %d"),
3454 psessionEntry->bssIdx);
3455 )
3456 psessionEntry->limSmeState = prevState;
3457
3458 MTRACE(mac_trace
3459 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3460 psessionEntry->limSmeState));
3461
3462 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3463 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3464 smetransactionId);
3465 }
3466}
3467
3468/**
3469 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3470 * @pMac: Global MAC context
3471 * @pMsg: Message from SME
3472 *
3473 * Wrapper for the function __lim_handle_sme_stop_bss_request
3474 * This message will be defered until softmac come out of
3475 * scan mode. Message should be handled even if we have
3476 * detected radar in the current operating channel.
3477 *
3478 * Return: true - If we consumed the buffer
3479 * false - If have defered the message.
3480 */
3481
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003482static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3483 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484{
3485 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3486 /**
3487 * If message defered, buffer is not consumed yet.
3488 * So return false
3489 */
3490 return false;
3491 }
3492 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3493 return true;
3494} /*** end __lim_process_sme_stop_bss_req() ***/
3495
3496void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3497 uint32_t body, tpPESession psessionEntry)
3498{
3499
3500 (void)body;
3501 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3502 lim_ibss_delete(pMac, psessionEntry);
3503 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3504 lim_delete_pre_auth_list(pMac);
3505 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3506 psessionEntry->smeSessionId,
3507 psessionEntry->transactionId);
3508 return;
3509}
3510
3511/**
3512 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3513 *
3514 * @mac_ctx: pointer to mac context
3515 * @msg_type: message type
3516 * @msg_buf: pointer to the SME message buffer
3517 *
3518 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3519 * in BTAMP AP.
3520 *
3521 * Return: None
3522 */
3523
3524void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3525 uint32_t *msg_buf)
3526{
3527 tSirSmeAssocCnf assoc_cnf;
3528 tpDphHashNode sta_ds = NULL;
3529 tpPESession session_entry = NULL;
3530 uint8_t session_id;
3531 tpSirAssocReq assoc_req;
3532
3533 if (msg_buf == NULL) {
3534 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3535 goto end;
3536 }
3537
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303538 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3540 lim_log(mac_ctx, LOGE,
3541 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3542 goto end;
3543 }
3544
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003545 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 &session_id);
3547 if (session_entry == NULL) {
3548 lim_log(mac_ctx, LOGE,
3549 FL("session does not exist for given bssId"));
3550 goto end;
3551 }
3552
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003553 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3555 (session_entry->limSmeState !=
3556 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3557 lim_log(mac_ctx, LOGE, FL(
3558 "Rcvd unexpected msg %X in state %X, in role %X"),
3559 msg_type, session_entry->limSmeState,
3560 GET_LIM_SYSTEM_ROLE(session_entry));
3561 goto end;
3562 }
3563 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3564 &session_entry->dph.dphHashTable);
3565 if (sta_ds == NULL) {
3566 lim_log(mac_ctx, LOGE, FL(
3567 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3568 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003569 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570
3571 /*
3572 * send a DISASSOC_IND message to WSM to make sure
3573 * the state in WSM and LIM is the same
3574 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003575 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 eSIR_SME_STA_NOT_ASSOCIATED,
3577 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3578 session_entry->smeSessionId,
3579 session_entry->transactionId,
3580 session_entry);
3581 goto end;
3582 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303583 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003584 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303585 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 lim_log(mac_ctx, LOG1, FL(
3587 "peerMacAddr mismatched for aid %d, peer "),
3588 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003589 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 goto end;
3591 }
3592
3593 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3594 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3595 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3596 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3597 (msg_type != eWNI_SME_ASSOC_CNF))) {
3598 lim_log(mac_ctx, LOG1, FL(
3599 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3600 "StaD mlmState : %d"),
3601 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003602 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 goto end;
3604 }
3605 /*
3606 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3607 * has been received
3608 */
3609 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3610 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3611 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3612
3613 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3614 /*
3615 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3616 * when it had received Assoc Request frame. Now, PE just needs
3617 * to send association rsp frame to the requesting BTAMP-STA.
3618 */
3619 sta_ds->mlmStaContext.mlmState =
3620 eLIM_MLM_LINK_ESTABLISHED_STATE;
3621 lim_log(mac_ctx, LOG1,
3622 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3623 sta_ds->assocId);
3624 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3625 sta_ds->assocId, sta_ds->staAddr,
3626 sta_ds->mlmStaContext.subType, sta_ds,
3627 session_entry);
3628 goto end;
3629 } else {
3630 /*
3631 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3632 * to be associated since the HAL sta entry is created for
3633 * denied STA we need to remove this HAL entry.
3634 * So to do that set updateContext to 1
3635 */
3636 if (!sta_ds->mlmStaContext.updateContext)
3637 sta_ds->mlmStaContext.updateContext = 1;
3638 lim_log(mac_ctx, LOG1,
3639 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3640 assoc_cnf.statusCode, sta_ds->assocId);
3641 lim_reject_association(mac_ctx, sta_ds->staAddr,
3642 sta_ds->mlmStaContext.subType,
3643 true, sta_ds->mlmStaContext.authType,
3644 sta_ds->assocId, true,
3645 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3646 session_entry);
3647 }
3648end:
3649 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3650 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3651 assoc_req = (tpSirAssocReq)
3652 session_entry->parsedAssocReq[sta_ds->assocId];
3653 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303654 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 assoc_req->assocReqFrame = NULL;
3656 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303657 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3659 }
3660}
3661
3662static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3663{
3664 tpDphHashNode pStaDs;
3665 tSirMacAddr peerMac;
3666 tpSirAddtsReq pSirAddts;
3667 uint32_t timeout;
3668 tpPESession psessionEntry;
3669 uint8_t sessionId; /* PE sessionId */
3670 uint8_t smesessionId;
3671 uint16_t smetransactionId;
3672
3673 if (pMsgBuf == NULL) {
3674 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3675 return;
3676 }
3677
3678 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3679 &smetransactionId);
3680
3681 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3682
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003683 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3684 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 if (psessionEntry == NULL) {
3686 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303687 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3688 NULL, pSirAddts->req.tspec,
3689 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 return;
3691 }
3692#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3693 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3694 0);
3695#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3696
3697 /* if sta
3698 * - verify assoc state
3699 * - send addts request to ap
3700 * - wait for addts response from ap
3701 * if ap, just ignore with error log
3702 */
3703 PELOG1(lim_log(pMac, LOG1,
3704 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3705 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3706 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3707 )
3708
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003709 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3711 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3712 psessionEntry, pSirAddts->req.tspec,
3713 smesessionId, smetransactionId);
3714 return;
3715 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716
3717 pStaDs =
3718 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3719 &psessionEntry->dph.dphHashTable);
3720
3721 if (pStaDs == NULL) {
3722 PELOGE(lim_log
3723 (pMac, LOGE, "Cannot find AP context for addts req");
3724 )
3725 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3726 psessionEntry, pSirAddts->req.tspec,
3727 smesessionId, smetransactionId);
3728 return;
3729 }
3730
3731 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3732 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3733 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3734 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3735 psessionEntry, pSirAddts->req.tspec,
3736 smesessionId, smetransactionId);
3737 return;
3738 }
3739
3740 pSirAddts->req.wsmTspecPresent = 0;
3741 pSirAddts->req.wmeTspecPresent = 0;
3742 pSirAddts->req.lleTspecPresent = 0;
3743
3744 if ((pStaDs->wsmEnabled) &&
3745 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3746 SIR_MAC_ACCESSPOLICY_EDCA))
3747 pSirAddts->req.wsmTspecPresent = 1;
3748 else if (pStaDs->wmeEnabled)
3749 pSirAddts->req.wmeTspecPresent = 1;
3750 else if (pStaDs->lleEnabled)
3751 pSirAddts->req.lleTspecPresent = 1;
3752 else {
3753 PELOGW(lim_log
3754 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3755 )
3756 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3757 psessionEntry, pSirAddts->req.tspec,
3758 smesessionId, smetransactionId);
3759 return;
3760 }
3761
3762 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3763 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3764 lim_log(pMac, LOGE,
3765 "AddTs received in invalid LIMsme state (%d)",
3766 psessionEntry->limSmeState);
3767 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3768 psessionEntry, pSirAddts->req.tspec,
3769 smesessionId, smetransactionId);
3770 return;
3771 }
3772
3773 if (pMac->lim.gLimAddtsSent) {
3774 lim_log(pMac, LOGE,
3775 "Addts (token %d, tsid %d, up %d) is still pending",
3776 pMac->lim.gLimAddtsReq.req.dialogToken,
3777 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3778 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3779 userPrio);
3780 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3781 psessionEntry, pSirAddts->req.tspec,
3782 smesessionId, smetransactionId);
3783 return;
3784 }
3785
3786 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3787
3788 /* save the addts request */
3789 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303790 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3792
3793 /* ship out the message now */
3794 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3795 psessionEntry);
3796 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3797 /* start a timer to wait for the response */
3798 if (pSirAddts->timeout)
3799 timeout = pSirAddts->timeout;
3800 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3801 eSIR_SUCCESS) {
3802 lim_log(pMac, LOGP,
3803 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3804 WNI_CFG_ADDTS_RSP_TIMEOUT);
3805 return;
3806 }
3807
3808 timeout = SYS_MS_TO_TICKS(timeout);
3809 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3810 != TX_SUCCESS) {
3811 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3812 return;
3813 }
3814 pMac->lim.gLimAddtsRspTimerCount++;
3815 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3816 pMac->lim.gLimAddtsRspTimerCount) !=
3817 TX_SUCCESS) {
3818 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3819 return;
3820 }
3821 MTRACE(mac_trace
3822 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3823 eLIM_ADDTS_RSP_TIMER));
3824
3825 /* add the sessionId to the timer object */
3826 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3827 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3828 TX_SUCCESS) {
3829 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3830 return;
3831 }
3832 return;
3833}
3834
3835static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3836{
3837 tSirMacAddr peerMacAddr;
3838 uint8_t ac;
3839 tSirMacTSInfo *pTsinfo;
3840 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3841 tpDphHashNode pStaDs = NULL;
3842 tpPESession psessionEntry;
3843 uint8_t sessionId;
3844 uint32_t status = eSIR_SUCCESS;
3845 uint8_t smesessionId;
3846 uint16_t smetransactionId;
3847
3848 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3849 &smetransactionId);
3850
3851 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003852 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 &sessionId);
3854 if (psessionEntry == NULL) {
3855 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3856 status = eSIR_FAILURE;
3857 goto end;
3858 }
3859#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3860 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3861 0);
3862#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3863
3864 if (eSIR_SUCCESS !=
3865 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3866 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3867 status = eSIR_FAILURE;
3868 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3869 smesessionId, smetransactionId);
3870 return;
3871 }
3872
3873 lim_log(pMac, LOG1,
3874 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3875 MAC_ADDRESS_STR),
3876 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3877
3878 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3879 pDeltsReq->req.wmeTspecPresent,
3880 &pDeltsReq->req.tsinfo,
3881 &pDeltsReq->req.tspec, psessionEntry);
3882
3883 pTsinfo =
3884 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3885 tsinfo : &pDeltsReq->req.tsinfo;
3886
3887 /* We've successfully send DELTS frame to AP. Update the
3888 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3889 * is no longer trigger enabled or delivery enabled
3890 */
3891 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3892 pTsinfo, CLEAR_UAPSD_MASK);
3893
3894 /* We're deleting the TSPEC, so this particular AC is no longer
3895 * admitted. PE needs to downgrade the EDCA
3896 * parameters(for the AC for which TS is being deleted) to the
3897 * next best AC for which ACM is not enabled, and send the
3898 * updated values to HAL.
3899 */
3900 ac = upToAc(pTsinfo->traffic.userPrio);
3901
3902 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3903 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3904 ~(1 << ac);
3905 } else if (pTsinfo->traffic.direction ==
3906 SIR_MAC_DIRECTION_DNLINK) {
3907 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3908 ~(1 << ac);
3909 } else if (pTsinfo->traffic.direction ==
3910 SIR_MAC_DIRECTION_BIDIR) {
3911 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3912 ~(1 << ac);
3913 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3914 ~(1 << ac);
3915 }
3916
3917 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3918 psessionEntry);
3919
3920 pStaDs =
3921 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3922 &psessionEntry->dph.dphHashTable);
3923 if (pStaDs != NULL) {
3924 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3925 pStaDs->bssId);
3926 status = eSIR_SUCCESS;
3927 } else {
3928 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3929 status = eSIR_FAILURE;
3930 }
3931#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003932 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933#endif
3934
3935 /* send an sme response back */
3936end:
3937 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3938 smesessionId, smetransactionId);
3939}
3940
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303941void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942{
3943 /* fetch the sessionEntry based on the sessionId */
3944 tpPESession psessionEntry;
3945 psessionEntry = pe_find_session_by_session_id(pMac,
3946 pMac->lim.limTimers.gLimAddtsRspTimer.
3947 sessionId);
3948 if (psessionEntry == NULL) {
3949 lim_log(pMac, LOGP,
3950 FL("Session Does not exist for given sessionID"));
3951 return;
3952 }
3953
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003954 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3956 GET_LIM_SYSTEM_ROLE(psessionEntry));
3957 pMac->lim.gLimAddtsSent = false;
3958 return;
3959 }
3960
3961 if (!pMac->lim.gLimAddtsSent) {
3962 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3963 return;
3964 }
3965
3966 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3967 lim_log(pMac, LOGE,
3968 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3969 pMac->lim.gLimAddtsRspTimerCount);
3970 return;
3971 }
3972 /* this a real response timeout */
3973 pMac->lim.gLimAddtsSent = false;
3974 pMac->lim.gLimAddtsRspTimerCount++;
3975
3976 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3977 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3978 psessionEntry->smeSessionId,
3979 psessionEntry->transactionId);
3980}
3981
3982/**
3983 * __lim_process_sme_get_statistics_request()
3984 *
3985 ***FUNCTION:
3986 *
3987 *
3988 ***NOTE:
3989 *
3990 * @param pMac Pointer to Global MAC structure
3991 * @param *pMsgBuf A pointer to the SME message buffer
3992 * @return None
3993 */
3994static void
3995__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3996{
3997 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003998 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999
4000 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4001
4002 msgQ.type = WMA_GET_STATISTICS_REQ;
4003
4004 msgQ.reserved = 0;
4005 msgQ.bodyptr = pMsgBuf;
4006 msgQ.bodyval = 0;
4007 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4008
4009 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304010 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011 pMsgBuf = NULL;
4012 lim_log(pMac, LOGP, "Unable to forward request");
4013 return;
4014 }
4015
4016 return;
4017}
4018
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004019#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004021 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004023 * @pMac: Pointer to Global MAC structure
4024 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004026 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 */
4028static void
4029__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4030{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004031 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032
4033 msgQ.type = WMA_TSM_STATS_REQ;
4034 msgQ.reserved = 0;
4035 msgQ.bodyptr = pMsgBuf;
4036 msgQ.bodyval = 0;
4037 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4038
4039 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304040 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 pMsgBuf = NULL;
4042 lim_log(pMac, LOGP, "Unable to forward request");
4043 return;
4044 }
4045}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004046#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047
4048static void
4049__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4050{
4051 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4052 tpPESession psessionEntry;
4053 uint8_t sessionId; /* PE sessionID */
4054
4055 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4056
4057 if (pMsgBuf == NULL) {
4058 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4059 return;
4060 }
4061
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304062 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 if (NULL == pUpdateAPWPSIEsReq) {
4064 lim_log(pMac, LOGP,
4065 FL
4066 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4067 return;
4068 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304069 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 sizeof(struct sSirUpdateAPWPSIEsReq));
4071
4072 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004073 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 &sessionId);
4075 if (psessionEntry == NULL) {
4076 lim_log(pMac, LOGW,
4077 FL("Session does not exist for given BSSID"));
4078 goto end;
4079 }
4080
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304081 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 sizeof(tSirAPWPSIEs));
4083
4084 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4085 lim_send_beacon_ind(pMac, psessionEntry);
4086
4087end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304088 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 return;
4090}
4091
4092void
4093lim_send_vdev_restart(tpAniSirGlobal pMac,
4094 tpPESession psessionEntry, uint8_t sessionId)
4095{
4096 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004097 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 tSirRetStatus retCode = eSIR_SUCCESS;
4099
4100 if (psessionEntry == NULL) {
4101 PELOGE(lim_log
4102 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4103 __LINE__);
4104 )
4105 return;
4106 }
4107
4108 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304109 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 if (NULL == pHalHiddenSsidVdevRestart) {
4111 PELOGE(lim_log
4112 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4113 __func__, __LINE__);
4114 )
4115 return;
4116 }
4117
4118 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4119 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4120
4121 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4122 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4123 msgQ.bodyval = 0;
4124
4125 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4126 if (eSIR_SUCCESS != retCode) {
4127 PELOGE(lim_log
4128 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4129 __LINE__);
4130 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304131 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 }
4133}
4134
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304135/**
4136 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4137 * @mac_ctx: Pointer to Global MAC structure
4138 * @msg_buf: Pointer to SME message buffer
4139 *
4140 * Return: None
4141 */
4142static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4143 uint32_t *msg_buf)
4144{
4145 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004146 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304147 tSirRetStatus status;
4148 tSirRoamOffloadScanReq *req_buffer;
4149 uint16_t local_ie_len;
4150 uint8_t *local_ie_buf;
4151
4152 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4153 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4154 req_buffer->sessionId);
4155
4156 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4157 if (!local_ie_buf) {
Arif Hussain963331b2016-10-27 22:59:01 -07004158 lim_log(mac_ctx, LOGE,
4159 FL("Mem Alloc failed for local_ie_buf"));
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304160 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304161 return;
4162 }
4163
4164 local_ie_len = req_buffer->assoc_ie.length;
4165 /* Update ext cap IE if present */
4166 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004167 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4168 local_ie_buf, &local_ie_len)) {
4169 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004170 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4171 req_buffer->assoc_ie.length = local_ie_len;
4172 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4173 local_ie_buf, local_ie_len);
4174 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304175 }
4176 qdf_mem_free(local_ie_buf);
4177
4178 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4179 wma_msg.bodyptr = req_buffer;
4180
4181 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4182 if (eSIR_SUCCESS != status) {
4183 lim_log(mac_ctx, LOGE,
4184 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4185 qdf_mem_free(req_buffer);
4186 }
4187}
4188
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304189/*
4190 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4191 * @mac_ctx: Pointer to global mac context
4192 * @session: Pointer to PE session
4193 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4194 * 1 - Disable broadcast SSID
4195 *
4196 * Return: None
4197 */
4198static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4199 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304201 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4202 if (ssid_hidden != session->ssidHidden)
4203 session->ssidHidden = ssid_hidden;
4204 else {
4205 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304206 return;
4207 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208
4209 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304210 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211
4212 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304213 sch_set_fixed_beacon_fields(mac_ctx, session);
4214 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215
4216 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304217}
4218
4219/**
4220 * __lim_process_sme_session_update - process SME session update msg
4221 *
4222 * @mac_ctx: Pointer to global mac context
4223 * @msg_buf: Pointer to the received message buffer
4224 *
4225 * Return: None
4226 */
4227static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4228 uint32_t *msg_buf)
4229{
4230 struct sir_update_session_param *msg;
4231 tpPESession session;
4232
4233 if (!msg_buf) {
4234 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4235 return;
4236 }
4237
4238 msg = (struct sir_update_session_param *) msg_buf;
4239
4240 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4241 if (!session) {
4242 lim_log(mac_ctx, LOGW,
4243 "Session does not exist for given sessionId %d",
4244 msg->session_id);
4245 return;
4246 }
4247
4248 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4249 msg->param_type, msg->param_val);
4250 switch (msg->param_type) {
4251 case SIR_PARAM_SSID_HIDDEN:
4252 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4253 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304254 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4255 session->ignore_assoc_disallowed = msg->param_val;
4256 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304257 default:
4258 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4259 break;
4260 }
4261}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262
4263static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4264{
4265 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4266 tpPESession psessionEntry;
4267 uint8_t sessionId; /* PE sessionID */
4268
4269 if (pMsgBuf == NULL) {
4270 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4271 return;
4272 }
4273
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304274 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 if (NULL == pUpdateAPWPARSNIEsReq) {
4276 lim_log(pMac, LOGP,
4277 FL
4278 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4279 return;
4280 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304281 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4283
4284 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004285 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 &sessionId);
4287 if (psessionEntry == NULL) {
4288 lim_log(pMac, LOGW,
4289 FL("Session does not exist for given BSSID"));
4290 goto end;
4291 }
4292
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304293 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4295
4296 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4297 &psessionEntry->
4298 pLimStartBssReq->rsnIE,
4299 psessionEntry);
4300
4301 psessionEntry->pLimStartBssReq->privacy = 1;
4302 psessionEntry->privacy = 1;
4303
4304 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4305 lim_send_beacon_ind(pMac, psessionEntry);
4306
4307end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304308 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 return;
4310} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4311
4312/*
4313 Update the beacon Interval dynamically if beaconInterval is different in MCC
4314 */
4315static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4316{
4317 tpSirChangeBIParams pChangeBIParams;
4318 tpPESession psessionEntry;
4319 uint8_t sessionId = 0;
4320 tUpdateBeaconParams beaconParams;
4321
4322 PELOG1(lim_log(pMac, LOG1,
4323 FL("received Update Beacon Interval message"));
4324 );
4325
4326 if (pMsgBuf == NULL) {
4327 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4328 return;
4329 }
4330
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304331 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4333
4334 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004335 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 &sessionId);
4337 if (psessionEntry == NULL) {
4338 lim_log(pMac, LOGE,
4339 FL("Session does not exist for given BSSID"));
4340 return;
4341 }
4342
4343 /*Update sessionEntry Beacon Interval */
4344 if (psessionEntry->beaconParams.beaconInterval !=
4345 pChangeBIParams->beaconInterval) {
4346 psessionEntry->beaconParams.beaconInterval =
4347 pChangeBIParams->beaconInterval;
4348 }
4349
4350 /*Update sch beaconInterval */
4351 if (pMac->sch.schObject.gSchBeaconInterval !=
4352 pChangeBIParams->beaconInterval) {
4353 pMac->sch.schObject.gSchBeaconInterval =
4354 pChangeBIParams->beaconInterval;
4355
4356 PELOG1(lim_log(pMac, LOG1,
4357 FL
4358 ("LIM send update BeaconInterval Indication : %d"),
4359 pChangeBIParams->beaconInterval);
4360 );
4361
4362 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4363 /* Update beacon */
4364 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4365
4366 beaconParams.bssIdx = psessionEntry->bssIdx;
4367 /* Set change in beacon Interval */
4368 beaconParams.beaconInterval =
4369 pChangeBIParams->beaconInterval;
4370 beaconParams.paramChangeBitmap =
4371 PARAM_BCN_INTERVAL_CHANGED;
4372 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4373 }
4374 }
4375
4376 return;
4377} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4378
4379#ifdef QCA_HT_2040_COEX
4380static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4381 uint32_t *pMsgBuf)
4382{
4383 tpSirSetHT2040Mode pSetHT2040Mode;
4384 tpPESession psessionEntry;
4385 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004386 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 tUpdateVHTOpMode *pHtOpMode = NULL;
4388 uint16_t staId = 0;
4389 tpDphHashNode pStaDs = NULL;
4390
4391 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4392 if (pMsgBuf == NULL) {
4393 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4394 return;
4395 }
4396
4397 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4398
4399 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004400 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 &sessionId);
4402 if (psessionEntry == NULL) {
4403 lim_log(pMac, LOG1,
4404 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004405 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 return;
4407 }
4408
4409 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4410 pSetHT2040Mode->cbMode);
4411 /*Update sessionEntry HT related fields */
4412 switch (pSetHT2040Mode->cbMode) {
4413 case PHY_SINGLE_CHANNEL_CENTERED:
4414 psessionEntry->htSecondaryChannelOffset =
4415 PHY_SINGLE_CHANNEL_CENTERED;
4416 psessionEntry->htRecommendedTxWidthSet = 0;
4417 if (pSetHT2040Mode->obssEnabled)
4418 psessionEntry->htSupportedChannelWidthSet
4419 = eHT_CHANNEL_WIDTH_40MHZ;
4420 else
4421 psessionEntry->htSupportedChannelWidthSet
4422 = eHT_CHANNEL_WIDTH_20MHZ;
4423 break;
4424 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4425 psessionEntry->htSecondaryChannelOffset =
4426 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4427 psessionEntry->htRecommendedTxWidthSet = 1;
4428 break;
4429 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4430 psessionEntry->htSecondaryChannelOffset =
4431 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4432 psessionEntry->htRecommendedTxWidthSet = 1;
4433 break;
4434 default:
4435 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4436 return;
4437 }
4438
4439 /* Update beacon */
4440 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4441 lim_send_beacon_ind(pMac, psessionEntry);
4442
4443 /* update OP Mode for each associated peer */
4444 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4445 pStaDs = dph_get_hash_entry(pMac, staId,
4446 &psessionEntry->dph.dphHashTable);
4447 if (NULL == pStaDs)
4448 continue;
4449
4450 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 if (NULL == pHtOpMode) {
4453 lim_log(pMac, LOGE,
4454 FL
4455 ("%s: Not able to allocate memory for setting OP mode"),
4456 __func__);
4457 return;
4458 }
4459 pHtOpMode->opMode =
4460 (psessionEntry->htSecondaryChannelOffset ==
4461 PHY_SINGLE_CHANNEL_CENTERED) ?
4462 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4463 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304464 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 sizeof(tSirMacAddr));
4466 pHtOpMode->smesessionId = sessionId;
4467
4468 msg.type = WMA_UPDATE_OP_MODE;
4469 msg.reserved = 0;
4470 msg.bodyptr = pHtOpMode;
Krunal Soni66c113f2016-12-21 16:46:47 -08004471 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004472 scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08004473 &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474 lim_log(pMac, LOGE,
4475 FL
4476 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4477 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304478 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 return;
4480 }
4481 lim_log(pMac, LOG1,
4482 FL
4483 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4484 __func__, pHtOpMode->opMode, staId);
4485
4486 } else
4487 lim_log(pMac, LOG1,
4488 FL("%s: station %d does not support HT40\n"),
4489 __func__, staId);
4490 }
4491
4492 return;
4493}
4494#endif
4495
4496/* -------------------------------------------------------------------- */
4497/**
4498 * __lim_process_report_message
4499 *
4500 * FUNCTION: Processes the next received Radio Resource Management message
4501 *
4502 * LOGIC:
4503 *
4504 * ASSUMPTIONS:
4505 *
4506 * NOTE:
4507 *
4508 * @param None
4509 * @return None
4510 */
4511
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004512static void __lim_process_report_message(tpAniSirGlobal pMac,
4513 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 switch (pMsg->type) {
4516 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4517 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4518 break;
4519 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004521 break;
4522 default:
4523 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525}
4526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527/* -------------------------------------------------------------------- */
4528/**
4529 * lim_send_set_max_tx_power_req
4530 *
4531 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4532 *
4533 * LOGIC:
4534 *
4535 * ASSUMPTIONS:
4536 *
4537 * NOTE:
4538 *
4539 * @param txPower txPower to be set.
4540 * @param pSessionEntry session entry.
4541 * @return None
4542 */
4543tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004544lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 tpPESession pSessionEntry)
4546{
4547 tpMaxTxPowerParams pMaxTxParams = NULL;
4548 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004549 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550
4551 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304552 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 return eSIR_FAILURE;
4554 }
4555
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304556 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 if (NULL == pMaxTxParams) {
4558 lim_log(pMac, LOGP,
4559 FL("Unable to allocate memory for pMaxTxParams "));
4560 return eSIR_MEM_ALLOC_FAILED;
4561
4562 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304564 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304565 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304566 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004567 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304568 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569
4570 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4571 msgQ.bodyptr = pMaxTxParams;
4572 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304573 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4575 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4576 if (eSIR_SUCCESS != retCode) {
4577 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304578 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 }
4580 return retCode;
4581}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582
4583/**
4584 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4585 *
4586 * @mac_ctx: Pointer to Global MAC structure
4587 * @msg_buf: pointer to the SME message buffer
4588 *
4589 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4590 * from SME. It Register this information within PE.
4591 *
4592 * Return: None
4593 */
4594static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4595 uint32_t *msg_buf)
4596{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304597 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4599 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4600 struct mgmt_frm_reg_info *next = NULL;
4601 bool match = false;
4602
4603 lim_log(mac_ctx, LOG1, FL(
4604 "registerFrame %d, frameType %d, matchLen %d"),
4605 sme_req->registerFrame, sme_req->frameType,
4606 sme_req->matchLen);
4607 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304608 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304609 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4610 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304611 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612
4613 while (lim_mgmt_regn != NULL) {
4614 if (lim_mgmt_regn->frameType != sme_req->frameType)
4615 goto skip_match;
4616 if (sme_req->matchLen) {
4617 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304618 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 sme_req->matchData,
4620 lim_mgmt_regn->matchLen))) {
4621 /* found match! */
4622 match = true;
4623 break;
4624 }
4625 } else {
4626 /* found match! */
4627 match = true;
4628 break;
4629 }
4630skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304631 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304632 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304634 (qdf_list_node_t *)lim_mgmt_regn,
4635 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304636 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 lim_mgmt_regn = next;
4638 next = NULL;
4639 }
4640 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304641 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004642 if (QDF_STATUS_SUCCESS ==
4643 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004645 (qdf_list_node_t *)lim_mgmt_regn))
4646 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304647 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 }
4649
4650 if (sme_req->registerFrame) {
4651 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304652 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 sme_req->matchLen);
4654 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 lim_mgmt_regn->frameType = sme_req->frameType;
4656 lim_mgmt_regn->matchLen = sme_req->matchLen;
4657 lim_mgmt_regn->sessionId = sme_req->sessionId;
4658 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304659 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 sme_req->matchData,
4661 sme_req->matchLen);
4662 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304663 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304665 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 gLimMgmtFrameRegistratinQueue,
4667 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304668 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 &mac_ctx->lim.lim_frame_register_lock);
4670 }
4671 }
4672 return;
4673}
4674
4675static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4676{
4677 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4678 pMac->lim.gDeferMsgTypeForNOA);
4679 pMac->lim.gDeferMsgTypeForNOA = 0;
4680 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4681 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304682 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4684 }
4685}
4686
4687/**
4688 * lim_process_regd_defd_sme_req_after_noa_start()
4689 *
4690 * mac_ctx: Pointer to Global MAC structure
4691 *
4692 * This function is called to process deferred sme req message
4693 * after noa start.
4694 *
4695 * Return: None
4696 */
4697void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4698{
4699 bool buf_consumed = true;
4700
4701 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4702 mac_ctx->lim.gDeferMsgTypeForNOA);
4703
4704 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4705 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4706 lim_log(mac_ctx, LOGW,
4707 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4708 lim_log(mac_ctx, LOGW,
4709 FL("It may happen when NOA start ind and timeout happen at the same time"));
4710 return;
4711 }
4712 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4713 case eWNI_SME_SCAN_REQ:
4714 __lim_process_sme_scan_req(mac_ctx,
4715 mac_ctx->lim.gpDefdSmeMsgForNOA);
4716 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4718 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4719 mac_ctx->lim.gpDefdSmeMsgForNOA);
4720 /*
4721 * lim_process_remain_on_chnl_req doesnt want us to free
4722 * the buffer since it is freed in lim_remain_on_chn_rsp.
4723 * this change is to avoid "double free"
4724 */
4725 if (false == buf_consumed)
4726 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4727 break;
4728 case eWNI_SME_JOIN_REQ:
4729 __lim_process_sme_join_req(mac_ctx,
4730 mac_ctx->lim.gpDefdSmeMsgForNOA);
4731 break;
4732 default:
4733 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4734 mac_ctx->lim.gDeferMsgTypeForNOA);
4735 break;
4736 }
4737 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4738}
4739
4740static void
4741__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4742{
4743 tpSirResetAPCapsChange pResetCapsChange;
4744 tpPESession psessionEntry;
4745 uint8_t sessionId = 0;
4746 if (pMsgBuf == NULL) {
4747 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4748 return;
4749 }
4750
4751 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4752 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004753 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4754 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 if (psessionEntry == NULL) {
4756 lim_log(pMac, LOGE,
4757 FL("Session does not exist for given BSSID"));
4758 return;
4759 }
4760
4761 psessionEntry->limSentCapsChangeNtf = false;
4762 return;
4763}
4764
4765/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304766 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4767 * @mac_ctx: Mac pointer
4768 * @msg_buf: Msg pointer containing the callback
4769 *
4770 * This function is used to save the p2p ack indication callback in PE.
4771 *
4772 * Return: None
4773 */
4774static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4775 uint32_t *msg_buf)
4776{
4777 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4778 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4779
4780 if (NULL == msg_buf) {
4781 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4782 return;
4783 }
4784 if (sme_req->callback)
4785 mac_ctx->p2p_ack_ind_cb =
4786 sme_req->callback;
4787 else
4788 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4789}
4790
4791/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304792 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4793 * indication callback in PE.
4794 * @mac_ptr: Mac pointer
4795 * @msg_buf: Msg pointer containing the callback
4796 *
4797 * This function is used save the Management frame
4798 * indication callback in PE.
4799 *
4800 * Return: None
4801 */
4802static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4803 uint32_t *msg_buf)
4804{
4805 struct sir_sme_mgmt_frame_cb_req *sme_req =
4806 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4807
4808 if (NULL == msg_buf) {
4809 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4810 return;
4811 }
4812 if (sme_req->callback)
4813 mac_ctx->mgmt_frame_ind_cb =
4814 (sir_mgmt_frame_ind_callback)sme_req->callback;
4815 else
4816 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4817}
4818
4819/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304820 *__lim_process_send_disassoc_frame: function processes disassoc frame
4821 * @mac_ctx: pointer to mac context
4822 * @msg_buf: message buffer
4823 *
4824 * function processes disassoc request received from SME
4825 *
4826 * return: none
4827 */
4828static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4829 uint32_t *msg_buf)
4830{
4831 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4832 tSirRetStatus status;
4833 tpPESession session_entry = NULL;
4834 uint8_t sme_session_id;
4835 uint16_t sme_trans_id;
4836
4837 if (msg_buf == NULL) {
4838 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4839 return;
4840 }
4841
4842 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4843 &sme_trans_id);
4844
4845 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4846 &sme_send_disassoc_frame_req,
4847 (uint8_t *)msg_buf);
4848
4849 if ((eSIR_FAILURE == status) ||
4850 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4851 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4852 PELOGE(lim_log(mac_ctx, LOGE,
4853 FL("received invalid SME_DISASSOC_REQ message"));)
4854 return;
4855 }
4856
4857 session_entry = pe_find_session_by_sme_session_id(
4858 mac_ctx, sme_session_id);
4859 if (session_entry == NULL) {
4860 lim_log(mac_ctx, LOGE,
4861 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4862 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4863 return;
4864 }
4865
4866 lim_log(mac_ctx, LOG1,
4867 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4868 sme_send_disassoc_frame_req.msg_type,
4869 sme_send_disassoc_frame_req.length,
4870 sme_send_disassoc_frame_req.session_id,
4871 sme_send_disassoc_frame_req.trans_id,
4872 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4873 sme_send_disassoc_frame_req.reason,
4874 sme_send_disassoc_frame_req.wait_for_ack);
4875
4876 lim_send_disassoc_mgmt_frame(mac_ctx,
4877 sme_send_disassoc_frame_req.reason,
4878 sme_send_disassoc_frame_req.peer_mac,
4879 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4880}
4881
4882/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004883 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4884 * @mac_ctx: Pointer to Global MAC structure
4885 * @pdev_id: pdev id to set the IE.
4886 * @nss: Nss values to prepare the HT IE.
4887 *
4888 * Prepares the HT IE with self capabilities for different
4889 * Nss values and sends the set HT IE req to FW.
4890 *
4891 * Return: None
4892 */
4893static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4894 uint8_t nss)
4895{
4896 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004897 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004898 tSirRetStatus rc = eSIR_SUCCESS;
4899 uint8_t *p_ie = NULL;
4900 tHtCaps *p_ht_cap;
4901 int i;
4902
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004903 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004904 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4905 if (NULL == ie_params) {
4906 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4907 return;
4908 }
4909 ie_params->nss = i;
4910 ie_params->pdev_id = pdev_id;
4911 ie_params->ie_type = DOT11_HT_IE;
4912 /* 2 for IE len and EID */
4913 ie_params->ie_len = 2 + sizeof(tHtCaps);
4914 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4915 if (NULL == ie_params->ie_ptr) {
4916 qdf_mem_free(ie_params);
4917 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4918 return;
4919 }
4920 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4921 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4922 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4923 ie_params->ie_len);
4924
4925 if (NSS_1x1_MODE == i) {
4926 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4927 ie_params->ie_len,
4928 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004929 if (NULL == p_ie) {
4930 qdf_mem_free(ie_params->ie_ptr);
4931 qdf_mem_free(ie_params);
4932 lim_log(mac_ctx, LOGE,
4933 FL("failed to get IE ptr"));
4934 return;
4935 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004936 p_ht_cap = (tHtCaps *)&p_ie[2];
4937 p_ht_cap->supportedMCSSet[1] = 0;
4938 p_ht_cap->txSTBC = 0;
4939 }
4940
4941 msg.type = WMA_SET_PDEV_IE_REQ;
4942 msg.bodyptr = ie_params;
4943 msg.bodyval = 0;
4944
4945 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4946 if (rc != eSIR_SUCCESS) {
4947 lim_log(mac_ctx, LOGE,
4948 FL("wma_post_ctrl_msg() return failure"));
4949 qdf_mem_free(ie_params->ie_ptr);
4950 qdf_mem_free(ie_params);
4951 return;
4952 }
4953 }
4954}
4955
4956/**
4957 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4958 * @mac_ctx: Pointer to Global MAC structure
4959 * @pdev_id: pdev id to set the IE.
4960 * @nss: Nss values to prepare the VHT IE.
4961 *
4962 * Prepares the VHT IE with self capabilities for different
4963 * Nss values and sends the set VHT IE req to FW.
4964 *
4965 * Return: None
4966 */
4967static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4968 uint8_t nss)
4969{
4970 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004971 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004972 tSirRetStatus rc = eSIR_SUCCESS;
4973 uint8_t *p_ie = NULL;
4974 tSirMacVHTCapabilityInfo *vht_cap;
4975 int i;
4976 tSirVhtMcsInfo *vht_mcs;
4977
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004978 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004979 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4980 if (NULL == ie_params) {
4981 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4982 return;
4983 }
4984 ie_params->nss = i;
4985 ie_params->pdev_id = pdev_id;
4986 ie_params->ie_type = DOT11_VHT_IE;
4987 /* 2 for IE len and EID */
4988 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4989 sizeof(tSirVhtMcsInfo);
4990 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4991 if (NULL == ie_params->ie_ptr) {
4992 qdf_mem_free(ie_params);
4993 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4994 return;
4995 }
4996 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4997 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4998 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4999 ie_params->ie_len);
5000
5001 if (NSS_1x1_MODE == i) {
5002 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
5003 ie_params->ie_len,
5004 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07005005 if (NULL == p_ie) {
5006 qdf_mem_free(ie_params->ie_ptr);
5007 qdf_mem_free(ie_params);
5008 lim_log(mac_ctx, LOGE,
5009 FL("failed to get IE ptr"));
5010 return;
5011 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005012 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5013 vht_cap->txSTBC = 0;
5014 vht_mcs =
5015 (tSirVhtMcsInfo *)&p_ie[2 +
5016 sizeof(tSirMacVHTCapabilityInfo)];
5017 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5018 vht_mcs->rxHighest =
5019 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5020 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5021 vht_mcs->txHighest =
5022 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5023 }
5024 msg.type = WMA_SET_PDEV_IE_REQ;
5025 msg.bodyptr = ie_params;
5026 msg.bodyval = 0;
5027
5028 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5029 if (rc != eSIR_SUCCESS) {
5030 lim_log(mac_ctx, LOGE,
5031 FL("wma_post_ctrl_msg failure"));
5032 qdf_mem_free(ie_params->ie_ptr);
5033 qdf_mem_free(ie_params);
5034 return;
5035 }
5036 }
5037}
5038
5039/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005040 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5041 * @mac_ctx: Pointer to Global MAC structure
5042 * @msg_buf: Pointer to the SME message buffer
5043 *
5044 * This function is called by limProcessMessageQueue(). This function sets the
5045 * VDEV IEs to the FW.
5046 *
5047 * Return: None
5048 */
5049static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5050 uint32_t *msg_buf)
5051{
5052 struct sir_set_vdev_ies_per_band *p_msg =
5053 (struct sir_set_vdev_ies_per_band *)msg_buf;
5054
5055 if (NULL == p_msg) {
5056 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5057 return;
5058 }
5059
5060 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5061 p_msg->vdev_id);
5062 /* intentionally using NULL here so that self capabilty are sent */
5063 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5064 QDF_STATUS_SUCCESS)
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08005065 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT/HE IE to FW"));
Naveen Rawata410c5a2016-09-19 14:22:33 -07005066}
5067
5068/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005069 * lim_process_set_pdev_IEs() - process the set pdev IE req
5070 * @mac_ctx: Pointer to Global MAC structure
5071 * @msg_buf: Pointer to the SME message buffer
5072 *
5073 * This function is called by limProcessMessageQueue(). This
5074 * function sets the PDEV IEs to the FW.
5075 *
5076 * Return: None
5077 */
5078static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5079{
5080 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5081
5082 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5083
5084 if (NULL == ht_vht_cfg) {
5085 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5086 return;
5087 }
5088
5089 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5090 ht_vht_cfg->nss);
5091 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5092
5093 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5094 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5095 ht_vht_cfg->nss);
5096}
5097
5098/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305099 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5100 *
5101 * access policy
5102 * @mac_ctx: pointer to mac context
5103 * @msg: message buffer
5104 *
5105 * function processes vendor IE and access policy from SME and updates PE
5106 *
5107 * session entry
5108 *
5109 * return: none
5110*/
5111static void lim_process_sme_update_access_policy_vendor_ie(
5112 tpAniSirGlobal mac_ctx,
5113 uint32_t *msg)
5114{
5115 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5116 struct sPESession *pe_session_entry;
5117 uint8_t num_bytes;
5118
5119 if (!msg) {
5120 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5121 return;
5122 }
5123 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5124 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5125 update_vendor_ie->sme_session_id);
5126
5127 if (!pe_session_entry) {
5128 lim_log(mac_ctx, LOGE,
5129 FL("Session does not exist for given sme session id(%hu)"),
5130 update_vendor_ie->sme_session_id);
5131 return;
5132 }
5133 if (pe_session_entry->access_policy_vendor_ie)
5134 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5135
5136 num_bytes = update_vendor_ie->ie[1] + 2;
5137 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5138
5139 if (!pe_session_entry->access_policy_vendor_ie) {
5140 lim_log(mac_ctx, LOGE,
5141 FL("Failed to allocate memory for vendor ie"));
5142 return;
5143 }
5144 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5145 &update_vendor_ie->ie[0], num_bytes);
5146
5147 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5148}
5149
5150/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 * lim_process_sme_req_messages()
5152 *
5153 ***FUNCTION:
5154 * This function is called by limProcessMessageQueue(). This
5155 * function processes SME request messages from HDD or upper layer
5156 * application.
5157 *
5158 ***LOGIC:
5159 *
5160 ***ASSUMPTIONS:
5161 *
5162 ***NOTE:
5163 *
5164 * @param pMac Pointer to Global MAC structure
5165 * @param msgType Indicates the SME message type
5166 * @param *pMsgBuf A pointer to the SME message buffer
5167 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5168 * false - if pMsgBuf is not to be freed.
5169 */
5170
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005171bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5172 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173{
5174 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5175 uint32_t *pMsgBuf = pMsg->bodyptr;
5176 tpSirSmeScanReq pScanReq;
5177 PELOG1(lim_log
5178 (pMac, LOG1,
5179 FL
5180 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5181 lim_msg_str(pMsg->type), pMsg->type,
5182 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5183 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5184 )
5185
5186 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5187 /* If no insert NOA required then execute the code below */
5188
5189 switch (pMsg->type) {
5190 case eWNI_SME_SYS_READY_IND:
5191 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5192 break;
5193
5194 case eWNI_SME_START_BSS_REQ:
5195 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5196 break;
5197
5198 case eWNI_SME_SCAN_REQ:
5199 __lim_process_sme_scan_req(pMac, pMsgBuf);
5200 break;
5201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5203 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5204 break;
5205
5206 case eWNI_SME_UPDATE_NOA:
5207 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5208 break;
5209 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5210 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5211 break;
5212 case eWNI_SME_JOIN_REQ:
5213 __lim_process_sme_join_req(pMac, pMsgBuf);
5214 break;
5215
5216 case eWNI_SME_REASSOC_REQ:
5217 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5218 break;
5219
5220 case eWNI_SME_DISASSOC_REQ:
5221 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5222 break;
5223
5224 case eWNI_SME_DISASSOC_CNF:
5225 case eWNI_SME_DEAUTH_CNF:
5226 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5227 break;
5228
5229 case eWNI_SME_DEAUTH_REQ:
5230 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5231 break;
5232
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305233 case eWNI_SME_SEND_DISASSOC_FRAME:
5234 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5235 break;
5236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237 case eWNI_SME_SETCONTEXT_REQ:
5238 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5239 break;
5240
5241 case eWNI_SME_STOP_BSS_REQ:
5242 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5243 break;
5244
5245 case eWNI_SME_ASSOC_CNF:
5246 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5247 PELOG1(lim_log(pMac,
5248 LOG1, FL("Received ASSOC_CNF message"));)
5249 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5250 pMsgBuf);
5251 break;
5252
5253 case eWNI_SME_ADDTS_REQ:
5254 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5255 __lim_process_sme_addts_req(pMac, pMsgBuf);
5256 break;
5257
5258 case eWNI_SME_DELTS_REQ:
5259 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5260 __lim_process_sme_delts_req(pMac, pMsgBuf);
5261 break;
5262
5263 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5264 PELOG1(lim_log
5265 (pMac, LOG1,
5266 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5267 )
5268 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5269 break;
5270
5271 case eWNI_SME_GET_STATISTICS_REQ:
5272 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5273 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5274 bufConsumed = false;
5275 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005276#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277 case eWNI_SME_GET_TSM_STATS_REQ:
5278 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5279 bufConsumed = false;
5280 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005281#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005282 case eWNI_SME_GET_ASSOC_STAS_REQ:
5283 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5284 break;
5285 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5286 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5287 break;
5288
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305289 case eWNI_SME_SESSION_UPDATE_PARAM:
5290 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305292 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5293 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5294 bufConsumed = false;
5295 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 case eWNI_SME_UPDATE_APWPSIE_REQ:
5297 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5298 break;
5299 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5300 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5301 break;
5302
5303 case eWNI_SME_SET_APWPARSNIEs_REQ:
5304 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5305 break;
5306
5307 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5308 /* Update the beaconInterval */
5309 __lim_process_sme_change_bi(pMac, pMsgBuf);
5310 break;
5311
5312#ifdef QCA_HT_2040_COEX
5313 case eWNI_SME_SET_HT_2040_MODE:
5314 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5315 break;
5316#endif
5317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5319 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5320 __lim_process_report_message(pMac, pMsg);
5321 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 case eWNI_SME_FT_PRE_AUTH_REQ:
5324 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5325 break;
5326 case eWNI_SME_FT_UPDATE_KEY:
5327 lim_process_ft_update_key(pMac, pMsgBuf);
5328 break;
5329
5330 case eWNI_SME_FT_AGGR_QOS_REQ:
5331 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5332 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333
5334 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5335 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5336 break;
5337#ifdef FEATURE_WLAN_TDLS
5338 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5339 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5340 break;
5341 case eWNI_SME_TDLS_ADD_STA_REQ:
5342 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5343 break;
5344 case eWNI_SME_TDLS_DEL_STA_REQ:
5345 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5346 break;
5347 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5348 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5349 break;
5350#endif
5351 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5352 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5353 break;
5354
5355 case eWNI_SME_CHANNEL_CHANGE_REQ:
5356 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5357 break;
5358
5359 case eWNI_SME_START_BEACON_REQ:
5360 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5361 break;
5362
5363 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5364 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5365 break;
5366
5367 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5368 lim_process_update_add_ies(pMac, pMsgBuf);
5369 break;
5370
5371 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5372 lim_process_modify_add_ies(pMac, pMsgBuf);
5373 break;
5374 case eWNI_SME_SET_HW_MODE_REQ:
5375 lim_process_set_hw_mode(pMac, pMsgBuf);
5376 break;
5377 case eWNI_SME_NSS_UPDATE_REQ:
5378 lim_process_nss_update_request(pMac, pMsgBuf);
5379 break;
5380 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5381 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5382 break;
5383 case eWNI_SME_SET_IE_REQ:
5384 lim_process_set_ie_req(pMac, pMsgBuf);
5385 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305386 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5387 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5388 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305389 case eWNI_SME_EXT_CHANGE_CHANNEL:
5390 lim_process_ext_change_channel(pMac, pMsgBuf);
5391 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005392 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5393 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5394 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005395 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5396 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005397 break;
5398 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5399 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5400 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005401 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005402 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005403 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005404 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005405 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305406 case eWNI_SME_REGISTER_P2P_ACK_CB:
5407 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5408 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305409 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5410 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5411 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305413 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 pMsg->bodyptr = NULL;
5415 break;
5416 } /* switch (msgType) */
5417
5418 return bufConsumed;
5419} /*** end lim_process_sme_req_messages() ***/
5420
5421/**
5422 * lim_process_sme_start_beacon_req()
5423 *
5424 ***FUNCTION:
5425 * This function is called by limProcessMessageQueue(). This
5426 * function processes SME request messages from HDD or upper layer
5427 * application.
5428 *
5429 ***LOGIC:
5430 *
5431 ***ASSUMPTIONS:
5432 *
5433 ***NOTE:
5434 *
5435 * @param pMac Pointer to Global MAC structure
5436 * @param msgType Indicates the SME message type
5437 * @param *pMsgBuf A pointer to the SME message buffer
5438 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5439 * false - if pMsgBuf is not to be freed.
5440 */
5441static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5442{
5443 tpSirStartBeaconIndication pBeaconStartInd;
5444 tpPESession psessionEntry;
5445 uint8_t sessionId; /* PE sessionID */
5446
5447 if (pMsg == NULL) {
5448 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5449 return;
5450 }
5451
5452 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5453 psessionEntry = pe_find_session_by_bssid(pMac,
5454 pBeaconStartInd->bssid,
5455 &sessionId);
5456 if (psessionEntry == NULL) {
5457 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5458 lim_log(pMac, LOGE,
5459 FL("Session does not exist for given bssId"));
5460 return;
5461 }
5462
5463 if (pBeaconStartInd->beaconStartStatus == true) {
5464 /*
5465 * Currently this Indication comes from SAP
5466 * to start Beacon Tx on a DFS channel
5467 * since beaconing has to be done on DFS
5468 * channel only after CAC WAIT is completed.
5469 * On a DFS Channel LIM does not start beacon
5470 * Tx right after the WMA_ADD_BSS_RSP.
5471 */
5472 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305473 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 FL("Start Beacon with ssid %s Ch %d"),
5475 psessionEntry->ssId.ssId,
5476 psessionEntry->currentOperChannel);
5477 lim_send_beacon_ind(pMac, psessionEntry);
5478 } else {
5479 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5480 return;
5481 }
5482}
5483
5484/**
5485 * lim_process_sme_channel_change_request() - process sme ch change req
5486 *
5487 * @mac_ctx: Pointer to Global MAC structure
5488 * @msg_buf: pointer to the SME message buffer
5489 *
5490 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5491 *
5492 * Return: None
5493 */
5494static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5495 uint32_t *msg_buf)
5496{
5497 tpSirChanChangeRequest ch_change_req;
5498 tpPESession session_entry;
5499 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005500 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501 uint32_t val = 0;
5502
5503 if (msg_buf == NULL) {
5504 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5505 return;
5506 }
5507 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5508
5509 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5510 ch_change_req->targetChannel);
5511
5512 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5513 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5514 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5515 return;
5516 }
5517
5518 session_entry = pe_find_session_by_bssid(mac_ctx,
5519 ch_change_req->bssid, &session_id);
5520 if (session_entry == NULL) {
5521 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5522 lim_log(mac_ctx, LOGE, FL(
5523 "Session does not exist for given bssId"));
5524 return;
5525 }
5526
5527 if (session_entry->currentOperChannel ==
5528 ch_change_req->targetChannel) {
5529 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5530 return;
5531 }
5532
5533 if (LIM_IS_AP_ROLE(session_entry))
5534 session_entry->channelChangeReasonCode =
5535 LIM_SWITCH_CHANNEL_SAP_DFS;
5536 else
5537 session_entry->channelChangeReasonCode =
5538 LIM_SWITCH_CHANNEL_OPERATION;
5539
5540 lim_log(mac_ctx, LOGW, FL(
5541 "switch old chnl %d to new chnl %d, ch_bw %d"),
5542 session_entry->currentOperChannel,
5543 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005544 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545
5546 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005547 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 session_entry->ch_center_freq_seg0 =
5549 ch_change_req->center_freq_seg_0;
5550 session_entry->ch_center_freq_seg1 =
5551 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005552 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005554 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 session_entry->htRecommendedTxWidthSet =
5556 session_entry->htSupportedChannelWidthSet;
5557 session_entry->currentOperChannel =
5558 ch_change_req->targetChannel;
5559 session_entry->limRFBand =
5560 lim_get_rf_band(session_entry->currentOperChannel);
5561 /* Initialize 11h Enable Flag */
5562 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5563 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5564 eSIR_SUCCESS)
5565 lim_log(mac_ctx, LOGP,
5566 FL("Fail to get WNI_CFG_11H_ENABLED"));
5567 }
5568
5569 session_entry->lim11hEnable = val;
5570 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305571 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 &ch_change_req->operational_rateset,
5573 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305574 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 &ch_change_req->extended_rateset,
5576 sizeof(session_entry->extRateSet));
5577 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5578 session_entry->ch_center_freq_seg0,
5579 session_entry->ch_center_freq_seg1,
5580 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005581 max_tx_pwr, session_entry->peSessionId,
5582 ch_change_req->cac_duration_ms,
5583 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584}
5585
5586/******************************************************************************
5587* lim_start_bss_update_add_ie_buffer()
5588*
5589***FUNCTION:
5590* This function checks the src buffer and its length and then malloc for
5591* dst buffer update the same
5592*
5593***LOGIC:
5594*
5595***ASSUMPTIONS:
5596*
5597***NOTE:
5598*
5599* @param pMac Pointer to Global MAC structure
5600* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5601* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5602* @param *pSrcData_buff A pointer of uint8_t src buffer
5603* @param srcDataLen src buffer length
5604******************************************************************************/
5605
5606static void
5607lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5608 uint8_t **pDstData_buff,
5609 uint16_t *pDstDataLen,
5610 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5611{
5612
5613 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5614 *pDstDataLen = srcDataLen;
5615
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305616 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617
5618 if (NULL == *pDstData_buff) {
5619 lim_log(pMac, LOGE,
5620 FL("AllocateMemory failed for pDstData_buff"));
5621 return;
5622 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305623 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 } else {
5625 *pDstData_buff = NULL;
5626 *pDstDataLen = 0;
5627 }
5628}
5629
5630/******************************************************************************
5631* lim_update_add_ie_buffer()
5632*
5633***FUNCTION:
5634* This function checks the src buffer and length if src buffer length more
5635* than dst buffer length then free the dst buffer and malloc for the new src
5636* length, and update the dst buffer and length. But if dst buffer is bigger
5637* than src buffer length then it just update the dst buffer and length
5638*
5639***LOGIC:
5640*
5641***ASSUMPTIONS:
5642*
5643***NOTE:
5644*
5645* @param pMac Pointer to Global MAC structure
5646* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5647* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5648* @param *pSrcData_buff A pointer of uint8_t src buffer
5649* @param srcDataLen src buffer length
5650******************************************************************************/
5651
5652static void
5653lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5654 uint8_t **pDstData_buff,
5655 uint16_t *pDstDataLen,
5656 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5657{
5658
5659 if (NULL == pSrcData_buff) {
5660 lim_log(pMac, LOGE, FL("src buffer is null."));
5661 return;
5662 }
5663
5664 if (srcDataLen > *pDstDataLen) {
5665 *pDstDataLen = srcDataLen;
5666 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305667 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305669 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670
5671 if (NULL == *pDstData_buff) {
5672 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5673 *pDstDataLen = 0;
5674 return;
5675 }
5676 }
5677
5678 /* copy the content of buffer into dst buffer
5679 */
5680 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305681 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682
5683}
5684
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005685/**
5686 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5687 * @pMac : Pointer to Global MAC structure
5688 * @pDstData_buff : A pointer to pointer of dst buffer
5689 * @pDstDataLen : A pointer to pointer of dst buffer length
5690 * @pModifyIE : A pointer to tSirModifyIE
5691 *
5692 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5693 *
5694 * Return:
5695 * True or false depending upon whether IE is updated or not
5696 */
5697static bool
5698lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5699 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5700{
Hong Shi1553d692016-09-28 12:16:19 +08005701 int32_t oui_length;
5702 uint8_t *ibss_ie = NULL;
5703 uint8_t *vendor_ie;
5704#define MAC_VENDOR_OUI "\x00\x16\x32"
5705#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005706
5707 ibss_ie = pModifyIE->pIEBuffer;
5708 oui_length = pModifyIE->oui_length;
5709
5710 if ((0 == oui_length) || (NULL == ibss_ie)) {
5711 PELOGE(lim_log(pMac, LOGE,
5712 FL("Invalid set IBSS vendor IE command length %d "),
5713 oui_length);)
5714 return false;
5715 }
5716
Hong Shi1553d692016-09-28 12:16:19 +08005717 /*
5718 * Why replace only beacon OUI data here:
5719 * 1. other ie (such as wpa) shall not be overwritten here.
5720 * 2. per spec, beacon oui ie might be set twice and original one
5721 * shall be updated.
5722 */
5723 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5724 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5725 if (vendor_ie) {
5726 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5727 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5728 pModifyIE->ieBufferlength);
5729 } else {
5730 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5731 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005732
Hong Shi1553d692016-09-28 12:16:19 +08005733 if (NULL == new_ptr) {
5734 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5735 return false;
5736 }
5737 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5738 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5739 pModifyIE->ieBufferlength);
5740 qdf_mem_free(*pDstData_buff);
5741 *pDstDataLen = new_length;
5742 *pDstData_buff = new_ptr;
5743 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005744 return true;
5745}
5746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747/*
5748* lim_process_modify_add_ies() - process modify additional IE req.
5749*
5750* @mac_ctx: Pointer to Global MAC structure
5751* @msg_buf: pointer to the SME message buffer
5752*
5753* This function update the PE buffers for additional IEs.
5754*
5755* Return: None
5756*/
5757static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5758 uint32_t *msg_buf)
5759{
5760 tpSirModifyIEsInd modify_add_ies;
5761 tpPESession session_entry;
5762 uint8_t session_id;
5763 bool ret = false;
5764 tSirAddIeParams *add_ie_params;
5765
5766 if (msg_buf == NULL) {
5767 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5768 return;
5769 }
5770
5771 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5772 /* Incoming message has smeSession, use BSSID to find PE session */
5773 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005774 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775
5776 if (NULL == session_entry) {
5777 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5778 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005779 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005780 goto end;
5781 }
5782 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5783 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5784 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5785 lim_log(mac_ctx, LOGE,
5786 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5787 modify_add_ies->modifyIE.pIEBuffer,
5788 modify_add_ies->modifyIE.ieBufferlength,
5789 modify_add_ies->modifyIE.ieID,
5790 modify_add_ies->modifyIE.ieIDLen,
5791 modify_add_ies->updateType);
5792 goto end;
5793 }
5794 add_ie_params = &session_entry->addIeParams;
5795 switch (modify_add_ies->updateType) {
5796 case eUPDATE_IE_PROBE_RESP:
5797 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005798 if (LIM_IS_IBSS_ROLE(session_entry)) {
5799 lim_update_ibss_prop_add_ies(mac_ctx,
5800 &add_ie_params->probeRespData_buff,
5801 &add_ie_params->probeRespDataLen,
5802 &modify_add_ies->modifyIE);
5803 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 break;
5805 case eUPDATE_IE_ASSOC_RESP:
5806 /* assoc resp IE */
5807 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305808 QDF_TRACE(QDF_MODULE_ID_PE,
5809 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810 "assoc resp add ie not present %d"),
5811 add_ie_params->assocRespDataLen);
5812 }
5813 /* search through the buffer and modify the IE */
5814 break;
5815 case eUPDATE_IE_PROBE_BCN:
5816 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005817 if (LIM_IS_IBSS_ROLE(session_entry)) {
5818 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5819 &add_ie_params->probeRespBCNData_buff,
5820 &add_ie_params->probeRespBCNDataLen,
5821 &modify_add_ies->modifyIE);
5822 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 if (ret == true && modify_add_ies->modifyIE.notify) {
5824 lim_handle_param_update(mac_ctx,
5825 modify_add_ies->updateType);
5826 }
5827 break;
5828 default:
5829 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5830 modify_add_ies->updateType);
5831 break;
5832 }
5833end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305834 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 modify_add_ies->modifyIE.pIEBuffer = NULL;
5836}
5837
5838/*
5839* lim_process_update_add_ies() - process additional IE update req
5840*
5841* @mac_ctx: Pointer to Global MAC structure
5842* @msg_buf: pointer to the SME message buffer
5843*
5844* This function update the PE buffers for additional IEs.
5845*
5846* Return: None
5847*/
5848static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5849 uint32_t *msg_buf)
5850{
5851 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5852 uint8_t session_id;
5853 tpPESession session_entry;
5854 tSirAddIeParams *addn_ie;
5855 uint16_t new_length = 0;
5856 uint8_t *new_ptr = NULL;
5857 tSirUpdateIE *update_ie;
5858
5859 if (msg_buf == NULL) {
5860 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5861 return;
5862 }
5863 update_ie = &update_add_ies->updateIE;
5864 /* incoming message has smeSession, use BSSID to find PE session */
5865 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005866 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867
5868 if (NULL == session_entry) {
5869 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5870 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005871 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872 goto end;
5873 }
5874 addn_ie = &session_entry->addIeParams;
5875 /* if len is 0, upper layer requested freeing of buffer */
5876 if (0 == update_ie->ieBufferlength) {
5877 switch (update_add_ies->updateType) {
5878 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305879 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 addn_ie->probeRespData_buff = NULL;
5881 addn_ie->probeRespDataLen = 0;
5882 break;
5883 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305884 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 addn_ie->assocRespData_buff = NULL;
5886 addn_ie->assocRespDataLen = 0;
5887 break;
5888 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305889 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 addn_ie->probeRespBCNData_buff = NULL;
5891 addn_ie->probeRespBCNDataLen = 0;
5892
5893 if (update_ie->notify)
5894 lim_handle_param_update(mac_ctx,
5895 update_add_ies->updateType);
5896 break;
5897 default:
5898 break;
5899 }
5900 return;
5901 }
5902 switch (update_add_ies->updateType) {
5903 case eUPDATE_IE_PROBE_RESP:
5904 if (update_ie->append) {
5905 /*
5906 * In case of append, allocate new memory
5907 * with combined length
5908 */
5909 new_length = update_ie->ieBufferlength +
5910 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305911 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005912 if (NULL == new_ptr) {
5913 lim_log(mac_ctx, LOGE, FL(
5914 "Memory allocation failed."));
5915 goto end;
5916 }
5917 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305918 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305920 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 update_ie->pAdditionIEBuffer,
5922 update_ie->ieBufferlength);
5923 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305924 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925 /* adjust length accordingly */
5926 addn_ie->probeRespDataLen = new_length;
5927 /* save refernece of local buffer in PE session */
5928 addn_ie->probeRespData_buff = new_ptr;
5929 goto end;
5930 }
5931 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5932 &addn_ie->probeRespDataLen,
5933 update_ie->pAdditionIEBuffer,
5934 update_ie->ieBufferlength);
5935 break;
5936 case eUPDATE_IE_ASSOC_RESP:
5937 /* assoc resp IE */
5938 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5939 &addn_ie->assocRespDataLen,
5940 update_ie->pAdditionIEBuffer,
5941 update_ie->ieBufferlength);
5942 break;
5943 case eUPDATE_IE_PROBE_BCN:
5944 /* probe resp Bcn IE */
5945 lim_update_add_ie_buffer(mac_ctx,
5946 &addn_ie->probeRespBCNData_buff,
5947 &addn_ie->probeRespBCNDataLen,
5948 update_ie->pAdditionIEBuffer,
5949 update_ie->ieBufferlength);
5950 if (update_ie->notify)
5951 lim_handle_param_update(mac_ctx,
5952 update_add_ies->updateType);
5953 break;
5954 default:
5955 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5956 update_add_ies->updateType);
5957 break;
5958 }
5959end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305960 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 update_ie->pAdditionIEBuffer = NULL;
5962}
5963
5964/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305965 * send_extended_chan_switch_action_frame()- function to send ECSA
5966 * action frame for each sta connected to SAP/GO and AP in case of
5967 * STA .
5968 * @mac_ctx: pointer to global mac structure
5969 * @new_channel: new channel to switch to.
5970 * @ch_bandwidth: BW of channel to calculate op_class
5971 * @session_entry: pe session
5972 *
5973 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5974 *
5975 * Return: void
5976 */
5977
5978static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5979 uint16_t new_channel, uint8_t ch_bandwidth,
5980 tpPESession session_entry)
5981{
5982 uint16_t op_class;
5983 uint8_t switch_mode = 0, i;
5984 tpDphHashNode psta;
5985
5986
Amar Singhal22995112016-01-22 10:42:33 -08005987 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305988 mac_ctx->scan.countryCodeCurrent,
5989 new_channel,
5990 ch_bandwidth);
5991
5992 if (LIM_IS_AP_ROLE(session_entry) &&
5993 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5994 switch_mode = 1;
5995
5996 if (LIM_IS_AP_ROLE(session_entry)) {
5997 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5998 psta =
5999 session_entry->dph.dphHashTable.pDphNodeArray + i;
6000 if (psta && psta->added)
6001 lim_send_extended_chan_switch_action_frame(
6002 mac_ctx,
6003 psta->staAddr,
6004 switch_mode, op_class, new_channel,
6005 LIM_MAX_CSA_IE_UPDATES, session_entry);
6006 }
6007 } else if (LIM_IS_STA_ROLE(session_entry)) {
6008 lim_send_extended_chan_switch_action_frame(mac_ctx,
6009 session_entry->bssId,
6010 switch_mode, op_class, new_channel,
6011 LIM_MAX_CSA_IE_UPDATES, session_entry);
6012 }
6013
6014}
6015
6016/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
6018 *
6019 * @mac_ctx: Pointer to Global MAC structure
6020 * @msg_buf: pointer to the SME message buffer
6021 *
6022 * This function processes SME request messages from HDD or upper layer
6023 * application.
6024 *
6025 * Return: None
6026 */
6027static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6028 uint32_t *msg_buf)
6029{
6030 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6031 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006032 uint8_t session_id;
6033 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006034 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035
6036 if (msg_buf == NULL) {
6037 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6038 return;
6039 }
6040
6041 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6042 session_entry = pe_find_session_by_bssid(mac_ctx,
6043 dfs_csa_ie_req->bssid, &session_id);
6044 if (session_entry == NULL) {
6045 lim_log(mac_ctx, LOGE, FL(
6046 "Session not found for given BSSID" MAC_ADDRESS_STR),
6047 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6048 return;
6049 }
6050
6051 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6052 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6053 GET_LIM_SYSTEM_ROLE(session_entry));
6054 return;
6055 }
6056
6057 /* target channel */
6058 session_entry->gLimChannelSwitch.primaryChannel =
6059 dfs_csa_ie_req->targetChannel;
6060
6061 /* Channel switch announcement needs to be included in beacon */
6062 session_entry->dfsIncludeChanSwIe = true;
6063 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6064 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006065 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306066 session_entry->gLimChannelSwitch.sec_ch_offset =
6067 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6069 session_entry->gLimChannelSwitch.switchMode = 1;
6070
6071 /*
6072 * Validate if SAP is operating HT or VHT mode and set the Channel
6073 * Switch Wrapper element with the Wide Band Switch subelement.
6074 */
6075 if (true != session_entry->vhtCapability)
6076 goto skip_vht;
6077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006078 /* Now encode the Wider Ch BW element depending on the ch width */
6079 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006080 switch (dfs_csa_ie_req->ch_params.ch_width) {
6081 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 /*
6083 * Wide channel BW sublement in channel wrapper element is not
6084 * required in case of 20 Mhz operation. Currently It is set
6085 * only set in case of 40/80 Mhz Operation.
6086 */
6087 session_entry->dfsIncludeChanWrapperIe = false;
6088 wider_bw_ch_switch->newChanWidth =
6089 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6090 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006091 case CH_WIDTH_40MHZ:
6092 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 wider_bw_ch_switch->newChanWidth =
6094 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6095 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006096 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 session_entry->dfsIncludeChanWrapperIe = true;
6098 wider_bw_ch_switch->newChanWidth =
6099 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6100 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006101 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 session_entry->dfsIncludeChanWrapperIe = true;
6103 wider_bw_ch_switch->newChanWidth =
6104 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6105 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006106 case CH_WIDTH_80P80MHZ:
6107 session_entry->dfsIncludeChanWrapperIe = true;
6108 wider_bw_ch_switch->newChanWidth =
6109 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006110 /*
6111 * This is not applicable for 20/40/80 Mhz.
6112 * Only used when we support 80+80 Mhz operation.
6113 * In case of 80+80 Mhz, this parameter indicates
6114 * center channel frequency index of 80 Mhz channel of
6115 * frequency segment 1.
6116 */
6117 wider_bw_ch_switch->newCenterChanFreq1 =
6118 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006119 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 default:
6121 session_entry->dfsIncludeChanWrapperIe = false;
6122 /*
6123 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6124 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6125 */
6126 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6127 break;
6128 }
6129 /* Fetch the center channel based on the channel width */
6130 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006131 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132skip_vht:
6133 /* Send CSA IE request from here */
6134 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6135 eSIR_SUCCESS) {
6136 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6137 return;
6138 }
6139
6140 /*
6141 * First beacon update request is sent here, the remaining updates are
6142 * done when the FW responds back after sending the first beacon after
6143 * the template update
6144 */
6145 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306146
6147 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6148 ch_offset = BW80;
6149 else
6150 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6151
6152 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6153 session_entry->gLimChannelSwitch.switchCount,
6154 session_entry->gLimChannelSwitch.primaryChannel,
6155 session_entry->gLimChannelSwitch.ch_width,
6156 session_entry->dfsIncludeChanWrapperIe,
6157 ch_offset);
6158
Abhishek Singh518323d2015-10-19 17:42:01 +05306159 /* Send ECSA Action frame after updating the beacon */
6160 send_extended_chan_switch_action_frame(mac_ctx,
6161 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306162 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 session_entry->gLimChannelSwitch.switchCount--;
6164}
6165
6166/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306167 * lim_process_ext_change_channel()- function to send ECSA
6168 * action frame for STA/CLI .
6169 * @mac_ctx: pointer to global mac structure
6170 * @msg: params from sme for new channel.
6171 *
6172 * This function is called to send ECSA frame for STA/CLI.
6173 *
6174 * Return: void
6175 */
6176
6177static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6178 uint32_t *msg)
6179{
6180 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6181 (struct sir_sme_ext_cng_chan_req *) msg;
6182 tpPESession session_entry = NULL;
6183
6184 if (NULL == msg) {
6185 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6186 return;
6187 }
6188 session_entry =
6189 pe_find_session_by_sme_session_id(mac_ctx,
6190 ext_chng_channel->session_id);
6191 if (NULL == session_entry) {
6192 lim_log(mac_ctx, LOGE,
6193 FL("Session not found for given session %d"),
6194 ext_chng_channel->session_id);
6195 return;
6196 }
6197 if (LIM_IS_AP_ROLE(session_entry)) {
6198 lim_log(mac_ctx, LOGE,
6199 FL("not an STA/CLI session"));
6200 return;
6201 }
6202 send_extended_chan_switch_action_frame(mac_ctx,
6203 ext_chng_channel->new_channel,
6204 0, session_entry);
6205}
6206
6207/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 * lim_process_nss_update_request() - process sme nss update req
6209 *
6210 * @mac_ctx: Pointer to Global MAC structure
6211 * @msg_buf: pointer to the SME message buffer
6212 *
6213 * This function processes SME request messages from HDD or upper layer
6214 * application.
6215 *
6216 * Return: None
6217 */
6218static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6219 uint32_t *msg_buf)
6220{
6221 struct sir_nss_update_request *nss_update_req_ptr;
6222 tpPESession session_entry = NULL;
6223
6224 if (msg_buf == NULL) {
6225 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6226 return;
6227 }
6228
6229 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306230 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006231 nss_update_req_ptr->vdev_id);
6232 if (session_entry == NULL) {
6233 lim_log(mac_ctx, LOGE, FL(
6234 "Session not found for given session_id %d"),
6235 nss_update_req_ptr->vdev_id);
6236 return;
6237 }
6238
6239 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6240 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6241 GET_LIM_SYSTEM_ROLE(session_entry));
6242 return;
6243 }
6244
6245 /* populate nss field in the beacon */
6246 session_entry->gLimOperatingMode.present = 1;
6247 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6248 /* Send nss update request from here */
6249 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6250 eSIR_SUCCESS) {
6251 lim_log(mac_ctx, LOGE,
6252 FL("Unable to set op mode IE in beacon"));
6253 return;
6254 }
6255
6256 lim_send_beacon_ind(mac_ctx, session_entry);
6257}
6258
6259/**
6260 * lim_process_set_ie_req() - process sme set IE request
6261 *
6262 * @mac_ctx: Pointer to Global MAC structure
6263 * @msg_buf: pointer to the SME message buffer
6264 *
6265 * This function processes SME request messages from HDD or upper layer
6266 * application.
6267 *
6268 * Return: None
6269 */
6270static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6271{
6272 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306273 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006274
6275 if (msg_buf == NULL) {
6276 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6277 return;
6278 }
6279
6280 msg = (struct send_extcap_ie *)msg_buf;
6281 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306282 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6284
6285}