blob: 82a598a865907691a06b7a785bbb442566e1e2ff [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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 struct sir_hw_mode *req_msg;
139 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;
1050
1051 if (LIM_IS_AP_ROLE(session)) {
1052 mlm_start_req->dtimPeriod = session->dtimPeriod;
1053 mlm_start_req->wps_state = session->wps_state;
1054
1055 } else {
1056 if (wlan_cfg_get_int(mac_ctx,
1057 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1058 lim_log(mac_ctx, LOGP,
1059 FL("could not retrieve DTIM Period"));
1060 mlm_start_req->dtimPeriod = (uint8_t) val;
1061 }
1062
1063 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1064 eSIR_SUCCESS)
1065 lim_log(mac_ctx, LOGP,
1066 FL("could not retrieve Beacon interval"));
1067 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1068
1069 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1070 eSIR_SUCCESS)
1071 lim_log(mac_ctx, LOGP,
1072 FL("could not retrieve CFPMaxDuration"));
1073 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1074
1075 /*
1076 * this may not be needed anymore now,
1077 * as rateSet is now included in the
1078 * session entry and MLM has session context.
1079 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301080 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 (void *)&session->rateSet,
1082 sizeof(tSirMacRateSet));
1083
1084 /* Now populate the 11n related parameters */
1085 mlm_start_req->nwType = session->nwType;
1086 mlm_start_req->htCapable = session->htCapability;
1087
1088 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1089 /* Unused */
1090 mlm_start_req->dualCTSProtection =
1091 mac_ctx->lim.gHTDualCTSProtection;
1092 mlm_start_req->txChannelWidthSet =
1093 session->htRecommendedTxWidthSet;
1094
1095 session->limRFBand = lim_get_rf_band(channel_number);
1096
1097 /* Initialize 11h Enable Flag */
1098 session->lim11hEnable = 0;
1099 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1100 (SIR_BAND_5_GHZ == session->limRFBand)) {
1101 if (wlan_cfg_get_int(mac_ctx,
1102 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1103 lim_log(mac_ctx, LOGP,
1104 FL("Fail to get WNI_CFG_11H_ENABLED "));
1105 else
1106 session->lim11hEnable = val;
1107
1108 if (session->lim11hEnable &&
1109 (eSIR_INFRA_AP_MODE ==
1110 mlm_start_req->bssType)) {
1111 cfg_get_wmi_dfs_master_param =
1112 wlan_cfg_get_int(mac_ctx,
1113 WNI_CFG_DFS_MASTER_ENABLED,
1114 &val);
1115 session->lim11hEnable = val;
1116 }
1117 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1118 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1119 lim_log(mac_ctx, LOGE,
1120 FL("Get Fail, CFG DFS ENABLE"));
1121 }
1122
1123 if (!session->lim11hEnable) {
1124 if (cfg_set_int(mac_ctx,
1125 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1126 eSIR_SUCCESS)
1127 /*
1128 * Failed to set the CFG param
1129 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1130 */
1131 lim_log(mac_ctx, LOGE,
1132 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1133 }
1134
1135 session->limPrevSmeState = session->limSmeState;
1136 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1137 MTRACE(mac_trace
1138 (mac_ctx, TRACE_CODE_SME_STATE,
1139 session->peSessionId,
1140 session->limSmeState));
1141
1142 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1143 (uint32_t *) mlm_start_req);
1144 return;
1145 } else {
1146
1147 lim_log(mac_ctx, LOGE,
1148 FL("Received unexpected START_BSS_REQ, in state %X"),
1149 mac_ctx->lim.gLimSmeState);
1150 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001151 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1153
1154free:
1155 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001156 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 session->pLimStartBssReq = NULL;
1158 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001159 if (NULL != sme_start_bss_req)
1160 qdf_mem_free(sme_start_bss_req);
1161 if (NULL != mlm_start_req)
1162 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 if (NULL != session) {
1164 pe_delete_session(mac_ctx, session);
1165 session = NULL;
1166 }
1167 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1168 session, sme_session_id, sme_transaction_id);
1169}
1170
1171/**
1172 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1173 *
1174 * @pMac: Global MAC context
1175 * @pMsg: Message pointer
1176 *
1177 * Wrapper for the function __lim_handle_sme_start_bss_request
1178 * This message will be defered until softmac come out of
1179 * scan mode or if we have detected radar on the current
1180 * operating channel.
1181 *
1182 * return true - If we consumed the buffer
1183 * false - If have defered the message.
1184 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001185static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1186 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187{
1188 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1189 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1190 /**
1191 * If message defered, buffer is not consumed yet.
1192 * So return false
1193 */
1194 return false;
1195 }
1196
1197 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1198 return true;
1199}
1200
1201/**
1202 * lim_get_random_bssid()
1203 *
1204 * FUNCTION:This function is called to process generate the random number for bssid
1205 * This function is called to process SME_SCAN_REQ message
1206 * from HDD or upper layer application.
1207 *
1208 * LOGIC:
1209 *
1210 * ASSUMPTIONS:
1211 *
1212 * NOTE:
1213 * 1. geneartes the unique random number for bssid in ibss
1214 *
1215 * @param pMac Pointer to Global MAC structure
1216 * @param *data Pointer to bssid buffer
1217 * @return None
1218 */
1219void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1220{
1221 uint32_t random[2];
1222 random[0] = tx_time_get();
1223 random[0] |= (random[0] << 15);
1224 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301225 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226}
1227
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301228static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 tpSirSmeScanReq pScanReq)
1230{
1231 tSirScanOffloadReq *pScanOffloadReq;
1232 uint8_t *p;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001233 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001235 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 tSirRetStatus status, rc = eSIR_SUCCESS;
1237 tDot11fIEExtCap extracted_extcap = {0};
1238 bool extcap_present = true;
1239
1240 if (pScanReq->uIEFieldLen) {
1241 status = lim_strip_extcap_update_struct(pMac,
1242 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1243 &pScanReq->uIEFieldLen, &extracted_extcap);
1244
1245 if (eSIR_SUCCESS != status) {
1246 extcap_present = false;
1247 lim_log(pMac, LOG1,
1248 FL("Unable to Strip ExtCap IE from Scan Req"));
1249 }
1250
1251 if (extcap_present) {
1252 lim_log(pMac, LOG1,
1253 FL("Extcap was part of SCAN IE - Updating FW"));
1254 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1255 &extracted_extcap, true);
1256 }
1257 } else {
1258 lim_log(pMac, LOG1,
1259 FL("No IEs in the scan request from supplicant"));
1260 }
1261
1262 /**
1263 * The tSirScanOffloadReq will reserve the space for first channel,
1264 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1265 */
1266 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001267 (pScanReq->channelList.numChannels - 1) +
1268 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001269
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301270 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 if (NULL == pScanOffloadReq) {
1272 lim_log(pMac, LOGE,
1273 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301274 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 }
1276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1278 msg.bodyptr = pScanOffloadReq;
1279 msg.bodyval = 0;
1280
Anurag Chouhanc5548422016-02-24 18:33:27 +05301281 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282
1283 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1284 lim_log(pMac, LOGE,
1285 FL("Invalid value (%d) for numSsid"),
1286 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301288 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 }
1290
1291 pScanOffloadReq->numSsid = pScanReq->numSsid;
1292 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1293 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301294 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 (uint8_t *) pScanReq->ssId[i].ssId,
1296 pScanOffloadReq->ssId[i].length);
1297 }
1298
1299 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301300 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 pScanOffloadReq->bssType = pScanReq->bssType;
1302 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1303 pScanOffloadReq->scanType = pScanReq->scanType;
1304 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1305 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1306 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301307 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1308 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301309 pScanOffloadReq->scan_adaptive_dwell_mode =
1310 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311
1312 /* for normal scan, the value for p2pScanType should be 0
1313 always */
1314 if (pScanReq->p2pSearch)
1315 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1316
1317 pScanOffloadReq->sessionId = pScanReq->sessionId;
1318 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001319 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301320 pScanOffloadReq->scan_adaptive_dwell_mode =
1321 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322
1323 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1324 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1325 pScanOffloadReq->sessionId);
1326
1327 pScanOffloadReq->channelList.numChannels =
1328 pScanReq->channelList.numChannels;
1329 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1330 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1331 p[i] = pScanReq->channelList.channelNumber[i];
1332
1333 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1334 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1335 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301336 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 pScanOffloadReq->uIEFieldOffset,
1338 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1339 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 rc = wma_post_ctrl_msg(pMac, &msg);
1342 if (rc != eSIR_SUCCESS) {
1343 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301344 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301345 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 }
1347
1348 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1349
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301350 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351}
1352
1353/**
1354 * __lim_process_sme_scan_req() - Process the SME Scan Request
1355 * @mac_ctx: Global MAC Context
1356 * @msg_buf: Buffer which contains the request and pertinent parameters
1357 *
1358 * This function is called to process SME_SCAN_REQ message
1359 * from HDD or upper layer application.
1360 *
1361 * Return: None
1362 */
1363
1364static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1365 uint32_t *msg_buf)
1366{
1367 tpSirSmeScanReq scan_req;
1368 uint8_t valid_req = 0;
1369
1370#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1371 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1372 eSIR_SUCCESS, eSIR_SUCCESS);
1373#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301374 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375
1376 scan_req = (tpSirSmeScanReq) msg_buf;
1377 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301378 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 -08001379 scan_req->scan_id, scan_req->channelList.numChannels,
1380 scan_req->minChannelTime, scan_req->maxChannelTime,
1381 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1382 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301383 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1385 /*
1386 * Since scan req always requires a response, we will overwrite response
1387 * required here. This is added esp to take care of the condition where
1388 * in p2p go case, we hold the scan req and insert single NOA. We send
1389 * the held scan request to FW later on getting start NOA ind from FW so
1390 * we lose state of the gLimRspReqd flag for the scan req if any other
1391 * request comes by then. e.g. While unit testing, we found when insert
1392 * single NOA is done, we see a get stats request which turns the flag
1393 * gLimRspReqd to false; now when we actually start the saved scan req
1394 * for init scan after getting NOA started, the gLimRspReqd being a
1395 * global flag is showing false instead of true value for this saved
1396 * scan req. Since all scan reqs coming to lim require a response,
1397 * there is no harm in setting the global flag gLimRspReqd to true here.
1398 */
1399 mac_ctx->lim.gLimRspReqd = true;
1400
1401 /*
1402 * copy the Self MAC address from SmeReq to the globalplace,
1403 * used for sending probe req
1404 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001405 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1406 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1408
1409 if (!valid_req || mac_ctx->lim.scan_disabled) {
1410 lim_log(mac_ctx, LOGE,
1411 FL("Scan disabled %d, Valid Scan Req %d"),
1412 mac_ctx->lim.scan_disabled, valid_req);
1413
1414 if (mac_ctx->lim.gLimRspReqd) {
1415 mac_ctx->lim.gLimRspReqd = false;
1416
1417 lim_send_sme_scan_rsp(mac_ctx,
1418 eSIR_SME_INVALID_PARAMETERS,
1419 scan_req->sessionId,
1420 scan_req->transactionId,
1421 scan_req->scan_id);
1422 }
1423 return;
1424 }
1425
1426 /*
1427 * If scan request is received in idle, joinFailed
1428 * states or in link established state (in STA role)
1429 * or in normal state (in STA-in-IBSS/AP role) with
1430 * 'return fresh scan results' request from HDD or
1431 * it is periodic background scanning request,
1432 * trigger fresh scan request to MLM
1433 */
1434 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1435
1436 mac_ctx->lim.gLim24Band11dScanDone = 0;
1437 mac_ctx->lim.gLim50Band11dScanDone = 0;
1438 mac_ctx->lim.gLimReturnAfterFirstMatch =
1439 scan_req->returnAfterFirstMatch;
1440 mac_ctx->lim.gLimReturnUniqueResults =
1441 ((scan_req->returnUniqueResults) > 0 ? true : false);
1442
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301443 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 lim_send_hal_start_scan_offload_req(mac_ctx,
1445 scan_req)) {
1446 lim_log(mac_ctx, LOGE, FL(
1447 "Couldn't send Offload scan request"));
1448 lim_send_sme_scan_rsp(mac_ctx,
1449 eSIR_SME_INVALID_PARAMETERS,
1450 scan_req->sessionId,
1451 scan_req->transactionId,
1452 scan_req->scan_id);
1453 return;
1454 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301455 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 /* In all other cases return 'cached' scan results */
1457 if (mac_ctx->lim.gLimRspReqd) {
1458 mac_ctx->lim.gLimRspReqd = false;
1459 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1460 scan_req->sessionId,
1461 scan_req->transactionId, scan_req->scan_id);
1462 }
1463 }
1464}
1465
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466/**
1467 * __lim_process_clear_dfs_channel_list()
1468 *
1469 ***FUNCTION:
1470 ***Clear DFS channel list when country is changed/aquired.
1471 .*This message is sent from SME.
1472 *
1473 ***LOGIC:
1474 *
1475 ***ASSUMPTIONS:
1476 *
1477 ***NOTE:
1478 *
1479 * @param pMac Pointer to Global MAC structure
1480 * @param *pMsgBuf A pointer to the SME message buffer
1481 * @return None
1482 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001483static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1484 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301486 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487}
1488
1489/**
1490 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1491 * @mac_ctx: Pointer to Global MAC structure
1492 * @msg_buf: A pointer to the SME message buffer
1493 *
1494 * This function is called to process SME_JOIN_REQ message
1495 * from HDD or upper layer application.
1496 *
1497 * Return: None
1498 */
1499static void
1500__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1501{
1502 tpSirSmeJoinReq sme_join_req = NULL;
1503 tLimMlmJoinReq *mlm_join_req;
1504 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1505 uint32_t val = 0;
1506 uint16_t n_size;
1507 uint8_t session_id;
1508 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301509 uint8_t sme_session_id = 0;
1510 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001511 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 uint16_t ie_len;
1513 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001514 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001515 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516
Arif Hussain995fcaf2016-07-18 11:28:22 -07001517 if (!mac_ctx || !msg_buf) {
1518 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1519 FL("JOIN REQ with invalid data"));
1520 return;
1521 }
1522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523/* FEATURE_WLAN_DIAG_SUPPORT */
1524#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1525 /*
1526 * Not sending any session, since it is not created yet.
1527 * The response whould have correct state.
1528 */
1529 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1530#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 /*
1533 * Expect Join request in idle state.
1534 * Reassociate request is expected in link established state.
1535 */
1536
1537 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1538 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1539 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1540 msg_buf);
1541
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 if (NULL == sme_join_req) {
1544 lim_log(mac_ctx, LOGP,
1545 FL("AllocateMemory failed for sme_join_req"));
1546 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301547 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 n_size);
1551
1552 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1553 /* Received invalid eWNI_SME_JOIN_REQ */
1554 /* Log the event */
1555 lim_log(mac_ctx, LOGW,
1556 FL("SessionId:%d JOIN REQ with invalid data"),
1557 sme_join_req->sessionId);
1558 ret_code = eSIR_SME_INVALID_PARAMETERS;
1559 goto end;
1560 }
1561
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001562 /*
1563 * Update the capability here itself as this is used in
1564 * lim_extract_ap_capability() below. If not updated issues
1565 * like not honoring power constraint on 1st association after
1566 * driver loading might occur.
1567 */
1568 lim_update_rrm_capability(mac_ctx, sme_join_req);
1569
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001570 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001572 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 &session_id);
1574
1575 if (session != NULL) {
1576 lim_log(mac_ctx, LOGE,
1577 FL("Session(%d) Already exists for BSSID: "
1578 MAC_ADDRESS_STR " in limSmeState = %X"),
1579 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001580 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 session->limSmeState);
1582
1583 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1584 session->smeSessionId == sme_join_req->sessionId) {
1585 /*
1586 * Received eWNI_SME_JOIN_REQ for same
1587 * BSS as currently associated.
1588 * Log the event and send success
1589 */
1590 lim_log(mac_ctx, LOGW,
1591 FL("SessionId: %d"), session_id);
1592 lim_log(mac_ctx, LOGW,
1593 FL("JOIN_REQ for current joined BSS"));
1594 /* Send Join success response to host */
1595 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1596 session = NULL;
1597 goto end;
1598 } else {
1599 lim_log(mac_ctx, LOGE,
1600 FL("JOIN_REQ not for current joined BSS"));
1601 ret_code = eSIR_SME_REFUSED;
1602 session = NULL;
1603 goto end;
1604 }
1605 } else {
1606 /*
1607 * Session Entry does not exist for given BSSId
1608 * Try to Create a new session
1609 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001610 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 &session_id, mac_ctx->lim.maxStation,
1612 eSIR_INFRASTRUCTURE_MODE);
1613 if (session == NULL) {
1614 lim_log(mac_ctx, LOGE,
1615 FL("Session Can not be created "));
1616 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1617 goto end;
1618 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301619 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 FL("SessionId:%d New session created"),
1621 session_id);
1622 }
1623 session->isAmsduSupportInAMPDU =
1624 sme_join_req->isAmsduSupportInAMPDU;
1625
1626 /*
1627 * Store Session related parameters
1628 * Store PE session Id in session Table
1629 */
1630 session->peSessionId = session_id;
1631
1632 /* store the smejoin req handle in session table */
1633 session->pLimJoinReq = sme_join_req;
1634
1635 /* Store SME session Id in sessionTable */
1636 session->smeSessionId = sme_join_req->sessionId;
1637
1638 /* Store SME transaction Id in session Table */
1639 session->transactionId = sme_join_req->transactionId;
1640
1641 /* Store beaconInterval */
1642 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001643 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301645 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 sizeof(session->htConfig));
1647
Sandeep Puligilla98917432016-06-10 13:50:28 -07001648 qdf_mem_copy(&(session->vht_config),
1649 &(sme_join_req->vht_config),
1650 sizeof(session->vht_config));
1651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 /* Copying of bssId is already done, while creating session */
1653 sir_copy_mac_addr(session->selfMacAddr,
1654 sme_join_req->selfMacAddr);
1655 session->bssType = sme_join_req->bsstype;
1656
1657 session->statypeForBss = STA_ENTRY_PEER;
1658 session->limWmeEnabled = sme_join_req->isWMEenabled;
1659 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301660 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661
1662 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001663 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1665
1666 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1667 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001668 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669
1670 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001671 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 session->isCiscoVendorAP = true;
1673 } else {
1674 session->isCiscoVendorAP = false;
1675 }
1676
1677 /* Copy the dot 11 mode in to the session table */
1678
1679 session->dot11mode = sme_join_req->dot11mode;
1680#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1681 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1682#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001683 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1685 session->enableHtSmps = sme_join_req->enableHtSmps;
1686 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001687 session->send_smps_action =
1688 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001689 /*
1690 * By default supported NSS 1x1 is set to true
1691 * and later on updated while determining session
1692 * supported rates which is the intersection of
1693 * self and peer rates
1694 */
1695 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301696 /*Store Persona */
1697 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001698 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301699 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001700 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001701 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001702 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301703 session->supported_nss_1x1,
1704 session->pePersona,
1705 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001706
1707 /*Store Persona */
1708 session->pePersona = sme_join_req->staPersona;
1709 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001710 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d"),
1711 session->pePersona, sme_join_req->cbMode,
1712 session->nwType, session->dot11mode);
1713
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001714 /* Copy The channel Id to the session Table */
1715 session->currentOperChannel = bss_desc->channelId;
1716 if (IS_5G_CH(session->currentOperChannel))
1717 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001719 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1720 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1721 session->vdev_nss = vdev_type_nss->p2p_cli;
1722 else
1723 session->vdev_nss = vdev_type_nss->sta;
1724 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 session->vhtCapability =
1726 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301728 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001729 session->vht_config.su_beam_formee =
1730 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001732 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 session->enableVhtpAid =
1735 sme_join_req->enableVhtpAid;
1736 session->enableVhtGid =
1737 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001738 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1739 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 }
Krunal Soni53993f72016-07-08 18:20:03 -07001741
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001742 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1743 lim_update_session_he_capable(mac_ctx, session);
1744 lim_copy_join_req_he_cap(session, sme_join_req);
1745 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001746
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301747 lim_log(mac_ctx, LOG1,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001748 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301749 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001750 session->vht_config.su_beam_formee,
1751 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001752 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001754 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 /* cbMode is already merged value of peer and self -
1757 * done by csr in csr_get_cb_mode_from_ies */
1758 session->htSupportedChannelWidthSet =
1759 (sme_join_req->cbMode) ? 1 : 0;
1760 session->htRecommendedTxWidthSet =
1761 session->htSupportedChannelWidthSet;
1762 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1763
1764 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1765 session->ch_center_freq_seg0 =
1766 session->currentOperChannel - 2;
1767 session->ch_width = CH_WIDTH_40MHZ;
1768 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1769 sme_join_req->cbMode) {
1770 session->ch_center_freq_seg0 =
1771 session->currentOperChannel + 2;
1772 session->ch_width = CH_WIDTH_40MHZ;
1773 } else {
1774 session->ch_center_freq_seg0 = 0;
1775 session->ch_width = CH_WIDTH_20MHZ;
1776 }
1777
1778 /* Record if management frames need to be protected */
1779#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001780 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001782 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784#endif
1785
1786#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001787 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788#endif
1789
1790 /* Copy the SSID from smejoinreq to session entry */
1791 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301792 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 session->ssId.length);
1794
1795 /*
1796 * Determin 11r or ESE connection based on input from SME
1797 * which inturn is dependent on the profile the user wants
1798 * to connect to, So input is coming from supplicant
1799 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801#ifdef FEATURE_WLAN_ESE
1802 session->isESEconnection = sme_join_req->isESEconnection;
1803#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 session->isFastTransitionEnabled =
1805 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 session->isFastRoamIniFeatureEnabled =
1808 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->txLdpcIniFeatureEnabled =
1810 sme_join_req->txLdpcIniFeatureEnabled;
1811
1812 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1813 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 } else {
1815 /*
1816 * Throw an error and return and make
1817 * sure to delete the session.
1818 */
1819 lim_log(mac_ctx, LOGE,
1820 FL("recvd JOIN_REQ with invalid bss type %d"),
1821 session->bssType);
1822 ret_code = eSIR_SME_INVALID_PARAMETERS;
1823 goto end;
1824 }
1825
1826 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301827 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 &sme_join_req->addIEScan, sizeof(tSirAddie));
1829
1830 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301831 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1833
1834 val = sizeof(tLimMlmJoinReq) +
1835 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301836 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 if (NULL == mlm_join_req) {
1838 lim_log(mac_ctx, LOGP,
1839 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301840 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1841 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843
1844 /* PE SessionId is stored as a part of JoinReq */
1845 mlm_join_req->sessionId = session->peSessionId;
1846
1847 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1848 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1849 eSIR_SUCCESS) {
1850 lim_log(mac_ctx, LOGP,
1851 FL("couldn't retrieve JoinFailureTimer value"
1852 " setting to default value"));
1853 mlm_join_req->joinFailureTimeout =
1854 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1855 }
1856
1857 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301858 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 (void *)&sme_join_req->operationalRateSet,
1860 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301861 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 (void *)&sme_join_req->extendedRateSet,
1863 sizeof(tSirMacRateSet));
1864 /*
1865 * this may not be needed anymore now, as rateSet is now
1866 * included in the session entry and MLM has session context.
1867 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301868 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 (void *)&session->rateSet,
1870 sizeof(tSirMacRateSet));
1871
1872 session->encryptType = sme_join_req->UCEncryptionType;
1873
1874 mlm_join_req->bssDescription.length =
1875 session->pLimJoinReq->bssDescription.length;
1876
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301877 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 (uint8_t *)
1879 &session->pLimJoinReq->bssDescription.bssId,
1880 session->pLimJoinReq->bssDescription.length + 2);
1881
1882 session->limCurrentBssCaps =
1883 session->pLimJoinReq->bssDescription.capabilityInfo;
1884
1885 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1886 session->currentOperChannel);
1887 local_power_constraint = reg_max;
1888
1889 lim_extract_ap_capability(mac_ctx,
1890 (uint8_t *)
1891 session->pLimJoinReq->bssDescription.ieFields,
1892 lim_get_ielen_from_bss_description(
1893 &session->pLimJoinReq->bssDescription),
1894 &session->limCurrentBssQosCaps,
1895 &session->limCurrentBssPropCap,
1896 &session->gLimCurrentBssUapsd,
1897 &local_power_constraint, session);
1898
Krunal Soni53993f72016-07-08 18:20:03 -07001899 /*
1900 * Once the AP capabilities are available then set the
1901 * beam forming capabilities accordingly.
1902 */
1903 if (session->nss == 1) {
1904 session->vht_config.su_beam_former = 0;
1905 session->vht_config.tx_stbc = 0;
1906 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301907 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001908 }
1909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 session->maxTxPower = lim_get_max_tx_power(reg_max,
1911 local_power_constraint,
1912 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301913
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301914 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301915 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301916 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917
1918 if (session->gLimCurrentBssUapsd) {
1919 session->gUapsdPerAcBitmask =
1920 session->pLimJoinReq->uapsdPerAcBitmask;
1921 lim_log(mac_ctx, LOG1,
1922 FL("UAPSD flag for all AC - 0x%2x"),
1923 session->gUapsdPerAcBitmask);
1924
1925 /* resetting the dynamic uapsd mask */
1926 session->gUapsdPerAcDeliveryEnableMask = 0;
1927 session->gUapsdPerAcTriggerEnableMask = 0;
1928 }
1929
1930 session->limRFBand =
1931 lim_get_rf_band(session->currentOperChannel);
1932
1933 /* Initialize 11h Enable Flag */
1934 if (SIR_BAND_5_GHZ == session->limRFBand) {
1935 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1936 &val) != eSIR_SUCCESS) {
1937 lim_log(mac_ctx, LOGP,
1938 FL("Fail to get WNI_CFG_11H_ENABLED "));
1939 session->lim11hEnable =
1940 WNI_CFG_11H_ENABLED_STADEF;
1941 } else {
1942 session->lim11hEnable = val;
1943 }
1944 } else {
1945 session->lim11hEnable = 0;
1946 }
1947
1948 /*
1949 * To care of the scenario when STA transitions from
1950 * IBSS to Infrastructure mode.
1951 */
1952 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1953
1954 session->limPrevSmeState = session->limSmeState;
1955 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1956 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1957 session->peSessionId,
1958 session->limSmeState));
1959
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 /* Indicate whether spectrum management is enabled */
1961 session->spectrumMgtEnabled =
1962 sme_join_req->spectrumMgtIndicator;
1963
1964 /* Enable the spectrum management if this is a DFS channel */
1965 if (session->country_info_present &&
1966 lim_isconnected_on_dfs_channel(
1967 session->currentOperChannel))
1968 session->spectrumMgtEnabled = true;
1969
1970 session->isOSENConnection = sme_join_req->isOSENConnection;
1971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 /* Issue LIM_MLM_JOIN_REQ to MLM */
1973 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1974 (uint32_t *) mlm_join_req);
1975 return;
1976
1977 } else {
1978 /* Received eWNI_SME_JOIN_REQ un expected state */
1979 lim_log(mac_ctx, LOGE,
1980 FL("received unexpected SME_JOIN_REQ in state %X"),
1981 mac_ctx->lim.gLimSmeState);
1982 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1983 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1984 session = NULL;
1985 goto end;
1986 }
1987
1988end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301989 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1990 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991
1992 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301993 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 sme_join_req = NULL;
1995 if (NULL != session)
1996 session->pLimJoinReq = NULL;
1997 }
1998 if (ret_code != eSIR_SME_SUCCESS) {
1999 if (NULL != session) {
2000 pe_delete_session(mac_ctx, session);
2001 session = NULL;
2002 }
2003 }
2004 lim_log(mac_ctx, LOG1,
2005 FL("Send failure status on sessionid: %d with ret_code = %d"),
2006 sme_session_id, ret_code);
2007 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2008 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2009 sme_transaction_id);
2010}
2011
Amar Singhala297bfa2015-10-15 15:07:29 -07002012uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 uint8_t iniTxPower)
2014{
2015 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302016 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2017 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2019 maxTxPower = txPower;
2020 else if (txPower < MIN_TX_PWR_CAP)
2021 maxTxPower = MIN_TX_PWR_CAP;
2022 else
2023 maxTxPower = MAX_TX_PWR_CAP;
2024
2025 return maxTxPower;
2026}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027
2028/**
2029 * __lim_process_sme_reassoc_req() - process reassoc req
2030 *
2031 * @mac_ctx: Pointer to Global MAC structure
2032 * @msg_buf: pointer to the SME message buffer
2033 *
2034 * This function is called to process SME_REASSOC_REQ message
2035 * from HDD or upper layer application.
2036 *
2037 * Return: None
2038 */
2039
2040static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2041 uint32_t *msg_buf)
2042{
2043 uint16_t caps;
2044 uint32_t val;
2045 tpSirSmeJoinReq reassoc_req = NULL;
2046 tLimMlmReassocReq *mlm_reassoc_req;
2047 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2048 tpPESession session_entry = NULL;
2049 uint8_t session_id;
2050 uint8_t sme_session_id;
2051 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002052 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 uint32_t tele_bcn_en = 0;
2054 uint16_t size;
2055
2056 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2057
2058 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302059 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 if (NULL == reassoc_req) {
2061 lim_log(mac_ctx, LOGP,
2062 FL("call to AllocateMemory failed for reassoc_req"));
2063
2064 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2065 goto end;
2066 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302067 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068
2069 if (!lim_is_sme_join_req_valid(mac_ctx,
2070 (tpSirSmeJoinReq)reassoc_req)) {
2071 /*
2072 * Received invalid eWNI_SME_REASSOC_REQ
2073 */
2074 lim_log(mac_ctx, LOGW,
2075 FL("received SME_REASSOC_REQ with invalid data"));
2076
2077 ret_code = eSIR_SME_INVALID_PARAMETERS;
2078 goto end;
2079 }
2080
2081 session_entry = pe_find_session_by_bssid(mac_ctx,
2082 reassoc_req->bssDescription.bssId,
2083 &session_id);
2084 if (session_entry == NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 lim_log(mac_ctx, LOGE,
2086 FL("Session does not exist for given bssId"));
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002087 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2088 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002090 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2091 &sme_session_id, &transaction_id);
2092 session_entry =
2093 pe_find_session_by_sme_session_id(mac_ctx,
2094 sme_session_id);
2095 if (session_entry != NULL)
2096 lim_handle_sme_join_result(mac_ctx,
2097 eSIR_SME_INVALID_PARAMETERS,
2098 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2099 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 goto end;
2101 }
2102#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2103 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2104 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2105#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2106 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2107
2108 /* Store the reassoc handle in the session Table */
2109 session_entry->pLimReAssocReq = reassoc_req;
2110
2111 session_entry->dot11mode = reassoc_req->dot11mode;
2112 session_entry->vhtCapability =
2113 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002114
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302115 if (session_entry->vhtCapability) {
2116 if (session_entry->pePersona == QDF_STA_MODE) {
2117 session_entry->vht_config.su_beam_formee =
2118 reassoc_req->vht_config.su_beam_formee;
2119 } else {
2120 reassoc_req->vht_config.su_beam_formee = 0;
2121 }
2122 session_entry->enableVhtpAid =
2123 reassoc_req->enableVhtpAid;
2124 session_entry->enableVhtGid =
2125 reassoc_req->enableVhtGid;
2126 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2127 session_entry->vht_config.su_beam_former);
2128 }
2129
2130 lim_log(mac_ctx, LOG1,
2131 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2132 session_entry->vhtCapability,
2133 session_entry->vht_config.su_beam_formee,
2134 session_entry->vht_config.su_beam_former);
2135
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002136 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2137 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002138 session_entry->send_smps_action =
2139 reassoc_req->send_smps_action;
2140 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002141 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002142 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002143 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002144 session_entry->send_smps_action,
2145 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 /*
2147 * Reassociate request is expected
2148 * in link established state only.
2149 */
2150
2151 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2153 /*
2154 * May be from 11r FT pre-auth. So lets check it
2155 * before we bail out
2156 */
2157 lim_log(mac_ctx, LOG1, FL(
2158 "Session in reassoc state is %d"),
2159 session_entry->peSessionId);
2160
2161 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302162 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 session_entry->limReAssocbssId,
2164 6)) {
2165 lim_print_mac_addr(mac_ctx,
2166 reassoc_req->bssDescription.
2167 bssId, LOGE);
2168 lim_log(mac_ctx, LOGP,
2169 FL("Unknown bssId in reassoc state"));
2170 ret_code = eSIR_SME_INVALID_PARAMETERS;
2171 goto end;
2172 }
2173
2174 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2175 session_entry);
2176 return;
2177 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 /*
2179 * Should not have received eWNI_SME_REASSOC_REQ
2180 */
2181 lim_log(mac_ctx, LOGE,
2182 FL("received unexpected SME_REASSOC_REQ in state %X"),
2183 session_entry->limSmeState);
2184 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2185
2186 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2187 goto end;
2188 }
2189
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302190 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191 session_entry->pLimReAssocReq->bssDescription.bssId,
2192 sizeof(tSirMacAddr));
2193
2194 session_entry->limReassocChannelId =
2195 session_entry->pLimReAssocReq->bssDescription.channelId;
2196
2197 session_entry->reAssocHtSupportedChannelWidthSet =
2198 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2199 session_entry->reAssocHtRecommendedTxWidthSet =
2200 session_entry->reAssocHtSupportedChannelWidthSet;
2201 session_entry->reAssocHtSecondaryChannelOffset =
2202 session_entry->pLimReAssocReq->cbMode;
2203
2204 session_entry->limReassocBssCaps =
2205 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2206 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2207 session_entry->currentOperChannel);
2208 local_pwr_constraint = reg_max;
2209
2210 lim_extract_ap_capability(mac_ctx,
2211 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2212 lim_get_ielen_from_bss_description(
2213 &session_entry->pLimReAssocReq->bssDescription),
2214 &session_entry->limReassocBssQosCaps,
2215 &session_entry->limReassocBssPropCap,
2216 &session_entry->gLimCurrentBssUapsd,
2217 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302218 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302220 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2221 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 /* Copy the SSID from session entry to local variable */
2223 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302224 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 reassoc_req->ssId.ssId,
2226 session_entry->limReassocSSID.length);
2227 if (session_entry->gLimCurrentBssUapsd) {
2228 session_entry->gUapsdPerAcBitmask =
2229 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2230 lim_log(mac_ctx, LOG1,
2231 FL("UAPSD flag for all AC - 0x%2x"),
2232 session_entry->gUapsdPerAcBitmask);
2233 }
2234
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 if (NULL == mlm_reassoc_req) {
2237 lim_log(mac_ctx, LOGP,
2238 FL("call to AllocateMemory failed for mlmReassocReq"));
2239
2240 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2241 goto end;
2242 }
2243
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302244 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2246
2247 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2248 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2249 eSIR_SUCCESS) {
2250 /*
2251 * Could not get ReassocFailureTimeout value
2252 * from CFG. Log error.
2253 */
2254 lim_log(mac_ctx, LOGP,
2255 FL("could not retrieve ReassocFailureTimeout value"));
2256 }
2257
2258 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2259 eSIR_SUCCESS) {
2260 /*
2261 * Could not get Capabilities value
2262 * from CFG. Log error.
2263 */
2264 lim_log(mac_ctx, LOGP, FL(
2265 "could not retrieve Capabilities value"));
2266 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302267
2268 lim_update_caps_info_for_bss(mac_ctx, &caps,
2269 reassoc_req->bssDescription.capabilityInfo);
2270 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 mlm_reassoc_req->capabilityInfo = caps;
2273
2274 /* Update PE session_id */
2275 mlm_reassoc_req->sessionId = session_id;
2276
2277 /*
2278 * If telescopic beaconing is enabled, set listen interval to
2279 * WNI_CFG_TELE_BCN_MAX_LI
2280 */
2281 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2282 &tele_bcn_en) != eSIR_SUCCESS)
2283 lim_log(mac_ctx, LOGP,
2284 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2285
2286 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2287
2288 if (tele_bcn_en) {
2289 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2290 eSIR_SUCCESS)
2291 /*
2292 * Could not get ListenInterval value
2293 * from CFG. Log error.
2294 */
2295 lim_log(mac_ctx, LOGP,
2296 FL("could not retrieve ListenInterval"));
2297 } else {
2298 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2299 eSIR_SUCCESS)
2300 /*
2301 * Could not get ListenInterval value
2302 * from CFG. Log error.
2303 */
2304 lim_log(mac_ctx, LOGP,
2305 FL("could not retrieve ListenInterval"));
2306 }
2307
2308 mlm_reassoc_req->listenInterval = (uint16_t) val;
2309
2310 /* Indicate whether spectrum management is enabled */
2311 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2312
2313 /* Enable the spectrum management if this is a DFS channel */
2314 if (session_entry->country_info_present &&
2315 lim_isconnected_on_dfs_channel(
2316 session_entry->currentOperChannel))
2317 session_entry->spectrumMgtEnabled = true;
2318
2319 session_entry->limPrevSmeState = session_entry->limSmeState;
2320 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2321
2322 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2323 session_entry->peSessionId,
2324 session_entry->limSmeState));
2325
2326 lim_post_mlm_message(mac_ctx,
2327 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2328 return;
2329end:
2330 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302331 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 if (session_entry)
2333 session_entry->pLimReAssocReq = NULL;
2334 }
2335
2336 if (session_entry) {
2337 /*
2338 * error occurred after we determined the session so extract
2339 * session and transaction info from there
2340 */
2341 sme_session_id = session_entry->smeSessionId;
2342 transaction_id = session_entry->transactionId;
2343 } else
2344 /*
2345 * error occurred before or during the time we determined
2346 * the session so extract the session and transaction info
2347 * from the message
2348 */
2349 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2350 &sme_session_id, &transaction_id);
2351
2352 /*
2353 * Send Reassoc failure response to host
2354 * (note session_entry may be NULL, but that's OK)
2355 */
2356 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2357 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2358 session_entry, sme_session_id,
2359 transaction_id);
2360}
2361
2362bool send_disassoc_frame = 1;
2363/**
2364 * __lim_process_sme_disassoc_req()
2365 *
2366 ***FUNCTION:
2367 * This function is called to process SME_DISASSOC_REQ message
2368 * from HDD or upper layer application.
2369 *
2370 ***LOGIC:
2371 *
2372 ***ASSUMPTIONS:
2373 *
2374 ***NOTE:
2375 *
2376 * @param pMac Pointer to Global MAC structure
2377 * @param *pMsgBuf A pointer to the SME message buffer
2378 * @return None
2379 */
2380
2381static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2382{
2383 uint16_t disassocTrigger, reasonCode;
2384 tLimMlmDisassocReq *pMlmDisassocReq;
2385 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2386 tSirSmeDisassocReq smeDisassocReq;
2387 tpPESession psessionEntry = NULL;
2388 uint8_t sessionId;
2389 uint8_t smesessionId;
2390 uint16_t smetransactionId;
2391
2392 if (pMsgBuf == NULL) {
2393 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2394 return;
2395 }
2396
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302397 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 smesessionId = smeDisassocReq.sessionId;
2399 smetransactionId = smeDisassocReq.transactionId;
2400 if (!lim_is_sme_disassoc_req_valid(pMac,
2401 &smeDisassocReq,
2402 psessionEntry)) {
2403 PELOGE(lim_log(pMac, LOGE,
2404 FL("received invalid SME_DISASSOC_REQ message"));)
2405 if (pMac->lim.gLimRspReqd) {
2406 pMac->lim.gLimRspReqd = false;
2407
2408 retCode = eSIR_SME_INVALID_PARAMETERS;
2409 disassocTrigger = eLIM_HOST_DISASSOC;
2410 goto sendDisassoc;
2411 }
2412
2413 return;
2414 }
2415
2416 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002417 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 &sessionId);
2419 if (psessionEntry == NULL) {
2420 lim_log(pMac, LOGE,
2421 FL("session does not exist for given bssId "
2422 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002423 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 retCode = eSIR_SME_INVALID_PARAMETERS;
2425 disassocTrigger = eLIM_HOST_DISASSOC;
2426 goto sendDisassoc;
2427 }
2428 lim_log(pMac, LOG1,
2429 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2430 MAC_ADDRESS_STR), smesessionId,
2431 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2432 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002433 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434
2435#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2436 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2437 0, smeDisassocReq.reasonCode);
2438#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2439
2440 /* Update SME session Id and SME transaction ID */
2441
2442 psessionEntry->smeSessionId = smesessionId;
2443 psessionEntry->transactionId = smetransactionId;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002444 lim_log(pMac, LOGW, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
2445 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446
2447 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2448 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 switch (psessionEntry->limSmeState) {
2450 case eLIM_SME_ASSOCIATED_STATE:
2451 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002452 lim_log(pMac, LOG1,
2453 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2454 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 psessionEntry->limPrevSmeState =
2456 psessionEntry->limSmeState;
2457 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 /* Delete all TDLS peers connected before leaving BSS */
2459 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002460 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2461 psessionEntry->peSessionId,
2462 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 break;
2464
2465 case eLIM_SME_WT_DEAUTH_STATE:
2466 /* PE shall still process the DISASSOC_REQ and proceed with
2467 * link tear down even if it had already sent a DEAUTH_IND to
2468 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2469 * its been set when PE entered WT_DEAUTH_STATE.
2470 */
2471 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2472 MTRACE(mac_trace
2473 (pMac, TRACE_CODE_SME_STATE,
2474 psessionEntry->peSessionId,
2475 psessionEntry->limSmeState));
2476 lim_log(pMac, LOG1,
2477 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2478 break;
2479
2480 case eLIM_SME_WT_DISASSOC_STATE:
2481 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2482 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2483 * PE can continue processing DISASSOC_REQ and send the response instead
2484 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2485 * for disassoc frame.
2486 *
2487 * It will send a disassoc, which is ok. However, we can use the global flag
2488 * sendDisassoc to not send disassoc frame.
2489 */
2490 lim_log(pMac, LOG1,
2491 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2492 break;
2493
2494 case eLIM_SME_JOIN_FAILURE_STATE: {
2495 /* Already in Disconnected State, return success */
2496 lim_log(pMac, LOG1,
2497 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2498 if (pMac->lim.gLimRspReqd) {
2499 retCode = eSIR_SME_SUCCESS;
2500 disassocTrigger = eLIM_HOST_DISASSOC;
2501 goto sendDisassoc;
2502 }
2503 }
2504 break;
2505 default:
2506 /**
2507 * STA is not currently associated.
2508 * Log error and send response to host
2509 */
2510 lim_log(pMac, LOGE,
2511 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2512 psessionEntry->limSmeState);
2513 lim_print_sme_state(pMac, LOGE,
2514 psessionEntry->limSmeState);
2515
2516 if (pMac->lim.gLimRspReqd) {
2517 if (psessionEntry->limSmeState !=
2518 eLIM_SME_WT_ASSOC_STATE)
2519 pMac->lim.gLimRspReqd = false;
2520
2521 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2522 disassocTrigger = eLIM_HOST_DISASSOC;
2523 goto sendDisassoc;
2524 }
2525
2526 return;
2527 }
2528
2529 break;
2530
2531 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 /* Fall through */
2533 break;
2534
2535 case eLIM_STA_IN_IBSS_ROLE:
2536 default:
2537 /* eLIM_UNKNOWN_ROLE */
2538 lim_log(pMac, LOGE,
2539 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2540 GET_LIM_SYSTEM_ROLE(psessionEntry));
2541
2542 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2543 disassocTrigger = eLIM_HOST_DISASSOC;
2544 goto sendDisassoc;
2545 } /* end switch (pMac->lim.gLimSystemRole) */
2546
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302547 disassocTrigger = eLIM_HOST_DISASSOC;
2548 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549
2550 if (smeDisassocReq.doNotSendOverTheAir) {
2551 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2552 send_disassoc_frame = 0;
2553 }
2554 /* Trigger Disassociation frame to peer MAC entity */
2555 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2556 " : %d, reasonCode : %d"),
2557 disassocTrigger, reasonCode);
2558
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302559 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 if (NULL == pMlmDisassocReq) {
2561 /* Log error */
2562 lim_log(pMac, LOGP,
2563 FL("call to AllocateMemory failed for mlmDisassocReq"));
2564
2565 return;
2566 }
2567
Anurag Chouhanc5548422016-02-24 18:33:27 +05302568 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002569 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570
2571 pMlmDisassocReq->reasonCode = reasonCode;
2572 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2573
2574 /* Update PE session ID */
2575 pMlmDisassocReq->sessionId = sessionId;
2576
2577 lim_post_mlm_message(pMac,
2578 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2579 return;
2580
2581sendDisassoc:
2582 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002583 lim_send_sme_disassoc_ntf(pMac,
2584 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 retCode,
2586 disassocTrigger,
2587 1, smesessionId, smetransactionId,
2588 psessionEntry);
2589 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002590 lim_send_sme_disassoc_ntf(pMac,
2591 smeDisassocReq.peer_macaddr.bytes,
2592 retCode, disassocTrigger, 1,
2593 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594
2595} /*** end __lim_process_sme_disassoc_req() ***/
2596
2597/** -----------------------------------------------------------------
2598 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2599
2600 This function is called to process SME_DISASSOC_CNF message
2601 from HDD or upper layer application.
2602
2603 \param pMac - global mac structure
2604 \param pStaDs - station dph hash node
2605 \return none
2606 \sa
2607 ----------------------------------------------------------------- */
2608static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2609{
2610 tSirSmeDisassocCnf smeDisassocCnf;
2611 uint16_t aid;
2612 tpDphHashNode pStaDs;
2613 tpPESession psessionEntry;
2614 uint8_t sessionId;
2615
2616 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2617
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302618 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 sizeof(struct sSirSmeDisassocCnf));
2620
2621 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002622 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 &sessionId);
2624 if (psessionEntry == NULL) {
2625 lim_log(pMac, LOGE,
2626 FL("session does not exist for given bssId"));
2627 return;
2628 }
2629
2630 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2631 lim_log(pMac, LOGE,
2632 FL("received invalid SME_DISASSOC_CNF message"));
2633 return;
2634 }
2635#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2636 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2637 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2638 psessionEntry,
2639 (uint16_t) smeDisassocCnf.statusCode, 0);
2640 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2641 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2642 psessionEntry,
2643 (uint16_t) smeDisassocCnf.statusCode, 0);
2644#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2645
2646 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2647 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2649 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2650 && (psessionEntry->limSmeState !=
2651 eLIM_SME_WT_DEAUTH_STATE)) {
2652 lim_log(pMac, LOGE,
2653 FL
2654 ("received unexp SME_DISASSOC_CNF in state %X"),
2655 psessionEntry->limSmeState);
2656 lim_print_sme_state(pMac, LOGE,
2657 psessionEntry->limSmeState);
2658 return;
2659 }
2660 break;
2661
2662 case eLIM_AP_ROLE:
2663 /* Fall through */
2664 break;
2665
2666 case eLIM_STA_IN_IBSS_ROLE:
2667 default: /* eLIM_UNKNOWN_ROLE */
2668 lim_log(pMac, LOGE,
2669 FL("received unexpected SME_DISASSOC_CNF role %d"),
2670 GET_LIM_SYSTEM_ROLE(psessionEntry));
2671
2672 return;
2673 }
2674
2675 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2676 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2677 LIM_IS_AP_ROLE(psessionEntry)) {
2678 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002679 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 &psessionEntry->dph.dphHashTable);
2681 if (pStaDs == NULL) {
2682 lim_log(pMac, LOGE,
2683 FL("DISASSOC_CNF for a STA with no context, addr= "
2684 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002685 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 return;
2687 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302688
2689 if ((pStaDs->mlmStaContext.mlmState ==
2690 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2691 (pStaDs->mlmStaContext.mlmState ==
2692 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2693 lim_log(pMac, LOGE,
2694 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002695 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302696 pStaDs->mlmStaContext.mlmState);
2697 return;
2698 }
2699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 /* Delete FT session if there exists one */
2701 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2703
2704 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002705 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 }
2707
2708 return;
2709}
2710
2711/**
2712 * __lim_process_sme_deauth_req() - process sme deauth req
2713 * @mac_ctx: Pointer to Global MAC structure
2714 * @msg_buf: pointer to the SME message buffer
2715 *
2716 * This function is called to process SME_DEAUTH_REQ message
2717 * from HDD or upper layer application.
2718 *
2719 * Return: None
2720 */
2721
2722static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2723 uint32_t *msg_buf)
2724{
2725 uint16_t deauth_trigger, reason_code;
2726 tLimMlmDeauthReq *mlm_deauth_req;
2727 tSirSmeDeauthReq sme_deauth_req;
2728 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2729 tpPESession session_entry;
2730 uint8_t session_id; /* PE sessionId */
2731 uint8_t sme_session_id;
2732 uint16_t sme_transaction_id;
2733
2734 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2735
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302736 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 sme_session_id = sme_deauth_req.sessionId;
2738 sme_transaction_id = sme_deauth_req.transactionId;
2739
2740 /*
2741 * We need to get a session first but we don't even know
2742 * if the message is correct.
2743 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002744 session_entry = pe_find_session_by_bssid(mac_ctx,
2745 sme_deauth_req.bssid.bytes,
2746 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 if (session_entry == NULL) {
2748 lim_log(mac_ctx, LOGE,
2749 FL("session does not exist for given bssId"));
2750 ret_code = eSIR_SME_INVALID_PARAMETERS;
2751 deauth_trigger = eLIM_HOST_DEAUTH;
2752 goto send_deauth;
2753 }
2754
2755 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2756 session_entry)) {
2757 lim_log(mac_ctx, LOGE,
2758 FL("received invalid SME_DEAUTH_REQ message"));
2759 mac_ctx->lim.gLimRspReqd = false;
2760
2761 ret_code = eSIR_SME_INVALID_PARAMETERS;
2762 deauth_trigger = eLIM_HOST_DEAUTH;
2763 goto send_deauth;
2764 }
2765 lim_log(mac_ctx, LOG1,
2766 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2767 MAC_ADDRESS_STR), sme_session_id,
2768 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2769 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002770 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2772 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2773 session_entry, 0, sme_deauth_req.reasonCode);
2774#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2775
2776 /* Update SME session ID and Transaction ID */
2777 session_entry->smeSessionId = sme_session_id;
2778 session_entry->transactionId = sme_transaction_id;
2779
2780 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2781 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 switch (session_entry->limSmeState) {
2783 case eLIM_SME_ASSOCIATED_STATE:
2784 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302785 /* Delete all TDLS peers connected before leaving BSS */
2786 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 case eLIM_SME_WT_ASSOC_STATE:
2788 case eLIM_SME_JOIN_FAILURE_STATE:
2789 case eLIM_SME_IDLE_STATE:
2790 session_entry->limPrevSmeState =
2791 session_entry->limSmeState;
2792 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2793 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2794 session_entry->peSessionId,
2795 session_entry->limSmeState));
2796 /* Send Deauthentication request to MLM below */
2797 break;
2798 case eLIM_SME_WT_DEAUTH_STATE:
2799 case eLIM_SME_WT_DISASSOC_STATE:
2800 /*
2801 * PE Recieved a Deauth/Disassoc frame. Normally it get
2802 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2803 * Which means host is also trying to disconnect.
2804 * PE can continue processing DEAUTH_REQ and send
2805 * the response instead of failing the request.
2806 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2807 * was sent for deauth/disassoc frame.
2808 */
2809 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2810 lim_log(mac_ctx, LOG1, FL(
2811 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2812 break;
2813 default:
2814 /*
2815 * STA is not in a state to deauthenticate with
2816 * peer. Log error and send response to host.
2817 */
2818 lim_log(mac_ctx, LOGE, FL(
2819 "received unexp SME_DEAUTH_REQ in state %X"),
2820 session_entry->limSmeState);
2821 lim_print_sme_state(mac_ctx, LOGE,
2822 session_entry->limSmeState);
2823
2824 if (mac_ctx->lim.gLimRspReqd) {
2825 mac_ctx->lim.gLimRspReqd = false;
2826
2827 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2828 deauth_trigger = eLIM_HOST_DEAUTH;
2829
2830 /*
2831 * here we received deauth request from AP so sme state
2832 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2833 * delSta then mlm state should be
2834 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2835 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2836 * so the below condition captures the state where
2837 * delSta not done and firmware still in
2838 * connected state.
2839 */
2840 if (session_entry->limSmeState ==
2841 eLIM_SME_WT_DEAUTH_STATE &&
2842 session_entry->limMlmState !=
2843 eLIM_MLM_IDLE_STATE &&
2844 session_entry->limMlmState !=
2845 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2846 ret_code = eSIR_SME_DEAUTH_STATUS;
2847 goto send_deauth;
2848 }
2849 return;
2850 }
2851 break;
2852
2853 case eLIM_STA_IN_IBSS_ROLE:
2854 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2855 if (mac_ctx->lim.gLimRspReqd) {
2856 mac_ctx->lim.gLimRspReqd = false;
2857 ret_code = eSIR_SME_INVALID_PARAMETERS;
2858 deauth_trigger = eLIM_HOST_DEAUTH;
2859 goto send_deauth;
2860 }
2861 return;
2862 case eLIM_AP_ROLE:
2863 break;
2864 default:
2865 lim_log(mac_ctx, LOGE,
2866 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2867 GET_LIM_SYSTEM_ROLE(session_entry));
2868 if (mac_ctx->lim.gLimRspReqd) {
2869 mac_ctx->lim.gLimRspReqd = false;
2870 ret_code = eSIR_SME_INVALID_PARAMETERS;
2871 deauth_trigger = eLIM_HOST_DEAUTH;
2872 goto send_deauth;
2873 }
2874 return;
2875 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2876
2877 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2878 /* Deauthentication is triggered by Link Monitoring */
2879 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2880 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2881 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2882 } else {
2883 deauth_trigger = eLIM_HOST_DEAUTH;
2884 reason_code = sme_deauth_req.reasonCode;
2885 }
2886
2887 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302888 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 if (NULL == mlm_deauth_req) {
2890 lim_log(mac_ctx, LOGP,
2891 FL("call to AllocateMemory failed for mlmDeauthReq"));
2892 if (mac_ctx->lim.gLimRspReqd) {
2893 mac_ctx->lim.gLimRspReqd = false;
2894 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2895 deauth_trigger = eLIM_HOST_DEAUTH;
2896 goto send_deauth;
2897 }
2898 return;
2899 }
2900
Anurag Chouhanc5548422016-02-24 18:33:27 +05302901 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002902 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903
2904 mlm_deauth_req->reasonCode = reason_code;
2905 mlm_deauth_req->deauthTrigger = deauth_trigger;
2906
2907 /* Update PE session Id */
2908 mlm_deauth_req->sessionId = session_id;
2909
2910 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2911 (uint32_t *)mlm_deauth_req);
2912 return;
2913
2914send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002915 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2916 ret_code, deauth_trigger, 1,
2917 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918}
2919
2920/**
2921 * __lim_process_sme_set_context_req()
2922 *
2923 * @mac_ctx: Pointer to Global MAC structure
2924 * @msg_buf: pointer to the SME message buffer
2925 *
2926 * This function is called to process SME_SETCONTEXT_REQ message
2927 * from HDD or upper layer application.
2928 *
2929 * Return: None
2930 */
2931
2932static void
2933__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2934{
2935 tpSirSmeSetContextReq set_context_req;
2936 tLimMlmSetKeysReq *mlm_set_key_req;
2937 tpPESession session_entry;
2938 uint8_t session_id; /* PE sessionID */
2939 uint8_t sme_session_id;
2940 uint16_t sme_transaction_id;
2941
2942 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2943
2944 if (msg_buf == NULL) {
2945 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2946 return;
2947 }
2948
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302949 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 if (NULL == set_context_req) {
2951 lim_log(mac_ctx, LOGP, FL(
2952 "call to AllocateMemory failed for set_context_req"));
2953 return;
2954 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302955 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 sizeof(struct sSirSmeSetContextReq));
2957 sme_session_id = set_context_req->sessionId;
2958 sme_transaction_id = set_context_req->transactionId;
2959
2960 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2961 lim_log(mac_ctx, LOGW,
2962 FL("received invalid SME_SETCONTEXT_REQ message"));
2963 goto end;
2964 }
2965
2966 if (set_context_req->keyMaterial.numKeys >
2967 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2968 lim_log(mac_ctx, LOGE, FL(
2969 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2970 set_context_req->keyMaterial.numKeys);
2971 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002972 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 eSIR_SME_INVALID_PARAMETERS, NULL,
2974 sme_session_id, sme_transaction_id);
2975 goto end;
2976 }
2977
2978 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002979 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 if (session_entry == NULL) {
2981 lim_log(mac_ctx, LOGW,
2982 FL("Session does not exist for given BSSID"));
2983 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002984 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 eSIR_SME_INVALID_PARAMETERS, NULL,
2986 sme_session_id, sme_transaction_id);
2987 goto end;
2988 }
2989#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2990 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2991 session_entry, 0, 0);
2992#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2993
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002994 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2996 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002997 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2999 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303000 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 if (NULL == mlm_set_key_req) {
3002 lim_log(mac_ctx, LOGP, FL(
3003 "mem alloc failed for mlmSetKeysReq"));
3004 goto end;
3005 }
3006 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3007 mlm_set_key_req->numKeys =
3008 set_context_req->keyMaterial.numKeys;
3009 if (mlm_set_key_req->numKeys >
3010 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3011 lim_log(mac_ctx, LOGP, FL(
3012 "no.of keys exceeded max num of default keys limit"));
3013 goto end;
3014 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303015 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003016 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303018 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 (uint8_t *) &set_context_req->keyMaterial.key,
3020 sizeof(tSirKeys) *
3021 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3022 numKeys : 1));
3023
3024 mlm_set_key_req->sessionId = session_id;
3025 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 lim_log(mac_ctx, LOG1, FL(
3027 "received SETCONTEXT_REQ message sessionId=%d"),
3028 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029
3030 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3031 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3032 LIM_IS_AP_ROLE(session_entry)) {
3033 if (set_context_req->keyMaterial.key[0].keyLength) {
3034 uint8_t key_id;
3035 key_id =
3036 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303037 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 &session_entry->WEPKeyMaterial[key_id],
3039 (uint8_t *) &set_context_req->keyMaterial,
3040 sizeof(tSirKeyMaterial));
3041 } else {
3042 uint32_t i;
3043 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3044 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303045 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 &mlm_set_key_req->key[i],
3047 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3048 sizeof(tSirKeys));
3049 }
3050 }
3051 }
3052 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3053 (uint32_t *) mlm_set_key_req);
3054 } else {
3055 lim_log(mac_ctx, LOGE, FL(
3056 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3057 GET_LIM_SYSTEM_ROLE(session_entry),
3058 session_entry->limSmeState);
3059 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3060
3061 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003062 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3064 session_entry, sme_session_id,
3065 sme_transaction_id);
3066 }
3067end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303068 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 return;
3070}
3071
3072/**
3073 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3074 *
3075 * @mac_ctx: Pointer to Global MAC structure
3076 * @msg_buf: pointer to the SME message buffer
3077 *
3078 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3079 * from HDD or upper layer application.
3080 *
3081 * Return: None
3082 */
3083
Jeff Johnson801f1532016-10-07 07:54:50 -07003084static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3085 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086{
3087 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3088 tpDphHashNode sta_ds = NULL;
3089 tpPESession session_entry = NULL;
3090 tSap_Event sap_event;
3091 tpWLAN_SAPEventCB sap_event_cb = NULL;
3092 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3093 uint8_t session_id = CSR_SESSION_ID_INVALID;
3094 uint8_t assoc_id = 0;
3095 uint8_t sta_cnt = 0;
3096
3097 if (msg_buf == NULL) {
3098 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3099 return;
3100 }
3101
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303102 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 sizeof(struct sSirSmeGetAssocSTAsReq));
3104 /*
3105 * Get Associated stations from PE.
3106 * Find PE session Entry
3107 */
3108 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003109 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 &session_id);
3111 if (session_entry == NULL) {
3112 lim_log(mac_ctx, LOGE,
3113 FL("session does not exist for given bssId"));
3114 goto lim_assoc_sta_end;
3115 }
3116
3117 if (!LIM_IS_AP_ROLE(session_entry)) {
3118 lim_log(mac_ctx, LOGE, FL(
3119 "Received unexpected message in state %X, in role %X"),
3120 session_entry->limSmeState,
3121 GET_LIM_SYSTEM_ROLE(session_entry));
3122 goto lim_assoc_sta_end;
3123 }
3124 /* Retrieve values obtained in the request message */
3125 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3126 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3127
3128 if (NULL == assoc_sta_tmp)
3129 goto lim_assoc_sta_end;
3130 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3131 assoc_id++) {
3132 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3133 &session_entry->dph.dphHashTable);
3134 if (NULL == sta_ds)
3135 continue;
3136 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303137 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303139 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3141 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3142
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303143 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 (uint8_t *)&sta_ds->supportedRates,
3145 sizeof(tSirSupportedRates));
3146 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3147 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3148 assoc_sta_tmp->Support40Mhz =
3149 sta_ds->htDsssCckRate40MHzSupport;
3150
3151 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3152 sta_cnt + 1);
3153 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3154 MAC_ADDR_ARRAY(sta_ds->staAddr));
3155 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3156 sta_ds->assocId);
3157 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3158 sta_ds->staIndex);
3159 assoc_sta_tmp++;
3160 sta_cnt++;
3161 }
3162 }
3163lim_assoc_sta_end:
3164 /*
3165 * Call hdd callback with sap event to send the list of
3166 * associated stations from PE
3167 */
3168 if (sap_event_cb != NULL) {
3169 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3170 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303171 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3173 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3174 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3175 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3176 }
3177}
3178
3179/**
3180 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3181 *
3182 * @mac_ctx: Pointer to Global MAC structure
3183 * @msg_buf: pointer to WPS PBC overlap query message
3184 *
3185 * This function parses get WPS PBC overlap information
3186 * message and call callback to pass WPS PBC overlap
3187 * information back to hdd.
3188 *
3189 * Return: None
3190 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003191static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3192 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193{
3194 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3195 tpPESession session_entry = NULL;
3196 tSap_Event sap_event;
3197 tpWLAN_SAPEventCB sap_event_cb = NULL;
3198 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3200
3201 if (msg_buf == NULL) {
3202 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3203 return;
3204 }
3205
3206 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303207 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303209 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3211 /*
3212 * Get Associated stations from PE
3213 * Find PE session Entry
3214 */
3215 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003216 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 if (session_entry == NULL) {
3218 lim_log(mac_ctx, LOGE,
3219 FL("session does not exist for given bssId"));
3220 goto lim_get_wpspbc_sessions_end;
3221 }
3222
3223 if (!LIM_IS_AP_ROLE(session_entry)) {
3224 lim_log(mac_ctx, LOGE,
3225 FL("Received unexpected message in role %X"),
3226 GET_LIM_SYSTEM_ROLE(session_entry));
3227 goto lim_get_wpspbc_sessions_end;
3228 }
3229 /*
3230 * Call hdd callback with sap event to send the
3231 * WPS PBC overlap information
3232 */
3233 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303234 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235
Anurag Chouhanc5548422016-02-24 18:33:27 +05303236 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003238 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 sap_get_wpspbc_event->UUID_E,
3240 &sap_get_wpspbc_event->wpsPBCOverlap,
3241 session_entry);
3242 } else {
3243 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003244 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 session_entry);
3246 /* don't have to inform the HDD/Host */
3247 return;
3248 }
3249
3250 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3251 sap_get_wpspbc_event->wpsPBCOverlap);
3252 lim_print_mac_addr(mac_ctx,
3253 sap_get_wpspbc_event->addr.bytes, LOG4);
3254
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303255 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256
3257lim_get_wpspbc_sessions_end:
3258 sap_event_cb =
3259 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3260 if (NULL != sap_event_cb)
3261 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3262}
3263
3264/**
3265 * __lim_counter_measures()
3266 *
3267 * FUNCTION:
3268 * This function is called to "implement" MIC counter measure
3269 * and is *temporary* only
3270 *
3271 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3272 * we don't do the proper STA disassoc sequence since the
3273 * BSS will be stoped anyway
3274 *
3275 ***ASSUMPTIONS:
3276 *
3277 ***NOTE:
3278 *
3279 * @param pMac Pointer to Global MAC structure
3280 * @return None
3281 */
3282
3283static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3284{
3285 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003286 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3288 mac, psessionEntry, false);
3289};
3290
Jeff Johnson801f1532016-10-07 07:54:50 -07003291static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3292 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293{
3294 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3295 tpPESession psessionEntry;
3296 uint8_t sessionId; /* PE sessionId */
3297
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303298 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 sizeof(struct sSirSmeTkipCntrMeasReq));
3300
3301 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003302 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 if (NULL == psessionEntry) {
3304 lim_log(pMac, LOGE,
3305 FL("session does not exist for given BSSID "));
3306 return;
3307 }
3308
3309 if (tkipCntrMeasReq.bEnable)
3310 __lim_counter_measures(pMac, psessionEntry);
3311
3312 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3313}
3314
3315static void
3316__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3317{
3318 tSirSmeStopBssReq stopBssReq;
3319 tSirRetStatus status;
3320 tLimSmeStates prevState;
3321 tpPESession psessionEntry;
3322 uint8_t smesessionId;
3323 uint8_t sessionId;
3324 uint16_t smetransactionId;
3325 uint8_t i = 0;
3326 tpDphHashNode pStaDs = NULL;
3327
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303328 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 smesessionId = stopBssReq.sessionId;
3330 smetransactionId = stopBssReq.transactionId;
3331
3332 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3333 PELOGW(lim_log(pMac, LOGW,
3334 FL("received invalid SME_STOP_BSS_REQ message"));)
3335 /* Send Stop BSS response to host */
3336 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3337 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3338 smetransactionId);
3339 return;
3340 }
3341
3342 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003343 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 &sessionId);
3345 if (psessionEntry == NULL) {
3346 lim_log(pMac, LOGW,
3347 FL("session does not exist for given BSSID "));
3348 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3349 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3350 smetransactionId);
3351 return;
3352 }
3353#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3354 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3355 0, 0);
3356#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3357
3358 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3359 LIM_IS_STA_ROLE(psessionEntry)) {
3360 /**
3361 * Should not have received STOP_BSS_REQ in states
3362 * other than 'normal' state or on STA in Infrastructure
3363 * mode. Log error and return response to host.
3364 */
3365 lim_log(pMac, LOGE,
3366 FL
3367 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3368 psessionEntry->limSmeState,
3369 GET_LIM_SYSTEM_ROLE(psessionEntry));
3370 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3371 /* / Send Stop BSS response to host */
3372 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3373 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3374 smetransactionId);
3375 return;
3376 }
3377
3378 if (LIM_IS_AP_ROLE(psessionEntry))
3379 lim_wpspbc_close(pMac, psessionEntry);
3380
3381 lim_log(pMac, LOGW,
3382 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3383 stopBssReq.reasonCode);
3384
3385 prevState = psessionEntry->limSmeState;
3386
3387 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3388 MTRACE(mac_trace
3389 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3390 psessionEntry->limSmeState));
3391
3392 /* Update SME session Id and Transaction Id */
3393 psessionEntry->smeSessionId = smesessionId;
3394 psessionEntry->transactionId = smetransactionId;
3395
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003396 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3397 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3398 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3400 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3401 /* Send disassoc all stations associated thru TKIP */
3402 __lim_counter_measures(pMac, psessionEntry);
3403 else
3404 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003405 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3406 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 }
3408
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003409 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3410 /* Free the buffer allocated in START_BSS_REQ */
3411 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3412 psessionEntry->addIeParams.probeRespDataLen = 0;
3413 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003415 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3416 psessionEntry->addIeParams.assocRespDataLen = 0;
3417 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003419 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3420 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3421 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003423 /*
3424 * lim_del_bss is also called as part of coalescing,
3425 * when we send DEL BSS followed by Add Bss msg.
3426 */
3427 pMac->lim.gLimIbssCoalescingHappened = false;
3428 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3430 pStaDs =
3431 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3432 if (NULL == pStaDs)
3433 continue;
3434 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3435 if (eSIR_SUCCESS == status) {
3436 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3437 pStaDs->assocId, psessionEntry);
3438 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3439 } else {
3440 lim_log(pMac, LOGE,
3441 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303442 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 }
3444 }
3445 /* send a delBss to HAL and wait for a response */
3446 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3447
3448 if (status != eSIR_SUCCESS) {
3449 PELOGE(lim_log
3450 (pMac, LOGE, FL("delBss failed for bss %d"),
3451 psessionEntry->bssIdx);
3452 )
3453 psessionEntry->limSmeState = prevState;
3454
3455 MTRACE(mac_trace
3456 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3457 psessionEntry->limSmeState));
3458
3459 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3460 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3461 smetransactionId);
3462 }
3463}
3464
3465/**
3466 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3467 * @pMac: Global MAC context
3468 * @pMsg: Message from SME
3469 *
3470 * Wrapper for the function __lim_handle_sme_stop_bss_request
3471 * This message will be defered until softmac come out of
3472 * scan mode. Message should be handled even if we have
3473 * detected radar in the current operating channel.
3474 *
3475 * Return: true - If we consumed the buffer
3476 * false - If have defered the message.
3477 */
3478
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003479static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3480 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481{
3482 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3483 /**
3484 * If message defered, buffer is not consumed yet.
3485 * So return false
3486 */
3487 return false;
3488 }
3489 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3490 return true;
3491} /*** end __lim_process_sme_stop_bss_req() ***/
3492
3493void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3494 uint32_t body, tpPESession psessionEntry)
3495{
3496
3497 (void)body;
3498 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3499 lim_ibss_delete(pMac, psessionEntry);
3500 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3501 lim_delete_pre_auth_list(pMac);
3502 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3503 psessionEntry->smeSessionId,
3504 psessionEntry->transactionId);
3505 return;
3506}
3507
3508/**
3509 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3510 *
3511 * @mac_ctx: pointer to mac context
3512 * @msg_type: message type
3513 * @msg_buf: pointer to the SME message buffer
3514 *
3515 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3516 * in BTAMP AP.
3517 *
3518 * Return: None
3519 */
3520
3521void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3522 uint32_t *msg_buf)
3523{
3524 tSirSmeAssocCnf assoc_cnf;
3525 tpDphHashNode sta_ds = NULL;
3526 tpPESession session_entry = NULL;
3527 uint8_t session_id;
3528 tpSirAssocReq assoc_req;
3529
3530 if (msg_buf == NULL) {
3531 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3532 goto end;
3533 }
3534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303535 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3537 lim_log(mac_ctx, LOGE,
3538 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3539 goto end;
3540 }
3541
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003542 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 &session_id);
3544 if (session_entry == NULL) {
3545 lim_log(mac_ctx, LOGE,
3546 FL("session does not exist for given bssId"));
3547 goto end;
3548 }
3549
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003550 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3552 (session_entry->limSmeState !=
3553 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3554 lim_log(mac_ctx, LOGE, FL(
3555 "Rcvd unexpected msg %X in state %X, in role %X"),
3556 msg_type, session_entry->limSmeState,
3557 GET_LIM_SYSTEM_ROLE(session_entry));
3558 goto end;
3559 }
3560 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3561 &session_entry->dph.dphHashTable);
3562 if (sta_ds == NULL) {
3563 lim_log(mac_ctx, LOGE, FL(
3564 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3565 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003566 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567
3568 /*
3569 * send a DISASSOC_IND message to WSM to make sure
3570 * the state in WSM and LIM is the same
3571 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003572 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 eSIR_SME_STA_NOT_ASSOCIATED,
3574 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3575 session_entry->smeSessionId,
3576 session_entry->transactionId,
3577 session_entry);
3578 goto end;
3579 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303580 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003581 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303582 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 lim_log(mac_ctx, LOG1, FL(
3584 "peerMacAddr mismatched for aid %d, peer "),
3585 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003586 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 goto end;
3588 }
3589
3590 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3591 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3592 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3593 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3594 (msg_type != eWNI_SME_ASSOC_CNF))) {
3595 lim_log(mac_ctx, LOG1, FL(
3596 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3597 "StaD mlmState : %d"),
3598 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003599 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 goto end;
3601 }
3602 /*
3603 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3604 * has been received
3605 */
3606 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3607 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3608 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3609
3610 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3611 /*
3612 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3613 * when it had received Assoc Request frame. Now, PE just needs
3614 * to send association rsp frame to the requesting BTAMP-STA.
3615 */
3616 sta_ds->mlmStaContext.mlmState =
3617 eLIM_MLM_LINK_ESTABLISHED_STATE;
3618 lim_log(mac_ctx, LOG1,
3619 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3620 sta_ds->assocId);
3621 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3622 sta_ds->assocId, sta_ds->staAddr,
3623 sta_ds->mlmStaContext.subType, sta_ds,
3624 session_entry);
3625 goto end;
3626 } else {
3627 /*
3628 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3629 * to be associated since the HAL sta entry is created for
3630 * denied STA we need to remove this HAL entry.
3631 * So to do that set updateContext to 1
3632 */
3633 if (!sta_ds->mlmStaContext.updateContext)
3634 sta_ds->mlmStaContext.updateContext = 1;
3635 lim_log(mac_ctx, LOG1,
3636 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3637 assoc_cnf.statusCode, sta_ds->assocId);
3638 lim_reject_association(mac_ctx, sta_ds->staAddr,
3639 sta_ds->mlmStaContext.subType,
3640 true, sta_ds->mlmStaContext.authType,
3641 sta_ds->assocId, true,
3642 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3643 session_entry);
3644 }
3645end:
3646 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3647 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3648 assoc_req = (tpSirAssocReq)
3649 session_entry->parsedAssocReq[sta_ds->assocId];
3650 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303651 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 assoc_req->assocReqFrame = NULL;
3653 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303654 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3656 }
3657}
3658
3659static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3660{
3661 tpDphHashNode pStaDs;
3662 tSirMacAddr peerMac;
3663 tpSirAddtsReq pSirAddts;
3664 uint32_t timeout;
3665 tpPESession psessionEntry;
3666 uint8_t sessionId; /* PE sessionId */
3667 uint8_t smesessionId;
3668 uint16_t smetransactionId;
3669
3670 if (pMsgBuf == NULL) {
3671 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3672 return;
3673 }
3674
3675 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3676 &smetransactionId);
3677
3678 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3679
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003680 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3681 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 if (psessionEntry == NULL) {
3683 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3684 return;
3685 }
3686#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3687 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3688 0);
3689#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3690
3691 /* if sta
3692 * - verify assoc state
3693 * - send addts request to ap
3694 * - wait for addts response from ap
3695 * if ap, just ignore with error log
3696 */
3697 PELOG1(lim_log(pMac, LOG1,
3698 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3699 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3700 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3701 )
3702
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003703 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3705 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3706 psessionEntry, pSirAddts->req.tspec,
3707 smesessionId, smetransactionId);
3708 return;
3709 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710
3711 pStaDs =
3712 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3713 &psessionEntry->dph.dphHashTable);
3714
3715 if (pStaDs == NULL) {
3716 PELOGE(lim_log
3717 (pMac, LOGE, "Cannot find AP context for addts req");
3718 )
3719 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3720 psessionEntry, pSirAddts->req.tspec,
3721 smesessionId, smetransactionId);
3722 return;
3723 }
3724
3725 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3726 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3727 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3728 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3729 psessionEntry, pSirAddts->req.tspec,
3730 smesessionId, smetransactionId);
3731 return;
3732 }
3733
3734 pSirAddts->req.wsmTspecPresent = 0;
3735 pSirAddts->req.wmeTspecPresent = 0;
3736 pSirAddts->req.lleTspecPresent = 0;
3737
3738 if ((pStaDs->wsmEnabled) &&
3739 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3740 SIR_MAC_ACCESSPOLICY_EDCA))
3741 pSirAddts->req.wsmTspecPresent = 1;
3742 else if (pStaDs->wmeEnabled)
3743 pSirAddts->req.wmeTspecPresent = 1;
3744 else if (pStaDs->lleEnabled)
3745 pSirAddts->req.lleTspecPresent = 1;
3746 else {
3747 PELOGW(lim_log
3748 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3749 )
3750 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3751 psessionEntry, pSirAddts->req.tspec,
3752 smesessionId, smetransactionId);
3753 return;
3754 }
3755
3756 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3757 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3758 lim_log(pMac, LOGE,
3759 "AddTs received in invalid LIMsme state (%d)",
3760 psessionEntry->limSmeState);
3761 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3762 psessionEntry, pSirAddts->req.tspec,
3763 smesessionId, smetransactionId);
3764 return;
3765 }
3766
3767 if (pMac->lim.gLimAddtsSent) {
3768 lim_log(pMac, LOGE,
3769 "Addts (token %d, tsid %d, up %d) is still pending",
3770 pMac->lim.gLimAddtsReq.req.dialogToken,
3771 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3772 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3773 userPrio);
3774 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3775 psessionEntry, pSirAddts->req.tspec,
3776 smesessionId, smetransactionId);
3777 return;
3778 }
3779
3780 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3781
3782 /* save the addts request */
3783 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303784 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3786
3787 /* ship out the message now */
3788 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3789 psessionEntry);
3790 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3791 /* start a timer to wait for the response */
3792 if (pSirAddts->timeout)
3793 timeout = pSirAddts->timeout;
3794 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3795 eSIR_SUCCESS) {
3796 lim_log(pMac, LOGP,
3797 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3798 WNI_CFG_ADDTS_RSP_TIMEOUT);
3799 return;
3800 }
3801
3802 timeout = SYS_MS_TO_TICKS(timeout);
3803 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3804 != TX_SUCCESS) {
3805 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3806 return;
3807 }
3808 pMac->lim.gLimAddtsRspTimerCount++;
3809 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3810 pMac->lim.gLimAddtsRspTimerCount) !=
3811 TX_SUCCESS) {
3812 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3813 return;
3814 }
3815 MTRACE(mac_trace
3816 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3817 eLIM_ADDTS_RSP_TIMER));
3818
3819 /* add the sessionId to the timer object */
3820 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3821 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3822 TX_SUCCESS) {
3823 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3824 return;
3825 }
3826 return;
3827}
3828
3829static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3830{
3831 tSirMacAddr peerMacAddr;
3832 uint8_t ac;
3833 tSirMacTSInfo *pTsinfo;
3834 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3835 tpDphHashNode pStaDs = NULL;
3836 tpPESession psessionEntry;
3837 uint8_t sessionId;
3838 uint32_t status = eSIR_SUCCESS;
3839 uint8_t smesessionId;
3840 uint16_t smetransactionId;
3841
3842 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3843 &smetransactionId);
3844
3845 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003846 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847 &sessionId);
3848 if (psessionEntry == NULL) {
3849 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3850 status = eSIR_FAILURE;
3851 goto end;
3852 }
3853#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3854 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3855 0);
3856#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3857
3858 if (eSIR_SUCCESS !=
3859 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3860 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3861 status = eSIR_FAILURE;
3862 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3863 smesessionId, smetransactionId);
3864 return;
3865 }
3866
3867 lim_log(pMac, LOG1,
3868 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3869 MAC_ADDRESS_STR),
3870 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3871
3872 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3873 pDeltsReq->req.wmeTspecPresent,
3874 &pDeltsReq->req.tsinfo,
3875 &pDeltsReq->req.tspec, psessionEntry);
3876
3877 pTsinfo =
3878 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3879 tsinfo : &pDeltsReq->req.tsinfo;
3880
3881 /* We've successfully send DELTS frame to AP. Update the
3882 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3883 * is no longer trigger enabled or delivery enabled
3884 */
3885 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3886 pTsinfo, CLEAR_UAPSD_MASK);
3887
3888 /* We're deleting the TSPEC, so this particular AC is no longer
3889 * admitted. PE needs to downgrade the EDCA
3890 * parameters(for the AC for which TS is being deleted) to the
3891 * next best AC for which ACM is not enabled, and send the
3892 * updated values to HAL.
3893 */
3894 ac = upToAc(pTsinfo->traffic.userPrio);
3895
3896 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3897 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3898 ~(1 << ac);
3899 } else if (pTsinfo->traffic.direction ==
3900 SIR_MAC_DIRECTION_DNLINK) {
3901 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3902 ~(1 << ac);
3903 } else if (pTsinfo->traffic.direction ==
3904 SIR_MAC_DIRECTION_BIDIR) {
3905 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3906 ~(1 << ac);
3907 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3908 ~(1 << ac);
3909 }
3910
3911 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3912 psessionEntry);
3913
3914 pStaDs =
3915 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3916 &psessionEntry->dph.dphHashTable);
3917 if (pStaDs != NULL) {
3918 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3919 pStaDs->bssId);
3920 status = eSIR_SUCCESS;
3921 } else {
3922 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3923 status = eSIR_FAILURE;
3924 }
3925#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927#endif
3928
3929 /* send an sme response back */
3930end:
3931 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3932 smesessionId, smetransactionId);
3933}
3934
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303935void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936{
3937 /* fetch the sessionEntry based on the sessionId */
3938 tpPESession psessionEntry;
3939 psessionEntry = pe_find_session_by_session_id(pMac,
3940 pMac->lim.limTimers.gLimAddtsRspTimer.
3941 sessionId);
3942 if (psessionEntry == NULL) {
3943 lim_log(pMac, LOGP,
3944 FL("Session Does not exist for given sessionID"));
3945 return;
3946 }
3947
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003948 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3950 GET_LIM_SYSTEM_ROLE(psessionEntry));
3951 pMac->lim.gLimAddtsSent = false;
3952 return;
3953 }
3954
3955 if (!pMac->lim.gLimAddtsSent) {
3956 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3957 return;
3958 }
3959
3960 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3961 lim_log(pMac, LOGE,
3962 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3963 pMac->lim.gLimAddtsRspTimerCount);
3964 return;
3965 }
3966 /* this a real response timeout */
3967 pMac->lim.gLimAddtsSent = false;
3968 pMac->lim.gLimAddtsRspTimerCount++;
3969
3970 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3971 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3972 psessionEntry->smeSessionId,
3973 psessionEntry->transactionId);
3974}
3975
3976/**
3977 * __lim_process_sme_get_statistics_request()
3978 *
3979 ***FUNCTION:
3980 *
3981 *
3982 ***NOTE:
3983 *
3984 * @param pMac Pointer to Global MAC structure
3985 * @param *pMsgBuf A pointer to the SME message buffer
3986 * @return None
3987 */
3988static void
3989__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3990{
3991 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08003992 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993
3994 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3995
3996 msgQ.type = WMA_GET_STATISTICS_REQ;
3997
3998 msgQ.reserved = 0;
3999 msgQ.bodyptr = pMsgBuf;
4000 msgQ.bodyval = 0;
4001 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4002
4003 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304004 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 pMsgBuf = NULL;
4006 lim_log(pMac, LOGP, "Unable to forward request");
4007 return;
4008 }
4009
4010 return;
4011}
4012
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004013#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004015 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004017 * @pMac: Pointer to Global MAC structure
4018 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004020 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 */
4022static void
4023__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4024{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004025 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026
4027 msgQ.type = WMA_TSM_STATS_REQ;
4028 msgQ.reserved = 0;
4029 msgQ.bodyptr = pMsgBuf;
4030 msgQ.bodyval = 0;
4031 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4032
4033 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304034 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 pMsgBuf = NULL;
4036 lim_log(pMac, LOGP, "Unable to forward request");
4037 return;
4038 }
4039}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004040#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041
4042static void
4043__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4044{
4045 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4046 tpPESession psessionEntry;
4047 uint8_t sessionId; /* PE sessionID */
4048
4049 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4050
4051 if (pMsgBuf == NULL) {
4052 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4053 return;
4054 }
4055
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304056 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 if (NULL == pUpdateAPWPSIEsReq) {
4058 lim_log(pMac, LOGP,
4059 FL
4060 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4061 return;
4062 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304063 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 sizeof(struct sSirUpdateAPWPSIEsReq));
4065
4066 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004067 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 &sessionId);
4069 if (psessionEntry == NULL) {
4070 lim_log(pMac, LOGW,
4071 FL("Session does not exist for given BSSID"));
4072 goto end;
4073 }
4074
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304075 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 sizeof(tSirAPWPSIEs));
4077
4078 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4079 lim_send_beacon_ind(pMac, psessionEntry);
4080
4081end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304082 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 return;
4084}
4085
4086void
4087lim_send_vdev_restart(tpAniSirGlobal pMac,
4088 tpPESession psessionEntry, uint8_t sessionId)
4089{
4090 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004091 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 tSirRetStatus retCode = eSIR_SUCCESS;
4093
4094 if (psessionEntry == NULL) {
4095 PELOGE(lim_log
4096 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4097 __LINE__);
4098 )
4099 return;
4100 }
4101
4102 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304103 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 if (NULL == pHalHiddenSsidVdevRestart) {
4105 PELOGE(lim_log
4106 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4107 __func__, __LINE__);
4108 )
4109 return;
4110 }
4111
4112 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4113 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4114
4115 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4116 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4117 msgQ.bodyval = 0;
4118
4119 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4120 if (eSIR_SUCCESS != retCode) {
4121 PELOGE(lim_log
4122 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4123 __LINE__);
4124 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304125 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 }
4127}
4128
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304129/**
4130 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4131 * @mac_ctx: Pointer to Global MAC structure
4132 * @msg_buf: Pointer to SME message buffer
4133 *
4134 * Return: None
4135 */
4136static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4137 uint32_t *msg_buf)
4138{
4139 tpPESession pe_session;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004140 struct scheduler_msg wma_msg;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304141 tSirRetStatus status;
4142 tSirRoamOffloadScanReq *req_buffer;
4143 uint16_t local_ie_len;
4144 uint8_t *local_ie_buf;
4145
4146 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4147 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4148 req_buffer->sessionId);
4149
4150 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4151 if (!local_ie_buf) {
Arif Hussain963331b2016-10-27 22:59:01 -07004152 lim_log(mac_ctx, LOGE,
4153 FL("Mem Alloc failed for local_ie_buf"));
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304154 return;
4155 }
4156
4157 local_ie_len = req_buffer->assoc_ie.length;
4158 /* Update ext cap IE if present */
4159 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004160 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4161 local_ie_buf, &local_ie_len)) {
4162 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004163 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4164 req_buffer->assoc_ie.length = local_ie_len;
4165 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4166 local_ie_buf, local_ie_len);
4167 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304168 }
4169 qdf_mem_free(local_ie_buf);
4170
4171 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4172 wma_msg.bodyptr = req_buffer;
4173
4174 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4175 if (eSIR_SUCCESS != status) {
4176 lim_log(mac_ctx, LOGE,
4177 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4178 qdf_mem_free(req_buffer);
4179 }
4180}
4181
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304182/*
4183 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4184 * @mac_ctx: Pointer to global mac context
4185 * @session: Pointer to PE session
4186 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4187 * 1 - Disable broadcast SSID
4188 *
4189 * Return: None
4190 */
4191static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4192 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304194 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4195 if (ssid_hidden != session->ssidHidden)
4196 session->ssidHidden = ssid_hidden;
4197 else {
4198 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304199 return;
4200 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201
4202 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304203 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204
4205 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304206 sch_set_fixed_beacon_fields(mac_ctx, session);
4207 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208
4209 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304210}
4211
4212/**
4213 * __lim_process_sme_session_update - process SME session update msg
4214 *
4215 * @mac_ctx: Pointer to global mac context
4216 * @msg_buf: Pointer to the received message buffer
4217 *
4218 * Return: None
4219 */
4220static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4221 uint32_t *msg_buf)
4222{
4223 struct sir_update_session_param *msg;
4224 tpPESession session;
4225
4226 if (!msg_buf) {
4227 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4228 return;
4229 }
4230
4231 msg = (struct sir_update_session_param *) msg_buf;
4232
4233 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4234 if (!session) {
4235 lim_log(mac_ctx, LOGW,
4236 "Session does not exist for given sessionId %d",
4237 msg->session_id);
4238 return;
4239 }
4240
4241 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4242 msg->param_type, msg->param_val);
4243 switch (msg->param_type) {
4244 case SIR_PARAM_SSID_HIDDEN:
4245 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4246 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304247 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4248 session->ignore_assoc_disallowed = msg->param_val;
4249 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304250 default:
4251 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4252 break;
4253 }
4254}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255
4256static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4257{
4258 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4259 tpPESession psessionEntry;
4260 uint8_t sessionId; /* PE sessionID */
4261
4262 if (pMsgBuf == NULL) {
4263 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4264 return;
4265 }
4266
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304267 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 if (NULL == pUpdateAPWPARSNIEsReq) {
4269 lim_log(pMac, LOGP,
4270 FL
4271 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4272 return;
4273 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304274 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4276
4277 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004278 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 &sessionId);
4280 if (psessionEntry == NULL) {
4281 lim_log(pMac, LOGW,
4282 FL("Session does not exist for given BSSID"));
4283 goto end;
4284 }
4285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304286 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4288
4289 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4290 &psessionEntry->
4291 pLimStartBssReq->rsnIE,
4292 psessionEntry);
4293
4294 psessionEntry->pLimStartBssReq->privacy = 1;
4295 psessionEntry->privacy = 1;
4296
4297 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4298 lim_send_beacon_ind(pMac, psessionEntry);
4299
4300end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304301 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 return;
4303} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4304
4305/*
4306 Update the beacon Interval dynamically if beaconInterval is different in MCC
4307 */
4308static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4309{
4310 tpSirChangeBIParams pChangeBIParams;
4311 tpPESession psessionEntry;
4312 uint8_t sessionId = 0;
4313 tUpdateBeaconParams beaconParams;
4314
4315 PELOG1(lim_log(pMac, LOG1,
4316 FL("received Update Beacon Interval message"));
4317 );
4318
4319 if (pMsgBuf == NULL) {
4320 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4321 return;
4322 }
4323
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304324 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4326
4327 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004328 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 &sessionId);
4330 if (psessionEntry == NULL) {
4331 lim_log(pMac, LOGE,
4332 FL("Session does not exist for given BSSID"));
4333 return;
4334 }
4335
4336 /*Update sessionEntry Beacon Interval */
4337 if (psessionEntry->beaconParams.beaconInterval !=
4338 pChangeBIParams->beaconInterval) {
4339 psessionEntry->beaconParams.beaconInterval =
4340 pChangeBIParams->beaconInterval;
4341 }
4342
4343 /*Update sch beaconInterval */
4344 if (pMac->sch.schObject.gSchBeaconInterval !=
4345 pChangeBIParams->beaconInterval) {
4346 pMac->sch.schObject.gSchBeaconInterval =
4347 pChangeBIParams->beaconInterval;
4348
4349 PELOG1(lim_log(pMac, LOG1,
4350 FL
4351 ("LIM send update BeaconInterval Indication : %d"),
4352 pChangeBIParams->beaconInterval);
4353 );
4354
4355 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4356 /* Update beacon */
4357 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4358
4359 beaconParams.bssIdx = psessionEntry->bssIdx;
4360 /* Set change in beacon Interval */
4361 beaconParams.beaconInterval =
4362 pChangeBIParams->beaconInterval;
4363 beaconParams.paramChangeBitmap =
4364 PARAM_BCN_INTERVAL_CHANGED;
4365 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4366 }
4367 }
4368
4369 return;
4370} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4371
4372#ifdef QCA_HT_2040_COEX
4373static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4374 uint32_t *pMsgBuf)
4375{
4376 tpSirSetHT2040Mode pSetHT2040Mode;
4377 tpPESession psessionEntry;
4378 uint8_t sessionId = 0;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004379 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 tUpdateVHTOpMode *pHtOpMode = NULL;
4381 uint16_t staId = 0;
4382 tpDphHashNode pStaDs = NULL;
4383
4384 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4385 if (pMsgBuf == NULL) {
4386 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4387 return;
4388 }
4389
4390 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4391
4392 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004393 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 &sessionId);
4395 if (psessionEntry == NULL) {
4396 lim_log(pMac, LOG1,
4397 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004398 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 return;
4400 }
4401
4402 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4403 pSetHT2040Mode->cbMode);
4404 /*Update sessionEntry HT related fields */
4405 switch (pSetHT2040Mode->cbMode) {
4406 case PHY_SINGLE_CHANNEL_CENTERED:
4407 psessionEntry->htSecondaryChannelOffset =
4408 PHY_SINGLE_CHANNEL_CENTERED;
4409 psessionEntry->htRecommendedTxWidthSet = 0;
4410 if (pSetHT2040Mode->obssEnabled)
4411 psessionEntry->htSupportedChannelWidthSet
4412 = eHT_CHANNEL_WIDTH_40MHZ;
4413 else
4414 psessionEntry->htSupportedChannelWidthSet
4415 = eHT_CHANNEL_WIDTH_20MHZ;
4416 break;
4417 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4418 psessionEntry->htSecondaryChannelOffset =
4419 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4420 psessionEntry->htRecommendedTxWidthSet = 1;
4421 break;
4422 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4423 psessionEntry->htSecondaryChannelOffset =
4424 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4425 psessionEntry->htRecommendedTxWidthSet = 1;
4426 break;
4427 default:
4428 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4429 return;
4430 }
4431
4432 /* Update beacon */
4433 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4434 lim_send_beacon_ind(pMac, psessionEntry);
4435
4436 /* update OP Mode for each associated peer */
4437 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4438 pStaDs = dph_get_hash_entry(pMac, staId,
4439 &psessionEntry->dph.dphHashTable);
4440 if (NULL == pStaDs)
4441 continue;
4442
4443 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304444 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 if (NULL == pHtOpMode) {
4446 lim_log(pMac, LOGE,
4447 FL
4448 ("%s: Not able to allocate memory for setting OP mode"),
4449 __func__);
4450 return;
4451 }
4452 pHtOpMode->opMode =
4453 (psessionEntry->htSecondaryChannelOffset ==
4454 PHY_SINGLE_CHANNEL_CENTERED) ?
4455 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4456 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 sizeof(tSirMacAddr));
4459 pHtOpMode->smesessionId = sessionId;
4460
4461 msg.type = WMA_UPDATE_OP_MODE;
4462 msg.reserved = 0;
4463 msg.bodyptr = pHtOpMode;
Krunal Soni66c113f2016-12-21 16:46:47 -08004464 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004465 scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08004466 &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 lim_log(pMac, LOGE,
4468 FL
4469 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4470 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304471 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 return;
4473 }
4474 lim_log(pMac, LOG1,
4475 FL
4476 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4477 __func__, pHtOpMode->opMode, staId);
4478
4479 } else
4480 lim_log(pMac, LOG1,
4481 FL("%s: station %d does not support HT40\n"),
4482 __func__, staId);
4483 }
4484
4485 return;
4486}
4487#endif
4488
4489/* -------------------------------------------------------------------- */
4490/**
4491 * __lim_process_report_message
4492 *
4493 * FUNCTION: Processes the next received Radio Resource Management message
4494 *
4495 * LOGIC:
4496 *
4497 * ASSUMPTIONS:
4498 *
4499 * NOTE:
4500 *
4501 * @param None
4502 * @return None
4503 */
4504
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004505static void __lim_process_report_message(tpAniSirGlobal pMac,
4506 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 switch (pMsg->type) {
4509 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4510 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4511 break;
4512 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004514 break;
4515 default:
4516 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518}
4519
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520/* -------------------------------------------------------------------- */
4521/**
4522 * lim_send_set_max_tx_power_req
4523 *
4524 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4525 *
4526 * LOGIC:
4527 *
4528 * ASSUMPTIONS:
4529 *
4530 * NOTE:
4531 *
4532 * @param txPower txPower to be set.
4533 * @param pSessionEntry session entry.
4534 * @return None
4535 */
4536tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004537lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 tpPESession pSessionEntry)
4539{
4540 tpMaxTxPowerParams pMaxTxParams = NULL;
4541 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004542 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543
4544 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304545 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 return eSIR_FAILURE;
4547 }
4548
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304549 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 if (NULL == pMaxTxParams) {
4551 lim_log(pMac, LOGP,
4552 FL("Unable to allocate memory for pMaxTxParams "));
4553 return eSIR_MEM_ALLOC_FAILED;
4554
4555 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304557 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304558 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304559 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004560 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304561 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562
4563 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4564 msgQ.bodyptr = pMaxTxParams;
4565 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304566 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4568 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4569 if (eSIR_SUCCESS != retCode) {
4570 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304571 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 }
4573 return retCode;
4574}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575
4576/**
4577 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4578 *
4579 * @mac_ctx: Pointer to Global MAC structure
4580 * @msg_buf: pointer to the SME message buffer
4581 *
4582 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4583 * from SME. It Register this information within PE.
4584 *
4585 * Return: None
4586 */
4587static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4588 uint32_t *msg_buf)
4589{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304590 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4592 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4593 struct mgmt_frm_reg_info *next = NULL;
4594 bool match = false;
4595
4596 lim_log(mac_ctx, LOG1, FL(
4597 "registerFrame %d, frameType %d, matchLen %d"),
4598 sme_req->registerFrame, sme_req->frameType,
4599 sme_req->matchLen);
4600 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304601 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304602 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4603 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304604 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605
4606 while (lim_mgmt_regn != NULL) {
4607 if (lim_mgmt_regn->frameType != sme_req->frameType)
4608 goto skip_match;
4609 if (sme_req->matchLen) {
4610 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304611 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 sme_req->matchData,
4613 lim_mgmt_regn->matchLen))) {
4614 /* found match! */
4615 match = true;
4616 break;
4617 }
4618 } else {
4619 /* found match! */
4620 match = true;
4621 break;
4622 }
4623skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304624 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304625 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304627 (qdf_list_node_t *)lim_mgmt_regn,
4628 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304629 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 lim_mgmt_regn = next;
4631 next = NULL;
4632 }
4633 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304634 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004635 if (QDF_STATUS_SUCCESS ==
4636 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004638 (qdf_list_node_t *)lim_mgmt_regn))
4639 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304640 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 }
4642
4643 if (sme_req->registerFrame) {
4644 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304645 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 sme_req->matchLen);
4647 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 lim_mgmt_regn->frameType = sme_req->frameType;
4649 lim_mgmt_regn->matchLen = sme_req->matchLen;
4650 lim_mgmt_regn->sessionId = sme_req->sessionId;
4651 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304652 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 sme_req->matchData,
4654 sme_req->matchLen);
4655 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304656 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304658 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 gLimMgmtFrameRegistratinQueue,
4660 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304661 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 &mac_ctx->lim.lim_frame_register_lock);
4663 }
4664 }
4665 return;
4666}
4667
4668static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4669{
4670 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4671 pMac->lim.gDeferMsgTypeForNOA);
4672 pMac->lim.gDeferMsgTypeForNOA = 0;
4673 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4674 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304675 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4677 }
4678}
4679
4680/**
4681 * lim_process_regd_defd_sme_req_after_noa_start()
4682 *
4683 * mac_ctx: Pointer to Global MAC structure
4684 *
4685 * This function is called to process deferred sme req message
4686 * after noa start.
4687 *
4688 * Return: None
4689 */
4690void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4691{
4692 bool buf_consumed = true;
4693
4694 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4695 mac_ctx->lim.gDeferMsgTypeForNOA);
4696
4697 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4698 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4699 lim_log(mac_ctx, LOGW,
4700 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4701 lim_log(mac_ctx, LOGW,
4702 FL("It may happen when NOA start ind and timeout happen at the same time"));
4703 return;
4704 }
4705 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4706 case eWNI_SME_SCAN_REQ:
4707 __lim_process_sme_scan_req(mac_ctx,
4708 mac_ctx->lim.gpDefdSmeMsgForNOA);
4709 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4711 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4712 mac_ctx->lim.gpDefdSmeMsgForNOA);
4713 /*
4714 * lim_process_remain_on_chnl_req doesnt want us to free
4715 * the buffer since it is freed in lim_remain_on_chn_rsp.
4716 * this change is to avoid "double free"
4717 */
4718 if (false == buf_consumed)
4719 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4720 break;
4721 case eWNI_SME_JOIN_REQ:
4722 __lim_process_sme_join_req(mac_ctx,
4723 mac_ctx->lim.gpDefdSmeMsgForNOA);
4724 break;
4725 default:
4726 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4727 mac_ctx->lim.gDeferMsgTypeForNOA);
4728 break;
4729 }
4730 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4731}
4732
4733static void
4734__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4735{
4736 tpSirResetAPCapsChange pResetCapsChange;
4737 tpPESession psessionEntry;
4738 uint8_t sessionId = 0;
4739 if (pMsgBuf == NULL) {
4740 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4741 return;
4742 }
4743
4744 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4745 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004746 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4747 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 if (psessionEntry == NULL) {
4749 lim_log(pMac, LOGE,
4750 FL("Session does not exist for given BSSID"));
4751 return;
4752 }
4753
4754 psessionEntry->limSentCapsChangeNtf = false;
4755 return;
4756}
4757
4758/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304759 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4760 * @mac_ctx: Mac pointer
4761 * @msg_buf: Msg pointer containing the callback
4762 *
4763 * This function is used to save the p2p ack indication callback in PE.
4764 *
4765 * Return: None
4766 */
4767static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4768 uint32_t *msg_buf)
4769{
4770 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4771 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4772
4773 if (NULL == msg_buf) {
4774 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4775 return;
4776 }
4777 if (sme_req->callback)
4778 mac_ctx->p2p_ack_ind_cb =
4779 sme_req->callback;
4780 else
4781 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4782}
4783
4784/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304785 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4786 * indication callback in PE.
4787 * @mac_ptr: Mac pointer
4788 * @msg_buf: Msg pointer containing the callback
4789 *
4790 * This function is used save the Management frame
4791 * indication callback in PE.
4792 *
4793 * Return: None
4794 */
4795static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4796 uint32_t *msg_buf)
4797{
4798 struct sir_sme_mgmt_frame_cb_req *sme_req =
4799 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4800
4801 if (NULL == msg_buf) {
4802 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4803 return;
4804 }
4805 if (sme_req->callback)
4806 mac_ctx->mgmt_frame_ind_cb =
4807 (sir_mgmt_frame_ind_callback)sme_req->callback;
4808 else
4809 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4810}
4811
4812/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304813 *__lim_process_send_disassoc_frame: function processes disassoc frame
4814 * @mac_ctx: pointer to mac context
4815 * @msg_buf: message buffer
4816 *
4817 * function processes disassoc request received from SME
4818 *
4819 * return: none
4820 */
4821static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4822 uint32_t *msg_buf)
4823{
4824 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4825 tSirRetStatus status;
4826 tpPESession session_entry = NULL;
4827 uint8_t sme_session_id;
4828 uint16_t sme_trans_id;
4829
4830 if (msg_buf == NULL) {
4831 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4832 return;
4833 }
4834
4835 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4836 &sme_trans_id);
4837
4838 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4839 &sme_send_disassoc_frame_req,
4840 (uint8_t *)msg_buf);
4841
4842 if ((eSIR_FAILURE == status) ||
4843 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4844 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4845 PELOGE(lim_log(mac_ctx, LOGE,
4846 FL("received invalid SME_DISASSOC_REQ message"));)
4847 return;
4848 }
4849
4850 session_entry = pe_find_session_by_sme_session_id(
4851 mac_ctx, sme_session_id);
4852 if (session_entry == NULL) {
4853 lim_log(mac_ctx, LOGE,
4854 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4855 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4856 return;
4857 }
4858
4859 lim_log(mac_ctx, LOG1,
4860 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4861 sme_send_disassoc_frame_req.msg_type,
4862 sme_send_disassoc_frame_req.length,
4863 sme_send_disassoc_frame_req.session_id,
4864 sme_send_disassoc_frame_req.trans_id,
4865 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4866 sme_send_disassoc_frame_req.reason,
4867 sme_send_disassoc_frame_req.wait_for_ack);
4868
4869 lim_send_disassoc_mgmt_frame(mac_ctx,
4870 sme_send_disassoc_frame_req.reason,
4871 sme_send_disassoc_frame_req.peer_mac,
4872 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4873}
4874
4875/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004876 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4877 * @mac_ctx: Pointer to Global MAC structure
4878 * @pdev_id: pdev id to set the IE.
4879 * @nss: Nss values to prepare the HT IE.
4880 *
4881 * Prepares the HT IE with self capabilities for different
4882 * Nss values and sends the set HT IE req to FW.
4883 *
4884 * Return: None
4885 */
4886static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4887 uint8_t nss)
4888{
4889 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004890 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004891 tSirRetStatus rc = eSIR_SUCCESS;
4892 uint8_t *p_ie = NULL;
4893 tHtCaps *p_ht_cap;
4894 int i;
4895
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004896 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004897 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4898 if (NULL == ie_params) {
4899 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4900 return;
4901 }
4902 ie_params->nss = i;
4903 ie_params->pdev_id = pdev_id;
4904 ie_params->ie_type = DOT11_HT_IE;
4905 /* 2 for IE len and EID */
4906 ie_params->ie_len = 2 + sizeof(tHtCaps);
4907 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4908 if (NULL == ie_params->ie_ptr) {
4909 qdf_mem_free(ie_params);
4910 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4911 return;
4912 }
4913 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4914 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4915 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4916 ie_params->ie_len);
4917
4918 if (NSS_1x1_MODE == i) {
4919 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4920 ie_params->ie_len,
4921 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004922 if (NULL == p_ie) {
4923 qdf_mem_free(ie_params->ie_ptr);
4924 qdf_mem_free(ie_params);
4925 lim_log(mac_ctx, LOGE,
4926 FL("failed to get IE ptr"));
4927 return;
4928 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004929 p_ht_cap = (tHtCaps *)&p_ie[2];
4930 p_ht_cap->supportedMCSSet[1] = 0;
4931 p_ht_cap->txSTBC = 0;
4932 }
4933
4934 msg.type = WMA_SET_PDEV_IE_REQ;
4935 msg.bodyptr = ie_params;
4936 msg.bodyval = 0;
4937
4938 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4939 if (rc != eSIR_SUCCESS) {
4940 lim_log(mac_ctx, LOGE,
4941 FL("wma_post_ctrl_msg() return failure"));
4942 qdf_mem_free(ie_params->ie_ptr);
4943 qdf_mem_free(ie_params);
4944 return;
4945 }
4946 }
4947}
4948
4949/**
4950 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4951 * @mac_ctx: Pointer to Global MAC structure
4952 * @pdev_id: pdev id to set the IE.
4953 * @nss: Nss values to prepare the VHT IE.
4954 *
4955 * Prepares the VHT IE with self capabilities for different
4956 * Nss values and sends the set VHT IE req to FW.
4957 *
4958 * Return: None
4959 */
4960static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4961 uint8_t nss)
4962{
4963 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004964 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004965 tSirRetStatus rc = eSIR_SUCCESS;
4966 uint8_t *p_ie = NULL;
4967 tSirMacVHTCapabilityInfo *vht_cap;
4968 int i;
4969 tSirVhtMcsInfo *vht_mcs;
4970
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004971 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004972 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4973 if (NULL == ie_params) {
4974 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4975 return;
4976 }
4977 ie_params->nss = i;
4978 ie_params->pdev_id = pdev_id;
4979 ie_params->ie_type = DOT11_VHT_IE;
4980 /* 2 for IE len and EID */
4981 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4982 sizeof(tSirVhtMcsInfo);
4983 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4984 if (NULL == ie_params->ie_ptr) {
4985 qdf_mem_free(ie_params);
4986 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4987 return;
4988 }
4989 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4990 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4991 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4992 ie_params->ie_len);
4993
4994 if (NSS_1x1_MODE == i) {
4995 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4996 ie_params->ie_len,
4997 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004998 if (NULL == p_ie) {
4999 qdf_mem_free(ie_params->ie_ptr);
5000 qdf_mem_free(ie_params);
5001 lim_log(mac_ctx, LOGE,
5002 FL("failed to get IE ptr"));
5003 return;
5004 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005005 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5006 vht_cap->txSTBC = 0;
5007 vht_mcs =
5008 (tSirVhtMcsInfo *)&p_ie[2 +
5009 sizeof(tSirMacVHTCapabilityInfo)];
5010 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5011 vht_mcs->rxHighest =
5012 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5013 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5014 vht_mcs->txHighest =
5015 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5016 }
5017 msg.type = WMA_SET_PDEV_IE_REQ;
5018 msg.bodyptr = ie_params;
5019 msg.bodyval = 0;
5020
5021 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5022 if (rc != eSIR_SUCCESS) {
5023 lim_log(mac_ctx, LOGE,
5024 FL("wma_post_ctrl_msg failure"));
5025 qdf_mem_free(ie_params->ie_ptr);
5026 qdf_mem_free(ie_params);
5027 return;
5028 }
5029 }
5030}
5031
5032/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005033 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5034 * @mac_ctx: Pointer to Global MAC structure
5035 * @msg_buf: Pointer to the SME message buffer
5036 *
5037 * This function is called by limProcessMessageQueue(). This function sets the
5038 * VDEV IEs to the FW.
5039 *
5040 * Return: None
5041 */
5042static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5043 uint32_t *msg_buf)
5044{
5045 struct sir_set_vdev_ies_per_band *p_msg =
5046 (struct sir_set_vdev_ies_per_band *)msg_buf;
5047
5048 if (NULL == p_msg) {
5049 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5050 return;
5051 }
5052
5053 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5054 p_msg->vdev_id);
5055 /* intentionally using NULL here so that self capabilty are sent */
5056 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5057 QDF_STATUS_SUCCESS)
5058 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5059}
5060
5061/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005062 * lim_process_set_pdev_IEs() - process the set pdev IE req
5063 * @mac_ctx: Pointer to Global MAC structure
5064 * @msg_buf: Pointer to the SME message buffer
5065 *
5066 * This function is called by limProcessMessageQueue(). This
5067 * function sets the PDEV IEs to the FW.
5068 *
5069 * Return: None
5070 */
5071static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5072{
5073 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5074
5075 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5076
5077 if (NULL == ht_vht_cfg) {
5078 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5079 return;
5080 }
5081
5082 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5083 ht_vht_cfg->nss);
5084 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5085
5086 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5087 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5088 ht_vht_cfg->nss);
5089}
5090
5091/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305092 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5093 *
5094 * access policy
5095 * @mac_ctx: pointer to mac context
5096 * @msg: message buffer
5097 *
5098 * function processes vendor IE and access policy from SME and updates PE
5099 *
5100 * session entry
5101 *
5102 * return: none
5103*/
5104static void lim_process_sme_update_access_policy_vendor_ie(
5105 tpAniSirGlobal mac_ctx,
5106 uint32_t *msg)
5107{
5108 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5109 struct sPESession *pe_session_entry;
5110 uint8_t num_bytes;
5111
5112 if (!msg) {
5113 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5114 return;
5115 }
5116 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5117 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5118 update_vendor_ie->sme_session_id);
5119
5120 if (!pe_session_entry) {
5121 lim_log(mac_ctx, LOGE,
5122 FL("Session does not exist for given sme session id(%hu)"),
5123 update_vendor_ie->sme_session_id);
5124 return;
5125 }
5126 if (pe_session_entry->access_policy_vendor_ie)
5127 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5128
5129 num_bytes = update_vendor_ie->ie[1] + 2;
5130 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5131
5132 if (!pe_session_entry->access_policy_vendor_ie) {
5133 lim_log(mac_ctx, LOGE,
5134 FL("Failed to allocate memory for vendor ie"));
5135 return;
5136 }
5137 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5138 &update_vendor_ie->ie[0], num_bytes);
5139
5140 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5141}
5142
5143/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 * lim_process_sme_req_messages()
5145 *
5146 ***FUNCTION:
5147 * This function is called by limProcessMessageQueue(). This
5148 * function processes SME request messages from HDD or upper layer
5149 * application.
5150 *
5151 ***LOGIC:
5152 *
5153 ***ASSUMPTIONS:
5154 *
5155 ***NOTE:
5156 *
5157 * @param pMac Pointer to Global MAC structure
5158 * @param msgType Indicates the SME message type
5159 * @param *pMsgBuf A pointer to the SME message buffer
5160 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5161 * false - if pMsgBuf is not to be freed.
5162 */
5163
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005164bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5165 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166{
5167 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5168 uint32_t *pMsgBuf = pMsg->bodyptr;
5169 tpSirSmeScanReq pScanReq;
5170 PELOG1(lim_log
5171 (pMac, LOG1,
5172 FL
5173 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5174 lim_msg_str(pMsg->type), pMsg->type,
5175 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5176 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5177 )
5178
5179 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5180 /* If no insert NOA required then execute the code below */
5181
5182 switch (pMsg->type) {
5183 case eWNI_SME_SYS_READY_IND:
5184 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5185 break;
5186
5187 case eWNI_SME_START_BSS_REQ:
5188 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5189 break;
5190
5191 case eWNI_SME_SCAN_REQ:
5192 __lim_process_sme_scan_req(pMac, pMsgBuf);
5193 break;
5194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5196 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5197 break;
5198
5199 case eWNI_SME_UPDATE_NOA:
5200 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5201 break;
5202 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5203 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5204 break;
5205 case eWNI_SME_JOIN_REQ:
5206 __lim_process_sme_join_req(pMac, pMsgBuf);
5207 break;
5208
5209 case eWNI_SME_REASSOC_REQ:
5210 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5211 break;
5212
5213 case eWNI_SME_DISASSOC_REQ:
5214 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5215 break;
5216
5217 case eWNI_SME_DISASSOC_CNF:
5218 case eWNI_SME_DEAUTH_CNF:
5219 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5220 break;
5221
5222 case eWNI_SME_DEAUTH_REQ:
5223 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5224 break;
5225
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305226 case eWNI_SME_SEND_DISASSOC_FRAME:
5227 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5228 break;
5229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 case eWNI_SME_SETCONTEXT_REQ:
5231 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5232 break;
5233
5234 case eWNI_SME_STOP_BSS_REQ:
5235 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5236 break;
5237
5238 case eWNI_SME_ASSOC_CNF:
5239 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5240 PELOG1(lim_log(pMac,
5241 LOG1, FL("Received ASSOC_CNF message"));)
5242 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5243 pMsgBuf);
5244 break;
5245
5246 case eWNI_SME_ADDTS_REQ:
5247 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5248 __lim_process_sme_addts_req(pMac, pMsgBuf);
5249 break;
5250
5251 case eWNI_SME_DELTS_REQ:
5252 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5253 __lim_process_sme_delts_req(pMac, pMsgBuf);
5254 break;
5255
5256 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5257 PELOG1(lim_log
5258 (pMac, LOG1,
5259 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5260 )
5261 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5262 break;
5263
5264 case eWNI_SME_GET_STATISTICS_REQ:
5265 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5266 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5267 bufConsumed = false;
5268 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005269#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 case eWNI_SME_GET_TSM_STATS_REQ:
5271 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5272 bufConsumed = false;
5273 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005274#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 case eWNI_SME_GET_ASSOC_STAS_REQ:
5276 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5277 break;
5278 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5279 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5280 break;
5281
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305282 case eWNI_SME_SESSION_UPDATE_PARAM:
5283 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305285 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5286 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5287 bufConsumed = false;
5288 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289 case eWNI_SME_UPDATE_APWPSIE_REQ:
5290 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5291 break;
5292 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5293 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5294 break;
5295
5296 case eWNI_SME_SET_APWPARSNIEs_REQ:
5297 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5298 break;
5299
5300 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5301 /* Update the beaconInterval */
5302 __lim_process_sme_change_bi(pMac, pMsgBuf);
5303 break;
5304
5305#ifdef QCA_HT_2040_COEX
5306 case eWNI_SME_SET_HT_2040_MODE:
5307 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5308 break;
5309#endif
5310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5312 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5313 __lim_process_report_message(pMac, pMsg);
5314 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 case eWNI_SME_FT_PRE_AUTH_REQ:
5317 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5318 break;
5319 case eWNI_SME_FT_UPDATE_KEY:
5320 lim_process_ft_update_key(pMac, pMsgBuf);
5321 break;
5322
5323 case eWNI_SME_FT_AGGR_QOS_REQ:
5324 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5325 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326
5327 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5328 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5329 break;
5330#ifdef FEATURE_WLAN_TDLS
5331 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5332 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5333 break;
5334 case eWNI_SME_TDLS_ADD_STA_REQ:
5335 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5336 break;
5337 case eWNI_SME_TDLS_DEL_STA_REQ:
5338 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5339 break;
5340 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5341 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5342 break;
5343#endif
5344 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5345 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5346 break;
5347
5348 case eWNI_SME_CHANNEL_CHANGE_REQ:
5349 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5350 break;
5351
5352 case eWNI_SME_START_BEACON_REQ:
5353 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5354 break;
5355
5356 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5357 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5358 break;
5359
5360 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5361 lim_process_update_add_ies(pMac, pMsgBuf);
5362 break;
5363
5364 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5365 lim_process_modify_add_ies(pMac, pMsgBuf);
5366 break;
5367 case eWNI_SME_SET_HW_MODE_REQ:
5368 lim_process_set_hw_mode(pMac, pMsgBuf);
5369 break;
5370 case eWNI_SME_NSS_UPDATE_REQ:
5371 lim_process_nss_update_request(pMac, pMsgBuf);
5372 break;
5373 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5374 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5375 break;
5376 case eWNI_SME_SET_IE_REQ:
5377 lim_process_set_ie_req(pMac, pMsgBuf);
5378 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305379 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5380 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5381 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305382 case eWNI_SME_EXT_CHANGE_CHANNEL:
5383 lim_process_ext_change_channel(pMac, pMsgBuf);
5384 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005385 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5386 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5387 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005388 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5389 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005390 break;
5391 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5392 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5393 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005394 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005395 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005396 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005397 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005398 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305399 case eWNI_SME_REGISTER_P2P_ACK_CB:
5400 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5401 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305402 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5403 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5404 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305406 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 pMsg->bodyptr = NULL;
5408 break;
5409 } /* switch (msgType) */
5410
5411 return bufConsumed;
5412} /*** end lim_process_sme_req_messages() ***/
5413
5414/**
5415 * lim_process_sme_start_beacon_req()
5416 *
5417 ***FUNCTION:
5418 * This function is called by limProcessMessageQueue(). This
5419 * function processes SME request messages from HDD or upper layer
5420 * application.
5421 *
5422 ***LOGIC:
5423 *
5424 ***ASSUMPTIONS:
5425 *
5426 ***NOTE:
5427 *
5428 * @param pMac Pointer to Global MAC structure
5429 * @param msgType Indicates the SME message type
5430 * @param *pMsgBuf A pointer to the SME message buffer
5431 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5432 * false - if pMsgBuf is not to be freed.
5433 */
5434static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5435{
5436 tpSirStartBeaconIndication pBeaconStartInd;
5437 tpPESession psessionEntry;
5438 uint8_t sessionId; /* PE sessionID */
5439
5440 if (pMsg == NULL) {
5441 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5442 return;
5443 }
5444
5445 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5446 psessionEntry = pe_find_session_by_bssid(pMac,
5447 pBeaconStartInd->bssid,
5448 &sessionId);
5449 if (psessionEntry == NULL) {
5450 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5451 lim_log(pMac, LOGE,
5452 FL("Session does not exist for given bssId"));
5453 return;
5454 }
5455
5456 if (pBeaconStartInd->beaconStartStatus == true) {
5457 /*
5458 * Currently this Indication comes from SAP
5459 * to start Beacon Tx on a DFS channel
5460 * since beaconing has to be done on DFS
5461 * channel only after CAC WAIT is completed.
5462 * On a DFS Channel LIM does not start beacon
5463 * Tx right after the WMA_ADD_BSS_RSP.
5464 */
5465 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305466 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 FL("Start Beacon with ssid %s Ch %d"),
5468 psessionEntry->ssId.ssId,
5469 psessionEntry->currentOperChannel);
5470 lim_send_beacon_ind(pMac, psessionEntry);
5471 } else {
5472 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5473 return;
5474 }
5475}
5476
5477/**
5478 * lim_process_sme_channel_change_request() - process sme ch change req
5479 *
5480 * @mac_ctx: Pointer to Global MAC structure
5481 * @msg_buf: pointer to the SME message buffer
5482 *
5483 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5484 *
5485 * Return: None
5486 */
5487static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5488 uint32_t *msg_buf)
5489{
5490 tpSirChanChangeRequest ch_change_req;
5491 tpPESession session_entry;
5492 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005493 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 uint32_t val = 0;
5495
5496 if (msg_buf == NULL) {
5497 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5498 return;
5499 }
5500 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5501
5502 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5503 ch_change_req->targetChannel);
5504
5505 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5506 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5507 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5508 return;
5509 }
5510
5511 session_entry = pe_find_session_by_bssid(mac_ctx,
5512 ch_change_req->bssid, &session_id);
5513 if (session_entry == NULL) {
5514 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5515 lim_log(mac_ctx, LOGE, FL(
5516 "Session does not exist for given bssId"));
5517 return;
5518 }
5519
5520 if (session_entry->currentOperChannel ==
5521 ch_change_req->targetChannel) {
5522 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5523 return;
5524 }
5525
5526 if (LIM_IS_AP_ROLE(session_entry))
5527 session_entry->channelChangeReasonCode =
5528 LIM_SWITCH_CHANNEL_SAP_DFS;
5529 else
5530 session_entry->channelChangeReasonCode =
5531 LIM_SWITCH_CHANNEL_OPERATION;
5532
5533 lim_log(mac_ctx, LOGW, FL(
5534 "switch old chnl %d to new chnl %d, ch_bw %d"),
5535 session_entry->currentOperChannel,
5536 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005537 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538
5539 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005540 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 session_entry->ch_center_freq_seg0 =
5542 ch_change_req->center_freq_seg_0;
5543 session_entry->ch_center_freq_seg1 =
5544 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005545 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005547 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 session_entry->htRecommendedTxWidthSet =
5549 session_entry->htSupportedChannelWidthSet;
5550 session_entry->currentOperChannel =
5551 ch_change_req->targetChannel;
5552 session_entry->limRFBand =
5553 lim_get_rf_band(session_entry->currentOperChannel);
5554 /* Initialize 11h Enable Flag */
5555 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5556 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5557 eSIR_SUCCESS)
5558 lim_log(mac_ctx, LOGP,
5559 FL("Fail to get WNI_CFG_11H_ENABLED"));
5560 }
5561
5562 session_entry->lim11hEnable = val;
5563 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305564 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 &ch_change_req->operational_rateset,
5566 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305567 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 &ch_change_req->extended_rateset,
5569 sizeof(session_entry->extRateSet));
5570 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5571 session_entry->ch_center_freq_seg0,
5572 session_entry->ch_center_freq_seg1,
5573 session_entry->ch_width,
5574 max_tx_pwr, session_entry->peSessionId);
5575}
5576
5577/******************************************************************************
5578* lim_start_bss_update_add_ie_buffer()
5579*
5580***FUNCTION:
5581* This function checks the src buffer and its length and then malloc for
5582* dst buffer update the same
5583*
5584***LOGIC:
5585*
5586***ASSUMPTIONS:
5587*
5588***NOTE:
5589*
5590* @param pMac Pointer to Global MAC structure
5591* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5592* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5593* @param *pSrcData_buff A pointer of uint8_t src buffer
5594* @param srcDataLen src buffer length
5595******************************************************************************/
5596
5597static void
5598lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5599 uint8_t **pDstData_buff,
5600 uint16_t *pDstDataLen,
5601 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5602{
5603
5604 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5605 *pDstDataLen = srcDataLen;
5606
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305607 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
5609 if (NULL == *pDstData_buff) {
5610 lim_log(pMac, LOGE,
5611 FL("AllocateMemory failed for pDstData_buff"));
5612 return;
5613 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 } else {
5616 *pDstData_buff = NULL;
5617 *pDstDataLen = 0;
5618 }
5619}
5620
5621/******************************************************************************
5622* lim_update_add_ie_buffer()
5623*
5624***FUNCTION:
5625* This function checks the src buffer and length if src buffer length more
5626* than dst buffer length then free the dst buffer and malloc for the new src
5627* length, and update the dst buffer and length. But if dst buffer is bigger
5628* than src buffer length then it just update the dst buffer and length
5629*
5630***LOGIC:
5631*
5632***ASSUMPTIONS:
5633*
5634***NOTE:
5635*
5636* @param pMac Pointer to Global MAC structure
5637* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5638* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5639* @param *pSrcData_buff A pointer of uint8_t src buffer
5640* @param srcDataLen src buffer length
5641******************************************************************************/
5642
5643static void
5644lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5645 uint8_t **pDstData_buff,
5646 uint16_t *pDstDataLen,
5647 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5648{
5649
5650 if (NULL == pSrcData_buff) {
5651 lim_log(pMac, LOGE, FL("src buffer is null."));
5652 return;
5653 }
5654
5655 if (srcDataLen > *pDstDataLen) {
5656 *pDstDataLen = srcDataLen;
5657 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305658 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305660 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661
5662 if (NULL == *pDstData_buff) {
5663 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5664 *pDstDataLen = 0;
5665 return;
5666 }
5667 }
5668
5669 /* copy the content of buffer into dst buffer
5670 */
5671 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305672 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673
5674}
5675
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005676/**
5677 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5678 * @pMac : Pointer to Global MAC structure
5679 * @pDstData_buff : A pointer to pointer of dst buffer
5680 * @pDstDataLen : A pointer to pointer of dst buffer length
5681 * @pModifyIE : A pointer to tSirModifyIE
5682 *
5683 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5684 *
5685 * Return:
5686 * True or false depending upon whether IE is updated or not
5687 */
5688static bool
5689lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5690 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5691{
Hong Shi1553d692016-09-28 12:16:19 +08005692 int32_t oui_length;
5693 uint8_t *ibss_ie = NULL;
5694 uint8_t *vendor_ie;
5695#define MAC_VENDOR_OUI "\x00\x16\x32"
5696#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005697
5698 ibss_ie = pModifyIE->pIEBuffer;
5699 oui_length = pModifyIE->oui_length;
5700
5701 if ((0 == oui_length) || (NULL == ibss_ie)) {
5702 PELOGE(lim_log(pMac, LOGE,
5703 FL("Invalid set IBSS vendor IE command length %d "),
5704 oui_length);)
5705 return false;
5706 }
5707
Hong Shi1553d692016-09-28 12:16:19 +08005708 /*
5709 * Why replace only beacon OUI data here:
5710 * 1. other ie (such as wpa) shall not be overwritten here.
5711 * 2. per spec, beacon oui ie might be set twice and original one
5712 * shall be updated.
5713 */
5714 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5715 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5716 if (vendor_ie) {
5717 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5718 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5719 pModifyIE->ieBufferlength);
5720 } else {
5721 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5722 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005723
Hong Shi1553d692016-09-28 12:16:19 +08005724 if (NULL == new_ptr) {
5725 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5726 return false;
5727 }
5728 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5729 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5730 pModifyIE->ieBufferlength);
5731 qdf_mem_free(*pDstData_buff);
5732 *pDstDataLen = new_length;
5733 *pDstData_buff = new_ptr;
5734 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005735 return true;
5736}
5737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738/*
5739* lim_process_modify_add_ies() - process modify additional IE req.
5740*
5741* @mac_ctx: Pointer to Global MAC structure
5742* @msg_buf: pointer to the SME message buffer
5743*
5744* This function update the PE buffers for additional IEs.
5745*
5746* Return: None
5747*/
5748static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5749 uint32_t *msg_buf)
5750{
5751 tpSirModifyIEsInd modify_add_ies;
5752 tpPESession session_entry;
5753 uint8_t session_id;
5754 bool ret = false;
5755 tSirAddIeParams *add_ie_params;
5756
5757 if (msg_buf == NULL) {
5758 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5759 return;
5760 }
5761
5762 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5763 /* Incoming message has smeSession, use BSSID to find PE session */
5764 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005765 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766
5767 if (NULL == session_entry) {
5768 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5769 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005770 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 goto end;
5772 }
5773 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5774 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5775 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5776 lim_log(mac_ctx, LOGE,
5777 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5778 modify_add_ies->modifyIE.pIEBuffer,
5779 modify_add_ies->modifyIE.ieBufferlength,
5780 modify_add_ies->modifyIE.ieID,
5781 modify_add_ies->modifyIE.ieIDLen,
5782 modify_add_ies->updateType);
5783 goto end;
5784 }
5785 add_ie_params = &session_entry->addIeParams;
5786 switch (modify_add_ies->updateType) {
5787 case eUPDATE_IE_PROBE_RESP:
5788 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005789 if (LIM_IS_IBSS_ROLE(session_entry)) {
5790 lim_update_ibss_prop_add_ies(mac_ctx,
5791 &add_ie_params->probeRespData_buff,
5792 &add_ie_params->probeRespDataLen,
5793 &modify_add_ies->modifyIE);
5794 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005795 break;
5796 case eUPDATE_IE_ASSOC_RESP:
5797 /* assoc resp IE */
5798 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305799 QDF_TRACE(QDF_MODULE_ID_PE,
5800 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 "assoc resp add ie not present %d"),
5802 add_ie_params->assocRespDataLen);
5803 }
5804 /* search through the buffer and modify the IE */
5805 break;
5806 case eUPDATE_IE_PROBE_BCN:
5807 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005808 if (LIM_IS_IBSS_ROLE(session_entry)) {
5809 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5810 &add_ie_params->probeRespBCNData_buff,
5811 &add_ie_params->probeRespBCNDataLen,
5812 &modify_add_ies->modifyIE);
5813 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814 if (ret == true && modify_add_ies->modifyIE.notify) {
5815 lim_handle_param_update(mac_ctx,
5816 modify_add_ies->updateType);
5817 }
5818 break;
5819 default:
5820 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5821 modify_add_ies->updateType);
5822 break;
5823 }
5824end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305825 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826 modify_add_ies->modifyIE.pIEBuffer = NULL;
5827}
5828
5829/*
5830* lim_process_update_add_ies() - process additional IE update req
5831*
5832* @mac_ctx: Pointer to Global MAC structure
5833* @msg_buf: pointer to the SME message buffer
5834*
5835* This function update the PE buffers for additional IEs.
5836*
5837* Return: None
5838*/
5839static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5840 uint32_t *msg_buf)
5841{
5842 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5843 uint8_t session_id;
5844 tpPESession session_entry;
5845 tSirAddIeParams *addn_ie;
5846 uint16_t new_length = 0;
5847 uint8_t *new_ptr = NULL;
5848 tSirUpdateIE *update_ie;
5849
5850 if (msg_buf == NULL) {
5851 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5852 return;
5853 }
5854 update_ie = &update_add_ies->updateIE;
5855 /* incoming message has smeSession, use BSSID to find PE session */
5856 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005857 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858
5859 if (NULL == session_entry) {
5860 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5861 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005862 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 goto end;
5864 }
5865 addn_ie = &session_entry->addIeParams;
5866 /* if len is 0, upper layer requested freeing of buffer */
5867 if (0 == update_ie->ieBufferlength) {
5868 switch (update_add_ies->updateType) {
5869 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305870 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 addn_ie->probeRespData_buff = NULL;
5872 addn_ie->probeRespDataLen = 0;
5873 break;
5874 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305875 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 addn_ie->assocRespData_buff = NULL;
5877 addn_ie->assocRespDataLen = 0;
5878 break;
5879 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305880 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881 addn_ie->probeRespBCNData_buff = NULL;
5882 addn_ie->probeRespBCNDataLen = 0;
5883
5884 if (update_ie->notify)
5885 lim_handle_param_update(mac_ctx,
5886 update_add_ies->updateType);
5887 break;
5888 default:
5889 break;
5890 }
5891 return;
5892 }
5893 switch (update_add_ies->updateType) {
5894 case eUPDATE_IE_PROBE_RESP:
5895 if (update_ie->append) {
5896 /*
5897 * In case of append, allocate new memory
5898 * with combined length
5899 */
5900 new_length = update_ie->ieBufferlength +
5901 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305902 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 if (NULL == new_ptr) {
5904 lim_log(mac_ctx, LOGE, FL(
5905 "Memory allocation failed."));
5906 goto end;
5907 }
5908 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305909 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305911 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005912 update_ie->pAdditionIEBuffer,
5913 update_ie->ieBufferlength);
5914 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305915 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005916 /* adjust length accordingly */
5917 addn_ie->probeRespDataLen = new_length;
5918 /* save refernece of local buffer in PE session */
5919 addn_ie->probeRespData_buff = new_ptr;
5920 goto end;
5921 }
5922 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5923 &addn_ie->probeRespDataLen,
5924 update_ie->pAdditionIEBuffer,
5925 update_ie->ieBufferlength);
5926 break;
5927 case eUPDATE_IE_ASSOC_RESP:
5928 /* assoc resp IE */
5929 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5930 &addn_ie->assocRespDataLen,
5931 update_ie->pAdditionIEBuffer,
5932 update_ie->ieBufferlength);
5933 break;
5934 case eUPDATE_IE_PROBE_BCN:
5935 /* probe resp Bcn IE */
5936 lim_update_add_ie_buffer(mac_ctx,
5937 &addn_ie->probeRespBCNData_buff,
5938 &addn_ie->probeRespBCNDataLen,
5939 update_ie->pAdditionIEBuffer,
5940 update_ie->ieBufferlength);
5941 if (update_ie->notify)
5942 lim_handle_param_update(mac_ctx,
5943 update_add_ies->updateType);
5944 break;
5945 default:
5946 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5947 update_add_ies->updateType);
5948 break;
5949 }
5950end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305951 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 update_ie->pAdditionIEBuffer = NULL;
5953}
5954
5955/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305956 * send_extended_chan_switch_action_frame()- function to send ECSA
5957 * action frame for each sta connected to SAP/GO and AP in case of
5958 * STA .
5959 * @mac_ctx: pointer to global mac structure
5960 * @new_channel: new channel to switch to.
5961 * @ch_bandwidth: BW of channel to calculate op_class
5962 * @session_entry: pe session
5963 *
5964 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5965 *
5966 * Return: void
5967 */
5968
5969static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5970 uint16_t new_channel, uint8_t ch_bandwidth,
5971 tpPESession session_entry)
5972{
5973 uint16_t op_class;
5974 uint8_t switch_mode = 0, i;
5975 tpDphHashNode psta;
5976
5977
Amar Singhal22995112016-01-22 10:42:33 -08005978 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305979 mac_ctx->scan.countryCodeCurrent,
5980 new_channel,
5981 ch_bandwidth);
5982
5983 if (LIM_IS_AP_ROLE(session_entry) &&
5984 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5985 switch_mode = 1;
5986
5987 if (LIM_IS_AP_ROLE(session_entry)) {
5988 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5989 psta =
5990 session_entry->dph.dphHashTable.pDphNodeArray + i;
5991 if (psta && psta->added)
5992 lim_send_extended_chan_switch_action_frame(
5993 mac_ctx,
5994 psta->staAddr,
5995 switch_mode, op_class, new_channel,
5996 LIM_MAX_CSA_IE_UPDATES, session_entry);
5997 }
5998 } else if (LIM_IS_STA_ROLE(session_entry)) {
5999 lim_send_extended_chan_switch_action_frame(mac_ctx,
6000 session_entry->bssId,
6001 switch_mode, op_class, new_channel,
6002 LIM_MAX_CSA_IE_UPDATES, session_entry);
6003 }
6004
6005}
6006
6007/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
6009 *
6010 * @mac_ctx: Pointer to Global MAC structure
6011 * @msg_buf: pointer to the SME message buffer
6012 *
6013 * This function processes SME request messages from HDD or upper layer
6014 * application.
6015 *
6016 * Return: None
6017 */
6018static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6019 uint32_t *msg_buf)
6020{
6021 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6022 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 uint8_t session_id;
6024 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006025 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006026
6027 if (msg_buf == NULL) {
6028 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6029 return;
6030 }
6031
6032 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6033 session_entry = pe_find_session_by_bssid(mac_ctx,
6034 dfs_csa_ie_req->bssid, &session_id);
6035 if (session_entry == NULL) {
6036 lim_log(mac_ctx, LOGE, FL(
6037 "Session not found for given BSSID" MAC_ADDRESS_STR),
6038 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6039 return;
6040 }
6041
6042 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6043 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6044 GET_LIM_SYSTEM_ROLE(session_entry));
6045 return;
6046 }
6047
6048 /* target channel */
6049 session_entry->gLimChannelSwitch.primaryChannel =
6050 dfs_csa_ie_req->targetChannel;
6051
6052 /* Channel switch announcement needs to be included in beacon */
6053 session_entry->dfsIncludeChanSwIe = true;
6054 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6055 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006056 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306057 session_entry->gLimChannelSwitch.sec_ch_offset =
6058 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6060 session_entry->gLimChannelSwitch.switchMode = 1;
6061
6062 /*
6063 * Validate if SAP is operating HT or VHT mode and set the Channel
6064 * Switch Wrapper element with the Wide Band Switch subelement.
6065 */
6066 if (true != session_entry->vhtCapability)
6067 goto skip_vht;
6068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 /* Now encode the Wider Ch BW element depending on the ch width */
6070 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006071 switch (dfs_csa_ie_req->ch_params.ch_width) {
6072 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073 /*
6074 * Wide channel BW sublement in channel wrapper element is not
6075 * required in case of 20 Mhz operation. Currently It is set
6076 * only set in case of 40/80 Mhz Operation.
6077 */
6078 session_entry->dfsIncludeChanWrapperIe = false;
6079 wider_bw_ch_switch->newChanWidth =
6080 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6081 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006082 case CH_WIDTH_40MHZ:
6083 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006084 wider_bw_ch_switch->newChanWidth =
6085 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6086 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006087 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 session_entry->dfsIncludeChanWrapperIe = true;
6089 wider_bw_ch_switch->newChanWidth =
6090 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6091 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006092 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 session_entry->dfsIncludeChanWrapperIe = true;
6094 wider_bw_ch_switch->newChanWidth =
6095 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6096 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006097 case CH_WIDTH_80P80MHZ:
6098 session_entry->dfsIncludeChanWrapperIe = true;
6099 wider_bw_ch_switch->newChanWidth =
6100 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006101 /*
6102 * This is not applicable for 20/40/80 Mhz.
6103 * Only used when we support 80+80 Mhz operation.
6104 * In case of 80+80 Mhz, this parameter indicates
6105 * center channel frequency index of 80 Mhz channel of
6106 * frequency segment 1.
6107 */
6108 wider_bw_ch_switch->newCenterChanFreq1 =
6109 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006110 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 default:
6112 session_entry->dfsIncludeChanWrapperIe = false;
6113 /*
6114 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6115 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6116 */
6117 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6118 break;
6119 }
6120 /* Fetch the center channel based on the channel width */
6121 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006122 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123skip_vht:
6124 /* Send CSA IE request from here */
6125 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6126 eSIR_SUCCESS) {
6127 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6128 return;
6129 }
6130
6131 /*
6132 * First beacon update request is sent here, the remaining updates are
6133 * done when the FW responds back after sending the first beacon after
6134 * the template update
6135 */
6136 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306137
6138 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6139 ch_offset = BW80;
6140 else
6141 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6142
6143 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6144 session_entry->gLimChannelSwitch.switchCount,
6145 session_entry->gLimChannelSwitch.primaryChannel,
6146 session_entry->gLimChannelSwitch.ch_width,
6147 session_entry->dfsIncludeChanWrapperIe,
6148 ch_offset);
6149
Abhishek Singh518323d2015-10-19 17:42:01 +05306150 /* Send ECSA Action frame after updating the beacon */
6151 send_extended_chan_switch_action_frame(mac_ctx,
6152 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306153 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154 session_entry->gLimChannelSwitch.switchCount--;
6155}
6156
6157/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306158 * lim_process_ext_change_channel()- function to send ECSA
6159 * action frame for STA/CLI .
6160 * @mac_ctx: pointer to global mac structure
6161 * @msg: params from sme for new channel.
6162 *
6163 * This function is called to send ECSA frame for STA/CLI.
6164 *
6165 * Return: void
6166 */
6167
6168static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6169 uint32_t *msg)
6170{
6171 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6172 (struct sir_sme_ext_cng_chan_req *) msg;
6173 tpPESession session_entry = NULL;
6174
6175 if (NULL == msg) {
6176 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6177 return;
6178 }
6179 session_entry =
6180 pe_find_session_by_sme_session_id(mac_ctx,
6181 ext_chng_channel->session_id);
6182 if (NULL == session_entry) {
6183 lim_log(mac_ctx, LOGE,
6184 FL("Session not found for given session %d"),
6185 ext_chng_channel->session_id);
6186 return;
6187 }
6188 if (LIM_IS_AP_ROLE(session_entry)) {
6189 lim_log(mac_ctx, LOGE,
6190 FL("not an STA/CLI session"));
6191 return;
6192 }
6193 send_extended_chan_switch_action_frame(mac_ctx,
6194 ext_chng_channel->new_channel,
6195 0, session_entry);
6196}
6197
6198/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 * lim_process_nss_update_request() - process sme nss update req
6200 *
6201 * @mac_ctx: Pointer to Global MAC structure
6202 * @msg_buf: pointer to the SME message buffer
6203 *
6204 * This function processes SME request messages from HDD or upper layer
6205 * application.
6206 *
6207 * Return: None
6208 */
6209static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6210 uint32_t *msg_buf)
6211{
6212 struct sir_nss_update_request *nss_update_req_ptr;
6213 tpPESession session_entry = NULL;
6214
6215 if (msg_buf == NULL) {
6216 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6217 return;
6218 }
6219
6220 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306221 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 nss_update_req_ptr->vdev_id);
6223 if (session_entry == NULL) {
6224 lim_log(mac_ctx, LOGE, FL(
6225 "Session not found for given session_id %d"),
6226 nss_update_req_ptr->vdev_id);
6227 return;
6228 }
6229
6230 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6231 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6232 GET_LIM_SYSTEM_ROLE(session_entry));
6233 return;
6234 }
6235
6236 /* populate nss field in the beacon */
6237 session_entry->gLimOperatingMode.present = 1;
6238 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6239 /* Send nss update request from here */
6240 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6241 eSIR_SUCCESS) {
6242 lim_log(mac_ctx, LOGE,
6243 FL("Unable to set op mode IE in beacon"));
6244 return;
6245 }
6246
6247 lim_send_beacon_ind(mac_ctx, session_entry);
6248}
6249
6250/**
6251 * lim_process_set_ie_req() - process sme set IE request
6252 *
6253 * @mac_ctx: Pointer to Global MAC structure
6254 * @msg_buf: pointer to the SME message buffer
6255 *
6256 * This function processes SME request messages from HDD or upper layer
6257 * application.
6258 *
6259 * Return: None
6260 */
6261static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6262{
6263 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306264 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265
6266 if (msg_buf == NULL) {
6267 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6268 return;
6269 }
6270
6271 msg = (struct send_extcap_ie *)msg_buf;
6272 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306273 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006274 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6275
6276}