blob: 2a7434b2c7a6b69edf8a4f1221e25d77c9063d63 [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);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530797 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 FL("*****session->vhtCapability = %d"),
799 session->vhtCapability);
800 session->txLdpcIniFeatureEnabled =
801 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#ifdef WLAN_FEATURE_11W
803 session->limRmfEnabled =
804 sme_start_bss_req->pmfCapable ? 1 : 0;
805 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
806 session->limRmfEnabled);
807#endif
808
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530809 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 (void *)&sme_start_bss_req->operationalRateSet,
811 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 (void *)&sme_start_bss_req->extendedRateSet,
814 sizeof(tSirMacRateSet));
815
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700816 if (IS_5G_CH(session->currentOperChannel))
817 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
818 else
819 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 switch (sme_start_bss_req->bssType) {
822 case eSIR_INFRA_AP_MODE:
823 lim_configure_ap_start_bss_session(mac_ctx, session,
824 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700825 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700826 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700827 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700828 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 break;
830 case eSIR_IBSS_MODE:
831 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
832 lim_get_short_slot_from_phy_mode(mac_ctx, session,
833 session->gLimPhyMode,
834 &session->shortSlotTimeSupported);
835
836 /*
837 * initialize to "OPEN".
838 * will be updated upon key installation
839 */
840 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700841 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842
843 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700844 case eSIR_NDI_MODE:
845 session->limSystemRole = eLIM_NDI_ROLE;
846 break;
847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 /*
850 * There is one more mode called auto mode.
851 * which is used no where
852 */
853
854 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
855
856 default:
857 /* not used anywhere...used in scan function */
858 break;
859 }
860
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700861 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
862 session->pePersona, session->vdev_nss);
863 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700865 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 * parsed (Re)Assoc request structure
867 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700868 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700871 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 if (NULL == session->parsedAssocReq) {
873 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700874 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
876 goto free;
877 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 }
879
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700880 if (!sme_start_bss_req->channelId &&
881 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 lim_log(mac_ctx, LOGE,
883 FL("Received invalid eWNI_SME_START_BSS_REQ"));
884 ret_code = eSIR_SME_INVALID_PARAMETERS;
885 goto free;
886 }
887 channel_number = sme_start_bss_req->channelId;
888#ifdef QCA_HT_2040_COEX
889 if (sme_start_bss_req->obssEnabled)
890 session->htSupportedChannelWidthSet =
891 session->htCapability;
892 else
893#endif
894 session->htSupportedChannelWidthSet =
895 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
896 session->htSecondaryChannelOffset =
897 sme_start_bss_req->sec_ch_offset;
898 session->htRecommendedTxWidthSet =
899 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530900 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 FL("cbMode %u"), sme_start_bss_req->cbMode);
902 if (session->vhtCapability || session->htCapability) {
903 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800904 lim_log(mac_ctx, LOG1,
905 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
906 sme_start_bss_req->vht_channel_width,
907 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 session->ch_width = chanwidth;
909 if (session->htSupportedChannelWidthSet) {
910 session->ch_center_freq_seg0 =
911 sme_start_bss_req->center_freq_seg0;
912 session->ch_center_freq_seg1 =
913 sme_start_bss_req->center_freq_seg1;
914 } else {
915 session->ch_center_freq_seg0 = 0;
916 session->ch_center_freq_seg1 = 0;
917 }
918 }
919
920 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700921 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700923 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
924 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 }
Krunal Soni53993f72016-07-08 18:20:03 -0700926 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
927 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
929 /* Delete pre-auth list if any */
930 lim_delete_pre_auth_list(mac_ctx);
931
Krunal Soni53993f72016-07-08 18:20:03 -0700932 if (session->nss == 1) {
933 session->vht_config.su_beam_former = 0;
934 session->vht_config.tx_stbc = 0;
935 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530936 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700937 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 /*
939 * keep the RSN/WPA IE information in PE Session Entry
940 * later will be using this to check when received (Re)Assoc req
941 */
942 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
943 &sme_start_bss_req->rsnIE, session);
944
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700945 if (LIM_IS_AP_ROLE(session) ||
946 LIM_IS_IBSS_ROLE(session) ||
947 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 session->gLimProtectionControl =
949 sme_start_bss_req->protEnabled;
950 /*
951 * each byte will have the following info
952 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
953 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
954 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530955 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 (void *)&sme_start_bss_req->ht_capab,
957 sizeof(uint16_t));
958 /* Initialize WPS PBC session link list */
959 session->pAPWPSPBCSession = NULL;
960 }
961 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530962 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 if (NULL == mlm_start_req) {
964 lim_log(mac_ctx, LOGP,
965 FL("Allocate Memory failed for mlmStartReq"));
966 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
967 goto free;
968 }
969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530971 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 (uint8_t *) &sme_start_bss_req->ssId,
973 sme_start_bss_req->ssId.length + 1);
974 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
975 mlm_start_req->obssProtEnabled =
976 sme_start_bss_req->obssProtEnabled;
977
978 mlm_start_req->bssType = session->bssType;
979
980 /* Fill PE session Id from the session Table */
981 mlm_start_req->sessionId = session->peSessionId;
982
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700983 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
984 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 /*
986 * Copy the BSSId from sessionTable to
987 * mlmStartReq struct
988 */
989 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
990 } else {
991 /* ibss mode */
992 mac_ctx->lim.gLimIbssCoalescingHappened = false;
993
994 ret_status = wlan_cfg_get_int(mac_ctx,
995 WNI_CFG_IBSS_AUTO_BSSID,
996 &auto_gen_bssid);
997 if (ret_status != eSIR_SUCCESS) {
998 lim_log(mac_ctx, LOGP,
999 FL("Get Auto Gen BSSID fail,Status=%d"),
1000 ret_status);
1001 ret_code = eSIR_LOGP_EXCEPTION;
1002 goto free;
1003 }
1004
1005 if (!auto_gen_bssid) {
1006 /*
1007 * We're not auto generating BSSID.
1008 * Instead, get it from session entry
1009 */
1010 sir_copy_mac_addr(mlm_start_req->bssId,
1011 session->bssId);
1012 /*
1013 * Start IBSS group BSSID
1014 * Auto Generating BSSID.
1015 */
1016 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1017 0x01) ? true : false);
1018 }
1019
1020 if (auto_gen_bssid) {
1021 /*
1022 * if BSSID is not any uc id.
1023 * then use locally generated BSSID.
1024 * Autogenerate the BSSID
1025 */
1026 lim_get_random_bssid(mac_ctx,
1027 mlm_start_req->bssId);
1028 mlm_start_req->bssId[0] = 0x02;
1029
1030 /*
1031 * Copy randomly generated BSSID
1032 * to the session Table
1033 */
1034 sir_copy_mac_addr(session->bssId,
1035 mlm_start_req->bssId);
1036 }
1037 }
1038 /* store the channel num in mlmstart req structure */
1039 mlm_start_req->channelNumber = session->currentOperChannel;
1040 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1041 mlm_start_req->beaconPeriod =
1042 session->beaconParams.beaconInterval;
1043
1044 if (LIM_IS_AP_ROLE(session)) {
1045 mlm_start_req->dtimPeriod = session->dtimPeriod;
1046 mlm_start_req->wps_state = session->wps_state;
1047
1048 } else {
1049 if (wlan_cfg_get_int(mac_ctx,
1050 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1051 lim_log(mac_ctx, LOGP,
1052 FL("could not retrieve DTIM Period"));
1053 mlm_start_req->dtimPeriod = (uint8_t) val;
1054 }
1055
1056 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1057 eSIR_SUCCESS)
1058 lim_log(mac_ctx, LOGP,
1059 FL("could not retrieve Beacon interval"));
1060 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1061
1062 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1063 eSIR_SUCCESS)
1064 lim_log(mac_ctx, LOGP,
1065 FL("could not retrieve CFPMaxDuration"));
1066 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1067
1068 /*
1069 * this may not be needed anymore now,
1070 * as rateSet is now included in the
1071 * session entry and MLM has session context.
1072 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301073 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 (void *)&session->rateSet,
1075 sizeof(tSirMacRateSet));
1076
1077 /* Now populate the 11n related parameters */
1078 mlm_start_req->nwType = session->nwType;
1079 mlm_start_req->htCapable = session->htCapability;
1080
1081 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1082 /* Unused */
1083 mlm_start_req->dualCTSProtection =
1084 mac_ctx->lim.gHTDualCTSProtection;
1085 mlm_start_req->txChannelWidthSet =
1086 session->htRecommendedTxWidthSet;
1087
1088 session->limRFBand = lim_get_rf_band(channel_number);
1089
1090 /* Initialize 11h Enable Flag */
1091 session->lim11hEnable = 0;
1092 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1093 (SIR_BAND_5_GHZ == session->limRFBand)) {
1094 if (wlan_cfg_get_int(mac_ctx,
1095 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1096 lim_log(mac_ctx, LOGP,
1097 FL("Fail to get WNI_CFG_11H_ENABLED "));
1098 else
1099 session->lim11hEnable = val;
1100
1101 if (session->lim11hEnable &&
1102 (eSIR_INFRA_AP_MODE ==
1103 mlm_start_req->bssType)) {
1104 cfg_get_wmi_dfs_master_param =
1105 wlan_cfg_get_int(mac_ctx,
1106 WNI_CFG_DFS_MASTER_ENABLED,
1107 &val);
1108 session->lim11hEnable = val;
1109 }
1110 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1111 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1112 lim_log(mac_ctx, LOGE,
1113 FL("Get Fail, CFG DFS ENABLE"));
1114 }
1115
1116 if (!session->lim11hEnable) {
1117 if (cfg_set_int(mac_ctx,
1118 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1119 eSIR_SUCCESS)
1120 /*
1121 * Failed to set the CFG param
1122 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1123 */
1124 lim_log(mac_ctx, LOGE,
1125 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1126 }
1127
1128 session->limPrevSmeState = session->limSmeState;
1129 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1130 MTRACE(mac_trace
1131 (mac_ctx, TRACE_CODE_SME_STATE,
1132 session->peSessionId,
1133 session->limSmeState));
1134
1135 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1136 (uint32_t *) mlm_start_req);
1137 return;
1138 } else {
1139
1140 lim_log(mac_ctx, LOGE,
1141 FL("Received unexpected START_BSS_REQ, in state %X"),
1142 mac_ctx->lim.gLimSmeState);
1143 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001144 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1146
1147free:
1148 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001149 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 session->pLimStartBssReq = NULL;
1151 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001152 if (NULL != sme_start_bss_req)
1153 qdf_mem_free(sme_start_bss_req);
1154 if (NULL != mlm_start_req)
1155 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 if (NULL != session) {
1157 pe_delete_session(mac_ctx, session);
1158 session = NULL;
1159 }
1160 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1161 session, sme_session_id, sme_transaction_id);
1162}
1163
1164/**
1165 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1166 *
1167 * @pMac: Global MAC context
1168 * @pMsg: Message pointer
1169 *
1170 * Wrapper for the function __lim_handle_sme_start_bss_request
1171 * This message will be defered until softmac come out of
1172 * scan mode or if we have detected radar on the current
1173 * operating channel.
1174 *
1175 * return true - If we consumed the buffer
1176 * false - If have defered the message.
1177 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001178static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1179 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180{
1181 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1182 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1183 /**
1184 * If message defered, buffer is not consumed yet.
1185 * So return false
1186 */
1187 return false;
1188 }
1189
1190 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1191 return true;
1192}
1193
1194/**
1195 * lim_get_random_bssid()
1196 *
1197 * FUNCTION:This function is called to process generate the random number for bssid
1198 * This function is called to process SME_SCAN_REQ message
1199 * from HDD or upper layer application.
1200 *
1201 * LOGIC:
1202 *
1203 * ASSUMPTIONS:
1204 *
1205 * NOTE:
1206 * 1. geneartes the unique random number for bssid in ibss
1207 *
1208 * @param pMac Pointer to Global MAC structure
1209 * @param *data Pointer to bssid buffer
1210 * @return None
1211 */
1212void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1213{
1214 uint32_t random[2];
1215 random[0] = tx_time_get();
1216 random[0] |= (random[0] << 15);
1217 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301218 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219}
1220
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301221static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 tpSirSmeScanReq pScanReq)
1223{
1224 tSirScanOffloadReq *pScanOffloadReq;
1225 uint8_t *p;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001226 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001228 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 tSirRetStatus status, rc = eSIR_SUCCESS;
1230 tDot11fIEExtCap extracted_extcap = {0};
1231 bool extcap_present = true;
1232
1233 if (pScanReq->uIEFieldLen) {
1234 status = lim_strip_extcap_update_struct(pMac,
1235 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1236 &pScanReq->uIEFieldLen, &extracted_extcap);
1237
1238 if (eSIR_SUCCESS != status) {
1239 extcap_present = false;
1240 lim_log(pMac, LOG1,
1241 FL("Unable to Strip ExtCap IE from Scan Req"));
1242 }
1243
1244 if (extcap_present) {
1245 lim_log(pMac, LOG1,
1246 FL("Extcap was part of SCAN IE - Updating FW"));
1247 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1248 &extracted_extcap, true);
1249 }
1250 } else {
1251 lim_log(pMac, LOG1,
1252 FL("No IEs in the scan request from supplicant"));
1253 }
1254
1255 /**
1256 * The tSirScanOffloadReq will reserve the space for first channel,
1257 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1258 */
1259 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001260 (pScanReq->channelList.numChannels - 1) +
1261 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001262
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301263 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 if (NULL == pScanOffloadReq) {
1265 lim_log(pMac, LOGE,
1266 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301267 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 }
1269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1271 msg.bodyptr = pScanOffloadReq;
1272 msg.bodyval = 0;
1273
Anurag Chouhanc5548422016-02-24 18:33:27 +05301274 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275
1276 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1277 lim_log(pMac, LOGE,
1278 FL("Invalid value (%d) for numSsid"),
1279 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301280 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301281 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 }
1283
1284 pScanOffloadReq->numSsid = pScanReq->numSsid;
1285 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1286 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 (uint8_t *) pScanReq->ssId[i].ssId,
1289 pScanOffloadReq->ssId[i].length);
1290 }
1291
1292 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301293 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 pScanOffloadReq->bssType = pScanReq->bssType;
1295 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1296 pScanOffloadReq->scanType = pScanReq->scanType;
1297 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1298 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1299 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301300 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1301 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301302 pScanOffloadReq->scan_adaptive_dwell_mode =
1303 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304
1305 /* for normal scan, the value for p2pScanType should be 0
1306 always */
1307 if (pScanReq->p2pSearch)
1308 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1309
1310 pScanOffloadReq->sessionId = pScanReq->sessionId;
1311 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001312 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301313 pScanOffloadReq->scan_adaptive_dwell_mode =
1314 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
1316 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1317 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1318 pScanOffloadReq->sessionId);
1319
1320 pScanOffloadReq->channelList.numChannels =
1321 pScanReq->channelList.numChannels;
1322 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1323 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1324 p[i] = pScanReq->channelList.channelNumber[i];
1325
1326 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1327 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1328 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301329 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 pScanOffloadReq->uIEFieldOffset,
1331 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1332 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 rc = wma_post_ctrl_msg(pMac, &msg);
1335 if (rc != eSIR_SUCCESS) {
1336 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301337 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301338 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 }
1340
1341 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1342
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301343 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344}
1345
1346/**
1347 * __lim_process_sme_scan_req() - Process the SME Scan Request
1348 * @mac_ctx: Global MAC Context
1349 * @msg_buf: Buffer which contains the request and pertinent parameters
1350 *
1351 * This function is called to process SME_SCAN_REQ message
1352 * from HDD or upper layer application.
1353 *
1354 * Return: None
1355 */
1356
1357static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1358 uint32_t *msg_buf)
1359{
1360 tpSirSmeScanReq scan_req;
1361 uint8_t valid_req = 0;
1362
1363#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1364 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1365 eSIR_SUCCESS, eSIR_SUCCESS);
1366#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301367 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368
1369 scan_req = (tpSirSmeScanReq) msg_buf;
1370 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301371 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 -08001372 scan_req->scan_id, scan_req->channelList.numChannels,
1373 scan_req->minChannelTime, scan_req->maxChannelTime,
1374 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1375 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301376 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1378 /*
1379 * Since scan req always requires a response, we will overwrite response
1380 * required here. This is added esp to take care of the condition where
1381 * in p2p go case, we hold the scan req and insert single NOA. We send
1382 * the held scan request to FW later on getting start NOA ind from FW so
1383 * we lose state of the gLimRspReqd flag for the scan req if any other
1384 * request comes by then. e.g. While unit testing, we found when insert
1385 * single NOA is done, we see a get stats request which turns the flag
1386 * gLimRspReqd to false; now when we actually start the saved scan req
1387 * for init scan after getting NOA started, the gLimRspReqd being a
1388 * global flag is showing false instead of true value for this saved
1389 * scan req. Since all scan reqs coming to lim require a response,
1390 * there is no harm in setting the global flag gLimRspReqd to true here.
1391 */
1392 mac_ctx->lim.gLimRspReqd = true;
1393
1394 /*
1395 * copy the Self MAC address from SmeReq to the globalplace,
1396 * used for sending probe req
1397 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001398 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1399 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1401
1402 if (!valid_req || mac_ctx->lim.scan_disabled) {
1403 lim_log(mac_ctx, LOGE,
1404 FL("Scan disabled %d, Valid Scan Req %d"),
1405 mac_ctx->lim.scan_disabled, valid_req);
1406
1407 if (mac_ctx->lim.gLimRspReqd) {
1408 mac_ctx->lim.gLimRspReqd = false;
1409
1410 lim_send_sme_scan_rsp(mac_ctx,
1411 eSIR_SME_INVALID_PARAMETERS,
1412 scan_req->sessionId,
1413 scan_req->transactionId,
1414 scan_req->scan_id);
1415 }
1416 return;
1417 }
1418
1419 /*
1420 * If scan request is received in idle, joinFailed
1421 * states or in link established state (in STA role)
1422 * or in normal state (in STA-in-IBSS/AP role) with
1423 * 'return fresh scan results' request from HDD or
1424 * it is periodic background scanning request,
1425 * trigger fresh scan request to MLM
1426 */
1427 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1428
1429 mac_ctx->lim.gLim24Band11dScanDone = 0;
1430 mac_ctx->lim.gLim50Band11dScanDone = 0;
1431 mac_ctx->lim.gLimReturnAfterFirstMatch =
1432 scan_req->returnAfterFirstMatch;
1433 mac_ctx->lim.gLimReturnUniqueResults =
1434 ((scan_req->returnUniqueResults) > 0 ? true : false);
1435
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301436 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 lim_send_hal_start_scan_offload_req(mac_ctx,
1438 scan_req)) {
1439 lim_log(mac_ctx, LOGE, FL(
1440 "Couldn't send Offload scan request"));
1441 lim_send_sme_scan_rsp(mac_ctx,
1442 eSIR_SME_INVALID_PARAMETERS,
1443 scan_req->sessionId,
1444 scan_req->transactionId,
1445 scan_req->scan_id);
1446 return;
1447 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301448 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 /* In all other cases return 'cached' scan results */
1450 if (mac_ctx->lim.gLimRspReqd) {
1451 mac_ctx->lim.gLimRspReqd = false;
1452 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1453 scan_req->sessionId,
1454 scan_req->transactionId, scan_req->scan_id);
1455 }
1456 }
1457}
1458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459/**
1460 * __lim_process_clear_dfs_channel_list()
1461 *
1462 ***FUNCTION:
1463 ***Clear DFS channel list when country is changed/aquired.
1464 .*This message is sent from SME.
1465 *
1466 ***LOGIC:
1467 *
1468 ***ASSUMPTIONS:
1469 *
1470 ***NOTE:
1471 *
1472 * @param pMac Pointer to Global MAC structure
1473 * @param *pMsgBuf A pointer to the SME message buffer
1474 * @return None
1475 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001476static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1477 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480}
1481
1482/**
1483 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1484 * @mac_ctx: Pointer to Global MAC structure
1485 * @msg_buf: A pointer to the SME message buffer
1486 *
1487 * This function is called to process SME_JOIN_REQ message
1488 * from HDD or upper layer application.
1489 *
1490 * Return: None
1491 */
1492static void
1493__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1494{
1495 tpSirSmeJoinReq sme_join_req = NULL;
1496 tLimMlmJoinReq *mlm_join_req;
1497 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1498 uint32_t val = 0;
1499 uint16_t n_size;
1500 uint8_t session_id;
1501 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301502 uint8_t sme_session_id = 0;
1503 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001504 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 uint16_t ie_len;
1506 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001507 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001508 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509
Arif Hussain995fcaf2016-07-18 11:28:22 -07001510 if (!mac_ctx || !msg_buf) {
1511 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1512 FL("JOIN REQ with invalid data"));
1513 return;
1514 }
1515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516/* FEATURE_WLAN_DIAG_SUPPORT */
1517#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1518 /*
1519 * Not sending any session, since it is not created yet.
1520 * The response whould have correct state.
1521 */
1522 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1523#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 /*
1526 * Expect Join request in idle state.
1527 * Reassociate request is expected in link established state.
1528 */
1529
1530 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1531 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1532 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1533 msg_buf);
1534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 if (NULL == sme_join_req) {
1537 lim_log(mac_ctx, LOGP,
1538 FL("AllocateMemory failed for sme_join_req"));
1539 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301540 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 n_size);
1544
1545 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1546 /* Received invalid eWNI_SME_JOIN_REQ */
1547 /* Log the event */
1548 lim_log(mac_ctx, LOGW,
1549 FL("SessionId:%d JOIN REQ with invalid data"),
1550 sme_join_req->sessionId);
1551 ret_code = eSIR_SME_INVALID_PARAMETERS;
1552 goto end;
1553 }
1554
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001555 /*
1556 * Update the capability here itself as this is used in
1557 * lim_extract_ap_capability() below. If not updated issues
1558 * like not honoring power constraint on 1st association after
1559 * driver loading might occur.
1560 */
1561 lim_update_rrm_capability(mac_ctx, sme_join_req);
1562
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001563 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001565 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 &session_id);
1567
1568 if (session != NULL) {
1569 lim_log(mac_ctx, LOGE,
1570 FL("Session(%d) Already exists for BSSID: "
1571 MAC_ADDRESS_STR " in limSmeState = %X"),
1572 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001573 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 session->limSmeState);
1575
1576 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1577 session->smeSessionId == sme_join_req->sessionId) {
1578 /*
1579 * Received eWNI_SME_JOIN_REQ for same
1580 * BSS as currently associated.
1581 * Log the event and send success
1582 */
1583 lim_log(mac_ctx, LOGW,
1584 FL("SessionId: %d"), session_id);
1585 lim_log(mac_ctx, LOGW,
1586 FL("JOIN_REQ for current joined BSS"));
1587 /* Send Join success response to host */
1588 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1589 session = NULL;
1590 goto end;
1591 } else {
1592 lim_log(mac_ctx, LOGE,
1593 FL("JOIN_REQ not for current joined BSS"));
1594 ret_code = eSIR_SME_REFUSED;
1595 session = NULL;
1596 goto end;
1597 }
1598 } else {
1599 /*
1600 * Session Entry does not exist for given BSSId
1601 * Try to Create a new session
1602 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001603 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 &session_id, mac_ctx->lim.maxStation,
1605 eSIR_INFRASTRUCTURE_MODE);
1606 if (session == NULL) {
1607 lim_log(mac_ctx, LOGE,
1608 FL("Session Can not be created "));
1609 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1610 goto end;
1611 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301612 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 FL("SessionId:%d New session created"),
1614 session_id);
1615 }
1616 session->isAmsduSupportInAMPDU =
1617 sme_join_req->isAmsduSupportInAMPDU;
1618
1619 /*
1620 * Store Session related parameters
1621 * Store PE session Id in session Table
1622 */
1623 session->peSessionId = session_id;
1624
1625 /* store the smejoin req handle in session table */
1626 session->pLimJoinReq = sme_join_req;
1627
1628 /* Store SME session Id in sessionTable */
1629 session->smeSessionId = sme_join_req->sessionId;
1630
1631 /* Store SME transaction Id in session Table */
1632 session->transactionId = sme_join_req->transactionId;
1633
1634 /* Store beaconInterval */
1635 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001636 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301638 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 sizeof(session->htConfig));
1640
Sandeep Puligilla98917432016-06-10 13:50:28 -07001641 qdf_mem_copy(&(session->vht_config),
1642 &(sme_join_req->vht_config),
1643 sizeof(session->vht_config));
1644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 /* Copying of bssId is already done, while creating session */
1646 sir_copy_mac_addr(session->selfMacAddr,
1647 sme_join_req->selfMacAddr);
1648 session->bssType = sme_join_req->bsstype;
1649
1650 session->statypeForBss = STA_ENTRY_PEER;
1651 session->limWmeEnabled = sme_join_req->isWMEenabled;
1652 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301653 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654
1655 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001656 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1658
1659 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1660 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001661 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662
1663 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001664 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 session->isCiscoVendorAP = true;
1666 } else {
1667 session->isCiscoVendorAP = false;
1668 }
1669
1670 /* Copy the dot 11 mode in to the session table */
1671
1672 session->dot11mode = sme_join_req->dot11mode;
1673#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1674 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1675#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001676 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1678 session->enableHtSmps = sme_join_req->enableHtSmps;
1679 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001680 session->send_smps_action =
1681 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001682 /*
1683 * By default supported NSS 1x1 is set to true
1684 * and later on updated while determining session
1685 * supported rates which is the intersection of
1686 * self and peer rates
1687 */
1688 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301689 /*Store Persona */
1690 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001691 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301692 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001693 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001694 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001695 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301696 session->supported_nss_1x1,
1697 session->pePersona,
1698 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001699
1700 /*Store Persona */
1701 session->pePersona = sme_join_req->staPersona;
1702 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1703 FL("PE PERSONA=%d cbMode %u"),
1704 session->pePersona, sme_join_req->cbMode);
1705 /* Copy The channel Id to the session Table */
1706 session->currentOperChannel = bss_desc->channelId;
1707 if (IS_5G_CH(session->currentOperChannel))
1708 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001710 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1711 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1712 session->vdev_nss = vdev_type_nss->p2p_cli;
1713 else
1714 session->vdev_nss = vdev_type_nss->sta;
1715 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 session->vhtCapability =
1717 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301719 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001720 session->vht_config.su_beam_formee =
1721 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001723 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 session->enableVhtpAid =
1726 sme_join_req->enableVhtpAid;
1727 session->enableVhtGid =
1728 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001729 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1730 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 }
Krunal Soni53993f72016-07-08 18:20:03 -07001732
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301733 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001734 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301735 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001736 session->vht_config.su_beam_formee,
1737 session->vht_config.csnof_beamformer_antSup,
1738 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001740 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 /* cbMode is already merged value of peer and self -
1743 * done by csr in csr_get_cb_mode_from_ies */
1744 session->htSupportedChannelWidthSet =
1745 (sme_join_req->cbMode) ? 1 : 0;
1746 session->htRecommendedTxWidthSet =
1747 session->htSupportedChannelWidthSet;
1748 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1749
1750 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1751 session->ch_center_freq_seg0 =
1752 session->currentOperChannel - 2;
1753 session->ch_width = CH_WIDTH_40MHZ;
1754 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1755 sme_join_req->cbMode) {
1756 session->ch_center_freq_seg0 =
1757 session->currentOperChannel + 2;
1758 session->ch_width = CH_WIDTH_40MHZ;
1759 } else {
1760 session->ch_center_freq_seg0 = 0;
1761 session->ch_width = CH_WIDTH_20MHZ;
1762 }
1763
1764 /* Record if management frames need to be protected */
1765#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001766 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001768 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770#endif
1771
1772#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001773 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774#endif
1775
1776 /* Copy the SSID from smejoinreq to session entry */
1777 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301778 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 session->ssId.length);
1780
1781 /*
1782 * Determin 11r or ESE connection based on input from SME
1783 * which inturn is dependent on the profile the user wants
1784 * to connect to, So input is coming from supplicant
1785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787#ifdef FEATURE_WLAN_ESE
1788 session->isESEconnection = sme_join_req->isESEconnection;
1789#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 session->isFastTransitionEnabled =
1791 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 session->isFastRoamIniFeatureEnabled =
1794 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 session->txLdpcIniFeatureEnabled =
1796 sme_join_req->txLdpcIniFeatureEnabled;
1797
1798 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1799 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 } else {
1801 /*
1802 * Throw an error and return and make
1803 * sure to delete the session.
1804 */
1805 lim_log(mac_ctx, LOGE,
1806 FL("recvd JOIN_REQ with invalid bss type %d"),
1807 session->bssType);
1808 ret_code = eSIR_SME_INVALID_PARAMETERS;
1809 goto end;
1810 }
1811
1812 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301813 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 &sme_join_req->addIEScan, sizeof(tSirAddie));
1815
1816 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301817 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1819
1820 val = sizeof(tLimMlmJoinReq) +
1821 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301822 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 if (NULL == mlm_join_req) {
1824 lim_log(mac_ctx, LOGP,
1825 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301826 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1827 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
1830 /* PE SessionId is stored as a part of JoinReq */
1831 mlm_join_req->sessionId = session->peSessionId;
1832
1833 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1834 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1835 eSIR_SUCCESS) {
1836 lim_log(mac_ctx, LOGP,
1837 FL("couldn't retrieve JoinFailureTimer value"
1838 " setting to default value"));
1839 mlm_join_req->joinFailureTimeout =
1840 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1841 }
1842
1843 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301844 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 (void *)&sme_join_req->operationalRateSet,
1846 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301847 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 (void *)&sme_join_req->extendedRateSet,
1849 sizeof(tSirMacRateSet));
1850 /*
1851 * this may not be needed anymore now, as rateSet is now
1852 * included in the session entry and MLM has session context.
1853 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301854 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 (void *)&session->rateSet,
1856 sizeof(tSirMacRateSet));
1857
1858 session->encryptType = sme_join_req->UCEncryptionType;
1859
1860 mlm_join_req->bssDescription.length =
1861 session->pLimJoinReq->bssDescription.length;
1862
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301863 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 (uint8_t *)
1865 &session->pLimJoinReq->bssDescription.bssId,
1866 session->pLimJoinReq->bssDescription.length + 2);
1867
1868 session->limCurrentBssCaps =
1869 session->pLimJoinReq->bssDescription.capabilityInfo;
1870
1871 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1872 session->currentOperChannel);
1873 local_power_constraint = reg_max;
1874
1875 lim_extract_ap_capability(mac_ctx,
1876 (uint8_t *)
1877 session->pLimJoinReq->bssDescription.ieFields,
1878 lim_get_ielen_from_bss_description(
1879 &session->pLimJoinReq->bssDescription),
1880 &session->limCurrentBssQosCaps,
1881 &session->limCurrentBssPropCap,
1882 &session->gLimCurrentBssUapsd,
1883 &local_power_constraint, session);
1884
Krunal Soni53993f72016-07-08 18:20:03 -07001885 /*
1886 * Once the AP capabilities are available then set the
1887 * beam forming capabilities accordingly.
1888 */
1889 if (session->nss == 1) {
1890 session->vht_config.su_beam_former = 0;
1891 session->vht_config.tx_stbc = 0;
1892 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301893 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001894 }
1895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 session->maxTxPower = lim_get_max_tx_power(reg_max,
1897 local_power_constraint,
1898 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301899
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301900 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301901 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301902 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903
1904 if (session->gLimCurrentBssUapsd) {
1905 session->gUapsdPerAcBitmask =
1906 session->pLimJoinReq->uapsdPerAcBitmask;
1907 lim_log(mac_ctx, LOG1,
1908 FL("UAPSD flag for all AC - 0x%2x"),
1909 session->gUapsdPerAcBitmask);
1910
1911 /* resetting the dynamic uapsd mask */
1912 session->gUapsdPerAcDeliveryEnableMask = 0;
1913 session->gUapsdPerAcTriggerEnableMask = 0;
1914 }
1915
1916 session->limRFBand =
1917 lim_get_rf_band(session->currentOperChannel);
1918
1919 /* Initialize 11h Enable Flag */
1920 if (SIR_BAND_5_GHZ == session->limRFBand) {
1921 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1922 &val) != eSIR_SUCCESS) {
1923 lim_log(mac_ctx, LOGP,
1924 FL("Fail to get WNI_CFG_11H_ENABLED "));
1925 session->lim11hEnable =
1926 WNI_CFG_11H_ENABLED_STADEF;
1927 } else {
1928 session->lim11hEnable = val;
1929 }
1930 } else {
1931 session->lim11hEnable = 0;
1932 }
1933
1934 /*
1935 * To care of the scenario when STA transitions from
1936 * IBSS to Infrastructure mode.
1937 */
1938 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1939
1940 session->limPrevSmeState = session->limSmeState;
1941 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1942 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1943 session->peSessionId,
1944 session->limSmeState));
1945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 /* Indicate whether spectrum management is enabled */
1947 session->spectrumMgtEnabled =
1948 sme_join_req->spectrumMgtIndicator;
1949
1950 /* Enable the spectrum management if this is a DFS channel */
1951 if (session->country_info_present &&
1952 lim_isconnected_on_dfs_channel(
1953 session->currentOperChannel))
1954 session->spectrumMgtEnabled = true;
1955
1956 session->isOSENConnection = sme_join_req->isOSENConnection;
1957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 /* Issue LIM_MLM_JOIN_REQ to MLM */
1959 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1960 (uint32_t *) mlm_join_req);
1961 return;
1962
1963 } else {
1964 /* Received eWNI_SME_JOIN_REQ un expected state */
1965 lim_log(mac_ctx, LOGE,
1966 FL("received unexpected SME_JOIN_REQ in state %X"),
1967 mac_ctx->lim.gLimSmeState);
1968 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1969 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1970 session = NULL;
1971 goto end;
1972 }
1973
1974end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301975 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1976 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
1978 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301979 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 sme_join_req = NULL;
1981 if (NULL != session)
1982 session->pLimJoinReq = NULL;
1983 }
1984 if (ret_code != eSIR_SME_SUCCESS) {
1985 if (NULL != session) {
1986 pe_delete_session(mac_ctx, session);
1987 session = NULL;
1988 }
1989 }
1990 lim_log(mac_ctx, LOG1,
1991 FL("Send failure status on sessionid: %d with ret_code = %d"),
1992 sme_session_id, ret_code);
1993 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1994 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1995 sme_transaction_id);
1996}
1997
Amar Singhala297bfa2015-10-15 15:07:29 -07001998uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 uint8_t iniTxPower)
2000{
2001 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302002 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2003 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2005 maxTxPower = txPower;
2006 else if (txPower < MIN_TX_PWR_CAP)
2007 maxTxPower = MIN_TX_PWR_CAP;
2008 else
2009 maxTxPower = MAX_TX_PWR_CAP;
2010
2011 return maxTxPower;
2012}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013
2014/**
2015 * __lim_process_sme_reassoc_req() - process reassoc req
2016 *
2017 * @mac_ctx: Pointer to Global MAC structure
2018 * @msg_buf: pointer to the SME message buffer
2019 *
2020 * This function is called to process SME_REASSOC_REQ message
2021 * from HDD or upper layer application.
2022 *
2023 * Return: None
2024 */
2025
2026static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2027 uint32_t *msg_buf)
2028{
2029 uint16_t caps;
2030 uint32_t val;
2031 tpSirSmeJoinReq reassoc_req = NULL;
2032 tLimMlmReassocReq *mlm_reassoc_req;
2033 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2034 tpPESession session_entry = NULL;
2035 uint8_t session_id;
2036 uint8_t sme_session_id;
2037 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002038 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 uint32_t tele_bcn_en = 0;
2040 uint16_t size;
2041
2042 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2043
2044 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302045 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 if (NULL == reassoc_req) {
2047 lim_log(mac_ctx, LOGP,
2048 FL("call to AllocateMemory failed for reassoc_req"));
2049
2050 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2051 goto end;
2052 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054
2055 if (!lim_is_sme_join_req_valid(mac_ctx,
2056 (tpSirSmeJoinReq)reassoc_req)) {
2057 /*
2058 * Received invalid eWNI_SME_REASSOC_REQ
2059 */
2060 lim_log(mac_ctx, LOGW,
2061 FL("received SME_REASSOC_REQ with invalid data"));
2062
2063 ret_code = eSIR_SME_INVALID_PARAMETERS;
2064 goto end;
2065 }
2066
2067 session_entry = pe_find_session_by_bssid(mac_ctx,
2068 reassoc_req->bssDescription.bssId,
2069 &session_id);
2070 if (session_entry == NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 lim_log(mac_ctx, LOGE,
2072 FL("Session does not exist for given bssId"));
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002073 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2074 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002076 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2077 &sme_session_id, &transaction_id);
2078 session_entry =
2079 pe_find_session_by_sme_session_id(mac_ctx,
2080 sme_session_id);
2081 if (session_entry != NULL)
2082 lim_handle_sme_join_result(mac_ctx,
2083 eSIR_SME_INVALID_PARAMETERS,
2084 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2085 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 goto end;
2087 }
2088#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2089 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2090 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2091#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2092 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2093
2094 /* Store the reassoc handle in the session Table */
2095 session_entry->pLimReAssocReq = reassoc_req;
2096
2097 session_entry->dot11mode = reassoc_req->dot11mode;
2098 session_entry->vhtCapability =
2099 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002100
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302101 if (session_entry->vhtCapability) {
2102 if (session_entry->pePersona == QDF_STA_MODE) {
2103 session_entry->vht_config.su_beam_formee =
2104 reassoc_req->vht_config.su_beam_formee;
2105 } else {
2106 reassoc_req->vht_config.su_beam_formee = 0;
2107 }
2108 session_entry->enableVhtpAid =
2109 reassoc_req->enableVhtpAid;
2110 session_entry->enableVhtGid =
2111 reassoc_req->enableVhtGid;
2112 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2113 session_entry->vht_config.su_beam_former);
2114 }
2115
2116 lim_log(mac_ctx, LOG1,
2117 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2118 session_entry->vhtCapability,
2119 session_entry->vht_config.su_beam_formee,
2120 session_entry->vht_config.su_beam_former);
2121
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002122 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2123 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002124 session_entry->send_smps_action =
2125 reassoc_req->send_smps_action;
2126 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002127 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002128 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002129 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002130 session_entry->send_smps_action,
2131 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 /*
2133 * Reassociate request is expected
2134 * in link established state only.
2135 */
2136
2137 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2139 /*
2140 * May be from 11r FT pre-auth. So lets check it
2141 * before we bail out
2142 */
2143 lim_log(mac_ctx, LOG1, FL(
2144 "Session in reassoc state is %d"),
2145 session_entry->peSessionId);
2146
2147 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302148 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 session_entry->limReAssocbssId,
2150 6)) {
2151 lim_print_mac_addr(mac_ctx,
2152 reassoc_req->bssDescription.
2153 bssId, LOGE);
2154 lim_log(mac_ctx, LOGP,
2155 FL("Unknown bssId in reassoc state"));
2156 ret_code = eSIR_SME_INVALID_PARAMETERS;
2157 goto end;
2158 }
2159
2160 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2161 session_entry);
2162 return;
2163 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 /*
2165 * Should not have received eWNI_SME_REASSOC_REQ
2166 */
2167 lim_log(mac_ctx, LOGE,
2168 FL("received unexpected SME_REASSOC_REQ in state %X"),
2169 session_entry->limSmeState);
2170 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2171
2172 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2173 goto end;
2174 }
2175
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302176 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 session_entry->pLimReAssocReq->bssDescription.bssId,
2178 sizeof(tSirMacAddr));
2179
2180 session_entry->limReassocChannelId =
2181 session_entry->pLimReAssocReq->bssDescription.channelId;
2182
2183 session_entry->reAssocHtSupportedChannelWidthSet =
2184 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2185 session_entry->reAssocHtRecommendedTxWidthSet =
2186 session_entry->reAssocHtSupportedChannelWidthSet;
2187 session_entry->reAssocHtSecondaryChannelOffset =
2188 session_entry->pLimReAssocReq->cbMode;
2189
2190 session_entry->limReassocBssCaps =
2191 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2192 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2193 session_entry->currentOperChannel);
2194 local_pwr_constraint = reg_max;
2195
2196 lim_extract_ap_capability(mac_ctx,
2197 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2198 lim_get_ielen_from_bss_description(
2199 &session_entry->pLimReAssocReq->bssDescription),
2200 &session_entry->limReassocBssQosCaps,
2201 &session_entry->limReassocBssPropCap,
2202 &session_entry->gLimCurrentBssUapsd,
2203 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302204 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302206 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2207 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 /* Copy the SSID from session entry to local variable */
2209 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 reassoc_req->ssId.ssId,
2212 session_entry->limReassocSSID.length);
2213 if (session_entry->gLimCurrentBssUapsd) {
2214 session_entry->gUapsdPerAcBitmask =
2215 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2216 lim_log(mac_ctx, LOG1,
2217 FL("UAPSD flag for all AC - 0x%2x"),
2218 session_entry->gUapsdPerAcBitmask);
2219 }
2220
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302221 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 if (NULL == mlm_reassoc_req) {
2223 lim_log(mac_ctx, LOGP,
2224 FL("call to AllocateMemory failed for mlmReassocReq"));
2225
2226 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2227 goto end;
2228 }
2229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302230 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2232
2233 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2234 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2235 eSIR_SUCCESS) {
2236 /*
2237 * Could not get ReassocFailureTimeout value
2238 * from CFG. Log error.
2239 */
2240 lim_log(mac_ctx, LOGP,
2241 FL("could not retrieve ReassocFailureTimeout value"));
2242 }
2243
2244 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2245 eSIR_SUCCESS) {
2246 /*
2247 * Could not get Capabilities value
2248 * from CFG. Log error.
2249 */
2250 lim_log(mac_ctx, LOGP, FL(
2251 "could not retrieve Capabilities value"));
2252 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302253
2254 lim_update_caps_info_for_bss(mac_ctx, &caps,
2255 reassoc_req->bssDescription.capabilityInfo);
2256 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 mlm_reassoc_req->capabilityInfo = caps;
2259
2260 /* Update PE session_id */
2261 mlm_reassoc_req->sessionId = session_id;
2262
2263 /*
2264 * If telescopic beaconing is enabled, set listen interval to
2265 * WNI_CFG_TELE_BCN_MAX_LI
2266 */
2267 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2268 &tele_bcn_en) != eSIR_SUCCESS)
2269 lim_log(mac_ctx, LOGP,
2270 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2271
2272 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2273
2274 if (tele_bcn_en) {
2275 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2276 eSIR_SUCCESS)
2277 /*
2278 * Could not get ListenInterval value
2279 * from CFG. Log error.
2280 */
2281 lim_log(mac_ctx, LOGP,
2282 FL("could not retrieve ListenInterval"));
2283 } else {
2284 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2285 eSIR_SUCCESS)
2286 /*
2287 * Could not get ListenInterval value
2288 * from CFG. Log error.
2289 */
2290 lim_log(mac_ctx, LOGP,
2291 FL("could not retrieve ListenInterval"));
2292 }
2293
2294 mlm_reassoc_req->listenInterval = (uint16_t) val;
2295
2296 /* Indicate whether spectrum management is enabled */
2297 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2298
2299 /* Enable the spectrum management if this is a DFS channel */
2300 if (session_entry->country_info_present &&
2301 lim_isconnected_on_dfs_channel(
2302 session_entry->currentOperChannel))
2303 session_entry->spectrumMgtEnabled = true;
2304
2305 session_entry->limPrevSmeState = session_entry->limSmeState;
2306 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2307
2308 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2309 session_entry->peSessionId,
2310 session_entry->limSmeState));
2311
2312 lim_post_mlm_message(mac_ctx,
2313 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2314 return;
2315end:
2316 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302317 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 if (session_entry)
2319 session_entry->pLimReAssocReq = NULL;
2320 }
2321
2322 if (session_entry) {
2323 /*
2324 * error occurred after we determined the session so extract
2325 * session and transaction info from there
2326 */
2327 sme_session_id = session_entry->smeSessionId;
2328 transaction_id = session_entry->transactionId;
2329 } else
2330 /*
2331 * error occurred before or during the time we determined
2332 * the session so extract the session and transaction info
2333 * from the message
2334 */
2335 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2336 &sme_session_id, &transaction_id);
2337
2338 /*
2339 * Send Reassoc failure response to host
2340 * (note session_entry may be NULL, but that's OK)
2341 */
2342 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2343 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2344 session_entry, sme_session_id,
2345 transaction_id);
2346}
2347
2348bool send_disassoc_frame = 1;
2349/**
2350 * __lim_process_sme_disassoc_req()
2351 *
2352 ***FUNCTION:
2353 * This function is called to process SME_DISASSOC_REQ message
2354 * from HDD or upper layer application.
2355 *
2356 ***LOGIC:
2357 *
2358 ***ASSUMPTIONS:
2359 *
2360 ***NOTE:
2361 *
2362 * @param pMac Pointer to Global MAC structure
2363 * @param *pMsgBuf A pointer to the SME message buffer
2364 * @return None
2365 */
2366
2367static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2368{
2369 uint16_t disassocTrigger, reasonCode;
2370 tLimMlmDisassocReq *pMlmDisassocReq;
2371 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2372 tSirSmeDisassocReq smeDisassocReq;
2373 tpPESession psessionEntry = NULL;
2374 uint8_t sessionId;
2375 uint8_t smesessionId;
2376 uint16_t smetransactionId;
2377
2378 if (pMsgBuf == NULL) {
2379 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2380 return;
2381 }
2382
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302383 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 smesessionId = smeDisassocReq.sessionId;
2385 smetransactionId = smeDisassocReq.transactionId;
2386 if (!lim_is_sme_disassoc_req_valid(pMac,
2387 &smeDisassocReq,
2388 psessionEntry)) {
2389 PELOGE(lim_log(pMac, LOGE,
2390 FL("received invalid SME_DISASSOC_REQ message"));)
2391 if (pMac->lim.gLimRspReqd) {
2392 pMac->lim.gLimRspReqd = false;
2393
2394 retCode = eSIR_SME_INVALID_PARAMETERS;
2395 disassocTrigger = eLIM_HOST_DISASSOC;
2396 goto sendDisassoc;
2397 }
2398
2399 return;
2400 }
2401
2402 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002403 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 &sessionId);
2405 if (psessionEntry == NULL) {
2406 lim_log(pMac, LOGE,
2407 FL("session does not exist for given bssId "
2408 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002409 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 retCode = eSIR_SME_INVALID_PARAMETERS;
2411 disassocTrigger = eLIM_HOST_DISASSOC;
2412 goto sendDisassoc;
2413 }
2414 lim_log(pMac, LOG1,
2415 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2416 MAC_ADDRESS_STR), smesessionId,
2417 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2418 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002419 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420
2421#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2422 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2423 0, smeDisassocReq.reasonCode);
2424#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2425
2426 /* Update SME session Id and SME transaction ID */
2427
2428 psessionEntry->smeSessionId = smesessionId;
2429 psessionEntry->transactionId = smetransactionId;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002430 lim_log(pMac, LOGW, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
2431 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432
2433 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2434 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 switch (psessionEntry->limSmeState) {
2436 case eLIM_SME_ASSOCIATED_STATE:
2437 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002438 lim_log(pMac, LOG1,
2439 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2440 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 psessionEntry->limPrevSmeState =
2442 psessionEntry->limSmeState;
2443 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2444#ifdef FEATURE_WLAN_TDLS
2445 /* Delete all TDLS peers connected before leaving BSS */
2446 lim_delete_tdls_peers(pMac, psessionEntry);
2447#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002448 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2449 psessionEntry->peSessionId,
2450 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 break;
2452
2453 case eLIM_SME_WT_DEAUTH_STATE:
2454 /* PE shall still process the DISASSOC_REQ and proceed with
2455 * link tear down even if it had already sent a DEAUTH_IND to
2456 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2457 * its been set when PE entered WT_DEAUTH_STATE.
2458 */
2459 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2460 MTRACE(mac_trace
2461 (pMac, TRACE_CODE_SME_STATE,
2462 psessionEntry->peSessionId,
2463 psessionEntry->limSmeState));
2464 lim_log(pMac, LOG1,
2465 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2466 break;
2467
2468 case eLIM_SME_WT_DISASSOC_STATE:
2469 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2470 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2471 * PE can continue processing DISASSOC_REQ and send the response instead
2472 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2473 * for disassoc frame.
2474 *
2475 * It will send a disassoc, which is ok. However, we can use the global flag
2476 * sendDisassoc to not send disassoc frame.
2477 */
2478 lim_log(pMac, LOG1,
2479 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2480 break;
2481
2482 case eLIM_SME_JOIN_FAILURE_STATE: {
2483 /* Already in Disconnected State, return success */
2484 lim_log(pMac, LOG1,
2485 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2486 if (pMac->lim.gLimRspReqd) {
2487 retCode = eSIR_SME_SUCCESS;
2488 disassocTrigger = eLIM_HOST_DISASSOC;
2489 goto sendDisassoc;
2490 }
2491 }
2492 break;
2493 default:
2494 /**
2495 * STA is not currently associated.
2496 * Log error and send response to host
2497 */
2498 lim_log(pMac, LOGE,
2499 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2500 psessionEntry->limSmeState);
2501 lim_print_sme_state(pMac, LOGE,
2502 psessionEntry->limSmeState);
2503
2504 if (pMac->lim.gLimRspReqd) {
2505 if (psessionEntry->limSmeState !=
2506 eLIM_SME_WT_ASSOC_STATE)
2507 pMac->lim.gLimRspReqd = false;
2508
2509 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2510 disassocTrigger = eLIM_HOST_DISASSOC;
2511 goto sendDisassoc;
2512 }
2513
2514 return;
2515 }
2516
2517 break;
2518
2519 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 /* Fall through */
2521 break;
2522
2523 case eLIM_STA_IN_IBSS_ROLE:
2524 default:
2525 /* eLIM_UNKNOWN_ROLE */
2526 lim_log(pMac, LOGE,
2527 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2528 GET_LIM_SYSTEM_ROLE(psessionEntry));
2529
2530 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2531 disassocTrigger = eLIM_HOST_DISASSOC;
2532 goto sendDisassoc;
2533 } /* end switch (pMac->lim.gLimSystemRole) */
2534
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302535 disassocTrigger = eLIM_HOST_DISASSOC;
2536 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
2538 if (smeDisassocReq.doNotSendOverTheAir) {
2539 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2540 send_disassoc_frame = 0;
2541 }
2542 /* Trigger Disassociation frame to peer MAC entity */
2543 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2544 " : %d, reasonCode : %d"),
2545 disassocTrigger, reasonCode);
2546
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302547 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 if (NULL == pMlmDisassocReq) {
2549 /* Log error */
2550 lim_log(pMac, LOGP,
2551 FL("call to AllocateMemory failed for mlmDisassocReq"));
2552
2553 return;
2554 }
2555
Anurag Chouhanc5548422016-02-24 18:33:27 +05302556 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002557 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558
2559 pMlmDisassocReq->reasonCode = reasonCode;
2560 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2561
2562 /* Update PE session ID */
2563 pMlmDisassocReq->sessionId = sessionId;
2564
2565 lim_post_mlm_message(pMac,
2566 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2567 return;
2568
2569sendDisassoc:
2570 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002571 lim_send_sme_disassoc_ntf(pMac,
2572 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 retCode,
2574 disassocTrigger,
2575 1, smesessionId, smetransactionId,
2576 psessionEntry);
2577 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002578 lim_send_sme_disassoc_ntf(pMac,
2579 smeDisassocReq.peer_macaddr.bytes,
2580 retCode, disassocTrigger, 1,
2581 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582
2583} /*** end __lim_process_sme_disassoc_req() ***/
2584
2585/** -----------------------------------------------------------------
2586 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2587
2588 This function is called to process SME_DISASSOC_CNF message
2589 from HDD or upper layer application.
2590
2591 \param pMac - global mac structure
2592 \param pStaDs - station dph hash node
2593 \return none
2594 \sa
2595 ----------------------------------------------------------------- */
2596static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2597{
2598 tSirSmeDisassocCnf smeDisassocCnf;
2599 uint16_t aid;
2600 tpDphHashNode pStaDs;
2601 tpPESession psessionEntry;
2602 uint8_t sessionId;
2603
2604 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2605
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302606 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 sizeof(struct sSirSmeDisassocCnf));
2608
2609 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002610 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 &sessionId);
2612 if (psessionEntry == NULL) {
2613 lim_log(pMac, LOGE,
2614 FL("session does not exist for given bssId"));
2615 return;
2616 }
2617
2618 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2619 lim_log(pMac, LOGE,
2620 FL("received invalid SME_DISASSOC_CNF message"));
2621 return;
2622 }
2623#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2624 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2625 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2626 psessionEntry,
2627 (uint16_t) smeDisassocCnf.statusCode, 0);
2628 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2629 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2630 psessionEntry,
2631 (uint16_t) smeDisassocCnf.statusCode, 0);
2632#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2633
2634 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2635 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2637 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2638 && (psessionEntry->limSmeState !=
2639 eLIM_SME_WT_DEAUTH_STATE)) {
2640 lim_log(pMac, LOGE,
2641 FL
2642 ("received unexp SME_DISASSOC_CNF in state %X"),
2643 psessionEntry->limSmeState);
2644 lim_print_sme_state(pMac, LOGE,
2645 psessionEntry->limSmeState);
2646 return;
2647 }
2648 break;
2649
2650 case eLIM_AP_ROLE:
2651 /* Fall through */
2652 break;
2653
2654 case eLIM_STA_IN_IBSS_ROLE:
2655 default: /* eLIM_UNKNOWN_ROLE */
2656 lim_log(pMac, LOGE,
2657 FL("received unexpected SME_DISASSOC_CNF role %d"),
2658 GET_LIM_SYSTEM_ROLE(psessionEntry));
2659
2660 return;
2661 }
2662
2663 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2664 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2665 LIM_IS_AP_ROLE(psessionEntry)) {
2666 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002667 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 &psessionEntry->dph.dphHashTable);
2669 if (pStaDs == NULL) {
2670 lim_log(pMac, LOGE,
2671 FL("DISASSOC_CNF for a STA with no context, addr= "
2672 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002673 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 return;
2675 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302676
2677 if ((pStaDs->mlmStaContext.mlmState ==
2678 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2679 (pStaDs->mlmStaContext.mlmState ==
2680 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2681 lim_log(pMac, LOGE,
2682 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002683 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302684 pStaDs->mlmStaContext.mlmState);
2685 return;
2686 }
2687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 /* Delete FT session if there exists one */
2689 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2691
2692 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002693 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 }
2695
2696 return;
2697}
2698
2699/**
2700 * __lim_process_sme_deauth_req() - process sme deauth req
2701 * @mac_ctx: Pointer to Global MAC structure
2702 * @msg_buf: pointer to the SME message buffer
2703 *
2704 * This function is called to process SME_DEAUTH_REQ message
2705 * from HDD or upper layer application.
2706 *
2707 * Return: None
2708 */
2709
2710static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2711 uint32_t *msg_buf)
2712{
2713 uint16_t deauth_trigger, reason_code;
2714 tLimMlmDeauthReq *mlm_deauth_req;
2715 tSirSmeDeauthReq sme_deauth_req;
2716 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2717 tpPESession session_entry;
2718 uint8_t session_id; /* PE sessionId */
2719 uint8_t sme_session_id;
2720 uint16_t sme_transaction_id;
2721
2722 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2723
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302724 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 sme_session_id = sme_deauth_req.sessionId;
2726 sme_transaction_id = sme_deauth_req.transactionId;
2727
2728 /*
2729 * We need to get a session first but we don't even know
2730 * if the message is correct.
2731 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002732 session_entry = pe_find_session_by_bssid(mac_ctx,
2733 sme_deauth_req.bssid.bytes,
2734 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 if (session_entry == NULL) {
2736 lim_log(mac_ctx, LOGE,
2737 FL("session does not exist for given bssId"));
2738 ret_code = eSIR_SME_INVALID_PARAMETERS;
2739 deauth_trigger = eLIM_HOST_DEAUTH;
2740 goto send_deauth;
2741 }
2742
2743 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2744 session_entry)) {
2745 lim_log(mac_ctx, LOGE,
2746 FL("received invalid SME_DEAUTH_REQ message"));
2747 mac_ctx->lim.gLimRspReqd = false;
2748
2749 ret_code = eSIR_SME_INVALID_PARAMETERS;
2750 deauth_trigger = eLIM_HOST_DEAUTH;
2751 goto send_deauth;
2752 }
2753 lim_log(mac_ctx, LOG1,
2754 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2755 MAC_ADDRESS_STR), sme_session_id,
2756 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2757 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002758 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2760 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2761 session_entry, 0, sme_deauth_req.reasonCode);
2762#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2763
2764 /* Update SME session ID and Transaction ID */
2765 session_entry->smeSessionId = sme_session_id;
2766 session_entry->transactionId = sme_transaction_id;
2767
2768 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2769 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 switch (session_entry->limSmeState) {
2771 case eLIM_SME_ASSOCIATED_STATE:
2772 case eLIM_SME_LINK_EST_STATE:
2773 case eLIM_SME_WT_ASSOC_STATE:
2774 case eLIM_SME_JOIN_FAILURE_STATE:
2775 case eLIM_SME_IDLE_STATE:
2776 session_entry->limPrevSmeState =
2777 session_entry->limSmeState;
2778 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2779 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2780 session_entry->peSessionId,
2781 session_entry->limSmeState));
2782 /* Send Deauthentication request to MLM below */
2783 break;
2784 case eLIM_SME_WT_DEAUTH_STATE:
2785 case eLIM_SME_WT_DISASSOC_STATE:
2786 /*
2787 * PE Recieved a Deauth/Disassoc frame. Normally it get
2788 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2789 * Which means host is also trying to disconnect.
2790 * PE can continue processing DEAUTH_REQ and send
2791 * the response instead of failing the request.
2792 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2793 * was sent for deauth/disassoc frame.
2794 */
2795 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2796 lim_log(mac_ctx, LOG1, FL(
2797 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2798 break;
2799 default:
2800 /*
2801 * STA is not in a state to deauthenticate with
2802 * peer. Log error and send response to host.
2803 */
2804 lim_log(mac_ctx, LOGE, FL(
2805 "received unexp SME_DEAUTH_REQ in state %X"),
2806 session_entry->limSmeState);
2807 lim_print_sme_state(mac_ctx, LOGE,
2808 session_entry->limSmeState);
2809
2810 if (mac_ctx->lim.gLimRspReqd) {
2811 mac_ctx->lim.gLimRspReqd = false;
2812
2813 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2814 deauth_trigger = eLIM_HOST_DEAUTH;
2815
2816 /*
2817 * here we received deauth request from AP so sme state
2818 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2819 * delSta then mlm state should be
2820 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2821 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2822 * so the below condition captures the state where
2823 * delSta not done and firmware still in
2824 * connected state.
2825 */
2826 if (session_entry->limSmeState ==
2827 eLIM_SME_WT_DEAUTH_STATE &&
2828 session_entry->limMlmState !=
2829 eLIM_MLM_IDLE_STATE &&
2830 session_entry->limMlmState !=
2831 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2832 ret_code = eSIR_SME_DEAUTH_STATUS;
2833 goto send_deauth;
2834 }
2835 return;
2836 }
2837 break;
2838
2839 case eLIM_STA_IN_IBSS_ROLE:
2840 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2841 if (mac_ctx->lim.gLimRspReqd) {
2842 mac_ctx->lim.gLimRspReqd = false;
2843 ret_code = eSIR_SME_INVALID_PARAMETERS;
2844 deauth_trigger = eLIM_HOST_DEAUTH;
2845 goto send_deauth;
2846 }
2847 return;
2848 case eLIM_AP_ROLE:
2849 break;
2850 default:
2851 lim_log(mac_ctx, LOGE,
2852 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2853 GET_LIM_SYSTEM_ROLE(session_entry));
2854 if (mac_ctx->lim.gLimRspReqd) {
2855 mac_ctx->lim.gLimRspReqd = false;
2856 ret_code = eSIR_SME_INVALID_PARAMETERS;
2857 deauth_trigger = eLIM_HOST_DEAUTH;
2858 goto send_deauth;
2859 }
2860 return;
2861 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2862
2863 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2864 /* Deauthentication is triggered by Link Monitoring */
2865 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2866 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2867 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2868 } else {
2869 deauth_trigger = eLIM_HOST_DEAUTH;
2870 reason_code = sme_deauth_req.reasonCode;
2871 }
2872
2873 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302874 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 if (NULL == mlm_deauth_req) {
2876 lim_log(mac_ctx, LOGP,
2877 FL("call to AllocateMemory failed for mlmDeauthReq"));
2878 if (mac_ctx->lim.gLimRspReqd) {
2879 mac_ctx->lim.gLimRspReqd = false;
2880 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2881 deauth_trigger = eLIM_HOST_DEAUTH;
2882 goto send_deauth;
2883 }
2884 return;
2885 }
2886
Anurag Chouhanc5548422016-02-24 18:33:27 +05302887 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002888 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889
2890 mlm_deauth_req->reasonCode = reason_code;
2891 mlm_deauth_req->deauthTrigger = deauth_trigger;
2892
2893 /* Update PE session Id */
2894 mlm_deauth_req->sessionId = session_id;
2895
2896 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2897 (uint32_t *)mlm_deauth_req);
2898 return;
2899
2900send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002901 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2902 ret_code, deauth_trigger, 1,
2903 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904}
2905
2906/**
2907 * __lim_process_sme_set_context_req()
2908 *
2909 * @mac_ctx: Pointer to Global MAC structure
2910 * @msg_buf: pointer to the SME message buffer
2911 *
2912 * This function is called to process SME_SETCONTEXT_REQ message
2913 * from HDD or upper layer application.
2914 *
2915 * Return: None
2916 */
2917
2918static void
2919__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2920{
2921 tpSirSmeSetContextReq set_context_req;
2922 tLimMlmSetKeysReq *mlm_set_key_req;
2923 tpPESession session_entry;
2924 uint8_t session_id; /* PE sessionID */
2925 uint8_t sme_session_id;
2926 uint16_t sme_transaction_id;
2927
2928 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2929
2930 if (msg_buf == NULL) {
2931 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2932 return;
2933 }
2934
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302935 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 if (NULL == set_context_req) {
2937 lim_log(mac_ctx, LOGP, FL(
2938 "call to AllocateMemory failed for set_context_req"));
2939 return;
2940 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302941 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 sizeof(struct sSirSmeSetContextReq));
2943 sme_session_id = set_context_req->sessionId;
2944 sme_transaction_id = set_context_req->transactionId;
2945
2946 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2947 lim_log(mac_ctx, LOGW,
2948 FL("received invalid SME_SETCONTEXT_REQ message"));
2949 goto end;
2950 }
2951
2952 if (set_context_req->keyMaterial.numKeys >
2953 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2954 lim_log(mac_ctx, LOGE, FL(
2955 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2956 set_context_req->keyMaterial.numKeys);
2957 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002958 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 eSIR_SME_INVALID_PARAMETERS, NULL,
2960 sme_session_id, sme_transaction_id);
2961 goto end;
2962 }
2963
2964 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002965 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 if (session_entry == NULL) {
2967 lim_log(mac_ctx, LOGW,
2968 FL("Session does not exist for given BSSID"));
2969 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002970 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 eSIR_SME_INVALID_PARAMETERS, NULL,
2972 sme_session_id, sme_transaction_id);
2973 goto end;
2974 }
2975#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2976 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2977 session_entry, 0, 0);
2978#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2979
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002980 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2982 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002983 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2985 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302986 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 if (NULL == mlm_set_key_req) {
2988 lim_log(mac_ctx, LOGP, FL(
2989 "mem alloc failed for mlmSetKeysReq"));
2990 goto end;
2991 }
2992 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2993 mlm_set_key_req->numKeys =
2994 set_context_req->keyMaterial.numKeys;
2995 if (mlm_set_key_req->numKeys >
2996 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2997 lim_log(mac_ctx, LOGP, FL(
2998 "no.of keys exceeded max num of default keys limit"));
2999 goto end;
3000 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303001 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003002 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303004 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 (uint8_t *) &set_context_req->keyMaterial.key,
3006 sizeof(tSirKeys) *
3007 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3008 numKeys : 1));
3009
3010 mlm_set_key_req->sessionId = session_id;
3011 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 lim_log(mac_ctx, LOG1, FL(
3013 "received SETCONTEXT_REQ message sessionId=%d"),
3014 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015
3016 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3017 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3018 LIM_IS_AP_ROLE(session_entry)) {
3019 if (set_context_req->keyMaterial.key[0].keyLength) {
3020 uint8_t key_id;
3021 key_id =
3022 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303023 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 &session_entry->WEPKeyMaterial[key_id],
3025 (uint8_t *) &set_context_req->keyMaterial,
3026 sizeof(tSirKeyMaterial));
3027 } else {
3028 uint32_t i;
3029 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3030 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303031 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 &mlm_set_key_req->key[i],
3033 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3034 sizeof(tSirKeys));
3035 }
3036 }
3037 }
3038 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3039 (uint32_t *) mlm_set_key_req);
3040 } else {
3041 lim_log(mac_ctx, LOGE, FL(
3042 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3043 GET_LIM_SYSTEM_ROLE(session_entry),
3044 session_entry->limSmeState);
3045 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3046
3047 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003048 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3050 session_entry, sme_session_id,
3051 sme_transaction_id);
3052 }
3053end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 return;
3056}
3057
3058/**
3059 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3060 *
3061 * @mac_ctx: Pointer to Global MAC structure
3062 * @msg_buf: pointer to the SME message buffer
3063 *
3064 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3065 * from HDD or upper layer application.
3066 *
3067 * Return: None
3068 */
3069
Jeff Johnson801f1532016-10-07 07:54:50 -07003070static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3071 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072{
3073 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3074 tpDphHashNode sta_ds = NULL;
3075 tpPESession session_entry = NULL;
3076 tSap_Event sap_event;
3077 tpWLAN_SAPEventCB sap_event_cb = NULL;
3078 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3079 uint8_t session_id = CSR_SESSION_ID_INVALID;
3080 uint8_t assoc_id = 0;
3081 uint8_t sta_cnt = 0;
3082
3083 if (msg_buf == NULL) {
3084 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3085 return;
3086 }
3087
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303088 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 sizeof(struct sSirSmeGetAssocSTAsReq));
3090 /*
3091 * Get Associated stations from PE.
3092 * Find PE session Entry
3093 */
3094 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003095 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 &session_id);
3097 if (session_entry == NULL) {
3098 lim_log(mac_ctx, LOGE,
3099 FL("session does not exist for given bssId"));
3100 goto lim_assoc_sta_end;
3101 }
3102
3103 if (!LIM_IS_AP_ROLE(session_entry)) {
3104 lim_log(mac_ctx, LOGE, FL(
3105 "Received unexpected message in state %X, in role %X"),
3106 session_entry->limSmeState,
3107 GET_LIM_SYSTEM_ROLE(session_entry));
3108 goto lim_assoc_sta_end;
3109 }
3110 /* Retrieve values obtained in the request message */
3111 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3112 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3113
3114 if (NULL == assoc_sta_tmp)
3115 goto lim_assoc_sta_end;
3116 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3117 assoc_id++) {
3118 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3119 &session_entry->dph.dphHashTable);
3120 if (NULL == sta_ds)
3121 continue;
3122 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303123 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303125 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3127 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3128
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303129 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 (uint8_t *)&sta_ds->supportedRates,
3131 sizeof(tSirSupportedRates));
3132 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3133 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3134 assoc_sta_tmp->Support40Mhz =
3135 sta_ds->htDsssCckRate40MHzSupport;
3136
3137 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3138 sta_cnt + 1);
3139 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3140 MAC_ADDR_ARRAY(sta_ds->staAddr));
3141 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3142 sta_ds->assocId);
3143 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3144 sta_ds->staIndex);
3145 assoc_sta_tmp++;
3146 sta_cnt++;
3147 }
3148 }
3149lim_assoc_sta_end:
3150 /*
3151 * Call hdd callback with sap event to send the list of
3152 * associated stations from PE
3153 */
3154 if (sap_event_cb != NULL) {
3155 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3156 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303157 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3159 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3160 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3161 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3162 }
3163}
3164
3165/**
3166 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3167 *
3168 * @mac_ctx: Pointer to Global MAC structure
3169 * @msg_buf: pointer to WPS PBC overlap query message
3170 *
3171 * This function parses get WPS PBC overlap information
3172 * message and call callback to pass WPS PBC overlap
3173 * information back to hdd.
3174 *
3175 * Return: None
3176 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003177static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3178 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179{
3180 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3181 tpPESession session_entry = NULL;
3182 tSap_Event sap_event;
3183 tpWLAN_SAPEventCB sap_event_cb = NULL;
3184 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3186
3187 if (msg_buf == NULL) {
3188 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3189 return;
3190 }
3191
3192 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303193 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303195 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3197 /*
3198 * Get Associated stations from PE
3199 * Find PE session Entry
3200 */
3201 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003202 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 if (session_entry == NULL) {
3204 lim_log(mac_ctx, LOGE,
3205 FL("session does not exist for given bssId"));
3206 goto lim_get_wpspbc_sessions_end;
3207 }
3208
3209 if (!LIM_IS_AP_ROLE(session_entry)) {
3210 lim_log(mac_ctx, LOGE,
3211 FL("Received unexpected message in role %X"),
3212 GET_LIM_SYSTEM_ROLE(session_entry));
3213 goto lim_get_wpspbc_sessions_end;
3214 }
3215 /*
3216 * Call hdd callback with sap event to send the
3217 * WPS PBC overlap information
3218 */
3219 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303220 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221
Anurag Chouhanc5548422016-02-24 18:33:27 +05303222 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003224 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 sap_get_wpspbc_event->UUID_E,
3226 &sap_get_wpspbc_event->wpsPBCOverlap,
3227 session_entry);
3228 } else {
3229 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003230 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 session_entry);
3232 /* don't have to inform the HDD/Host */
3233 return;
3234 }
3235
3236 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3237 sap_get_wpspbc_event->wpsPBCOverlap);
3238 lim_print_mac_addr(mac_ctx,
3239 sap_get_wpspbc_event->addr.bytes, LOG4);
3240
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303241 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242
3243lim_get_wpspbc_sessions_end:
3244 sap_event_cb =
3245 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3246 if (NULL != sap_event_cb)
3247 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3248}
3249
3250/**
3251 * __lim_counter_measures()
3252 *
3253 * FUNCTION:
3254 * This function is called to "implement" MIC counter measure
3255 * and is *temporary* only
3256 *
3257 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3258 * we don't do the proper STA disassoc sequence since the
3259 * BSS will be stoped anyway
3260 *
3261 ***ASSUMPTIONS:
3262 *
3263 ***NOTE:
3264 *
3265 * @param pMac Pointer to Global MAC structure
3266 * @return None
3267 */
3268
3269static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3270{
3271 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003272 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3274 mac, psessionEntry, false);
3275};
3276
Jeff Johnson801f1532016-10-07 07:54:50 -07003277static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3278 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279{
3280 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3281 tpPESession psessionEntry;
3282 uint8_t sessionId; /* PE sessionId */
3283
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303284 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 sizeof(struct sSirSmeTkipCntrMeasReq));
3286
3287 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003288 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 if (NULL == psessionEntry) {
3290 lim_log(pMac, LOGE,
3291 FL("session does not exist for given BSSID "));
3292 return;
3293 }
3294
3295 if (tkipCntrMeasReq.bEnable)
3296 __lim_counter_measures(pMac, psessionEntry);
3297
3298 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3299}
3300
3301static void
3302__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3303{
3304 tSirSmeStopBssReq stopBssReq;
3305 tSirRetStatus status;
3306 tLimSmeStates prevState;
3307 tpPESession psessionEntry;
3308 uint8_t smesessionId;
3309 uint8_t sessionId;
3310 uint16_t smetransactionId;
3311 uint8_t i = 0;
3312 tpDphHashNode pStaDs = NULL;
3313
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303314 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 smesessionId = stopBssReq.sessionId;
3316 smetransactionId = stopBssReq.transactionId;
3317
3318 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3319 PELOGW(lim_log(pMac, LOGW,
3320 FL("received invalid SME_STOP_BSS_REQ message"));)
3321 /* Send Stop BSS response to host */
3322 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3323 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3324 smetransactionId);
3325 return;
3326 }
3327
3328 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003329 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 &sessionId);
3331 if (psessionEntry == NULL) {
3332 lim_log(pMac, LOGW,
3333 FL("session does not exist for given BSSID "));
3334 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3335 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3336 smetransactionId);
3337 return;
3338 }
3339#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3340 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3341 0, 0);
3342#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3343
3344 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3345 LIM_IS_STA_ROLE(psessionEntry)) {
3346 /**
3347 * Should not have received STOP_BSS_REQ in states
3348 * other than 'normal' state or on STA in Infrastructure
3349 * mode. Log error and return response to host.
3350 */
3351 lim_log(pMac, LOGE,
3352 FL
3353 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3354 psessionEntry->limSmeState,
3355 GET_LIM_SYSTEM_ROLE(psessionEntry));
3356 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3357 /* / Send Stop BSS response to host */
3358 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3359 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3360 smetransactionId);
3361 return;
3362 }
3363
3364 if (LIM_IS_AP_ROLE(psessionEntry))
3365 lim_wpspbc_close(pMac, psessionEntry);
3366
3367 lim_log(pMac, LOGW,
3368 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3369 stopBssReq.reasonCode);
3370
3371 prevState = psessionEntry->limSmeState;
3372
3373 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3374 MTRACE(mac_trace
3375 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3376 psessionEntry->limSmeState));
3377
3378 /* Update SME session Id and Transaction Id */
3379 psessionEntry->smeSessionId = smesessionId;
3380 psessionEntry->transactionId = smetransactionId;
3381
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003382 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3383 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3384 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3386 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3387 /* Send disassoc all stations associated thru TKIP */
3388 __lim_counter_measures(pMac, psessionEntry);
3389 else
3390 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003391 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3392 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 }
3394
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003395 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3396 /* Free the buffer allocated in START_BSS_REQ */
3397 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3398 psessionEntry->addIeParams.probeRespDataLen = 0;
3399 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003401 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3402 psessionEntry->addIeParams.assocRespDataLen = 0;
3403 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003405 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3406 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3407 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003409 /*
3410 * lim_del_bss is also called as part of coalescing,
3411 * when we send DEL BSS followed by Add Bss msg.
3412 */
3413 pMac->lim.gLimIbssCoalescingHappened = false;
3414 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3416 pStaDs =
3417 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3418 if (NULL == pStaDs)
3419 continue;
3420 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3421 if (eSIR_SUCCESS == status) {
3422 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3423 pStaDs->assocId, psessionEntry);
3424 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3425 } else {
3426 lim_log(pMac, LOGE,
3427 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303428 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 }
3430 }
3431 /* send a delBss to HAL and wait for a response */
3432 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3433
3434 if (status != eSIR_SUCCESS) {
3435 PELOGE(lim_log
3436 (pMac, LOGE, FL("delBss failed for bss %d"),
3437 psessionEntry->bssIdx);
3438 )
3439 psessionEntry->limSmeState = prevState;
3440
3441 MTRACE(mac_trace
3442 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3443 psessionEntry->limSmeState));
3444
3445 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3446 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3447 smetransactionId);
3448 }
3449}
3450
3451/**
3452 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3453 * @pMac: Global MAC context
3454 * @pMsg: Message from SME
3455 *
3456 * Wrapper for the function __lim_handle_sme_stop_bss_request
3457 * This message will be defered until softmac come out of
3458 * scan mode. Message should be handled even if we have
3459 * detected radar in the current operating channel.
3460 *
3461 * Return: true - If we consumed the buffer
3462 * false - If have defered the message.
3463 */
3464
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003465static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3466 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467{
3468 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3469 /**
3470 * If message defered, buffer is not consumed yet.
3471 * So return false
3472 */
3473 return false;
3474 }
3475 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3476 return true;
3477} /*** end __lim_process_sme_stop_bss_req() ***/
3478
3479void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3480 uint32_t body, tpPESession psessionEntry)
3481{
3482
3483 (void)body;
3484 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3485 lim_ibss_delete(pMac, psessionEntry);
3486 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3487 lim_delete_pre_auth_list(pMac);
3488 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3489 psessionEntry->smeSessionId,
3490 psessionEntry->transactionId);
3491 return;
3492}
3493
3494/**
3495 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3496 *
3497 * @mac_ctx: pointer to mac context
3498 * @msg_type: message type
3499 * @msg_buf: pointer to the SME message buffer
3500 *
3501 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3502 * in BTAMP AP.
3503 *
3504 * Return: None
3505 */
3506
3507void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3508 uint32_t *msg_buf)
3509{
3510 tSirSmeAssocCnf assoc_cnf;
3511 tpDphHashNode sta_ds = NULL;
3512 tpPESession session_entry = NULL;
3513 uint8_t session_id;
3514 tpSirAssocReq assoc_req;
3515
3516 if (msg_buf == NULL) {
3517 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3518 goto end;
3519 }
3520
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303521 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3523 lim_log(mac_ctx, LOGE,
3524 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3525 goto end;
3526 }
3527
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003528 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 &session_id);
3530 if (session_entry == NULL) {
3531 lim_log(mac_ctx, LOGE,
3532 FL("session does not exist for given bssId"));
3533 goto end;
3534 }
3535
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003536 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3538 (session_entry->limSmeState !=
3539 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3540 lim_log(mac_ctx, LOGE, FL(
3541 "Rcvd unexpected msg %X in state %X, in role %X"),
3542 msg_type, session_entry->limSmeState,
3543 GET_LIM_SYSTEM_ROLE(session_entry));
3544 goto end;
3545 }
3546 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3547 &session_entry->dph.dphHashTable);
3548 if (sta_ds == NULL) {
3549 lim_log(mac_ctx, LOGE, FL(
3550 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3551 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003552 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553
3554 /*
3555 * send a DISASSOC_IND message to WSM to make sure
3556 * the state in WSM and LIM is the same
3557 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003558 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 eSIR_SME_STA_NOT_ASSOCIATED,
3560 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3561 session_entry->smeSessionId,
3562 session_entry->transactionId,
3563 session_entry);
3564 goto end;
3565 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303566 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003567 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303568 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 lim_log(mac_ctx, LOG1, FL(
3570 "peerMacAddr mismatched for aid %d, peer "),
3571 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003572 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 goto end;
3574 }
3575
3576 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3577 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3578 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3579 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3580 (msg_type != eWNI_SME_ASSOC_CNF))) {
3581 lim_log(mac_ctx, LOG1, FL(
3582 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3583 "StaD mlmState : %d"),
3584 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003585 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 goto end;
3587 }
3588 /*
3589 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3590 * has been received
3591 */
3592 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3593 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3594 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3595
3596 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3597 /*
3598 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3599 * when it had received Assoc Request frame. Now, PE just needs
3600 * to send association rsp frame to the requesting BTAMP-STA.
3601 */
3602 sta_ds->mlmStaContext.mlmState =
3603 eLIM_MLM_LINK_ESTABLISHED_STATE;
3604 lim_log(mac_ctx, LOG1,
3605 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3606 sta_ds->assocId);
3607 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3608 sta_ds->assocId, sta_ds->staAddr,
3609 sta_ds->mlmStaContext.subType, sta_ds,
3610 session_entry);
3611 goto end;
3612 } else {
3613 /*
3614 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3615 * to be associated since the HAL sta entry is created for
3616 * denied STA we need to remove this HAL entry.
3617 * So to do that set updateContext to 1
3618 */
3619 if (!sta_ds->mlmStaContext.updateContext)
3620 sta_ds->mlmStaContext.updateContext = 1;
3621 lim_log(mac_ctx, LOG1,
3622 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3623 assoc_cnf.statusCode, sta_ds->assocId);
3624 lim_reject_association(mac_ctx, sta_ds->staAddr,
3625 sta_ds->mlmStaContext.subType,
3626 true, sta_ds->mlmStaContext.authType,
3627 sta_ds->assocId, true,
3628 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3629 session_entry);
3630 }
3631end:
3632 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3633 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3634 assoc_req = (tpSirAssocReq)
3635 session_entry->parsedAssocReq[sta_ds->assocId];
3636 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303637 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 assoc_req->assocReqFrame = NULL;
3639 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303640 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3642 }
3643}
3644
3645static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3646{
3647 tpDphHashNode pStaDs;
3648 tSirMacAddr peerMac;
3649 tpSirAddtsReq pSirAddts;
3650 uint32_t timeout;
3651 tpPESession psessionEntry;
3652 uint8_t sessionId; /* PE sessionId */
3653 uint8_t smesessionId;
3654 uint16_t smetransactionId;
3655
3656 if (pMsgBuf == NULL) {
3657 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3658 return;
3659 }
3660
3661 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3662 &smetransactionId);
3663
3664 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3665
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003666 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3667 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 if (psessionEntry == NULL) {
3669 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3670 return;
3671 }
3672#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3673 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3674 0);
3675#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3676
3677 /* if sta
3678 * - verify assoc state
3679 * - send addts request to ap
3680 * - wait for addts response from ap
3681 * if ap, just ignore with error log
3682 */
3683 PELOG1(lim_log(pMac, LOG1,
3684 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3685 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3686 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3687 )
3688
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003689 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3691 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3692 psessionEntry, pSirAddts->req.tspec,
3693 smesessionId, smetransactionId);
3694 return;
3695 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696
3697 pStaDs =
3698 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3699 &psessionEntry->dph.dphHashTable);
3700
3701 if (pStaDs == NULL) {
3702 PELOGE(lim_log
3703 (pMac, LOGE, "Cannot find AP context for addts req");
3704 )
3705 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3706 psessionEntry, pSirAddts->req.tspec,
3707 smesessionId, smetransactionId);
3708 return;
3709 }
3710
3711 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3712 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3713 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3714 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3715 psessionEntry, pSirAddts->req.tspec,
3716 smesessionId, smetransactionId);
3717 return;
3718 }
3719
3720 pSirAddts->req.wsmTspecPresent = 0;
3721 pSirAddts->req.wmeTspecPresent = 0;
3722 pSirAddts->req.lleTspecPresent = 0;
3723
3724 if ((pStaDs->wsmEnabled) &&
3725 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3726 SIR_MAC_ACCESSPOLICY_EDCA))
3727 pSirAddts->req.wsmTspecPresent = 1;
3728 else if (pStaDs->wmeEnabled)
3729 pSirAddts->req.wmeTspecPresent = 1;
3730 else if (pStaDs->lleEnabled)
3731 pSirAddts->req.lleTspecPresent = 1;
3732 else {
3733 PELOGW(lim_log
3734 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3735 )
3736 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3737 psessionEntry, pSirAddts->req.tspec,
3738 smesessionId, smetransactionId);
3739 return;
3740 }
3741
3742 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3743 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3744 lim_log(pMac, LOGE,
3745 "AddTs received in invalid LIMsme state (%d)",
3746 psessionEntry->limSmeState);
3747 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3748 psessionEntry, pSirAddts->req.tspec,
3749 smesessionId, smetransactionId);
3750 return;
3751 }
3752
3753 if (pMac->lim.gLimAddtsSent) {
3754 lim_log(pMac, LOGE,
3755 "Addts (token %d, tsid %d, up %d) is still pending",
3756 pMac->lim.gLimAddtsReq.req.dialogToken,
3757 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3758 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3759 userPrio);
3760 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3761 psessionEntry, pSirAddts->req.tspec,
3762 smesessionId, smetransactionId);
3763 return;
3764 }
3765
3766 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3767
3768 /* save the addts request */
3769 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303770 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3772
3773 /* ship out the message now */
3774 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3775 psessionEntry);
3776 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3777 /* start a timer to wait for the response */
3778 if (pSirAddts->timeout)
3779 timeout = pSirAddts->timeout;
3780 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3781 eSIR_SUCCESS) {
3782 lim_log(pMac, LOGP,
3783 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3784 WNI_CFG_ADDTS_RSP_TIMEOUT);
3785 return;
3786 }
3787
3788 timeout = SYS_MS_TO_TICKS(timeout);
3789 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3790 != TX_SUCCESS) {
3791 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3792 return;
3793 }
3794 pMac->lim.gLimAddtsRspTimerCount++;
3795 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3796 pMac->lim.gLimAddtsRspTimerCount) !=
3797 TX_SUCCESS) {
3798 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3799 return;
3800 }
3801 MTRACE(mac_trace
3802 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3803 eLIM_ADDTS_RSP_TIMER));
3804
3805 /* add the sessionId to the timer object */
3806 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3807 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3808 TX_SUCCESS) {
3809 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3810 return;
3811 }
3812 return;
3813}
3814
3815static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3816{
3817 tSirMacAddr peerMacAddr;
3818 uint8_t ac;
3819 tSirMacTSInfo *pTsinfo;
3820 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3821 tpDphHashNode pStaDs = NULL;
3822 tpPESession psessionEntry;
3823 uint8_t sessionId;
3824 uint32_t status = eSIR_SUCCESS;
3825 uint8_t smesessionId;
3826 uint16_t smetransactionId;
3827
3828 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3829 &smetransactionId);
3830
3831 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003832 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 &sessionId);
3834 if (psessionEntry == NULL) {
3835 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3836 status = eSIR_FAILURE;
3837 goto end;
3838 }
3839#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3840 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3841 0);
3842#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3843
3844 if (eSIR_SUCCESS !=
3845 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3846 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3847 status = eSIR_FAILURE;
3848 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3849 smesessionId, smetransactionId);
3850 return;
3851 }
3852
3853 lim_log(pMac, LOG1,
3854 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3855 MAC_ADDRESS_STR),
3856 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3857
3858 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3859 pDeltsReq->req.wmeTspecPresent,
3860 &pDeltsReq->req.tsinfo,
3861 &pDeltsReq->req.tspec, psessionEntry);
3862
3863 pTsinfo =
3864 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3865 tsinfo : &pDeltsReq->req.tsinfo;
3866
3867 /* We've successfully send DELTS frame to AP. Update the
3868 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3869 * is no longer trigger enabled or delivery enabled
3870 */
3871 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3872 pTsinfo, CLEAR_UAPSD_MASK);
3873
3874 /* We're deleting the TSPEC, so this particular AC is no longer
3875 * admitted. PE needs to downgrade the EDCA
3876 * parameters(for the AC for which TS is being deleted) to the
3877 * next best AC for which ACM is not enabled, and send the
3878 * updated values to HAL.
3879 */
3880 ac = upToAc(pTsinfo->traffic.userPrio);
3881
3882 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3883 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3884 ~(1 << ac);
3885 } else if (pTsinfo->traffic.direction ==
3886 SIR_MAC_DIRECTION_DNLINK) {
3887 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3888 ~(1 << ac);
3889 } else if (pTsinfo->traffic.direction ==
3890 SIR_MAC_DIRECTION_BIDIR) {
3891 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3892 ~(1 << ac);
3893 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3894 ~(1 << ac);
3895 }
3896
3897 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3898 psessionEntry);
3899
3900 pStaDs =
3901 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3902 &psessionEntry->dph.dphHashTable);
3903 if (pStaDs != NULL) {
3904 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3905 pStaDs->bssId);
3906 status = eSIR_SUCCESS;
3907 } else {
3908 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3909 status = eSIR_FAILURE;
3910 }
3911#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913#endif
3914
3915 /* send an sme response back */
3916end:
3917 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3918 smesessionId, smetransactionId);
3919}
3920
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303921void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922{
3923 /* fetch the sessionEntry based on the sessionId */
3924 tpPESession psessionEntry;
3925 psessionEntry = pe_find_session_by_session_id(pMac,
3926 pMac->lim.limTimers.gLimAddtsRspTimer.
3927 sessionId);
3928 if (psessionEntry == NULL) {
3929 lim_log(pMac, LOGP,
3930 FL("Session Does not exist for given sessionID"));
3931 return;
3932 }
3933
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003934 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3936 GET_LIM_SYSTEM_ROLE(psessionEntry));
3937 pMac->lim.gLimAddtsSent = false;
3938 return;
3939 }
3940
3941 if (!pMac->lim.gLimAddtsSent) {
3942 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3943 return;
3944 }
3945
3946 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3947 lim_log(pMac, LOGE,
3948 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3949 pMac->lim.gLimAddtsRspTimerCount);
3950 return;
3951 }
3952 /* this a real response timeout */
3953 pMac->lim.gLimAddtsSent = false;
3954 pMac->lim.gLimAddtsRspTimerCount++;
3955
3956 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3957 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3958 psessionEntry->smeSessionId,
3959 psessionEntry->transactionId);
3960}
3961
3962/**
3963 * __lim_process_sme_get_statistics_request()
3964 *
3965 ***FUNCTION:
3966 *
3967 *
3968 ***NOTE:
3969 *
3970 * @param pMac Pointer to Global MAC structure
3971 * @param *pMsgBuf A pointer to the SME message buffer
3972 * @return None
3973 */
3974static void
3975__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3976{
3977 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08003978 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979
3980 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3981
3982 msgQ.type = WMA_GET_STATISTICS_REQ;
3983
3984 msgQ.reserved = 0;
3985 msgQ.bodyptr = pMsgBuf;
3986 msgQ.bodyval = 0;
3987 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3988
3989 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303990 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 pMsgBuf = NULL;
3992 lim_log(pMac, LOGP, "Unable to forward request");
3993 return;
3994 }
3995
3996 return;
3997}
3998
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003999#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004001 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004003 * @pMac: Pointer to Global MAC structure
4004 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004006 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 */
4008static void
4009__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4010{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004011 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012
4013 msgQ.type = WMA_TSM_STATS_REQ;
4014 msgQ.reserved = 0;
4015 msgQ.bodyptr = pMsgBuf;
4016 msgQ.bodyval = 0;
4017 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4018
4019 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304020 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 pMsgBuf = NULL;
4022 lim_log(pMac, LOGP, "Unable to forward request");
4023 return;
4024 }
4025}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004026#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027
4028static void
4029__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4030{
4031 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4032 tpPESession psessionEntry;
4033 uint8_t sessionId; /* PE sessionID */
4034
4035 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4036
4037 if (pMsgBuf == NULL) {
4038 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4039 return;
4040 }
4041
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304042 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 if (NULL == pUpdateAPWPSIEsReq) {
4044 lim_log(pMac, LOGP,
4045 FL
4046 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4047 return;
4048 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304049 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 sizeof(struct sSirUpdateAPWPSIEsReq));
4051
4052 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004053 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 &sessionId);
4055 if (psessionEntry == NULL) {
4056 lim_log(pMac, LOGW,
4057 FL("Session does not exist for given BSSID"));
4058 goto end;
4059 }
4060
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304061 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 sizeof(tSirAPWPSIEs));
4063
4064 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4065 lim_send_beacon_ind(pMac, psessionEntry);
4066
4067end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304068 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 return;
4070}
4071
4072void
4073lim_send_vdev_restart(tpAniSirGlobal pMac,
4074 tpPESession psessionEntry, uint8_t sessionId)
4075{
4076 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004077 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 tSirRetStatus retCode = eSIR_SUCCESS;
4079
4080 if (psessionEntry == NULL) {
4081 PELOGE(lim_log
4082 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4083 __LINE__);
4084 )
4085 return;
4086 }
4087
4088 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304089 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 if (NULL == pHalHiddenSsidVdevRestart) {
4091 PELOGE(lim_log
4092 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4093 __func__, __LINE__);
4094 )
4095 return;
4096 }
4097
4098 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4099 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4100
4101 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4102 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4103 msgQ.bodyval = 0;
4104
4105 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4106 if (eSIR_SUCCESS != retCode) {
4107 PELOGE(lim_log
4108 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4109 __LINE__);
4110 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304111 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 }
4113}
4114
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304115/**
4116 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4117 * @mac_ctx: Pointer to Global MAC structure
4118 * @msg_buf: Pointer to SME message buffer
4119 *
4120 * Return: None
4121 */
4122static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4123 uint32_t *msg_buf)
4124{
4125 tpPESession pe_session;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004126 struct scheduler_msg wma_msg;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304127 tSirRetStatus status;
4128 tSirRoamOffloadScanReq *req_buffer;
4129 uint16_t local_ie_len;
4130 uint8_t *local_ie_buf;
4131
4132 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4133 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4134 req_buffer->sessionId);
4135
4136 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4137 if (!local_ie_buf) {
Arif Hussain963331b2016-10-27 22:59:01 -07004138 lim_log(mac_ctx, LOGE,
4139 FL("Mem Alloc failed for local_ie_buf"));
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304140 return;
4141 }
4142
4143 local_ie_len = req_buffer->assoc_ie.length;
4144 /* Update ext cap IE if present */
4145 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004146 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4147 local_ie_buf, &local_ie_len)) {
4148 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004149 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4150 req_buffer->assoc_ie.length = local_ie_len;
4151 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4152 local_ie_buf, local_ie_len);
4153 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304154 }
4155 qdf_mem_free(local_ie_buf);
4156
4157 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4158 wma_msg.bodyptr = req_buffer;
4159
4160 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4161 if (eSIR_SUCCESS != status) {
4162 lim_log(mac_ctx, LOGE,
4163 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4164 qdf_mem_free(req_buffer);
4165 }
4166}
4167
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304168/*
4169 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4170 * @mac_ctx: Pointer to global mac context
4171 * @session: Pointer to PE session
4172 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4173 * 1 - Disable broadcast SSID
4174 *
4175 * Return: None
4176 */
4177static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4178 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304180 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4181 if (ssid_hidden != session->ssidHidden)
4182 session->ssidHidden = ssid_hidden;
4183 else {
4184 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304185 return;
4186 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187
4188 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304189 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190
4191 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304192 sch_set_fixed_beacon_fields(mac_ctx, session);
4193 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194
4195 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304196}
4197
4198/**
4199 * __lim_process_sme_session_update - process SME session update msg
4200 *
4201 * @mac_ctx: Pointer to global mac context
4202 * @msg_buf: Pointer to the received message buffer
4203 *
4204 * Return: None
4205 */
4206static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4207 uint32_t *msg_buf)
4208{
4209 struct sir_update_session_param *msg;
4210 tpPESession session;
4211
4212 if (!msg_buf) {
4213 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4214 return;
4215 }
4216
4217 msg = (struct sir_update_session_param *) msg_buf;
4218
4219 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4220 if (!session) {
4221 lim_log(mac_ctx, LOGW,
4222 "Session does not exist for given sessionId %d",
4223 msg->session_id);
4224 return;
4225 }
4226
4227 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4228 msg->param_type, msg->param_val);
4229 switch (msg->param_type) {
4230 case SIR_PARAM_SSID_HIDDEN:
4231 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4232 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304233 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4234 session->ignore_assoc_disallowed = msg->param_val;
4235 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304236 default:
4237 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4238 break;
4239 }
4240}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241
4242static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4243{
4244 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4245 tpPESession psessionEntry;
4246 uint8_t sessionId; /* PE sessionID */
4247
4248 if (pMsgBuf == NULL) {
4249 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4250 return;
4251 }
4252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304253 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 if (NULL == pUpdateAPWPARSNIEsReq) {
4255 lim_log(pMac, LOGP,
4256 FL
4257 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4258 return;
4259 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304260 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4262
4263 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004264 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 &sessionId);
4266 if (psessionEntry == NULL) {
4267 lim_log(pMac, LOGW,
4268 FL("Session does not exist for given BSSID"));
4269 goto end;
4270 }
4271
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304272 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4274
4275 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4276 &psessionEntry->
4277 pLimStartBssReq->rsnIE,
4278 psessionEntry);
4279
4280 psessionEntry->pLimStartBssReq->privacy = 1;
4281 psessionEntry->privacy = 1;
4282
4283 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4284 lim_send_beacon_ind(pMac, psessionEntry);
4285
4286end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304287 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 return;
4289} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4290
4291/*
4292 Update the beacon Interval dynamically if beaconInterval is different in MCC
4293 */
4294static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4295{
4296 tpSirChangeBIParams pChangeBIParams;
4297 tpPESession psessionEntry;
4298 uint8_t sessionId = 0;
4299 tUpdateBeaconParams beaconParams;
4300
4301 PELOG1(lim_log(pMac, LOG1,
4302 FL("received Update Beacon Interval message"));
4303 );
4304
4305 if (pMsgBuf == NULL) {
4306 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4307 return;
4308 }
4309
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304310 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4312
4313 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004314 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 &sessionId);
4316 if (psessionEntry == NULL) {
4317 lim_log(pMac, LOGE,
4318 FL("Session does not exist for given BSSID"));
4319 return;
4320 }
4321
4322 /*Update sessionEntry Beacon Interval */
4323 if (psessionEntry->beaconParams.beaconInterval !=
4324 pChangeBIParams->beaconInterval) {
4325 psessionEntry->beaconParams.beaconInterval =
4326 pChangeBIParams->beaconInterval;
4327 }
4328
4329 /*Update sch beaconInterval */
4330 if (pMac->sch.schObject.gSchBeaconInterval !=
4331 pChangeBIParams->beaconInterval) {
4332 pMac->sch.schObject.gSchBeaconInterval =
4333 pChangeBIParams->beaconInterval;
4334
4335 PELOG1(lim_log(pMac, LOG1,
4336 FL
4337 ("LIM send update BeaconInterval Indication : %d"),
4338 pChangeBIParams->beaconInterval);
4339 );
4340
4341 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4342 /* Update beacon */
4343 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4344
4345 beaconParams.bssIdx = psessionEntry->bssIdx;
4346 /* Set change in beacon Interval */
4347 beaconParams.beaconInterval =
4348 pChangeBIParams->beaconInterval;
4349 beaconParams.paramChangeBitmap =
4350 PARAM_BCN_INTERVAL_CHANGED;
4351 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4352 }
4353 }
4354
4355 return;
4356} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4357
4358#ifdef QCA_HT_2040_COEX
4359static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4360 uint32_t *pMsgBuf)
4361{
4362 tpSirSetHT2040Mode pSetHT2040Mode;
4363 tpPESession psessionEntry;
4364 uint8_t sessionId = 0;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004365 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 tUpdateVHTOpMode *pHtOpMode = NULL;
4367 uint16_t staId = 0;
4368 tpDphHashNode pStaDs = NULL;
4369
4370 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4371 if (pMsgBuf == NULL) {
4372 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4373 return;
4374 }
4375
4376 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4377
4378 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004379 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 &sessionId);
4381 if (psessionEntry == NULL) {
4382 lim_log(pMac, LOG1,
4383 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004384 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 return;
4386 }
4387
4388 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4389 pSetHT2040Mode->cbMode);
4390 /*Update sessionEntry HT related fields */
4391 switch (pSetHT2040Mode->cbMode) {
4392 case PHY_SINGLE_CHANNEL_CENTERED:
4393 psessionEntry->htSecondaryChannelOffset =
4394 PHY_SINGLE_CHANNEL_CENTERED;
4395 psessionEntry->htRecommendedTxWidthSet = 0;
4396 if (pSetHT2040Mode->obssEnabled)
4397 psessionEntry->htSupportedChannelWidthSet
4398 = eHT_CHANNEL_WIDTH_40MHZ;
4399 else
4400 psessionEntry->htSupportedChannelWidthSet
4401 = eHT_CHANNEL_WIDTH_20MHZ;
4402 break;
4403 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4404 psessionEntry->htSecondaryChannelOffset =
4405 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4406 psessionEntry->htRecommendedTxWidthSet = 1;
4407 break;
4408 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4409 psessionEntry->htSecondaryChannelOffset =
4410 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4411 psessionEntry->htRecommendedTxWidthSet = 1;
4412 break;
4413 default:
4414 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4415 return;
4416 }
4417
4418 /* Update beacon */
4419 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4420 lim_send_beacon_ind(pMac, psessionEntry);
4421
4422 /* update OP Mode for each associated peer */
4423 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4424 pStaDs = dph_get_hash_entry(pMac, staId,
4425 &psessionEntry->dph.dphHashTable);
4426 if (NULL == pStaDs)
4427 continue;
4428
4429 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304430 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 if (NULL == pHtOpMode) {
4432 lim_log(pMac, LOGE,
4433 FL
4434 ("%s: Not able to allocate memory for setting OP mode"),
4435 __func__);
4436 return;
4437 }
4438 pHtOpMode->opMode =
4439 (psessionEntry->htSecondaryChannelOffset ==
4440 PHY_SINGLE_CHANNEL_CENTERED) ?
4441 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4442 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304443 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 sizeof(tSirMacAddr));
4445 pHtOpMode->smesessionId = sessionId;
4446
4447 msg.type = WMA_UPDATE_OP_MODE;
4448 msg.reserved = 0;
4449 msg.bodyptr = pHtOpMode;
Krunal Soni66c113f2016-12-21 16:46:47 -08004450 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004451 scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08004452 &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 lim_log(pMac, LOGE,
4454 FL
4455 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4456 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 return;
4459 }
4460 lim_log(pMac, LOG1,
4461 FL
4462 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4463 __func__, pHtOpMode->opMode, staId);
4464
4465 } else
4466 lim_log(pMac, LOG1,
4467 FL("%s: station %d does not support HT40\n"),
4468 __func__, staId);
4469 }
4470
4471 return;
4472}
4473#endif
4474
4475/* -------------------------------------------------------------------- */
4476/**
4477 * __lim_process_report_message
4478 *
4479 * FUNCTION: Processes the next received Radio Resource Management message
4480 *
4481 * LOGIC:
4482 *
4483 * ASSUMPTIONS:
4484 *
4485 * NOTE:
4486 *
4487 * @param None
4488 * @return None
4489 */
4490
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004491static void __lim_process_report_message(tpAniSirGlobal pMac,
4492 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 switch (pMsg->type) {
4495 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4496 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4497 break;
4498 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004500 break;
4501 default:
4502 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504}
4505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506/* -------------------------------------------------------------------- */
4507/**
4508 * lim_send_set_max_tx_power_req
4509 *
4510 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4511 *
4512 * LOGIC:
4513 *
4514 * ASSUMPTIONS:
4515 *
4516 * NOTE:
4517 *
4518 * @param txPower txPower to be set.
4519 * @param pSessionEntry session entry.
4520 * @return None
4521 */
4522tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004523lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 tpPESession pSessionEntry)
4525{
4526 tpMaxTxPowerParams pMaxTxParams = NULL;
4527 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004528 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529
4530 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304531 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 return eSIR_FAILURE;
4533 }
4534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304535 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 if (NULL == pMaxTxParams) {
4537 lim_log(pMac, LOGP,
4538 FL("Unable to allocate memory for pMaxTxParams "));
4539 return eSIR_MEM_ALLOC_FAILED;
4540
4541 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304543 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304544 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304545 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004546 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304547 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548
4549 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4550 msgQ.bodyptr = pMaxTxParams;
4551 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304552 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4554 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4555 if (eSIR_SUCCESS != retCode) {
4556 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304557 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 }
4559 return retCode;
4560}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561
4562/**
4563 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4564 *
4565 * @mac_ctx: Pointer to Global MAC structure
4566 * @msg_buf: pointer to the SME message buffer
4567 *
4568 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4569 * from SME. It Register this information within PE.
4570 *
4571 * Return: None
4572 */
4573static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4574 uint32_t *msg_buf)
4575{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304576 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4578 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4579 struct mgmt_frm_reg_info *next = NULL;
4580 bool match = false;
4581
4582 lim_log(mac_ctx, LOG1, FL(
4583 "registerFrame %d, frameType %d, matchLen %d"),
4584 sme_req->registerFrame, sme_req->frameType,
4585 sme_req->matchLen);
4586 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304587 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304588 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4589 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304590 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591
4592 while (lim_mgmt_regn != NULL) {
4593 if (lim_mgmt_regn->frameType != sme_req->frameType)
4594 goto skip_match;
4595 if (sme_req->matchLen) {
4596 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304597 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 sme_req->matchData,
4599 lim_mgmt_regn->matchLen))) {
4600 /* found match! */
4601 match = true;
4602 break;
4603 }
4604 } else {
4605 /* found match! */
4606 match = true;
4607 break;
4608 }
4609skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304610 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304611 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304613 (qdf_list_node_t *)lim_mgmt_regn,
4614 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304615 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 lim_mgmt_regn = next;
4617 next = NULL;
4618 }
4619 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304620 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004621 if (QDF_STATUS_SUCCESS ==
4622 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004624 (qdf_list_node_t *)lim_mgmt_regn))
4625 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304626 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 }
4628
4629 if (sme_req->registerFrame) {
4630 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304631 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 sme_req->matchLen);
4633 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 lim_mgmt_regn->frameType = sme_req->frameType;
4635 lim_mgmt_regn->matchLen = sme_req->matchLen;
4636 lim_mgmt_regn->sessionId = sme_req->sessionId;
4637 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304638 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 sme_req->matchData,
4640 sme_req->matchLen);
4641 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304642 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304644 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 gLimMgmtFrameRegistratinQueue,
4646 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304647 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 &mac_ctx->lim.lim_frame_register_lock);
4649 }
4650 }
4651 return;
4652}
4653
4654static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4655{
4656 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4657 pMac->lim.gDeferMsgTypeForNOA);
4658 pMac->lim.gDeferMsgTypeForNOA = 0;
4659 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4660 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304661 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4663 }
4664}
4665
4666/**
4667 * lim_process_regd_defd_sme_req_after_noa_start()
4668 *
4669 * mac_ctx: Pointer to Global MAC structure
4670 *
4671 * This function is called to process deferred sme req message
4672 * after noa start.
4673 *
4674 * Return: None
4675 */
4676void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4677{
4678 bool buf_consumed = true;
4679
4680 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4681 mac_ctx->lim.gDeferMsgTypeForNOA);
4682
4683 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4684 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4685 lim_log(mac_ctx, LOGW,
4686 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4687 lim_log(mac_ctx, LOGW,
4688 FL("It may happen when NOA start ind and timeout happen at the same time"));
4689 return;
4690 }
4691 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4692 case eWNI_SME_SCAN_REQ:
4693 __lim_process_sme_scan_req(mac_ctx,
4694 mac_ctx->lim.gpDefdSmeMsgForNOA);
4695 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4697 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4698 mac_ctx->lim.gpDefdSmeMsgForNOA);
4699 /*
4700 * lim_process_remain_on_chnl_req doesnt want us to free
4701 * the buffer since it is freed in lim_remain_on_chn_rsp.
4702 * this change is to avoid "double free"
4703 */
4704 if (false == buf_consumed)
4705 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4706 break;
4707 case eWNI_SME_JOIN_REQ:
4708 __lim_process_sme_join_req(mac_ctx,
4709 mac_ctx->lim.gpDefdSmeMsgForNOA);
4710 break;
4711 default:
4712 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4713 mac_ctx->lim.gDeferMsgTypeForNOA);
4714 break;
4715 }
4716 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4717}
4718
4719static void
4720__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4721{
4722 tpSirResetAPCapsChange pResetCapsChange;
4723 tpPESession psessionEntry;
4724 uint8_t sessionId = 0;
4725 if (pMsgBuf == NULL) {
4726 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4727 return;
4728 }
4729
4730 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4731 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004732 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4733 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004734 if (psessionEntry == NULL) {
4735 lim_log(pMac, LOGE,
4736 FL("Session does not exist for given BSSID"));
4737 return;
4738 }
4739
4740 psessionEntry->limSentCapsChangeNtf = false;
4741 return;
4742}
4743
4744/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304745 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4746 * @mac_ctx: Mac pointer
4747 * @msg_buf: Msg pointer containing the callback
4748 *
4749 * This function is used to save the p2p ack indication callback in PE.
4750 *
4751 * Return: None
4752 */
4753static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4754 uint32_t *msg_buf)
4755{
4756 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4757 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4758
4759 if (NULL == msg_buf) {
4760 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4761 return;
4762 }
4763 if (sme_req->callback)
4764 mac_ctx->p2p_ack_ind_cb =
4765 sme_req->callback;
4766 else
4767 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4768}
4769
4770/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304771 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4772 * indication callback in PE.
4773 * @mac_ptr: Mac pointer
4774 * @msg_buf: Msg pointer containing the callback
4775 *
4776 * This function is used save the Management frame
4777 * indication callback in PE.
4778 *
4779 * Return: None
4780 */
4781static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4782 uint32_t *msg_buf)
4783{
4784 struct sir_sme_mgmt_frame_cb_req *sme_req =
4785 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4786
4787 if (NULL == msg_buf) {
4788 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4789 return;
4790 }
4791 if (sme_req->callback)
4792 mac_ctx->mgmt_frame_ind_cb =
4793 (sir_mgmt_frame_ind_callback)sme_req->callback;
4794 else
4795 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4796}
4797
4798/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304799 *__lim_process_send_disassoc_frame: function processes disassoc frame
4800 * @mac_ctx: pointer to mac context
4801 * @msg_buf: message buffer
4802 *
4803 * function processes disassoc request received from SME
4804 *
4805 * return: none
4806 */
4807static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4808 uint32_t *msg_buf)
4809{
4810 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4811 tSirRetStatus status;
4812 tpPESession session_entry = NULL;
4813 uint8_t sme_session_id;
4814 uint16_t sme_trans_id;
4815
4816 if (msg_buf == NULL) {
4817 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4818 return;
4819 }
4820
4821 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4822 &sme_trans_id);
4823
4824 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4825 &sme_send_disassoc_frame_req,
4826 (uint8_t *)msg_buf);
4827
4828 if ((eSIR_FAILURE == status) ||
4829 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4830 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4831 PELOGE(lim_log(mac_ctx, LOGE,
4832 FL("received invalid SME_DISASSOC_REQ message"));)
4833 return;
4834 }
4835
4836 session_entry = pe_find_session_by_sme_session_id(
4837 mac_ctx, sme_session_id);
4838 if (session_entry == NULL) {
4839 lim_log(mac_ctx, LOGE,
4840 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4841 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4842 return;
4843 }
4844
4845 lim_log(mac_ctx, LOG1,
4846 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4847 sme_send_disassoc_frame_req.msg_type,
4848 sme_send_disassoc_frame_req.length,
4849 sme_send_disassoc_frame_req.session_id,
4850 sme_send_disassoc_frame_req.trans_id,
4851 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4852 sme_send_disassoc_frame_req.reason,
4853 sme_send_disassoc_frame_req.wait_for_ack);
4854
4855 lim_send_disassoc_mgmt_frame(mac_ctx,
4856 sme_send_disassoc_frame_req.reason,
4857 sme_send_disassoc_frame_req.peer_mac,
4858 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4859}
4860
4861/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004862 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4863 * @mac_ctx: Pointer to Global MAC structure
4864 * @pdev_id: pdev id to set the IE.
4865 * @nss: Nss values to prepare the HT IE.
4866 *
4867 * Prepares the HT IE with self capabilities for different
4868 * Nss values and sends the set HT IE req to FW.
4869 *
4870 * Return: None
4871 */
4872static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4873 uint8_t nss)
4874{
4875 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004876 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004877 tSirRetStatus rc = eSIR_SUCCESS;
4878 uint8_t *p_ie = NULL;
4879 tHtCaps *p_ht_cap;
4880 int i;
4881
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004882 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004883 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4884 if (NULL == ie_params) {
4885 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4886 return;
4887 }
4888 ie_params->nss = i;
4889 ie_params->pdev_id = pdev_id;
4890 ie_params->ie_type = DOT11_HT_IE;
4891 /* 2 for IE len and EID */
4892 ie_params->ie_len = 2 + sizeof(tHtCaps);
4893 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4894 if (NULL == ie_params->ie_ptr) {
4895 qdf_mem_free(ie_params);
4896 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4897 return;
4898 }
4899 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4900 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4901 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4902 ie_params->ie_len);
4903
4904 if (NSS_1x1_MODE == i) {
4905 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4906 ie_params->ie_len,
4907 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004908 if (NULL == p_ie) {
4909 qdf_mem_free(ie_params->ie_ptr);
4910 qdf_mem_free(ie_params);
4911 lim_log(mac_ctx, LOGE,
4912 FL("failed to get IE ptr"));
4913 return;
4914 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004915 p_ht_cap = (tHtCaps *)&p_ie[2];
4916 p_ht_cap->supportedMCSSet[1] = 0;
4917 p_ht_cap->txSTBC = 0;
4918 }
4919
4920 msg.type = WMA_SET_PDEV_IE_REQ;
4921 msg.bodyptr = ie_params;
4922 msg.bodyval = 0;
4923
4924 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4925 if (rc != eSIR_SUCCESS) {
4926 lim_log(mac_ctx, LOGE,
4927 FL("wma_post_ctrl_msg() return failure"));
4928 qdf_mem_free(ie_params->ie_ptr);
4929 qdf_mem_free(ie_params);
4930 return;
4931 }
4932 }
4933}
4934
4935/**
4936 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4937 * @mac_ctx: Pointer to Global MAC structure
4938 * @pdev_id: pdev id to set the IE.
4939 * @nss: Nss values to prepare the VHT IE.
4940 *
4941 * Prepares the VHT IE with self capabilities for different
4942 * Nss values and sends the set VHT IE req to FW.
4943 *
4944 * Return: None
4945 */
4946static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4947 uint8_t nss)
4948{
4949 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004950 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004951 tSirRetStatus rc = eSIR_SUCCESS;
4952 uint8_t *p_ie = NULL;
4953 tSirMacVHTCapabilityInfo *vht_cap;
4954 int i;
4955 tSirVhtMcsInfo *vht_mcs;
4956
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004957 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004958 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4959 if (NULL == ie_params) {
4960 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4961 return;
4962 }
4963 ie_params->nss = i;
4964 ie_params->pdev_id = pdev_id;
4965 ie_params->ie_type = DOT11_VHT_IE;
4966 /* 2 for IE len and EID */
4967 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4968 sizeof(tSirVhtMcsInfo);
4969 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4970 if (NULL == ie_params->ie_ptr) {
4971 qdf_mem_free(ie_params);
4972 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4973 return;
4974 }
4975 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4976 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4977 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4978 ie_params->ie_len);
4979
4980 if (NSS_1x1_MODE == i) {
4981 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4982 ie_params->ie_len,
4983 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004984 if (NULL == p_ie) {
4985 qdf_mem_free(ie_params->ie_ptr);
4986 qdf_mem_free(ie_params);
4987 lim_log(mac_ctx, LOGE,
4988 FL("failed to get IE ptr"));
4989 return;
4990 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004991 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4992 vht_cap->txSTBC = 0;
4993 vht_mcs =
4994 (tSirVhtMcsInfo *)&p_ie[2 +
4995 sizeof(tSirMacVHTCapabilityInfo)];
4996 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4997 vht_mcs->rxHighest =
4998 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4999 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5000 vht_mcs->txHighest =
5001 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5002 }
5003 msg.type = WMA_SET_PDEV_IE_REQ;
5004 msg.bodyptr = ie_params;
5005 msg.bodyval = 0;
5006
5007 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5008 if (rc != eSIR_SUCCESS) {
5009 lim_log(mac_ctx, LOGE,
5010 FL("wma_post_ctrl_msg failure"));
5011 qdf_mem_free(ie_params->ie_ptr);
5012 qdf_mem_free(ie_params);
5013 return;
5014 }
5015 }
5016}
5017
5018/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005019 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5020 * @mac_ctx: Pointer to Global MAC structure
5021 * @msg_buf: Pointer to the SME message buffer
5022 *
5023 * This function is called by limProcessMessageQueue(). This function sets the
5024 * VDEV IEs to the FW.
5025 *
5026 * Return: None
5027 */
5028static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5029 uint32_t *msg_buf)
5030{
5031 struct sir_set_vdev_ies_per_band *p_msg =
5032 (struct sir_set_vdev_ies_per_band *)msg_buf;
5033
5034 if (NULL == p_msg) {
5035 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5036 return;
5037 }
5038
5039 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5040 p_msg->vdev_id);
5041 /* intentionally using NULL here so that self capabilty are sent */
5042 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5043 QDF_STATUS_SUCCESS)
5044 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5045}
5046
5047/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005048 * lim_process_set_pdev_IEs() - process the set pdev IE req
5049 * @mac_ctx: Pointer to Global MAC structure
5050 * @msg_buf: Pointer to the SME message buffer
5051 *
5052 * This function is called by limProcessMessageQueue(). This
5053 * function sets the PDEV IEs to the FW.
5054 *
5055 * Return: None
5056 */
5057static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5058{
5059 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5060
5061 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5062
5063 if (NULL == ht_vht_cfg) {
5064 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5065 return;
5066 }
5067
5068 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5069 ht_vht_cfg->nss);
5070 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5071
5072 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5073 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5074 ht_vht_cfg->nss);
5075}
5076
5077/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305078 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5079 *
5080 * access policy
5081 * @mac_ctx: pointer to mac context
5082 * @msg: message buffer
5083 *
5084 * function processes vendor IE and access policy from SME and updates PE
5085 *
5086 * session entry
5087 *
5088 * return: none
5089*/
5090static void lim_process_sme_update_access_policy_vendor_ie(
5091 tpAniSirGlobal mac_ctx,
5092 uint32_t *msg)
5093{
5094 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5095 struct sPESession *pe_session_entry;
5096 uint8_t num_bytes;
5097
5098 if (!msg) {
5099 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5100 return;
5101 }
5102 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5103 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5104 update_vendor_ie->sme_session_id);
5105
5106 if (!pe_session_entry) {
5107 lim_log(mac_ctx, LOGE,
5108 FL("Session does not exist for given sme session id(%hu)"),
5109 update_vendor_ie->sme_session_id);
5110 return;
5111 }
5112 if (pe_session_entry->access_policy_vendor_ie)
5113 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5114
5115 num_bytes = update_vendor_ie->ie[1] + 2;
5116 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5117
5118 if (!pe_session_entry->access_policy_vendor_ie) {
5119 lim_log(mac_ctx, LOGE,
5120 FL("Failed to allocate memory for vendor ie"));
5121 return;
5122 }
5123 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5124 &update_vendor_ie->ie[0], num_bytes);
5125
5126 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5127}
5128
5129/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130 * lim_process_sme_req_messages()
5131 *
5132 ***FUNCTION:
5133 * This function is called by limProcessMessageQueue(). This
5134 * function processes SME request messages from HDD or upper layer
5135 * application.
5136 *
5137 ***LOGIC:
5138 *
5139 ***ASSUMPTIONS:
5140 *
5141 ***NOTE:
5142 *
5143 * @param pMac Pointer to Global MAC structure
5144 * @param msgType Indicates the SME message type
5145 * @param *pMsgBuf A pointer to the SME message buffer
5146 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5147 * false - if pMsgBuf is not to be freed.
5148 */
5149
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005150bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5151 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152{
5153 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5154 uint32_t *pMsgBuf = pMsg->bodyptr;
5155 tpSirSmeScanReq pScanReq;
5156 PELOG1(lim_log
5157 (pMac, LOG1,
5158 FL
5159 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5160 lim_msg_str(pMsg->type), pMsg->type,
5161 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5162 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5163 )
5164
5165 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5166 /* If no insert NOA required then execute the code below */
5167
5168 switch (pMsg->type) {
5169 case eWNI_SME_SYS_READY_IND:
5170 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5171 break;
5172
5173 case eWNI_SME_START_BSS_REQ:
5174 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5175 break;
5176
5177 case eWNI_SME_SCAN_REQ:
5178 __lim_process_sme_scan_req(pMac, pMsgBuf);
5179 break;
5180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005181 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5182 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5183 break;
5184
5185 case eWNI_SME_UPDATE_NOA:
5186 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5187 break;
5188 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5189 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5190 break;
5191 case eWNI_SME_JOIN_REQ:
5192 __lim_process_sme_join_req(pMac, pMsgBuf);
5193 break;
5194
5195 case eWNI_SME_REASSOC_REQ:
5196 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5197 break;
5198
5199 case eWNI_SME_DISASSOC_REQ:
5200 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5201 break;
5202
5203 case eWNI_SME_DISASSOC_CNF:
5204 case eWNI_SME_DEAUTH_CNF:
5205 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5206 break;
5207
5208 case eWNI_SME_DEAUTH_REQ:
5209 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5210 break;
5211
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305212 case eWNI_SME_SEND_DISASSOC_FRAME:
5213 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5214 break;
5215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 case eWNI_SME_SETCONTEXT_REQ:
5217 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5218 break;
5219
5220 case eWNI_SME_STOP_BSS_REQ:
5221 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5222 break;
5223
5224 case eWNI_SME_ASSOC_CNF:
5225 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5226 PELOG1(lim_log(pMac,
5227 LOG1, FL("Received ASSOC_CNF message"));)
5228 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5229 pMsgBuf);
5230 break;
5231
5232 case eWNI_SME_ADDTS_REQ:
5233 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5234 __lim_process_sme_addts_req(pMac, pMsgBuf);
5235 break;
5236
5237 case eWNI_SME_DELTS_REQ:
5238 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5239 __lim_process_sme_delts_req(pMac, pMsgBuf);
5240 break;
5241
5242 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5243 PELOG1(lim_log
5244 (pMac, LOG1,
5245 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5246 )
5247 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5248 break;
5249
5250 case eWNI_SME_GET_STATISTICS_REQ:
5251 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5252 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5253 bufConsumed = false;
5254 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005255#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 case eWNI_SME_GET_TSM_STATS_REQ:
5257 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5258 bufConsumed = false;
5259 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005260#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261 case eWNI_SME_GET_ASSOC_STAS_REQ:
5262 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5263 break;
5264 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5265 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5266 break;
5267
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305268 case eWNI_SME_SESSION_UPDATE_PARAM:
5269 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305271 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5272 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5273 bufConsumed = false;
5274 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 case eWNI_SME_UPDATE_APWPSIE_REQ:
5276 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5277 break;
5278 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5279 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5280 break;
5281
5282 case eWNI_SME_SET_APWPARSNIEs_REQ:
5283 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5284 break;
5285
5286 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5287 /* Update the beaconInterval */
5288 __lim_process_sme_change_bi(pMac, pMsgBuf);
5289 break;
5290
5291#ifdef QCA_HT_2040_COEX
5292 case eWNI_SME_SET_HT_2040_MODE:
5293 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5294 break;
5295#endif
5296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5298 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5299 __lim_process_report_message(pMac, pMsg);
5300 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 case eWNI_SME_FT_PRE_AUTH_REQ:
5303 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5304 break;
5305 case eWNI_SME_FT_UPDATE_KEY:
5306 lim_process_ft_update_key(pMac, pMsgBuf);
5307 break;
5308
5309 case eWNI_SME_FT_AGGR_QOS_REQ:
5310 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5311 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312
5313 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5314 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5315 break;
5316#ifdef FEATURE_WLAN_TDLS
5317 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5318 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5319 break;
5320 case eWNI_SME_TDLS_ADD_STA_REQ:
5321 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5322 break;
5323 case eWNI_SME_TDLS_DEL_STA_REQ:
5324 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5325 break;
5326 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5327 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5328 break;
5329#endif
5330 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5331 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5332 break;
5333
5334 case eWNI_SME_CHANNEL_CHANGE_REQ:
5335 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5336 break;
5337
5338 case eWNI_SME_START_BEACON_REQ:
5339 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5340 break;
5341
5342 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5343 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5344 break;
5345
5346 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5347 lim_process_update_add_ies(pMac, pMsgBuf);
5348 break;
5349
5350 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5351 lim_process_modify_add_ies(pMac, pMsgBuf);
5352 break;
5353 case eWNI_SME_SET_HW_MODE_REQ:
5354 lim_process_set_hw_mode(pMac, pMsgBuf);
5355 break;
5356 case eWNI_SME_NSS_UPDATE_REQ:
5357 lim_process_nss_update_request(pMac, pMsgBuf);
5358 break;
5359 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5360 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5361 break;
5362 case eWNI_SME_SET_IE_REQ:
5363 lim_process_set_ie_req(pMac, pMsgBuf);
5364 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305365 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5366 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5367 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305368 case eWNI_SME_EXT_CHANGE_CHANNEL:
5369 lim_process_ext_change_channel(pMac, pMsgBuf);
5370 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005371 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5372 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5373 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005374 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5375 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005376 break;
5377 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5378 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5379 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005380 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005381 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005382 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005383 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005384 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305385 case eWNI_SME_REGISTER_P2P_ACK_CB:
5386 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5387 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305388 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5389 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5390 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305392 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393 pMsg->bodyptr = NULL;
5394 break;
5395 } /* switch (msgType) */
5396
5397 return bufConsumed;
5398} /*** end lim_process_sme_req_messages() ***/
5399
5400/**
5401 * lim_process_sme_start_beacon_req()
5402 *
5403 ***FUNCTION:
5404 * This function is called by limProcessMessageQueue(). This
5405 * function processes SME request messages from HDD or upper layer
5406 * application.
5407 *
5408 ***LOGIC:
5409 *
5410 ***ASSUMPTIONS:
5411 *
5412 ***NOTE:
5413 *
5414 * @param pMac Pointer to Global MAC structure
5415 * @param msgType Indicates the SME message type
5416 * @param *pMsgBuf A pointer to the SME message buffer
5417 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5418 * false - if pMsgBuf is not to be freed.
5419 */
5420static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5421{
5422 tpSirStartBeaconIndication pBeaconStartInd;
5423 tpPESession psessionEntry;
5424 uint8_t sessionId; /* PE sessionID */
5425
5426 if (pMsg == NULL) {
5427 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5428 return;
5429 }
5430
5431 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5432 psessionEntry = pe_find_session_by_bssid(pMac,
5433 pBeaconStartInd->bssid,
5434 &sessionId);
5435 if (psessionEntry == NULL) {
5436 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5437 lim_log(pMac, LOGE,
5438 FL("Session does not exist for given bssId"));
5439 return;
5440 }
5441
5442 if (pBeaconStartInd->beaconStartStatus == true) {
5443 /*
5444 * Currently this Indication comes from SAP
5445 * to start Beacon Tx on a DFS channel
5446 * since beaconing has to be done on DFS
5447 * channel only after CAC WAIT is completed.
5448 * On a DFS Channel LIM does not start beacon
5449 * Tx right after the WMA_ADD_BSS_RSP.
5450 */
5451 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305452 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 FL("Start Beacon with ssid %s Ch %d"),
5454 psessionEntry->ssId.ssId,
5455 psessionEntry->currentOperChannel);
5456 lim_send_beacon_ind(pMac, psessionEntry);
5457 } else {
5458 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5459 return;
5460 }
5461}
5462
5463/**
5464 * lim_process_sme_channel_change_request() - process sme ch change req
5465 *
5466 * @mac_ctx: Pointer to Global MAC structure
5467 * @msg_buf: pointer to the SME message buffer
5468 *
5469 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5470 *
5471 * Return: None
5472 */
5473static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5474 uint32_t *msg_buf)
5475{
5476 tpSirChanChangeRequest ch_change_req;
5477 tpPESession session_entry;
5478 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005479 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005480 uint32_t val = 0;
5481
5482 if (msg_buf == NULL) {
5483 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5484 return;
5485 }
5486 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5487
5488 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5489 ch_change_req->targetChannel);
5490
5491 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5492 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5493 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5494 return;
5495 }
5496
5497 session_entry = pe_find_session_by_bssid(mac_ctx,
5498 ch_change_req->bssid, &session_id);
5499 if (session_entry == NULL) {
5500 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5501 lim_log(mac_ctx, LOGE, FL(
5502 "Session does not exist for given bssId"));
5503 return;
5504 }
5505
5506 if (session_entry->currentOperChannel ==
5507 ch_change_req->targetChannel) {
5508 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5509 return;
5510 }
5511
5512 if (LIM_IS_AP_ROLE(session_entry))
5513 session_entry->channelChangeReasonCode =
5514 LIM_SWITCH_CHANNEL_SAP_DFS;
5515 else
5516 session_entry->channelChangeReasonCode =
5517 LIM_SWITCH_CHANNEL_OPERATION;
5518
5519 lim_log(mac_ctx, LOGW, FL(
5520 "switch old chnl %d to new chnl %d, ch_bw %d"),
5521 session_entry->currentOperChannel,
5522 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005523 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524
5525 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005526 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 session_entry->ch_center_freq_seg0 =
5528 ch_change_req->center_freq_seg_0;
5529 session_entry->ch_center_freq_seg1 =
5530 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005531 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005533 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 session_entry->htRecommendedTxWidthSet =
5535 session_entry->htSupportedChannelWidthSet;
5536 session_entry->currentOperChannel =
5537 ch_change_req->targetChannel;
5538 session_entry->limRFBand =
5539 lim_get_rf_band(session_entry->currentOperChannel);
5540 /* Initialize 11h Enable Flag */
5541 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5542 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5543 eSIR_SUCCESS)
5544 lim_log(mac_ctx, LOGP,
5545 FL("Fail to get WNI_CFG_11H_ENABLED"));
5546 }
5547
5548 session_entry->lim11hEnable = val;
5549 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305550 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551 &ch_change_req->operational_rateset,
5552 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305553 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 &ch_change_req->extended_rateset,
5555 sizeof(session_entry->extRateSet));
5556 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5557 session_entry->ch_center_freq_seg0,
5558 session_entry->ch_center_freq_seg1,
5559 session_entry->ch_width,
5560 max_tx_pwr, session_entry->peSessionId);
5561}
5562
5563/******************************************************************************
5564* lim_start_bss_update_add_ie_buffer()
5565*
5566***FUNCTION:
5567* This function checks the src buffer and its length and then malloc for
5568* dst buffer update the same
5569*
5570***LOGIC:
5571*
5572***ASSUMPTIONS:
5573*
5574***NOTE:
5575*
5576* @param pMac Pointer to Global MAC structure
5577* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5578* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5579* @param *pSrcData_buff A pointer of uint8_t src buffer
5580* @param srcDataLen src buffer length
5581******************************************************************************/
5582
5583static void
5584lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5585 uint8_t **pDstData_buff,
5586 uint16_t *pDstDataLen,
5587 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5588{
5589
5590 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5591 *pDstDataLen = srcDataLen;
5592
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305593 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594
5595 if (NULL == *pDstData_buff) {
5596 lim_log(pMac, LOGE,
5597 FL("AllocateMemory failed for pDstData_buff"));
5598 return;
5599 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305600 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601 } else {
5602 *pDstData_buff = NULL;
5603 *pDstDataLen = 0;
5604 }
5605}
5606
5607/******************************************************************************
5608* lim_update_add_ie_buffer()
5609*
5610***FUNCTION:
5611* This function checks the src buffer and length if src buffer length more
5612* than dst buffer length then free the dst buffer and malloc for the new src
5613* length, and update the dst buffer and length. But if dst buffer is bigger
5614* than src buffer length then it just update the dst buffer and length
5615*
5616***LOGIC:
5617*
5618***ASSUMPTIONS:
5619*
5620***NOTE:
5621*
5622* @param pMac Pointer to Global MAC structure
5623* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5624* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5625* @param *pSrcData_buff A pointer of uint8_t src buffer
5626* @param srcDataLen src buffer length
5627******************************************************************************/
5628
5629static void
5630lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5631 uint8_t **pDstData_buff,
5632 uint16_t *pDstDataLen,
5633 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5634{
5635
5636 if (NULL == pSrcData_buff) {
5637 lim_log(pMac, LOGE, FL("src buffer is null."));
5638 return;
5639 }
5640
5641 if (srcDataLen > *pDstDataLen) {
5642 *pDstDataLen = srcDataLen;
5643 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305644 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305646 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647
5648 if (NULL == *pDstData_buff) {
5649 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5650 *pDstDataLen = 0;
5651 return;
5652 }
5653 }
5654
5655 /* copy the content of buffer into dst buffer
5656 */
5657 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305658 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659
5660}
5661
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005662/**
5663 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5664 * @pMac : Pointer to Global MAC structure
5665 * @pDstData_buff : A pointer to pointer of dst buffer
5666 * @pDstDataLen : A pointer to pointer of dst buffer length
5667 * @pModifyIE : A pointer to tSirModifyIE
5668 *
5669 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5670 *
5671 * Return:
5672 * True or false depending upon whether IE is updated or not
5673 */
5674static bool
5675lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5676 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5677{
Hong Shi1553d692016-09-28 12:16:19 +08005678 int32_t oui_length;
5679 uint8_t *ibss_ie = NULL;
5680 uint8_t *vendor_ie;
5681#define MAC_VENDOR_OUI "\x00\x16\x32"
5682#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005683
5684 ibss_ie = pModifyIE->pIEBuffer;
5685 oui_length = pModifyIE->oui_length;
5686
5687 if ((0 == oui_length) || (NULL == ibss_ie)) {
5688 PELOGE(lim_log(pMac, LOGE,
5689 FL("Invalid set IBSS vendor IE command length %d "),
5690 oui_length);)
5691 return false;
5692 }
5693
Hong Shi1553d692016-09-28 12:16:19 +08005694 /*
5695 * Why replace only beacon OUI data here:
5696 * 1. other ie (such as wpa) shall not be overwritten here.
5697 * 2. per spec, beacon oui ie might be set twice and original one
5698 * shall be updated.
5699 */
5700 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5701 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5702 if (vendor_ie) {
5703 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5704 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5705 pModifyIE->ieBufferlength);
5706 } else {
5707 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5708 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005709
Hong Shi1553d692016-09-28 12:16:19 +08005710 if (NULL == new_ptr) {
5711 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5712 return false;
5713 }
5714 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5715 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5716 pModifyIE->ieBufferlength);
5717 qdf_mem_free(*pDstData_buff);
5718 *pDstDataLen = new_length;
5719 *pDstData_buff = new_ptr;
5720 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005721 return true;
5722}
5723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724/*
5725* lim_process_modify_add_ies() - process modify additional IE req.
5726*
5727* @mac_ctx: Pointer to Global MAC structure
5728* @msg_buf: pointer to the SME message buffer
5729*
5730* This function update the PE buffers for additional IEs.
5731*
5732* Return: None
5733*/
5734static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5735 uint32_t *msg_buf)
5736{
5737 tpSirModifyIEsInd modify_add_ies;
5738 tpPESession session_entry;
5739 uint8_t session_id;
5740 bool ret = false;
5741 tSirAddIeParams *add_ie_params;
5742
5743 if (msg_buf == NULL) {
5744 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5745 return;
5746 }
5747
5748 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5749 /* Incoming message has smeSession, use BSSID to find PE session */
5750 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005751 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752
5753 if (NULL == session_entry) {
5754 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5755 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005756 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757 goto end;
5758 }
5759 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5760 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5761 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5762 lim_log(mac_ctx, LOGE,
5763 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5764 modify_add_ies->modifyIE.pIEBuffer,
5765 modify_add_ies->modifyIE.ieBufferlength,
5766 modify_add_ies->modifyIE.ieID,
5767 modify_add_ies->modifyIE.ieIDLen,
5768 modify_add_ies->updateType);
5769 goto end;
5770 }
5771 add_ie_params = &session_entry->addIeParams;
5772 switch (modify_add_ies->updateType) {
5773 case eUPDATE_IE_PROBE_RESP:
5774 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005775 if (LIM_IS_IBSS_ROLE(session_entry)) {
5776 lim_update_ibss_prop_add_ies(mac_ctx,
5777 &add_ie_params->probeRespData_buff,
5778 &add_ie_params->probeRespDataLen,
5779 &modify_add_ies->modifyIE);
5780 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 break;
5782 case eUPDATE_IE_ASSOC_RESP:
5783 /* assoc resp IE */
5784 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305785 QDF_TRACE(QDF_MODULE_ID_PE,
5786 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 "assoc resp add ie not present %d"),
5788 add_ie_params->assocRespDataLen);
5789 }
5790 /* search through the buffer and modify the IE */
5791 break;
5792 case eUPDATE_IE_PROBE_BCN:
5793 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005794 if (LIM_IS_IBSS_ROLE(session_entry)) {
5795 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5796 &add_ie_params->probeRespBCNData_buff,
5797 &add_ie_params->probeRespBCNDataLen,
5798 &modify_add_ies->modifyIE);
5799 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 if (ret == true && modify_add_ies->modifyIE.notify) {
5801 lim_handle_param_update(mac_ctx,
5802 modify_add_ies->updateType);
5803 }
5804 break;
5805 default:
5806 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5807 modify_add_ies->updateType);
5808 break;
5809 }
5810end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305811 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 modify_add_ies->modifyIE.pIEBuffer = NULL;
5813}
5814
5815/*
5816* lim_process_update_add_ies() - process additional IE update req
5817*
5818* @mac_ctx: Pointer to Global MAC structure
5819* @msg_buf: pointer to the SME message buffer
5820*
5821* This function update the PE buffers for additional IEs.
5822*
5823* Return: None
5824*/
5825static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5826 uint32_t *msg_buf)
5827{
5828 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5829 uint8_t session_id;
5830 tpPESession session_entry;
5831 tSirAddIeParams *addn_ie;
5832 uint16_t new_length = 0;
5833 uint8_t *new_ptr = NULL;
5834 tSirUpdateIE *update_ie;
5835
5836 if (msg_buf == NULL) {
5837 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5838 return;
5839 }
5840 update_ie = &update_add_ies->updateIE;
5841 /* incoming message has smeSession, use BSSID to find PE session */
5842 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005843 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005844
5845 if (NULL == session_entry) {
5846 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5847 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005848 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 goto end;
5850 }
5851 addn_ie = &session_entry->addIeParams;
5852 /* if len is 0, upper layer requested freeing of buffer */
5853 if (0 == update_ie->ieBufferlength) {
5854 switch (update_add_ies->updateType) {
5855 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305856 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 addn_ie->probeRespData_buff = NULL;
5858 addn_ie->probeRespDataLen = 0;
5859 break;
5860 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305861 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 addn_ie->assocRespData_buff = NULL;
5863 addn_ie->assocRespDataLen = 0;
5864 break;
5865 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305866 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 addn_ie->probeRespBCNData_buff = NULL;
5868 addn_ie->probeRespBCNDataLen = 0;
5869
5870 if (update_ie->notify)
5871 lim_handle_param_update(mac_ctx,
5872 update_add_ies->updateType);
5873 break;
5874 default:
5875 break;
5876 }
5877 return;
5878 }
5879 switch (update_add_ies->updateType) {
5880 case eUPDATE_IE_PROBE_RESP:
5881 if (update_ie->append) {
5882 /*
5883 * In case of append, allocate new memory
5884 * with combined length
5885 */
5886 new_length = update_ie->ieBufferlength +
5887 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305888 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 if (NULL == new_ptr) {
5890 lim_log(mac_ctx, LOGE, FL(
5891 "Memory allocation failed."));
5892 goto end;
5893 }
5894 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305895 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005896 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305897 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 update_ie->pAdditionIEBuffer,
5899 update_ie->ieBufferlength);
5900 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305901 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 /* adjust length accordingly */
5903 addn_ie->probeRespDataLen = new_length;
5904 /* save refernece of local buffer in PE session */
5905 addn_ie->probeRespData_buff = new_ptr;
5906 goto end;
5907 }
5908 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5909 &addn_ie->probeRespDataLen,
5910 update_ie->pAdditionIEBuffer,
5911 update_ie->ieBufferlength);
5912 break;
5913 case eUPDATE_IE_ASSOC_RESP:
5914 /* assoc resp IE */
5915 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5916 &addn_ie->assocRespDataLen,
5917 update_ie->pAdditionIEBuffer,
5918 update_ie->ieBufferlength);
5919 break;
5920 case eUPDATE_IE_PROBE_BCN:
5921 /* probe resp Bcn IE */
5922 lim_update_add_ie_buffer(mac_ctx,
5923 &addn_ie->probeRespBCNData_buff,
5924 &addn_ie->probeRespBCNDataLen,
5925 update_ie->pAdditionIEBuffer,
5926 update_ie->ieBufferlength);
5927 if (update_ie->notify)
5928 lim_handle_param_update(mac_ctx,
5929 update_add_ies->updateType);
5930 break;
5931 default:
5932 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5933 update_add_ies->updateType);
5934 break;
5935 }
5936end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305937 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 update_ie->pAdditionIEBuffer = NULL;
5939}
5940
5941/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305942 * send_extended_chan_switch_action_frame()- function to send ECSA
5943 * action frame for each sta connected to SAP/GO and AP in case of
5944 * STA .
5945 * @mac_ctx: pointer to global mac structure
5946 * @new_channel: new channel to switch to.
5947 * @ch_bandwidth: BW of channel to calculate op_class
5948 * @session_entry: pe session
5949 *
5950 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5951 *
5952 * Return: void
5953 */
5954
5955static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5956 uint16_t new_channel, uint8_t ch_bandwidth,
5957 tpPESession session_entry)
5958{
5959 uint16_t op_class;
5960 uint8_t switch_mode = 0, i;
5961 tpDphHashNode psta;
5962
5963
Amar Singhal22995112016-01-22 10:42:33 -08005964 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305965 mac_ctx->scan.countryCodeCurrent,
5966 new_channel,
5967 ch_bandwidth);
5968
5969 if (LIM_IS_AP_ROLE(session_entry) &&
5970 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5971 switch_mode = 1;
5972
5973 if (LIM_IS_AP_ROLE(session_entry)) {
5974 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5975 psta =
5976 session_entry->dph.dphHashTable.pDphNodeArray + i;
5977 if (psta && psta->added)
5978 lim_send_extended_chan_switch_action_frame(
5979 mac_ctx,
5980 psta->staAddr,
5981 switch_mode, op_class, new_channel,
5982 LIM_MAX_CSA_IE_UPDATES, session_entry);
5983 }
5984 } else if (LIM_IS_STA_ROLE(session_entry)) {
5985 lim_send_extended_chan_switch_action_frame(mac_ctx,
5986 session_entry->bssId,
5987 switch_mode, op_class, new_channel,
5988 LIM_MAX_CSA_IE_UPDATES, session_entry);
5989 }
5990
5991}
5992
5993/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5995 *
5996 * @mac_ctx: Pointer to Global MAC structure
5997 * @msg_buf: pointer to the SME message buffer
5998 *
5999 * This function processes SME request messages from HDD or upper layer
6000 * application.
6001 *
6002 * Return: None
6003 */
6004static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6005 uint32_t *msg_buf)
6006{
6007 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6008 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 uint8_t session_id;
6010 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006011 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012
6013 if (msg_buf == NULL) {
6014 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6015 return;
6016 }
6017
6018 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6019 session_entry = pe_find_session_by_bssid(mac_ctx,
6020 dfs_csa_ie_req->bssid, &session_id);
6021 if (session_entry == NULL) {
6022 lim_log(mac_ctx, LOGE, FL(
6023 "Session not found for given BSSID" MAC_ADDRESS_STR),
6024 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6025 return;
6026 }
6027
6028 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6029 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6030 GET_LIM_SYSTEM_ROLE(session_entry));
6031 return;
6032 }
6033
6034 /* target channel */
6035 session_entry->gLimChannelSwitch.primaryChannel =
6036 dfs_csa_ie_req->targetChannel;
6037
6038 /* Channel switch announcement needs to be included in beacon */
6039 session_entry->dfsIncludeChanSwIe = true;
6040 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6041 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006042 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306043 session_entry->gLimChannelSwitch.sec_ch_offset =
6044 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6046 session_entry->gLimChannelSwitch.switchMode = 1;
6047
6048 /*
6049 * Validate if SAP is operating HT or VHT mode and set the Channel
6050 * Switch Wrapper element with the Wide Band Switch subelement.
6051 */
6052 if (true != session_entry->vhtCapability)
6053 goto skip_vht;
6054
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 /* Now encode the Wider Ch BW element depending on the ch width */
6056 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006057 switch (dfs_csa_ie_req->ch_params.ch_width) {
6058 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 /*
6060 * Wide channel BW sublement in channel wrapper element is not
6061 * required in case of 20 Mhz operation. Currently It is set
6062 * only set in case of 40/80 Mhz Operation.
6063 */
6064 session_entry->dfsIncludeChanWrapperIe = false;
6065 wider_bw_ch_switch->newChanWidth =
6066 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6067 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006068 case CH_WIDTH_40MHZ:
6069 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 wider_bw_ch_switch->newChanWidth =
6071 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6072 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006073 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 session_entry->dfsIncludeChanWrapperIe = true;
6075 wider_bw_ch_switch->newChanWidth =
6076 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6077 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006078 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079 session_entry->dfsIncludeChanWrapperIe = true;
6080 wider_bw_ch_switch->newChanWidth =
6081 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6082 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006083 case CH_WIDTH_80P80MHZ:
6084 session_entry->dfsIncludeChanWrapperIe = true;
6085 wider_bw_ch_switch->newChanWidth =
6086 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006087 /*
6088 * This is not applicable for 20/40/80 Mhz.
6089 * Only used when we support 80+80 Mhz operation.
6090 * In case of 80+80 Mhz, this parameter indicates
6091 * center channel frequency index of 80 Mhz channel of
6092 * frequency segment 1.
6093 */
6094 wider_bw_ch_switch->newCenterChanFreq1 =
6095 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006096 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 default:
6098 session_entry->dfsIncludeChanWrapperIe = false;
6099 /*
6100 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6101 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6102 */
6103 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6104 break;
6105 }
6106 /* Fetch the center channel based on the channel width */
6107 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006108 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109skip_vht:
6110 /* Send CSA IE request from here */
6111 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6112 eSIR_SUCCESS) {
6113 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6114 return;
6115 }
6116
6117 /*
6118 * First beacon update request is sent here, the remaining updates are
6119 * done when the FW responds back after sending the first beacon after
6120 * the template update
6121 */
6122 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306123
6124 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6125 ch_offset = BW80;
6126 else
6127 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6128
6129 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6130 session_entry->gLimChannelSwitch.switchCount,
6131 session_entry->gLimChannelSwitch.primaryChannel,
6132 session_entry->gLimChannelSwitch.ch_width,
6133 session_entry->dfsIncludeChanWrapperIe,
6134 ch_offset);
6135
Abhishek Singh518323d2015-10-19 17:42:01 +05306136 /* Send ECSA Action frame after updating the beacon */
6137 send_extended_chan_switch_action_frame(mac_ctx,
6138 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306139 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 session_entry->gLimChannelSwitch.switchCount--;
6141}
6142
6143/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306144 * lim_process_ext_change_channel()- function to send ECSA
6145 * action frame for STA/CLI .
6146 * @mac_ctx: pointer to global mac structure
6147 * @msg: params from sme for new channel.
6148 *
6149 * This function is called to send ECSA frame for STA/CLI.
6150 *
6151 * Return: void
6152 */
6153
6154static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6155 uint32_t *msg)
6156{
6157 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6158 (struct sir_sme_ext_cng_chan_req *) msg;
6159 tpPESession session_entry = NULL;
6160
6161 if (NULL == msg) {
6162 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6163 return;
6164 }
6165 session_entry =
6166 pe_find_session_by_sme_session_id(mac_ctx,
6167 ext_chng_channel->session_id);
6168 if (NULL == session_entry) {
6169 lim_log(mac_ctx, LOGE,
6170 FL("Session not found for given session %d"),
6171 ext_chng_channel->session_id);
6172 return;
6173 }
6174 if (LIM_IS_AP_ROLE(session_entry)) {
6175 lim_log(mac_ctx, LOGE,
6176 FL("not an STA/CLI session"));
6177 return;
6178 }
6179 send_extended_chan_switch_action_frame(mac_ctx,
6180 ext_chng_channel->new_channel,
6181 0, session_entry);
6182}
6183
6184/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006185 * lim_process_nss_update_request() - process sme nss update req
6186 *
6187 * @mac_ctx: Pointer to Global MAC structure
6188 * @msg_buf: pointer to the SME message buffer
6189 *
6190 * This function processes SME request messages from HDD or upper layer
6191 * application.
6192 *
6193 * Return: None
6194 */
6195static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6196 uint32_t *msg_buf)
6197{
6198 struct sir_nss_update_request *nss_update_req_ptr;
6199 tpPESession session_entry = NULL;
6200
6201 if (msg_buf == NULL) {
6202 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6203 return;
6204 }
6205
6206 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306207 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 nss_update_req_ptr->vdev_id);
6209 if (session_entry == NULL) {
6210 lim_log(mac_ctx, LOGE, FL(
6211 "Session not found for given session_id %d"),
6212 nss_update_req_ptr->vdev_id);
6213 return;
6214 }
6215
6216 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6217 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6218 GET_LIM_SYSTEM_ROLE(session_entry));
6219 return;
6220 }
6221
6222 /* populate nss field in the beacon */
6223 session_entry->gLimOperatingMode.present = 1;
6224 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6225 /* Send nss update request from here */
6226 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6227 eSIR_SUCCESS) {
6228 lim_log(mac_ctx, LOGE,
6229 FL("Unable to set op mode IE in beacon"));
6230 return;
6231 }
6232
6233 lim_send_beacon_ind(mac_ctx, session_entry);
6234}
6235
6236/**
6237 * lim_process_set_ie_req() - process sme set IE request
6238 *
6239 * @mac_ctx: Pointer to Global MAC structure
6240 * @msg_buf: pointer to the SME message buffer
6241 *
6242 * This function processes SME request messages from HDD or upper layer
6243 * application.
6244 *
6245 * Return: None
6246 */
6247static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6248{
6249 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306250 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251
6252 if (msg_buf == NULL) {
6253 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6254 return;
6255 }
6256
6257 msg = (struct send_extcap_ie *)msg_buf;
6258 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306259 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006260 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6261
6262}