blob: 10a1e76f74f7b94adce9bd9f056d9eee0a8ffa0f [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 Kumarf7d84422017-01-21 15:45:44 -0800137 struct scheduler_msg message;
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 Kumar416b73f2017-01-21 16:45:21 -0800141 struct scheduler_msg resp_msg;
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 Kumarf7d84422017-01-21 15:45:44 -0800208 struct scheduler_msg message;
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 Kumar416b73f2017-01-21 16:45:21 -0800212 struct scheduler_msg resp_msg;
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 Kumarf7d84422017-01-21 15:45:44 -0800280 struct scheduler_msg message;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 struct sir_antenna_mode_param *req_msg;
282 struct sir_set_antenna_mode *buf;
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800283 struct scheduler_msg resp_msg;
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);
468 return len + sizeof(uint16_t);
469}
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 Kumar416b73f2017-01-21 16:45:21 -0800550 struct scheduler_msg msg;
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 Kumar416b73f2017-01-21 16:45:21 -08001236 struct scheduler_msg msg;
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;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002447 lim_log(pMac, LOGW, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
2448 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 Kumar416b73f2017-01-21 16:45:21 -08003998 struct scheduler_msg msgQ;
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 Kumar416b73f2017-01-21 16:45:21 -08004031 struct scheduler_msg msgQ;
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 Kumar416b73f2017-01-21 16:45:21 -08004097 struct scheduler_msg msgQ;
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 Kumar416b73f2017-01-21 16:45:21 -08004146 struct scheduler_msg wma_msg;
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"));
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304160 return;
4161 }
4162
4163 local_ie_len = req_buffer->assoc_ie.length;
4164 /* Update ext cap IE if present */
4165 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004166 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4167 local_ie_buf, &local_ie_len)) {
4168 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004169 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4170 req_buffer->assoc_ie.length = local_ie_len;
4171 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4172 local_ie_buf, local_ie_len);
4173 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304174 }
4175 qdf_mem_free(local_ie_buf);
4176
4177 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4178 wma_msg.bodyptr = req_buffer;
4179
4180 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4181 if (eSIR_SUCCESS != status) {
4182 lim_log(mac_ctx, LOGE,
4183 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4184 qdf_mem_free(req_buffer);
4185 }
4186}
4187
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304188/*
4189 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4190 * @mac_ctx: Pointer to global mac context
4191 * @session: Pointer to PE session
4192 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4193 * 1 - Disable broadcast SSID
4194 *
4195 * Return: None
4196 */
4197static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4198 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304200 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4201 if (ssid_hidden != session->ssidHidden)
4202 session->ssidHidden = ssid_hidden;
4203 else {
4204 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304205 return;
4206 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207
4208 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304209 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210
4211 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304212 sch_set_fixed_beacon_fields(mac_ctx, session);
4213 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214
4215 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304216}
4217
4218/**
4219 * __lim_process_sme_session_update - process SME session update msg
4220 *
4221 * @mac_ctx: Pointer to global mac context
4222 * @msg_buf: Pointer to the received message buffer
4223 *
4224 * Return: None
4225 */
4226static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4227 uint32_t *msg_buf)
4228{
4229 struct sir_update_session_param *msg;
4230 tpPESession session;
4231
4232 if (!msg_buf) {
4233 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4234 return;
4235 }
4236
4237 msg = (struct sir_update_session_param *) msg_buf;
4238
4239 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4240 if (!session) {
4241 lim_log(mac_ctx, LOGW,
4242 "Session does not exist for given sessionId %d",
4243 msg->session_id);
4244 return;
4245 }
4246
4247 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4248 msg->param_type, msg->param_val);
4249 switch (msg->param_type) {
4250 case SIR_PARAM_SSID_HIDDEN:
4251 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4252 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304253 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4254 session->ignore_assoc_disallowed = msg->param_val;
4255 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304256 default:
4257 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4258 break;
4259 }
4260}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261
4262static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4263{
4264 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4265 tpPESession psessionEntry;
4266 uint8_t sessionId; /* PE sessionID */
4267
4268 if (pMsgBuf == NULL) {
4269 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4270 return;
4271 }
4272
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304273 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 if (NULL == pUpdateAPWPARSNIEsReq) {
4275 lim_log(pMac, LOGP,
4276 FL
4277 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4278 return;
4279 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304280 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4282
4283 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004284 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 &sessionId);
4286 if (psessionEntry == NULL) {
4287 lim_log(pMac, LOGW,
4288 FL("Session does not exist for given BSSID"));
4289 goto end;
4290 }
4291
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304292 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4294
4295 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4296 &psessionEntry->
4297 pLimStartBssReq->rsnIE,
4298 psessionEntry);
4299
4300 psessionEntry->pLimStartBssReq->privacy = 1;
4301 psessionEntry->privacy = 1;
4302
4303 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4304 lim_send_beacon_ind(pMac, psessionEntry);
4305
4306end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304307 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 return;
4309} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4310
4311/*
4312 Update the beacon Interval dynamically if beaconInterval is different in MCC
4313 */
4314static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4315{
4316 tpSirChangeBIParams pChangeBIParams;
4317 tpPESession psessionEntry;
4318 uint8_t sessionId = 0;
4319 tUpdateBeaconParams beaconParams;
4320
4321 PELOG1(lim_log(pMac, LOG1,
4322 FL("received Update Beacon Interval message"));
4323 );
4324
4325 if (pMsgBuf == NULL) {
4326 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4327 return;
4328 }
4329
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304330 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4332
4333 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004334 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 &sessionId);
4336 if (psessionEntry == NULL) {
4337 lim_log(pMac, LOGE,
4338 FL("Session does not exist for given BSSID"));
4339 return;
4340 }
4341
4342 /*Update sessionEntry Beacon Interval */
4343 if (psessionEntry->beaconParams.beaconInterval !=
4344 pChangeBIParams->beaconInterval) {
4345 psessionEntry->beaconParams.beaconInterval =
4346 pChangeBIParams->beaconInterval;
4347 }
4348
4349 /*Update sch beaconInterval */
4350 if (pMac->sch.schObject.gSchBeaconInterval !=
4351 pChangeBIParams->beaconInterval) {
4352 pMac->sch.schObject.gSchBeaconInterval =
4353 pChangeBIParams->beaconInterval;
4354
4355 PELOG1(lim_log(pMac, LOG1,
4356 FL
4357 ("LIM send update BeaconInterval Indication : %d"),
4358 pChangeBIParams->beaconInterval);
4359 );
4360
4361 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4362 /* Update beacon */
4363 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4364
4365 beaconParams.bssIdx = psessionEntry->bssIdx;
4366 /* Set change in beacon Interval */
4367 beaconParams.beaconInterval =
4368 pChangeBIParams->beaconInterval;
4369 beaconParams.paramChangeBitmap =
4370 PARAM_BCN_INTERVAL_CHANGED;
4371 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4372 }
4373 }
4374
4375 return;
4376} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4377
4378#ifdef QCA_HT_2040_COEX
4379static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4380 uint32_t *pMsgBuf)
4381{
4382 tpSirSetHT2040Mode pSetHT2040Mode;
4383 tpPESession psessionEntry;
4384 uint8_t sessionId = 0;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004385 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 tUpdateVHTOpMode *pHtOpMode = NULL;
4387 uint16_t staId = 0;
4388 tpDphHashNode pStaDs = NULL;
4389
4390 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4391 if (pMsgBuf == NULL) {
4392 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4393 return;
4394 }
4395
4396 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4397
4398 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004399 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 &sessionId);
4401 if (psessionEntry == NULL) {
4402 lim_log(pMac, LOG1,
4403 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004404 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 return;
4406 }
4407
4408 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4409 pSetHT2040Mode->cbMode);
4410 /*Update sessionEntry HT related fields */
4411 switch (pSetHT2040Mode->cbMode) {
4412 case PHY_SINGLE_CHANNEL_CENTERED:
4413 psessionEntry->htSecondaryChannelOffset =
4414 PHY_SINGLE_CHANNEL_CENTERED;
4415 psessionEntry->htRecommendedTxWidthSet = 0;
4416 if (pSetHT2040Mode->obssEnabled)
4417 psessionEntry->htSupportedChannelWidthSet
4418 = eHT_CHANNEL_WIDTH_40MHZ;
4419 else
4420 psessionEntry->htSupportedChannelWidthSet
4421 = eHT_CHANNEL_WIDTH_20MHZ;
4422 break;
4423 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4424 psessionEntry->htSecondaryChannelOffset =
4425 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4426 psessionEntry->htRecommendedTxWidthSet = 1;
4427 break;
4428 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4429 psessionEntry->htSecondaryChannelOffset =
4430 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4431 psessionEntry->htRecommendedTxWidthSet = 1;
4432 break;
4433 default:
4434 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4435 return;
4436 }
4437
4438 /* Update beacon */
4439 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4440 lim_send_beacon_ind(pMac, psessionEntry);
4441
4442 /* update OP Mode for each associated peer */
4443 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4444 pStaDs = dph_get_hash_entry(pMac, staId,
4445 &psessionEntry->dph.dphHashTable);
4446 if (NULL == pStaDs)
4447 continue;
4448
4449 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304450 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 if (NULL == pHtOpMode) {
4452 lim_log(pMac, LOGE,
4453 FL
4454 ("%s: Not able to allocate memory for setting OP mode"),
4455 __func__);
4456 return;
4457 }
4458 pHtOpMode->opMode =
4459 (psessionEntry->htSecondaryChannelOffset ==
4460 PHY_SINGLE_CHANNEL_CENTERED) ?
4461 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4462 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304463 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 sizeof(tSirMacAddr));
4465 pHtOpMode->smesessionId = sessionId;
4466
4467 msg.type = WMA_UPDATE_OP_MODE;
4468 msg.reserved = 0;
4469 msg.bodyptr = pHtOpMode;
Krunal Soni66c113f2016-12-21 16:46:47 -08004470 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004471 scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08004472 &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 lim_log(pMac, LOGE,
4474 FL
4475 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4476 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304477 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 return;
4479 }
4480 lim_log(pMac, LOG1,
4481 FL
4482 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4483 __func__, pHtOpMode->opMode, staId);
4484
4485 } else
4486 lim_log(pMac, LOG1,
4487 FL("%s: station %d does not support HT40\n"),
4488 __func__, staId);
4489 }
4490
4491 return;
4492}
4493#endif
4494
4495/* -------------------------------------------------------------------- */
4496/**
4497 * __lim_process_report_message
4498 *
4499 * FUNCTION: Processes the next received Radio Resource Management message
4500 *
4501 * LOGIC:
4502 *
4503 * ASSUMPTIONS:
4504 *
4505 * NOTE:
4506 *
4507 * @param None
4508 * @return None
4509 */
4510
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004511static void __lim_process_report_message(tpAniSirGlobal pMac,
4512 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 switch (pMsg->type) {
4515 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4516 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4517 break;
4518 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004520 break;
4521 default:
4522 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524}
4525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526/* -------------------------------------------------------------------- */
4527/**
4528 * lim_send_set_max_tx_power_req
4529 *
4530 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4531 *
4532 * LOGIC:
4533 *
4534 * ASSUMPTIONS:
4535 *
4536 * NOTE:
4537 *
4538 * @param txPower txPower to be set.
4539 * @param pSessionEntry session entry.
4540 * @return None
4541 */
4542tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004543lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544 tpPESession pSessionEntry)
4545{
4546 tpMaxTxPowerParams pMaxTxParams = NULL;
4547 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004548 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549
4550 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304551 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552 return eSIR_FAILURE;
4553 }
4554
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304555 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 if (NULL == pMaxTxParams) {
4557 lim_log(pMac, LOGP,
4558 FL("Unable to allocate memory for pMaxTxParams "));
4559 return eSIR_MEM_ALLOC_FAILED;
4560
4561 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304563 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304564 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304565 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004566 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304567 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568
4569 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4570 msgQ.bodyptr = pMaxTxParams;
4571 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304572 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4574 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4575 if (eSIR_SUCCESS != retCode) {
4576 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304577 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 }
4579 return retCode;
4580}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581
4582/**
4583 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4584 *
4585 * @mac_ctx: Pointer to Global MAC structure
4586 * @msg_buf: pointer to the SME message buffer
4587 *
4588 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4589 * from SME. It Register this information within PE.
4590 *
4591 * Return: None
4592 */
4593static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4594 uint32_t *msg_buf)
4595{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304596 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4598 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4599 struct mgmt_frm_reg_info *next = NULL;
4600 bool match = false;
4601
4602 lim_log(mac_ctx, LOG1, FL(
4603 "registerFrame %d, frameType %d, matchLen %d"),
4604 sme_req->registerFrame, sme_req->frameType,
4605 sme_req->matchLen);
4606 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304607 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304608 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4609 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304610 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611
4612 while (lim_mgmt_regn != NULL) {
4613 if (lim_mgmt_regn->frameType != sme_req->frameType)
4614 goto skip_match;
4615 if (sme_req->matchLen) {
4616 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304617 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 sme_req->matchData,
4619 lim_mgmt_regn->matchLen))) {
4620 /* found match! */
4621 match = true;
4622 break;
4623 }
4624 } else {
4625 /* found match! */
4626 match = true;
4627 break;
4628 }
4629skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304630 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304631 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304633 (qdf_list_node_t *)lim_mgmt_regn,
4634 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304635 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 lim_mgmt_regn = next;
4637 next = NULL;
4638 }
4639 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304640 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004641 if (QDF_STATUS_SUCCESS ==
4642 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004644 (qdf_list_node_t *)lim_mgmt_regn))
4645 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304646 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 }
4648
4649 if (sme_req->registerFrame) {
4650 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304651 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 sme_req->matchLen);
4653 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 lim_mgmt_regn->frameType = sme_req->frameType;
4655 lim_mgmt_regn->matchLen = sme_req->matchLen;
4656 lim_mgmt_regn->sessionId = sme_req->sessionId;
4657 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304658 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 sme_req->matchData,
4660 sme_req->matchLen);
4661 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304662 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304664 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 gLimMgmtFrameRegistratinQueue,
4666 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304667 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 &mac_ctx->lim.lim_frame_register_lock);
4669 }
4670 }
4671 return;
4672}
4673
4674static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4675{
4676 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4677 pMac->lim.gDeferMsgTypeForNOA);
4678 pMac->lim.gDeferMsgTypeForNOA = 0;
4679 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4680 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304681 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4683 }
4684}
4685
4686/**
4687 * lim_process_regd_defd_sme_req_after_noa_start()
4688 *
4689 * mac_ctx: Pointer to Global MAC structure
4690 *
4691 * This function is called to process deferred sme req message
4692 * after noa start.
4693 *
4694 * Return: None
4695 */
4696void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4697{
4698 bool buf_consumed = true;
4699
4700 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4701 mac_ctx->lim.gDeferMsgTypeForNOA);
4702
4703 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4704 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4705 lim_log(mac_ctx, LOGW,
4706 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4707 lim_log(mac_ctx, LOGW,
4708 FL("It may happen when NOA start ind and timeout happen at the same time"));
4709 return;
4710 }
4711 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4712 case eWNI_SME_SCAN_REQ:
4713 __lim_process_sme_scan_req(mac_ctx,
4714 mac_ctx->lim.gpDefdSmeMsgForNOA);
4715 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4717 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4718 mac_ctx->lim.gpDefdSmeMsgForNOA);
4719 /*
4720 * lim_process_remain_on_chnl_req doesnt want us to free
4721 * the buffer since it is freed in lim_remain_on_chn_rsp.
4722 * this change is to avoid "double free"
4723 */
4724 if (false == buf_consumed)
4725 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4726 break;
4727 case eWNI_SME_JOIN_REQ:
4728 __lim_process_sme_join_req(mac_ctx,
4729 mac_ctx->lim.gpDefdSmeMsgForNOA);
4730 break;
4731 default:
4732 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4733 mac_ctx->lim.gDeferMsgTypeForNOA);
4734 break;
4735 }
4736 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4737}
4738
4739static void
4740__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4741{
4742 tpSirResetAPCapsChange pResetCapsChange;
4743 tpPESession psessionEntry;
4744 uint8_t sessionId = 0;
4745 if (pMsgBuf == NULL) {
4746 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4747 return;
4748 }
4749
4750 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4751 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004752 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4753 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 if (psessionEntry == NULL) {
4755 lim_log(pMac, LOGE,
4756 FL("Session does not exist for given BSSID"));
4757 return;
4758 }
4759
4760 psessionEntry->limSentCapsChangeNtf = false;
4761 return;
4762}
4763
4764/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304765 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4766 * @mac_ctx: Mac pointer
4767 * @msg_buf: Msg pointer containing the callback
4768 *
4769 * This function is used to save the p2p ack indication callback in PE.
4770 *
4771 * Return: None
4772 */
4773static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4774 uint32_t *msg_buf)
4775{
4776 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4777 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4778
4779 if (NULL == msg_buf) {
4780 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4781 return;
4782 }
4783 if (sme_req->callback)
4784 mac_ctx->p2p_ack_ind_cb =
4785 sme_req->callback;
4786 else
4787 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4788}
4789
4790/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304791 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4792 * indication callback in PE.
4793 * @mac_ptr: Mac pointer
4794 * @msg_buf: Msg pointer containing the callback
4795 *
4796 * This function is used save the Management frame
4797 * indication callback in PE.
4798 *
4799 * Return: None
4800 */
4801static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4802 uint32_t *msg_buf)
4803{
4804 struct sir_sme_mgmt_frame_cb_req *sme_req =
4805 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4806
4807 if (NULL == msg_buf) {
4808 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4809 return;
4810 }
4811 if (sme_req->callback)
4812 mac_ctx->mgmt_frame_ind_cb =
4813 (sir_mgmt_frame_ind_callback)sme_req->callback;
4814 else
4815 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4816}
4817
4818/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304819 *__lim_process_send_disassoc_frame: function processes disassoc frame
4820 * @mac_ctx: pointer to mac context
4821 * @msg_buf: message buffer
4822 *
4823 * function processes disassoc request received from SME
4824 *
4825 * return: none
4826 */
4827static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4828 uint32_t *msg_buf)
4829{
4830 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4831 tSirRetStatus status;
4832 tpPESession session_entry = NULL;
4833 uint8_t sme_session_id;
4834 uint16_t sme_trans_id;
4835
4836 if (msg_buf == NULL) {
4837 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4838 return;
4839 }
4840
4841 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4842 &sme_trans_id);
4843
4844 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4845 &sme_send_disassoc_frame_req,
4846 (uint8_t *)msg_buf);
4847
4848 if ((eSIR_FAILURE == status) ||
4849 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4850 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4851 PELOGE(lim_log(mac_ctx, LOGE,
4852 FL("received invalid SME_DISASSOC_REQ message"));)
4853 return;
4854 }
4855
4856 session_entry = pe_find_session_by_sme_session_id(
4857 mac_ctx, sme_session_id);
4858 if (session_entry == NULL) {
4859 lim_log(mac_ctx, LOGE,
4860 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4861 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4862 return;
4863 }
4864
4865 lim_log(mac_ctx, LOG1,
4866 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4867 sme_send_disassoc_frame_req.msg_type,
4868 sme_send_disassoc_frame_req.length,
4869 sme_send_disassoc_frame_req.session_id,
4870 sme_send_disassoc_frame_req.trans_id,
4871 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4872 sme_send_disassoc_frame_req.reason,
4873 sme_send_disassoc_frame_req.wait_for_ack);
4874
4875 lim_send_disassoc_mgmt_frame(mac_ctx,
4876 sme_send_disassoc_frame_req.reason,
4877 sme_send_disassoc_frame_req.peer_mac,
4878 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4879}
4880
4881/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004882 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4883 * @mac_ctx: Pointer to Global MAC structure
4884 * @pdev_id: pdev id to set the IE.
4885 * @nss: Nss values to prepare the HT IE.
4886 *
4887 * Prepares the HT IE with self capabilities for different
4888 * Nss values and sends the set HT IE req to FW.
4889 *
4890 * Return: None
4891 */
4892static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4893 uint8_t nss)
4894{
4895 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004896 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004897 tSirRetStatus rc = eSIR_SUCCESS;
4898 uint8_t *p_ie = NULL;
4899 tHtCaps *p_ht_cap;
4900 int i;
4901
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004902 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004903 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4904 if (NULL == ie_params) {
4905 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4906 return;
4907 }
4908 ie_params->nss = i;
4909 ie_params->pdev_id = pdev_id;
4910 ie_params->ie_type = DOT11_HT_IE;
4911 /* 2 for IE len and EID */
4912 ie_params->ie_len = 2 + sizeof(tHtCaps);
4913 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4914 if (NULL == ie_params->ie_ptr) {
4915 qdf_mem_free(ie_params);
4916 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4917 return;
4918 }
4919 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4920 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4921 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4922 ie_params->ie_len);
4923
4924 if (NSS_1x1_MODE == i) {
4925 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4926 ie_params->ie_len,
4927 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004928 if (NULL == p_ie) {
4929 qdf_mem_free(ie_params->ie_ptr);
4930 qdf_mem_free(ie_params);
4931 lim_log(mac_ctx, LOGE,
4932 FL("failed to get IE ptr"));
4933 return;
4934 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004935 p_ht_cap = (tHtCaps *)&p_ie[2];
4936 p_ht_cap->supportedMCSSet[1] = 0;
4937 p_ht_cap->txSTBC = 0;
4938 }
4939
4940 msg.type = WMA_SET_PDEV_IE_REQ;
4941 msg.bodyptr = ie_params;
4942 msg.bodyval = 0;
4943
4944 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4945 if (rc != eSIR_SUCCESS) {
4946 lim_log(mac_ctx, LOGE,
4947 FL("wma_post_ctrl_msg() return failure"));
4948 qdf_mem_free(ie_params->ie_ptr);
4949 qdf_mem_free(ie_params);
4950 return;
4951 }
4952 }
4953}
4954
4955/**
4956 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4957 * @mac_ctx: Pointer to Global MAC structure
4958 * @pdev_id: pdev id to set the IE.
4959 * @nss: Nss values to prepare the VHT IE.
4960 *
4961 * Prepares the VHT IE with self capabilities for different
4962 * Nss values and sends the set VHT IE req to FW.
4963 *
4964 * Return: None
4965 */
4966static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4967 uint8_t nss)
4968{
4969 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004970 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004971 tSirRetStatus rc = eSIR_SUCCESS;
4972 uint8_t *p_ie = NULL;
4973 tSirMacVHTCapabilityInfo *vht_cap;
4974 int i;
4975 tSirVhtMcsInfo *vht_mcs;
4976
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004977 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004978 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4979 if (NULL == ie_params) {
4980 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4981 return;
4982 }
4983 ie_params->nss = i;
4984 ie_params->pdev_id = pdev_id;
4985 ie_params->ie_type = DOT11_VHT_IE;
4986 /* 2 for IE len and EID */
4987 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4988 sizeof(tSirVhtMcsInfo);
4989 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4990 if (NULL == ie_params->ie_ptr) {
4991 qdf_mem_free(ie_params);
4992 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4993 return;
4994 }
4995 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4996 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4997 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4998 ie_params->ie_len);
4999
5000 if (NSS_1x1_MODE == i) {
5001 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
5002 ie_params->ie_len,
5003 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07005004 if (NULL == p_ie) {
5005 qdf_mem_free(ie_params->ie_ptr);
5006 qdf_mem_free(ie_params);
5007 lim_log(mac_ctx, LOGE,
5008 FL("failed to get IE ptr"));
5009 return;
5010 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005011 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5012 vht_cap->txSTBC = 0;
5013 vht_mcs =
5014 (tSirVhtMcsInfo *)&p_ie[2 +
5015 sizeof(tSirMacVHTCapabilityInfo)];
5016 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5017 vht_mcs->rxHighest =
5018 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5019 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5020 vht_mcs->txHighest =
5021 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5022 }
5023 msg.type = WMA_SET_PDEV_IE_REQ;
5024 msg.bodyptr = ie_params;
5025 msg.bodyval = 0;
5026
5027 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5028 if (rc != eSIR_SUCCESS) {
5029 lim_log(mac_ctx, LOGE,
5030 FL("wma_post_ctrl_msg failure"));
5031 qdf_mem_free(ie_params->ie_ptr);
5032 qdf_mem_free(ie_params);
5033 return;
5034 }
5035 }
5036}
5037
5038/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005039 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5040 * @mac_ctx: Pointer to Global MAC structure
5041 * @msg_buf: Pointer to the SME message buffer
5042 *
5043 * This function is called by limProcessMessageQueue(). This function sets the
5044 * VDEV IEs to the FW.
5045 *
5046 * Return: None
5047 */
5048static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5049 uint32_t *msg_buf)
5050{
5051 struct sir_set_vdev_ies_per_band *p_msg =
5052 (struct sir_set_vdev_ies_per_band *)msg_buf;
5053
5054 if (NULL == p_msg) {
5055 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5056 return;
5057 }
5058
5059 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5060 p_msg->vdev_id);
5061 /* intentionally using NULL here so that self capabilty are sent */
5062 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5063 QDF_STATUS_SUCCESS)
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08005064 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT/HE IE to FW"));
Naveen Rawata410c5a2016-09-19 14:22:33 -07005065}
5066
5067/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005068 * lim_process_set_pdev_IEs() - process the set pdev IE req
5069 * @mac_ctx: Pointer to Global MAC structure
5070 * @msg_buf: Pointer to the SME message buffer
5071 *
5072 * This function is called by limProcessMessageQueue(). This
5073 * function sets the PDEV IEs to the FW.
5074 *
5075 * Return: None
5076 */
5077static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5078{
5079 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5080
5081 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5082
5083 if (NULL == ht_vht_cfg) {
5084 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5085 return;
5086 }
5087
5088 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5089 ht_vht_cfg->nss);
5090 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5091
5092 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5093 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5094 ht_vht_cfg->nss);
5095}
5096
5097/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305098 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5099 *
5100 * access policy
5101 * @mac_ctx: pointer to mac context
5102 * @msg: message buffer
5103 *
5104 * function processes vendor IE and access policy from SME and updates PE
5105 *
5106 * session entry
5107 *
5108 * return: none
5109*/
5110static void lim_process_sme_update_access_policy_vendor_ie(
5111 tpAniSirGlobal mac_ctx,
5112 uint32_t *msg)
5113{
5114 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5115 struct sPESession *pe_session_entry;
5116 uint8_t num_bytes;
5117
5118 if (!msg) {
5119 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5120 return;
5121 }
5122 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5123 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5124 update_vendor_ie->sme_session_id);
5125
5126 if (!pe_session_entry) {
5127 lim_log(mac_ctx, LOGE,
5128 FL("Session does not exist for given sme session id(%hu)"),
5129 update_vendor_ie->sme_session_id);
5130 return;
5131 }
5132 if (pe_session_entry->access_policy_vendor_ie)
5133 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5134
5135 num_bytes = update_vendor_ie->ie[1] + 2;
5136 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5137
5138 if (!pe_session_entry->access_policy_vendor_ie) {
5139 lim_log(mac_ctx, LOGE,
5140 FL("Failed to allocate memory for vendor ie"));
5141 return;
5142 }
5143 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5144 &update_vendor_ie->ie[0], num_bytes);
5145
5146 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5147}
5148
5149/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 * lim_process_sme_req_messages()
5151 *
5152 ***FUNCTION:
5153 * This function is called by limProcessMessageQueue(). This
5154 * function processes SME request messages from HDD or upper layer
5155 * application.
5156 *
5157 ***LOGIC:
5158 *
5159 ***ASSUMPTIONS:
5160 *
5161 ***NOTE:
5162 *
5163 * @param pMac Pointer to Global MAC structure
5164 * @param msgType Indicates the SME message type
5165 * @param *pMsgBuf A pointer to the SME message buffer
5166 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5167 * false - if pMsgBuf is not to be freed.
5168 */
5169
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005170bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5171 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172{
5173 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5174 uint32_t *pMsgBuf = pMsg->bodyptr;
5175 tpSirSmeScanReq pScanReq;
5176 PELOG1(lim_log
5177 (pMac, LOG1,
5178 FL
5179 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5180 lim_msg_str(pMsg->type), pMsg->type,
5181 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5182 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5183 )
5184
5185 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5186 /* If no insert NOA required then execute the code below */
5187
5188 switch (pMsg->type) {
5189 case eWNI_SME_SYS_READY_IND:
5190 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5191 break;
5192
5193 case eWNI_SME_START_BSS_REQ:
5194 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5195 break;
5196
5197 case eWNI_SME_SCAN_REQ:
5198 __lim_process_sme_scan_req(pMac, pMsgBuf);
5199 break;
5200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5202 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5203 break;
5204
5205 case eWNI_SME_UPDATE_NOA:
5206 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5207 break;
5208 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5209 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5210 break;
5211 case eWNI_SME_JOIN_REQ:
5212 __lim_process_sme_join_req(pMac, pMsgBuf);
5213 break;
5214
5215 case eWNI_SME_REASSOC_REQ:
5216 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5217 break;
5218
5219 case eWNI_SME_DISASSOC_REQ:
5220 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5221 break;
5222
5223 case eWNI_SME_DISASSOC_CNF:
5224 case eWNI_SME_DEAUTH_CNF:
5225 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5226 break;
5227
5228 case eWNI_SME_DEAUTH_REQ:
5229 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5230 break;
5231
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305232 case eWNI_SME_SEND_DISASSOC_FRAME:
5233 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5234 break;
5235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 case eWNI_SME_SETCONTEXT_REQ:
5237 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5238 break;
5239
5240 case eWNI_SME_STOP_BSS_REQ:
5241 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5242 break;
5243
5244 case eWNI_SME_ASSOC_CNF:
5245 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5246 PELOG1(lim_log(pMac,
5247 LOG1, FL("Received ASSOC_CNF message"));)
5248 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5249 pMsgBuf);
5250 break;
5251
5252 case eWNI_SME_ADDTS_REQ:
5253 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5254 __lim_process_sme_addts_req(pMac, pMsgBuf);
5255 break;
5256
5257 case eWNI_SME_DELTS_REQ:
5258 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5259 __lim_process_sme_delts_req(pMac, pMsgBuf);
5260 break;
5261
5262 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5263 PELOG1(lim_log
5264 (pMac, LOG1,
5265 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5266 )
5267 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5268 break;
5269
5270 case eWNI_SME_GET_STATISTICS_REQ:
5271 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5272 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5273 bufConsumed = false;
5274 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005275#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 case eWNI_SME_GET_TSM_STATS_REQ:
5277 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5278 bufConsumed = false;
5279 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005280#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 case eWNI_SME_GET_ASSOC_STAS_REQ:
5282 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5283 break;
5284 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5285 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5286 break;
5287
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305288 case eWNI_SME_SESSION_UPDATE_PARAM:
5289 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305291 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5292 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5293 bufConsumed = false;
5294 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 case eWNI_SME_UPDATE_APWPSIE_REQ:
5296 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5297 break;
5298 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5299 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5300 break;
5301
5302 case eWNI_SME_SET_APWPARSNIEs_REQ:
5303 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5304 break;
5305
5306 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5307 /* Update the beaconInterval */
5308 __lim_process_sme_change_bi(pMac, pMsgBuf);
5309 break;
5310
5311#ifdef QCA_HT_2040_COEX
5312 case eWNI_SME_SET_HT_2040_MODE:
5313 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5314 break;
5315#endif
5316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5318 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5319 __lim_process_report_message(pMac, pMsg);
5320 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 case eWNI_SME_FT_PRE_AUTH_REQ:
5323 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5324 break;
5325 case eWNI_SME_FT_UPDATE_KEY:
5326 lim_process_ft_update_key(pMac, pMsgBuf);
5327 break;
5328
5329 case eWNI_SME_FT_AGGR_QOS_REQ:
5330 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5331 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332
5333 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5334 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5335 break;
5336#ifdef FEATURE_WLAN_TDLS
5337 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5338 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5339 break;
5340 case eWNI_SME_TDLS_ADD_STA_REQ:
5341 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5342 break;
5343 case eWNI_SME_TDLS_DEL_STA_REQ:
5344 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5345 break;
5346 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5347 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5348 break;
5349#endif
5350 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5351 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5352 break;
5353
5354 case eWNI_SME_CHANNEL_CHANGE_REQ:
5355 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5356 break;
5357
5358 case eWNI_SME_START_BEACON_REQ:
5359 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5360 break;
5361
5362 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5363 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5364 break;
5365
5366 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5367 lim_process_update_add_ies(pMac, pMsgBuf);
5368 break;
5369
5370 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5371 lim_process_modify_add_ies(pMac, pMsgBuf);
5372 break;
5373 case eWNI_SME_SET_HW_MODE_REQ:
5374 lim_process_set_hw_mode(pMac, pMsgBuf);
5375 break;
5376 case eWNI_SME_NSS_UPDATE_REQ:
5377 lim_process_nss_update_request(pMac, pMsgBuf);
5378 break;
5379 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5380 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5381 break;
5382 case eWNI_SME_SET_IE_REQ:
5383 lim_process_set_ie_req(pMac, pMsgBuf);
5384 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305385 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5386 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5387 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305388 case eWNI_SME_EXT_CHANGE_CHANNEL:
5389 lim_process_ext_change_channel(pMac, pMsgBuf);
5390 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005391 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5392 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5393 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005394 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5395 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005396 break;
5397 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5398 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5399 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005400 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005401 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005402 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005403 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005404 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305405 case eWNI_SME_REGISTER_P2P_ACK_CB:
5406 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5407 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305408 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5409 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5410 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305412 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 pMsg->bodyptr = NULL;
5414 break;
5415 } /* switch (msgType) */
5416
5417 return bufConsumed;
5418} /*** end lim_process_sme_req_messages() ***/
5419
5420/**
5421 * lim_process_sme_start_beacon_req()
5422 *
5423 ***FUNCTION:
5424 * This function is called by limProcessMessageQueue(). This
5425 * function processes SME request messages from HDD or upper layer
5426 * application.
5427 *
5428 ***LOGIC:
5429 *
5430 ***ASSUMPTIONS:
5431 *
5432 ***NOTE:
5433 *
5434 * @param pMac Pointer to Global MAC structure
5435 * @param msgType Indicates the SME message type
5436 * @param *pMsgBuf A pointer to the SME message buffer
5437 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5438 * false - if pMsgBuf is not to be freed.
5439 */
5440static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5441{
5442 tpSirStartBeaconIndication pBeaconStartInd;
5443 tpPESession psessionEntry;
5444 uint8_t sessionId; /* PE sessionID */
5445
5446 if (pMsg == NULL) {
5447 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5448 return;
5449 }
5450
5451 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5452 psessionEntry = pe_find_session_by_bssid(pMac,
5453 pBeaconStartInd->bssid,
5454 &sessionId);
5455 if (psessionEntry == NULL) {
5456 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5457 lim_log(pMac, LOGE,
5458 FL("Session does not exist for given bssId"));
5459 return;
5460 }
5461
5462 if (pBeaconStartInd->beaconStartStatus == true) {
5463 /*
5464 * Currently this Indication comes from SAP
5465 * to start Beacon Tx on a DFS channel
5466 * since beaconing has to be done on DFS
5467 * channel only after CAC WAIT is completed.
5468 * On a DFS Channel LIM does not start beacon
5469 * Tx right after the WMA_ADD_BSS_RSP.
5470 */
5471 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305472 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 FL("Start Beacon with ssid %s Ch %d"),
5474 psessionEntry->ssId.ssId,
5475 psessionEntry->currentOperChannel);
5476 lim_send_beacon_ind(pMac, psessionEntry);
5477 } else {
5478 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5479 return;
5480 }
5481}
5482
5483/**
5484 * lim_process_sme_channel_change_request() - process sme ch change req
5485 *
5486 * @mac_ctx: Pointer to Global MAC structure
5487 * @msg_buf: pointer to the SME message buffer
5488 *
5489 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5490 *
5491 * Return: None
5492 */
5493static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5494 uint32_t *msg_buf)
5495{
5496 tpSirChanChangeRequest ch_change_req;
5497 tpPESession session_entry;
5498 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005499 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 uint32_t val = 0;
5501
5502 if (msg_buf == NULL) {
5503 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5504 return;
5505 }
5506 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5507
5508 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5509 ch_change_req->targetChannel);
5510
5511 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5512 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5513 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5514 return;
5515 }
5516
5517 session_entry = pe_find_session_by_bssid(mac_ctx,
5518 ch_change_req->bssid, &session_id);
5519 if (session_entry == NULL) {
5520 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5521 lim_log(mac_ctx, LOGE, FL(
5522 "Session does not exist for given bssId"));
5523 return;
5524 }
5525
5526 if (session_entry->currentOperChannel ==
5527 ch_change_req->targetChannel) {
5528 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5529 return;
5530 }
5531
5532 if (LIM_IS_AP_ROLE(session_entry))
5533 session_entry->channelChangeReasonCode =
5534 LIM_SWITCH_CHANNEL_SAP_DFS;
5535 else
5536 session_entry->channelChangeReasonCode =
5537 LIM_SWITCH_CHANNEL_OPERATION;
5538
5539 lim_log(mac_ctx, LOGW, FL(
5540 "switch old chnl %d to new chnl %d, ch_bw %d"),
5541 session_entry->currentOperChannel,
5542 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005543 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544
5545 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005546 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005547 session_entry->ch_center_freq_seg0 =
5548 ch_change_req->center_freq_seg_0;
5549 session_entry->ch_center_freq_seg1 =
5550 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005551 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005553 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 session_entry->htRecommendedTxWidthSet =
5555 session_entry->htSupportedChannelWidthSet;
5556 session_entry->currentOperChannel =
5557 ch_change_req->targetChannel;
5558 session_entry->limRFBand =
5559 lim_get_rf_band(session_entry->currentOperChannel);
5560 /* Initialize 11h Enable Flag */
5561 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5562 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5563 eSIR_SUCCESS)
5564 lim_log(mac_ctx, LOGP,
5565 FL("Fail to get WNI_CFG_11H_ENABLED"));
5566 }
5567
5568 session_entry->lim11hEnable = val;
5569 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305570 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571 &ch_change_req->operational_rateset,
5572 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305573 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 &ch_change_req->extended_rateset,
5575 sizeof(session_entry->extRateSet));
5576 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5577 session_entry->ch_center_freq_seg0,
5578 session_entry->ch_center_freq_seg1,
5579 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005580 max_tx_pwr, session_entry->peSessionId,
5581 ch_change_req->cac_duration_ms,
5582 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583}
5584
5585/******************************************************************************
5586* lim_start_bss_update_add_ie_buffer()
5587*
5588***FUNCTION:
5589* This function checks the src buffer and its length and then malloc for
5590* dst buffer update the same
5591*
5592***LOGIC:
5593*
5594***ASSUMPTIONS:
5595*
5596***NOTE:
5597*
5598* @param pMac Pointer to Global MAC structure
5599* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5600* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5601* @param *pSrcData_buff A pointer of uint8_t src buffer
5602* @param srcDataLen src buffer length
5603******************************************************************************/
5604
5605static void
5606lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5607 uint8_t **pDstData_buff,
5608 uint16_t *pDstDataLen,
5609 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5610{
5611
5612 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5613 *pDstDataLen = srcDataLen;
5614
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305615 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616
5617 if (NULL == *pDstData_buff) {
5618 lim_log(pMac, LOGE,
5619 FL("AllocateMemory failed for pDstData_buff"));
5620 return;
5621 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305622 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 } else {
5624 *pDstData_buff = NULL;
5625 *pDstDataLen = 0;
5626 }
5627}
5628
5629/******************************************************************************
5630* lim_update_add_ie_buffer()
5631*
5632***FUNCTION:
5633* This function checks the src buffer and length if src buffer length more
5634* than dst buffer length then free the dst buffer and malloc for the new src
5635* length, and update the dst buffer and length. But if dst buffer is bigger
5636* than src buffer length then it just update the dst buffer and length
5637*
5638***LOGIC:
5639*
5640***ASSUMPTIONS:
5641*
5642***NOTE:
5643*
5644* @param pMac Pointer to Global MAC structure
5645* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5646* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5647* @param *pSrcData_buff A pointer of uint8_t src buffer
5648* @param srcDataLen src buffer length
5649******************************************************************************/
5650
5651static void
5652lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5653 uint8_t **pDstData_buff,
5654 uint16_t *pDstDataLen,
5655 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5656{
5657
5658 if (NULL == pSrcData_buff) {
5659 lim_log(pMac, LOGE, FL("src buffer is null."));
5660 return;
5661 }
5662
5663 if (srcDataLen > *pDstDataLen) {
5664 *pDstDataLen = srcDataLen;
5665 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305666 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305668 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669
5670 if (NULL == *pDstData_buff) {
5671 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5672 *pDstDataLen = 0;
5673 return;
5674 }
5675 }
5676
5677 /* copy the content of buffer into dst buffer
5678 */
5679 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305680 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681
5682}
5683
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005684/**
5685 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5686 * @pMac : Pointer to Global MAC structure
5687 * @pDstData_buff : A pointer to pointer of dst buffer
5688 * @pDstDataLen : A pointer to pointer of dst buffer length
5689 * @pModifyIE : A pointer to tSirModifyIE
5690 *
5691 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5692 *
5693 * Return:
5694 * True or false depending upon whether IE is updated or not
5695 */
5696static bool
5697lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5698 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5699{
Hong Shi1553d692016-09-28 12:16:19 +08005700 int32_t oui_length;
5701 uint8_t *ibss_ie = NULL;
5702 uint8_t *vendor_ie;
5703#define MAC_VENDOR_OUI "\x00\x16\x32"
5704#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005705
5706 ibss_ie = pModifyIE->pIEBuffer;
5707 oui_length = pModifyIE->oui_length;
5708
5709 if ((0 == oui_length) || (NULL == ibss_ie)) {
5710 PELOGE(lim_log(pMac, LOGE,
5711 FL("Invalid set IBSS vendor IE command length %d "),
5712 oui_length);)
5713 return false;
5714 }
5715
Hong Shi1553d692016-09-28 12:16:19 +08005716 /*
5717 * Why replace only beacon OUI data here:
5718 * 1. other ie (such as wpa) shall not be overwritten here.
5719 * 2. per spec, beacon oui ie might be set twice and original one
5720 * shall be updated.
5721 */
5722 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5723 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5724 if (vendor_ie) {
5725 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5726 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5727 pModifyIE->ieBufferlength);
5728 } else {
5729 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5730 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005731
Hong Shi1553d692016-09-28 12:16:19 +08005732 if (NULL == new_ptr) {
5733 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5734 return false;
5735 }
5736 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5737 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5738 pModifyIE->ieBufferlength);
5739 qdf_mem_free(*pDstData_buff);
5740 *pDstDataLen = new_length;
5741 *pDstData_buff = new_ptr;
5742 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005743 return true;
5744}
5745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746/*
5747* lim_process_modify_add_ies() - process modify additional IE req.
5748*
5749* @mac_ctx: Pointer to Global MAC structure
5750* @msg_buf: pointer to the SME message buffer
5751*
5752* This function update the PE buffers for additional IEs.
5753*
5754* Return: None
5755*/
5756static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5757 uint32_t *msg_buf)
5758{
5759 tpSirModifyIEsInd modify_add_ies;
5760 tpPESession session_entry;
5761 uint8_t session_id;
5762 bool ret = false;
5763 tSirAddIeParams *add_ie_params;
5764
5765 if (msg_buf == NULL) {
5766 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5767 return;
5768 }
5769
5770 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5771 /* Incoming message has smeSession, use BSSID to find PE session */
5772 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005773 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774
5775 if (NULL == session_entry) {
5776 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5777 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005778 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 goto end;
5780 }
5781 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5782 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5783 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5784 lim_log(mac_ctx, LOGE,
5785 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5786 modify_add_ies->modifyIE.pIEBuffer,
5787 modify_add_ies->modifyIE.ieBufferlength,
5788 modify_add_ies->modifyIE.ieID,
5789 modify_add_ies->modifyIE.ieIDLen,
5790 modify_add_ies->updateType);
5791 goto end;
5792 }
5793 add_ie_params = &session_entry->addIeParams;
5794 switch (modify_add_ies->updateType) {
5795 case eUPDATE_IE_PROBE_RESP:
5796 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005797 if (LIM_IS_IBSS_ROLE(session_entry)) {
5798 lim_update_ibss_prop_add_ies(mac_ctx,
5799 &add_ie_params->probeRespData_buff,
5800 &add_ie_params->probeRespDataLen,
5801 &modify_add_ies->modifyIE);
5802 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 break;
5804 case eUPDATE_IE_ASSOC_RESP:
5805 /* assoc resp IE */
5806 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305807 QDF_TRACE(QDF_MODULE_ID_PE,
5808 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 "assoc resp add ie not present %d"),
5810 add_ie_params->assocRespDataLen);
5811 }
5812 /* search through the buffer and modify the IE */
5813 break;
5814 case eUPDATE_IE_PROBE_BCN:
5815 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005816 if (LIM_IS_IBSS_ROLE(session_entry)) {
5817 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5818 &add_ie_params->probeRespBCNData_buff,
5819 &add_ie_params->probeRespBCNDataLen,
5820 &modify_add_ies->modifyIE);
5821 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822 if (ret == true && modify_add_ies->modifyIE.notify) {
5823 lim_handle_param_update(mac_ctx,
5824 modify_add_ies->updateType);
5825 }
5826 break;
5827 default:
5828 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5829 modify_add_ies->updateType);
5830 break;
5831 }
5832end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305833 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834 modify_add_ies->modifyIE.pIEBuffer = NULL;
5835}
5836
5837/*
5838* lim_process_update_add_ies() - process additional IE update req
5839*
5840* @mac_ctx: Pointer to Global MAC structure
5841* @msg_buf: pointer to the SME message buffer
5842*
5843* This function update the PE buffers for additional IEs.
5844*
5845* Return: None
5846*/
5847static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5848 uint32_t *msg_buf)
5849{
5850 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5851 uint8_t session_id;
5852 tpPESession session_entry;
5853 tSirAddIeParams *addn_ie;
5854 uint16_t new_length = 0;
5855 uint8_t *new_ptr = NULL;
5856 tSirUpdateIE *update_ie;
5857
5858 if (msg_buf == NULL) {
5859 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5860 return;
5861 }
5862 update_ie = &update_add_ies->updateIE;
5863 /* incoming message has smeSession, use BSSID to find PE session */
5864 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005865 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866
5867 if (NULL == session_entry) {
5868 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5869 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005870 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 goto end;
5872 }
5873 addn_ie = &session_entry->addIeParams;
5874 /* if len is 0, upper layer requested freeing of buffer */
5875 if (0 == update_ie->ieBufferlength) {
5876 switch (update_add_ies->updateType) {
5877 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305878 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 addn_ie->probeRespData_buff = NULL;
5880 addn_ie->probeRespDataLen = 0;
5881 break;
5882 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305883 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 addn_ie->assocRespData_buff = NULL;
5885 addn_ie->assocRespDataLen = 0;
5886 break;
5887 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305888 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 addn_ie->probeRespBCNData_buff = NULL;
5890 addn_ie->probeRespBCNDataLen = 0;
5891
5892 if (update_ie->notify)
5893 lim_handle_param_update(mac_ctx,
5894 update_add_ies->updateType);
5895 break;
5896 default:
5897 break;
5898 }
5899 return;
5900 }
5901 switch (update_add_ies->updateType) {
5902 case eUPDATE_IE_PROBE_RESP:
5903 if (update_ie->append) {
5904 /*
5905 * In case of append, allocate new memory
5906 * with combined length
5907 */
5908 new_length = update_ie->ieBufferlength +
5909 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305910 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005911 if (NULL == new_ptr) {
5912 lim_log(mac_ctx, LOGE, FL(
5913 "Memory allocation failed."));
5914 goto end;
5915 }
5916 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305917 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305919 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 update_ie->pAdditionIEBuffer,
5921 update_ie->ieBufferlength);
5922 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305923 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924 /* adjust length accordingly */
5925 addn_ie->probeRespDataLen = new_length;
5926 /* save refernece of local buffer in PE session */
5927 addn_ie->probeRespData_buff = new_ptr;
5928 goto end;
5929 }
5930 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5931 &addn_ie->probeRespDataLen,
5932 update_ie->pAdditionIEBuffer,
5933 update_ie->ieBufferlength);
5934 break;
5935 case eUPDATE_IE_ASSOC_RESP:
5936 /* assoc resp IE */
5937 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5938 &addn_ie->assocRespDataLen,
5939 update_ie->pAdditionIEBuffer,
5940 update_ie->ieBufferlength);
5941 break;
5942 case eUPDATE_IE_PROBE_BCN:
5943 /* probe resp Bcn IE */
5944 lim_update_add_ie_buffer(mac_ctx,
5945 &addn_ie->probeRespBCNData_buff,
5946 &addn_ie->probeRespBCNDataLen,
5947 update_ie->pAdditionIEBuffer,
5948 update_ie->ieBufferlength);
5949 if (update_ie->notify)
5950 lim_handle_param_update(mac_ctx,
5951 update_add_ies->updateType);
5952 break;
5953 default:
5954 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5955 update_add_ies->updateType);
5956 break;
5957 }
5958end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305959 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005960 update_ie->pAdditionIEBuffer = NULL;
5961}
5962
5963/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305964 * send_extended_chan_switch_action_frame()- function to send ECSA
5965 * action frame for each sta connected to SAP/GO and AP in case of
5966 * STA .
5967 * @mac_ctx: pointer to global mac structure
5968 * @new_channel: new channel to switch to.
5969 * @ch_bandwidth: BW of channel to calculate op_class
5970 * @session_entry: pe session
5971 *
5972 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5973 *
5974 * Return: void
5975 */
5976
5977static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5978 uint16_t new_channel, uint8_t ch_bandwidth,
5979 tpPESession session_entry)
5980{
5981 uint16_t op_class;
5982 uint8_t switch_mode = 0, i;
5983 tpDphHashNode psta;
5984
5985
Amar Singhal22995112016-01-22 10:42:33 -08005986 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305987 mac_ctx->scan.countryCodeCurrent,
5988 new_channel,
5989 ch_bandwidth);
5990
5991 if (LIM_IS_AP_ROLE(session_entry) &&
5992 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5993 switch_mode = 1;
5994
5995 if (LIM_IS_AP_ROLE(session_entry)) {
5996 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5997 psta =
5998 session_entry->dph.dphHashTable.pDphNodeArray + i;
5999 if (psta && psta->added)
6000 lim_send_extended_chan_switch_action_frame(
6001 mac_ctx,
6002 psta->staAddr,
6003 switch_mode, op_class, new_channel,
6004 LIM_MAX_CSA_IE_UPDATES, session_entry);
6005 }
6006 } else if (LIM_IS_STA_ROLE(session_entry)) {
6007 lim_send_extended_chan_switch_action_frame(mac_ctx,
6008 session_entry->bssId,
6009 switch_mode, op_class, new_channel,
6010 LIM_MAX_CSA_IE_UPDATES, session_entry);
6011 }
6012
6013}
6014
6015/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
6017 *
6018 * @mac_ctx: Pointer to Global MAC structure
6019 * @msg_buf: pointer to the SME message buffer
6020 *
6021 * This function processes SME request messages from HDD or upper layer
6022 * application.
6023 *
6024 * Return: None
6025 */
6026static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6027 uint32_t *msg_buf)
6028{
6029 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6030 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 uint8_t session_id;
6032 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006033 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034
6035 if (msg_buf == NULL) {
6036 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6037 return;
6038 }
6039
6040 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6041 session_entry = pe_find_session_by_bssid(mac_ctx,
6042 dfs_csa_ie_req->bssid, &session_id);
6043 if (session_entry == NULL) {
6044 lim_log(mac_ctx, LOGE, FL(
6045 "Session not found for given BSSID" MAC_ADDRESS_STR),
6046 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6047 return;
6048 }
6049
6050 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6051 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6052 GET_LIM_SYSTEM_ROLE(session_entry));
6053 return;
6054 }
6055
6056 /* target channel */
6057 session_entry->gLimChannelSwitch.primaryChannel =
6058 dfs_csa_ie_req->targetChannel;
6059
6060 /* Channel switch announcement needs to be included in beacon */
6061 session_entry->dfsIncludeChanSwIe = true;
6062 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6063 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006064 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306065 session_entry->gLimChannelSwitch.sec_ch_offset =
6066 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6068 session_entry->gLimChannelSwitch.switchMode = 1;
6069
6070 /*
6071 * Validate if SAP is operating HT or VHT mode and set the Channel
6072 * Switch Wrapper element with the Wide Band Switch subelement.
6073 */
6074 if (true != session_entry->vhtCapability)
6075 goto skip_vht;
6076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 /* Now encode the Wider Ch BW element depending on the ch width */
6078 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006079 switch (dfs_csa_ie_req->ch_params.ch_width) {
6080 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 /*
6082 * Wide channel BW sublement in channel wrapper element is not
6083 * required in case of 20 Mhz operation. Currently It is set
6084 * only set in case of 40/80 Mhz Operation.
6085 */
6086 session_entry->dfsIncludeChanWrapperIe = false;
6087 wider_bw_ch_switch->newChanWidth =
6088 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6089 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006090 case CH_WIDTH_40MHZ:
6091 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 wider_bw_ch_switch->newChanWidth =
6093 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6094 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006095 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 session_entry->dfsIncludeChanWrapperIe = true;
6097 wider_bw_ch_switch->newChanWidth =
6098 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6099 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006100 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101 session_entry->dfsIncludeChanWrapperIe = true;
6102 wider_bw_ch_switch->newChanWidth =
6103 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6104 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006105 case CH_WIDTH_80P80MHZ:
6106 session_entry->dfsIncludeChanWrapperIe = true;
6107 wider_bw_ch_switch->newChanWidth =
6108 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006109 /*
6110 * This is not applicable for 20/40/80 Mhz.
6111 * Only used when we support 80+80 Mhz operation.
6112 * In case of 80+80 Mhz, this parameter indicates
6113 * center channel frequency index of 80 Mhz channel of
6114 * frequency segment 1.
6115 */
6116 wider_bw_ch_switch->newCenterChanFreq1 =
6117 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006118 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119 default:
6120 session_entry->dfsIncludeChanWrapperIe = false;
6121 /*
6122 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6123 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6124 */
6125 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6126 break;
6127 }
6128 /* Fetch the center channel based on the channel width */
6129 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006130 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131skip_vht:
6132 /* Send CSA IE request from here */
6133 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6134 eSIR_SUCCESS) {
6135 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6136 return;
6137 }
6138
6139 /*
6140 * First beacon update request is sent here, the remaining updates are
6141 * done when the FW responds back after sending the first beacon after
6142 * the template update
6143 */
6144 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306145
6146 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6147 ch_offset = BW80;
6148 else
6149 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6150
6151 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6152 session_entry->gLimChannelSwitch.switchCount,
6153 session_entry->gLimChannelSwitch.primaryChannel,
6154 session_entry->gLimChannelSwitch.ch_width,
6155 session_entry->dfsIncludeChanWrapperIe,
6156 ch_offset);
6157
Abhishek Singh518323d2015-10-19 17:42:01 +05306158 /* Send ECSA Action frame after updating the beacon */
6159 send_extended_chan_switch_action_frame(mac_ctx,
6160 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306161 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006162 session_entry->gLimChannelSwitch.switchCount--;
6163}
6164
6165/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306166 * lim_process_ext_change_channel()- function to send ECSA
6167 * action frame for STA/CLI .
6168 * @mac_ctx: pointer to global mac structure
6169 * @msg: params from sme for new channel.
6170 *
6171 * This function is called to send ECSA frame for STA/CLI.
6172 *
6173 * Return: void
6174 */
6175
6176static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6177 uint32_t *msg)
6178{
6179 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6180 (struct sir_sme_ext_cng_chan_req *) msg;
6181 tpPESession session_entry = NULL;
6182
6183 if (NULL == msg) {
6184 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6185 return;
6186 }
6187 session_entry =
6188 pe_find_session_by_sme_session_id(mac_ctx,
6189 ext_chng_channel->session_id);
6190 if (NULL == session_entry) {
6191 lim_log(mac_ctx, LOGE,
6192 FL("Session not found for given session %d"),
6193 ext_chng_channel->session_id);
6194 return;
6195 }
6196 if (LIM_IS_AP_ROLE(session_entry)) {
6197 lim_log(mac_ctx, LOGE,
6198 FL("not an STA/CLI session"));
6199 return;
6200 }
6201 send_extended_chan_switch_action_frame(mac_ctx,
6202 ext_chng_channel->new_channel,
6203 0, session_entry);
6204}
6205
6206/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207 * lim_process_nss_update_request() - process sme nss update req
6208 *
6209 * @mac_ctx: Pointer to Global MAC structure
6210 * @msg_buf: pointer to the SME message buffer
6211 *
6212 * This function processes SME request messages from HDD or upper layer
6213 * application.
6214 *
6215 * Return: None
6216 */
6217static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6218 uint32_t *msg_buf)
6219{
6220 struct sir_nss_update_request *nss_update_req_ptr;
6221 tpPESession session_entry = NULL;
6222
6223 if (msg_buf == NULL) {
6224 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6225 return;
6226 }
6227
6228 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306229 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 nss_update_req_ptr->vdev_id);
6231 if (session_entry == NULL) {
6232 lim_log(mac_ctx, LOGE, FL(
6233 "Session not found for given session_id %d"),
6234 nss_update_req_ptr->vdev_id);
6235 return;
6236 }
6237
6238 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6239 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6240 GET_LIM_SYSTEM_ROLE(session_entry));
6241 return;
6242 }
6243
6244 /* populate nss field in the beacon */
6245 session_entry->gLimOperatingMode.present = 1;
6246 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6247 /* Send nss update request from here */
6248 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6249 eSIR_SUCCESS) {
6250 lim_log(mac_ctx, LOGE,
6251 FL("Unable to set op mode IE in beacon"));
6252 return;
6253 }
6254
6255 lim_send_beacon_ind(mac_ctx, session_entry);
6256}
6257
6258/**
6259 * lim_process_set_ie_req() - process sme set IE request
6260 *
6261 * @mac_ctx: Pointer to Global MAC structure
6262 * @msg_buf: pointer to the SME message buffer
6263 *
6264 * This function processes SME request messages from HDD or upper layer
6265 * application.
6266 *
6267 * Return: None
6268 */
6269static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6270{
6271 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306272 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273
6274 if (msg_buf == NULL) {
6275 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6276 return;
6277 }
6278
6279 msg = (struct send_extcap_ie *)msg_buf;
6280 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306281 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6283
6284}