blob: 46de9dc32f2d1cc67797a44a5416811c831a4504 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08002 * Copyright (c) 2012-2016 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 *);
84static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
85static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
92static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
93static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
94 uint32_t *pMsg);
95static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
98static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
99
100static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
101 uint8_t **pDstData_buff,
102 uint16_t *pDstDataLen,
103 uint8_t *pSrcData_buff,
104 uint16_t srcDataLen);
105
106static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800110static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
111 uint8_t **pDstData_buff,
112 uint16_t *pDstDataLen,
113 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
115
116static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
117
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700118extern void pe_register_callbacks_with_wma(tpAniSirGlobal pMac,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800119 tSirSmeReadyReq *ready_req);
Abhishek Singh518323d2015-10-19 17:42:01 +0530120static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
121 uint32_t *msg);
122
123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124/**
125 * lim_process_set_hw_mode() - Send set HW mode command to WMA
126 * @mac: Globacl MAC pointer
127 * @msg: Message containing the hw mode index
128 *
129 * Send the set HW mode command to WMA
130 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530131 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530133static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530135 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136 cds_msg_t cds_message;
137 struct sir_hw_mode *req_msg;
138 uint32_t len;
139 struct s_sir_set_hw_mode *buf;
140 tSirMsgQ resp_msg;
141 struct sir_set_hw_mode_resp *param;
142
143 buf = (struct s_sir_set_hw_mode *) msg;
144 if (!buf) {
145 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
146 /* To free the active command list */
147 goto fail;
148 }
149
150 len = sizeof(*req_msg);
151
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530152 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530154 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 /* Free the active command list
156 * Probably the malloc is going to fail there as well?!
157 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530158 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 }
160
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530161 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162
163 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530164 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 /* Other parameters are not needed for WMA */
166
167 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530168 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169
170 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
171 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530172 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700174 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530176 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 goto fail;
178 }
179 return status;
180fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530181 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 if (!param) {
183 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530184 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 }
186 param->status = SET_HW_MODE_STATUS_ECANCELED;
187 param->cfgd_hw_mode_index = 0;
188 param->num_vdev_mac_entries = 0;
189 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
190 resp_msg.bodyptr = param;
191 resp_msg.bodyval = 0;
192 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530193 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194}
195
196/**
197 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
198 * @mac: Global MAC pointer
199 * @msg: Message containing the dual mac config parameter
200 *
201 * Send the set dual mac config command to WMA
202 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530203 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 uint32_t *msg)
207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530208 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 cds_msg_t cds_message;
210 struct sir_dual_mac_config *req_msg;
211 uint32_t len;
212 struct sir_set_dual_mac_cfg *buf;
213 tSirMsgQ resp_msg;
214 struct sir_dual_mac_config_resp *param;
215
216 buf = (struct sir_set_dual_mac_cfg *) msg;
217 if (!buf) {
218 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
219 /* To free the active command list */
220 goto fail;
221 }
222
223 len = sizeof(*req_msg);
224
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530225 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700227 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 /* Free the active command list
229 * Probably the malloc is going to fail there as well?!
230 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530231 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 }
233
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530234 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
236 req_msg->scan_config = buf->set_dual_mac.scan_config;
237 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
238 /* Other parameters are not needed for WMA */
239
240 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530241 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242
243 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530244 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 req_msg->scan_config, req_msg->fw_mode_config);
246 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700249 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530251 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 goto fail;
253 }
254 return status;
255fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530256 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 if (!param) {
258 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530259 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 }
261 param->status = SET_HW_MODE_STATUS_ECANCELED;
262 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
263 resp_msg.bodyptr = param;
264 resp_msg.bodyval = 0;
265 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530266 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267}
268
269/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800270 * lim_process_set_antenna_mode_req() - Set antenna mode command
271 * to WMA
272 * @mac: Global MAC pointer
273 * @msg: Message containing the antenna mode parameter
274 *
275 * Send the set antenna mode command to WMA
276 *
277 * Return: QDF_STATUS_SUCCESS if message posting is successful
278 */
279static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
280 uint32_t *msg)
281{
282 QDF_STATUS status = QDF_STATUS_SUCCESS;
283 cds_msg_t cds_message;
284 struct sir_antenna_mode_param *req_msg;
285 struct sir_set_antenna_mode *buf;
286 tSirMsgQ resp_msg;
287 struct sir_antenna_mode_resp *param;
288
289 buf = (struct sir_set_antenna_mode *) msg;
290 if (!buf) {
291 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
292 /* To free the active command list */
293 goto fail;
294 }
295
296 req_msg = qdf_mem_malloc(sizeof(*req_msg));
297 if (!req_msg) {
298 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
299 return QDF_STATUS_E_NOMEM;
300 }
301
302 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
303 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
304
305 cds_message.bodyptr = req_msg;
306 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
307
308 lim_log(mac, LOG1,
309 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
310 req_msg->num_rx_chains,
311 req_msg->num_tx_chains);
312 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
313 if (!QDF_IS_STATUS_SUCCESS(status)) {
314 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700315 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800316 status);
317 qdf_mem_free(req_msg);
318 goto fail;
319 }
320 return status;
321fail:
322 param = qdf_mem_malloc(sizeof(*param));
323 if (!param) {
324 lim_log(mac, LOGE, FL("antenna mode resp failed"));
325 return QDF_STATUS_E_NOMEM;
326 }
327 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
328 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
329 resp_msg.bodyptr = param;
330 resp_msg.bodyval = 0;
331 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
332 return QDF_STATUS_SUCCESS;
333}
334
335/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
337 * @mac_ctx: Pointer to Global MAC structure
338 * @return_fresh_results: Trigger fresh scan.
339 *
340 * PE will do fresh scan, if all of the active sessions are in
341 * good state (Link Est or BSS Started). If one of the sessions
342 * is not in one of the above states, then PE does not do fresh
343 * scan. If no session exists (scanning very first time),
344 * then PE will always do fresh scan if SME asks it to do that.
345 *
346 * Return: true for fresh scan results, false if in invalid state.
347 */
348static uint8_t
349__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
350{
351 uint8_t valid_state = true;
352 int i;
353
354 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
355 mac_ctx->lim.gLimSmeState, return_fresh_results);
356
357 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
358 lim_log(mac_ctx, LOG1, FL("return FALSE"));
359 return false;
360 }
361
362 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700363
364 if (mac_ctx->lim.gpSession[i].valid == false)
365 continue;
366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 lim_log(mac_ctx, LOG1,
368 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
369 i, mac_ctx->lim.gpSession[i].bssType,
370 mac_ctx->lim.gpSession[i].limSystemRole,
371 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700372
373 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
374 continue;
375
376 if (mac_ctx->lim.gpSession[i].bssType ==
377 eSIR_INFRASTRUCTURE_MODE &&
378 mac_ctx->lim.gpSession[i].limSmeState ==
379 eLIM_SME_LINK_EST_STATE)
380 continue;
381
382 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
383 mac_ctx->lim.gpSession[i].limSmeState ==
384 eLIM_SME_NORMAL_STATE)
385 continue;
386
387 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
388 mac_ctx->lim.gpSession[i].pePersona ==
389 QDF_P2P_GO_MODE &&
390 mac_ctx->lim.gpSession[i].limSmeState ==
391 eLIM_SME_NORMAL_STATE)
392 continue;
393
394 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
395 mac_ctx->lim.gpSession[i].limSmeState ==
396 eLIM_SME_NORMAL_STATE)
397 continue;
398
399 valid_state = false;
400 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 }
402
403 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
404
405 if ((valid_state) &&
406 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
407 return true;
408 else
409 return false;
410}
411
412/**
413 * __lim_is_sme_assoc_cnf_valid()
414 *
415 ***FUNCTION:
416 * This function is called by __lim_process_sme_assoc_cnf_new() upon
417 * receiving SME_ASSOC_CNF.
418 *
419 ***LOGIC:
420 * Message validity checks are performed in this function
421 *
422 ***ASSUMPTIONS:
423 *
424 ***NOTE:
425 *
426 * @param pMeasReq Pointer to Received ASSOC_CNF message
427 * @return true When received SME_ASSOC_CNF is formatted
428 * correctly
429 * false otherwise
430 */
431
432static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
433{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530434 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 return false;
436 else
437 return true;
438} /*** end __lim_is_sme_assoc_cnf_valid() ***/
439
440/**
441 * __lim_get_sme_join_req_size_for_alloc()
442 *
443 ***FUNCTION:
444 * This function is called in various places to get IE length
445 * from tSirBssDescription structure
446 * number being scanned.
447 *
448 ***PARAMS:
449 *
450 ***LOGIC:
451 *
452 ***ASSUMPTIONS:
453 * NA
454 *
455 ***NOTE:
456 * NA
457 *
458 * @param pBssDescr
459 * @return Total IE length
460 */
461
462static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
463{
464 uint16_t len = 0;
465
466 if (!pBuf)
467 return len;
468
469 pBuf += sizeof(uint16_t);
470 len = lim_get_u16(pBuf);
471 return len + sizeof(uint16_t);
472}
473
474/**
475 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
476 * @pMac: Global MAC context
477 * @pMsg: Pointer to message posted from SME to LIM.
478 *
479 * Has role only if 11h is enabled. Not used on STA side.
480 * Defers the message if SME is in learn state and brings
481 * the LIM back to normal mode.
482 *
483 * Return: true - If defered false - Otherwise
484 */
485
486static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
487{
488 if (lim_is_system_in_scan_state(pMac)) {
489 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
490 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
491 pMsg->type);
492 return false;
493 }
494 lim_log(pMac, LOG1,
495 FL("Defer the message, in learn mode type = %d"),
496 pMsg->type);
497 return true;
498 }
499 return false;
500}
501
502/**
503 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
504 * @mac_ctx: Pointer to Global MAC structure
505 * @message: Pointer to message posted from SME to LIM.
506 *
507 * Has role only if 11h is enabled. Not used on STA side.
508 * Defers the message if radar is detected.
509 *
510 * Return: true, if defered otherwise return false.
511 */
512static bool
513__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
514{
515 /*
516 * fRadarDetCurOperChan will be set only if we
517 * detect radar in current operating channel and
518 * System Role == AP ROLE
519 *
520 * TODO: Need to take care radar detection.
521 *
522 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
523 */
524 if (0) {
525 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
526 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
527 message->type);
528 return false;
529 }
530 lim_log(mac_ctx, LOG1,
531 FL("Defer the message, in learn mode type = %d"),
532 message->type);
533 return true;
534 }
535 return false;
536}
537
538/**
539 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
540 * @pMac: Global MAC context
541 * @pMsgBuf: Message from WMA
542 *
543 * handles the notification from HDD. PE just forwards this message to HAL.
544 *
545 * Return: true-Posting to HAL failed, so PE will consume the buffer.
546 * false-Posting to HAL successful, so HAL will consume the buffer.
547 */
548
549static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
550{
551 tSirMsgQ msg;
552 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
553
554 msg.type = WMA_SYS_READY_IND;
555 msg.reserved = 0;
556 msg.bodyptr = pMsgBuf;
557 msg.bodyval = 0;
558
559 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800560 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
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;
612 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
613 &session->shortSlotTimeSupported);
614 session->isCoalesingInIBSSAllowed =
615 sme_start_bss_req->isCoalesingInIBSSAllowed;
616
617}
618
619/**
620 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
621 *@mac_ctx: Pointer to Global MAC structure
622 *@msg_buf: A pointer to the SME message buffer
623 *
624 * This function is called to process SME_START_BSS_REQ message
625 * from HDD or upper layer application.
626 *
627 * Return: None
628 */
629static void
630__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
631{
632 uint16_t size;
633 uint32_t val = 0;
634 tSirRetStatus ret_status;
635 tSirMacChanNum channel_number;
636 tLimMlmStartReq *mlm_start_req = NULL;
637 tpSirSmeStartBssReq sme_start_bss_req = NULL;
638 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
639 /* Flag Used in case of IBSS to Auto generate BSSID. */
640 uint32_t auto_gen_bssid = false;
641 uint8_t session_id;
642 tpPESession session = NULL;
643 uint8_t sme_session_id = 0;
644 uint16_t sme_transaction_id = 0;
645 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700646 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
648
649/* FEATURE_WLAN_DIAG_SUPPORT */
650#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
651 /*
652 * Since the session is not created yet, sending NULL.
653 * The response should have the correct state.
654 */
655 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
656 NULL, 0, 0);
657#endif /* FEATURE_WLAN_DIAG_SUPPORT */
658
659 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
660
661 /*
662 * Global Sme state and mlm states are not defined yet,
663 * for BT-AMP Suppoprt . TO BE DONE
664 */
665 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
666 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
667 size = sizeof(tSirSmeStartBssReq);
668
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530669 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 if (NULL == sme_start_bss_req) {
671 lim_log(mac_ctx, LOGE,
672 FL("Allocate Memory fail for LimStartBssReq"));
673 /* Send failure response to host */
674 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
675 goto end;
676 }
677
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530678 qdf_mem_set((void *)sme_start_bss_req, size, 0);
679 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 sizeof(tSirSmeStartBssReq));
681 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
682 sme_start_bss_req)) {
683 lim_log(mac_ctx, LOGW,
684 FL("Received invalid eWNI_SME_START_BSS_REQ"));
685 ret_code = eSIR_SME_INVALID_PARAMETERS;
686 goto free;
687 }
688
689 /*
690 * This is the place where PE is going to create a session.
691 * If session is not existed, then create a new session
692 */
693 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800694 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 if (session != NULL) {
696 lim_log(mac_ctx, LOGW,
697 FL("Session Already exists for given BSSID"));
698 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
699 session = NULL;
700 goto free;
701 } else {
702 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800703 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 &session_id, mac_ctx->lim.maxStation,
705 sme_start_bss_req->bssType);
706 if (session == NULL) {
707 lim_log(mac_ctx, LOGW,
708 FL("Session Can not be created "));
709 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
710 goto free;
711 }
712 }
713
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700714 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
715 /* Probe resp add ie */
716 lim_start_bss_update_add_ie_buffer(mac_ctx,
717 &session->addIeParams.probeRespData_buff,
718 &session->addIeParams.probeRespDataLen,
719 sme_start_bss_req->addIeParams.
720 probeRespData_buff,
721 sme_start_bss_req->addIeParams.
722 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700724 /* Probe Beacon add ie */
725 lim_start_bss_update_add_ie_buffer(mac_ctx,
726 &session->addIeParams.probeRespBCNData_buff,
727 &session->addIeParams.probeRespBCNDataLen,
728 sme_start_bss_req->addIeParams.
729 probeRespBCNData_buff,
730 sme_start_bss_req->addIeParams.
731 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700733 /* Assoc resp IE */
734 lim_start_bss_update_add_ie_buffer(mac_ctx,
735 &session->addIeParams.assocRespData_buff,
736 &session->addIeParams.assocRespDataLen,
737 sme_start_bss_req->addIeParams.
738 assocRespData_buff,
739 sme_start_bss_req->addIeParams.
740 assocRespDataLen);
741 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 /* Store the session related params in newly created session */
743 session->pLimStartBssReq = sme_start_bss_req;
744
745 /* Store PE session_id in session Table */
746 session->peSessionId = session_id;
747
748 /* Store SME session Id in sessionTable */
749 session->smeSessionId = sme_start_bss_req->sessionId;
750
751 session->transactionId = sme_start_bss_req->transactionId;
752
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530753 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 &(sme_start_bss_req->htConfig),
755 sizeof(session->htConfig));
756
Sandeep Puligilla98917432016-06-10 13:50:28 -0700757 qdf_mem_copy(&(session->vht_config),
758 &(sme_start_bss_req->vht_config),
759 sizeof(session->vht_config));
760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800762 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
764 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530765 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 (uint8_t *) &sme_start_bss_req->ssId,
767 (sme_start_bss_req->ssId.length + 1));
768
769 session->bssType = sme_start_bss_req->bssType;
770
771 session->nwType = sme_start_bss_req->nwType;
772
773 session->beaconParams.beaconInterval =
774 sme_start_bss_req->beaconInterval;
775
776 /* Store the channel number in session Table */
777 session->currentOperChannel =
778 sme_start_bss_req->channelId;
779
780 /* Store Persona */
781 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530782 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 FL("PE PERSONA=%d"), session->pePersona);
784
785 /* Update the phymode */
786 session->gLimPhyMode = sme_start_bss_req->nwType;
787
788 session->maxTxPower =
789 cfg_get_regulatory_max_transmit_power(mac_ctx,
790 session->currentOperChannel);
791 /* Store the dot 11 mode in to the session Table */
792 session->dot11mode = sme_start_bss_req->dot11mode;
793#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
794 session->cc_switch_mode =
795 sme_start_bss_req->cc_switch_mode;
796#endif
797 session->htCapability =
798 IS_DOT11_MODE_HT(session->dot11mode);
799 session->vhtCapability =
800 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530801 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 FL("*****session->vhtCapability = %d"),
803 session->vhtCapability);
804 session->txLdpcIniFeatureEnabled =
805 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806#ifdef WLAN_FEATURE_11W
807 session->limRmfEnabled =
808 sme_start_bss_req->pmfCapable ? 1 : 0;
809 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
810 session->limRmfEnabled);
811#endif
812
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530813 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 (void *)&sme_start_bss_req->operationalRateSet,
815 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530816 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 (void *)&sme_start_bss_req->extendedRateSet,
818 sizeof(tSirMacRateSet));
819
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700820 if (IS_5G_CH(session->currentOperChannel))
821 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
822 else
823 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 switch (sme_start_bss_req->bssType) {
826 case eSIR_INFRA_AP_MODE:
827 lim_configure_ap_start_bss_session(mac_ctx, session,
828 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530829 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800830 session->txBFIniFeatureEnabled =
831 sme_start_bss_req->txbf_ini_enabled;
832 session->txbf_csn_value =
833 sme_start_bss_req->txbf_csn_val;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700834 session->vdev_nss = vdev_type_nss->sap;
835 } else {
836 session->vdev_nss = vdev_type_nss->p2p_go;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800837 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 break;
839 case eSIR_IBSS_MODE:
840 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
841 lim_get_short_slot_from_phy_mode(mac_ctx, session,
842 session->gLimPhyMode,
843 &session->shortSlotTimeSupported);
844
845 /*
846 * initialize to "OPEN".
847 * will be updated upon key installation
848 */
849 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700850 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
852 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700853 case eSIR_NDI_MODE:
854 session->limSystemRole = eLIM_NDI_ROLE;
855 break;
856
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 /*
859 * There is one more mode called auto mode.
860 * which is used no where
861 */
862
863 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
864
865 default:
866 /* not used anywhere...used in scan function */
867 break;
868 }
869
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700870 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
871 session->pePersona, session->vdev_nss);
872 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700874 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 * parsed (Re)Assoc request structure
876 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700877 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530879 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700880 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 if (NULL == session->parsedAssocReq) {
882 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700883 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
885 goto free;
886 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530887 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700888 (session->dph.dphHashTable.size *
889 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 }
891
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700892 if (!sme_start_bss_req->channelId &&
893 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800894 lim_log(mac_ctx, LOGE,
895 FL("Received invalid eWNI_SME_START_BSS_REQ"));
896 ret_code = eSIR_SME_INVALID_PARAMETERS;
897 goto free;
898 }
899 channel_number = sme_start_bss_req->channelId;
900#ifdef QCA_HT_2040_COEX
901 if (sme_start_bss_req->obssEnabled)
902 session->htSupportedChannelWidthSet =
903 session->htCapability;
904 else
905#endif
906 session->htSupportedChannelWidthSet =
907 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
908 session->htSecondaryChannelOffset =
909 sme_start_bss_req->sec_ch_offset;
910 session->htRecommendedTxWidthSet =
911 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530912 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 FL("cbMode %u"), sme_start_bss_req->cbMode);
914 if (session->vhtCapability || session->htCapability) {
915 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800916 lim_log(mac_ctx, LOG1,
917 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
918 sme_start_bss_req->vht_channel_width,
919 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 session->ch_width = chanwidth;
921 if (session->htSupportedChannelWidthSet) {
922 session->ch_center_freq_seg0 =
923 sme_start_bss_req->center_freq_seg0;
924 session->ch_center_freq_seg1 =
925 sme_start_bss_req->center_freq_seg1;
926 } else {
927 session->ch_center_freq_seg0 = 0;
928 session->ch_center_freq_seg1 = 0;
929 }
930 }
931
932 if (session->vhtCapability &&
933 (CH_WIDTH_160MHZ > session->ch_width)) {
934 if (wlan_cfg_get_int(mac_ctx,
935 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
936 eSIR_SUCCESS)
937 lim_log(mac_ctx, LOGE, FL(
938 "cfg get vht su bformer failed"));
939
940 session->enable_su_tx_bformer = val;
941 } else {
942 session->nss = 1;
943 }
944 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
945
946 /* Delete pre-auth list if any */
947 lim_delete_pre_auth_list(mac_ctx);
948
949 /*
950 * keep the RSN/WPA IE information in PE Session Entry
951 * later will be using this to check when received (Re)Assoc req
952 */
953 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
954 &sme_start_bss_req->rsnIE, session);
955
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700956 if (LIM_IS_AP_ROLE(session) ||
957 LIM_IS_IBSS_ROLE(session) ||
958 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 session->gLimProtectionControl =
960 sme_start_bss_req->protEnabled;
961 /*
962 * each byte will have the following info
963 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
964 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
965 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530966 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 (void *)&sme_start_bss_req->ht_capab,
968 sizeof(uint16_t));
969 /* Initialize WPS PBC session link list */
970 session->pAPWPSPBCSession = NULL;
971 }
972 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530973 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974 if (NULL == mlm_start_req) {
975 lim_log(mac_ctx, LOGP,
976 FL("Allocate Memory failed for mlmStartReq"));
977 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
978 goto free;
979 }
980
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530981 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
983 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530984 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 (uint8_t *) &sme_start_bss_req->ssId,
986 sme_start_bss_req->ssId.length + 1);
987 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
988 mlm_start_req->obssProtEnabled =
989 sme_start_bss_req->obssProtEnabled;
990
991 mlm_start_req->bssType = session->bssType;
992
993 /* Fill PE session Id from the session Table */
994 mlm_start_req->sessionId = session->peSessionId;
995
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700996 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
997 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 /*
999 * Copy the BSSId from sessionTable to
1000 * mlmStartReq struct
1001 */
1002 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
1003 } else {
1004 /* ibss mode */
1005 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1006
1007 ret_status = wlan_cfg_get_int(mac_ctx,
1008 WNI_CFG_IBSS_AUTO_BSSID,
1009 &auto_gen_bssid);
1010 if (ret_status != eSIR_SUCCESS) {
1011 lim_log(mac_ctx, LOGP,
1012 FL("Get Auto Gen BSSID fail,Status=%d"),
1013 ret_status);
1014 ret_code = eSIR_LOGP_EXCEPTION;
1015 goto free;
1016 }
1017
1018 if (!auto_gen_bssid) {
1019 /*
1020 * We're not auto generating BSSID.
1021 * Instead, get it from session entry
1022 */
1023 sir_copy_mac_addr(mlm_start_req->bssId,
1024 session->bssId);
1025 /*
1026 * Start IBSS group BSSID
1027 * Auto Generating BSSID.
1028 */
1029 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1030 0x01) ? true : false);
1031 }
1032
1033 if (auto_gen_bssid) {
1034 /*
1035 * if BSSID is not any uc id.
1036 * then use locally generated BSSID.
1037 * Autogenerate the BSSID
1038 */
1039 lim_get_random_bssid(mac_ctx,
1040 mlm_start_req->bssId);
1041 mlm_start_req->bssId[0] = 0x02;
1042
1043 /*
1044 * Copy randomly generated BSSID
1045 * to the session Table
1046 */
1047 sir_copy_mac_addr(session->bssId,
1048 mlm_start_req->bssId);
1049 }
1050 }
1051 /* store the channel num in mlmstart req structure */
1052 mlm_start_req->channelNumber = session->currentOperChannel;
1053 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1054 mlm_start_req->beaconPeriod =
1055 session->beaconParams.beaconInterval;
1056
1057 if (LIM_IS_AP_ROLE(session)) {
1058 mlm_start_req->dtimPeriod = session->dtimPeriod;
1059 mlm_start_req->wps_state = session->wps_state;
1060
1061 } else {
1062 if (wlan_cfg_get_int(mac_ctx,
1063 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1064 lim_log(mac_ctx, LOGP,
1065 FL("could not retrieve DTIM Period"));
1066 mlm_start_req->dtimPeriod = (uint8_t) val;
1067 }
1068
1069 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1070 eSIR_SUCCESS)
1071 lim_log(mac_ctx, LOGP,
1072 FL("could not retrieve Beacon interval"));
1073 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1074
1075 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1076 eSIR_SUCCESS)
1077 lim_log(mac_ctx, LOGP,
1078 FL("could not retrieve CFPMaxDuration"));
1079 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1080
1081 /*
1082 * this may not be needed anymore now,
1083 * as rateSet is now included in the
1084 * session entry and MLM has session context.
1085 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301086 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 (void *)&session->rateSet,
1088 sizeof(tSirMacRateSet));
1089
1090 /* Now populate the 11n related parameters */
1091 mlm_start_req->nwType = session->nwType;
1092 mlm_start_req->htCapable = session->htCapability;
1093
1094 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1095 /* Unused */
1096 mlm_start_req->dualCTSProtection =
1097 mac_ctx->lim.gHTDualCTSProtection;
1098 mlm_start_req->txChannelWidthSet =
1099 session->htRecommendedTxWidthSet;
1100
1101 session->limRFBand = lim_get_rf_band(channel_number);
1102
1103 /* Initialize 11h Enable Flag */
1104 session->lim11hEnable = 0;
1105 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1106 (SIR_BAND_5_GHZ == session->limRFBand)) {
1107 if (wlan_cfg_get_int(mac_ctx,
1108 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1109 lim_log(mac_ctx, LOGP,
1110 FL("Fail to get WNI_CFG_11H_ENABLED "));
1111 else
1112 session->lim11hEnable = val;
1113
1114 if (session->lim11hEnable &&
1115 (eSIR_INFRA_AP_MODE ==
1116 mlm_start_req->bssType)) {
1117 cfg_get_wmi_dfs_master_param =
1118 wlan_cfg_get_int(mac_ctx,
1119 WNI_CFG_DFS_MASTER_ENABLED,
1120 &val);
1121 session->lim11hEnable = val;
1122 }
1123 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1124 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1125 lim_log(mac_ctx, LOGE,
1126 FL("Get Fail, CFG DFS ENABLE"));
1127 }
1128
1129 if (!session->lim11hEnable) {
1130 if (cfg_set_int(mac_ctx,
1131 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1132 eSIR_SUCCESS)
1133 /*
1134 * Failed to set the CFG param
1135 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1136 */
1137 lim_log(mac_ctx, LOGE,
1138 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1139 }
1140
1141 session->limPrevSmeState = session->limSmeState;
1142 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1143 MTRACE(mac_trace
1144 (mac_ctx, TRACE_CODE_SME_STATE,
1145 session->peSessionId,
1146 session->limSmeState));
1147
1148 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1149 (uint32_t *) mlm_start_req);
1150 return;
1151 } else {
1152
1153 lim_log(mac_ctx, LOGE,
1154 FL("Received unexpected START_BSS_REQ, in state %X"),
1155 mac_ctx->lim.gLimSmeState);
1156 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1157 goto end;
1158 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1159
1160free:
1161 if ((session != NULL) &&
1162 (session->pLimStartBssReq == sme_start_bss_req)) {
1163 session->pLimStartBssReq = NULL;
1164 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_free(sme_start_bss_req);
1166 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167
1168end:
1169 if (sme_start_bss_req != NULL) {
1170 sme_session_id = sme_start_bss_req->sessionId;
1171 sme_transaction_id = sme_start_bss_req->transactionId;
1172 }
1173 if (NULL != session) {
1174 pe_delete_session(mac_ctx, session);
1175 session = NULL;
1176 }
1177 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1178 session, sme_session_id, sme_transaction_id);
1179}
1180
1181/**
1182 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1183 *
1184 * @pMac: Global MAC context
1185 * @pMsg: Message pointer
1186 *
1187 * Wrapper for the function __lim_handle_sme_start_bss_request
1188 * This message will be defered until softmac come out of
1189 * scan mode or if we have detected radar on the current
1190 * operating channel.
1191 *
1192 * return true - If we consumed the buffer
1193 * false - If have defered the message.
1194 */
1195static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1196{
1197 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1198 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1199 /**
1200 * If message defered, buffer is not consumed yet.
1201 * So return false
1202 */
1203 return false;
1204 }
1205
1206 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1207 return true;
1208}
1209
1210/**
1211 * lim_get_random_bssid()
1212 *
1213 * FUNCTION:This function is called to process generate the random number for bssid
1214 * This function is called to process SME_SCAN_REQ message
1215 * from HDD or upper layer application.
1216 *
1217 * LOGIC:
1218 *
1219 * ASSUMPTIONS:
1220 *
1221 * NOTE:
1222 * 1. geneartes the unique random number for bssid in ibss
1223 *
1224 * @param pMac Pointer to Global MAC structure
1225 * @param *data Pointer to bssid buffer
1226 * @return None
1227 */
1228void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1229{
1230 uint32_t random[2];
1231 random[0] = tx_time_get();
1232 random[0] |= (random[0] << 15);
1233 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301234 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235}
1236
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301237static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 tpSirSmeScanReq pScanReq)
1239{
1240 tSirScanOffloadReq *pScanOffloadReq;
1241 uint8_t *p;
1242 uint8_t *ht_cap_ie;
1243 tSirMsgQ msg;
1244 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001245 uint16_t ht_cap_len = 0;
1246 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 uint8_t *vht_cap_ie;
1248 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 tSirRetStatus status, rc = eSIR_SUCCESS;
1250 tDot11fIEExtCap extracted_extcap = {0};
1251 bool extcap_present = true;
1252
1253 if (pScanReq->uIEFieldLen) {
1254 status = lim_strip_extcap_update_struct(pMac,
1255 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1256 &pScanReq->uIEFieldLen, &extracted_extcap);
1257
1258 if (eSIR_SUCCESS != status) {
1259 extcap_present = false;
1260 lim_log(pMac, LOG1,
1261 FL("Unable to Strip ExtCap IE from Scan Req"));
1262 }
1263
1264 if (extcap_present) {
1265 lim_log(pMac, LOG1,
1266 FL("Extcap was part of SCAN IE - Updating FW"));
1267 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1268 &extracted_extcap, true);
1269 }
1270 } else {
1271 lim_log(pMac, LOG1,
1272 FL("No IEs in the scan request from supplicant"));
1273 }
1274
1275 /**
1276 * The tSirScanOffloadReq will reserve the space for first channel,
1277 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1278 */
1279 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001280 (pScanReq->channelList.numChannels - 1) +
1281 pScanReq->uIEFieldLen;
1282 if (!pMac->per_band_chainmask_supp) {
1283 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1284 lim_log(pMac, LOG1, FL(
1285 "Adding HT Caps IE since dot11mode=%d"),
1286 pScanReq->dot11mode);
1287 /* 2 bytes for EID and Length */
1288 ht_cap_len = 2 + sizeof(tHtCaps);
1289 len += ht_cap_len;
1290 addn_ie_len += ht_cap_len;
1291 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001293 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1294 lim_log(pMac, LOG1, FL(
1295 "Adding VHT Caps IE since dot11mode=%d"),
1296 pScanReq->dot11mode);
1297 /* 2 bytes for EID and Length */
1298 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1299 sizeof(tSirVhtMcsInfo);
1300 len += vht_cap_len;
1301 addn_ie_len += vht_cap_len;
1302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301304 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 if (NULL == pScanOffloadReq) {
1306 lim_log(pMac, LOGE,
1307 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301308 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 }
1310
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301311 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312
1313 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1314 msg.bodyptr = pScanOffloadReq;
1315 msg.bodyval = 0;
1316
Anurag Chouhanc5548422016-02-24 18:33:27 +05301317 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318
1319 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1320 lim_log(pMac, LOGE,
1321 FL("Invalid value (%d) for numSsid"),
1322 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301323 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301324 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 }
1326
1327 pScanOffloadReq->numSsid = pScanReq->numSsid;
1328 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1329 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301330 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 (uint8_t *) pScanReq->ssId[i].ssId,
1332 pScanOffloadReq->ssId[i].length);
1333 }
1334
1335 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301336 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 pScanOffloadReq->bssType = pScanReq->bssType;
1338 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1339 pScanOffloadReq->scanType = pScanReq->scanType;
1340 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1341 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1342 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301343 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1344 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301345 pScanOffloadReq->scan_adaptive_dwell_mode =
1346 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347
1348 /* for normal scan, the value for p2pScanType should be 0
1349 always */
1350 if (pScanReq->p2pSearch)
1351 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1352
1353 pScanOffloadReq->sessionId = pScanReq->sessionId;
1354 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001355 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301356 pScanOffloadReq->scan_adaptive_dwell_mode =
1357 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358
1359 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1360 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1361 pScanOffloadReq->sessionId);
1362
1363 pScanOffloadReq->channelList.numChannels =
1364 pScanReq->channelList.numChannels;
1365 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1366 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1367 p[i] = pScanReq->channelList.channelNumber[i];
1368
1369 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1370 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1371 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301372 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 pScanOffloadReq->uIEFieldOffset,
1374 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1375 pScanReq->uIEFieldLen);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001376 if (!pMac->per_band_chainmask_supp) {
1377 /* Copy HT Capability info if dot11mode is HT */
1378 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1379 /* Populate EID and Length field here */
1380 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1381 pScanOffloadReq->uIEFieldOffset +
1382 pScanOffloadReq->uIEFieldLen;
1383 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
1384 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1385 *(ht_cap_ie + 1) = ht_cap_len - 2;
1386 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1387 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1388 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001390 /* Copy VHT Capability info if dot11mode is VHT Capable */
1391 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1392 /* Populate EID and Length field here */
1393 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1394 pScanOffloadReq->uIEFieldOffset +
1395 pScanOffloadReq->uIEFieldLen;
1396 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
1397 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1398 *(vht_cap_ie + 1) = vht_cap_len - 2;
1399 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1400 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1401 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 rc = wma_post_ctrl_msg(pMac, &msg);
1404 if (rc != eSIR_SUCCESS) {
1405 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301406 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301407 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 }
1409
1410 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1411
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301412 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413}
1414
1415/**
1416 * __lim_process_sme_scan_req() - Process the SME Scan Request
1417 * @mac_ctx: Global MAC Context
1418 * @msg_buf: Buffer which contains the request and pertinent parameters
1419 *
1420 * This function is called to process SME_SCAN_REQ message
1421 * from HDD or upper layer application.
1422 *
1423 * Return: None
1424 */
1425
1426static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1427 uint32_t *msg_buf)
1428{
1429 tpSirSmeScanReq scan_req;
1430 uint8_t valid_req = 0;
1431
1432#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1433 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1434 eSIR_SUCCESS, eSIR_SUCCESS);
1435#endif
1436
1437 scan_req = (tpSirSmeScanReq) msg_buf;
1438 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301439 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 -08001440 scan_req->scan_id, scan_req->channelList.numChannels,
1441 scan_req->minChannelTime, scan_req->maxChannelTime,
1442 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1443 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301444 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1446 /*
1447 * Since scan req always requires a response, we will overwrite response
1448 * required here. This is added esp to take care of the condition where
1449 * in p2p go case, we hold the scan req and insert single NOA. We send
1450 * the held scan request to FW later on getting start NOA ind from FW so
1451 * we lose state of the gLimRspReqd flag for the scan req if any other
1452 * request comes by then. e.g. While unit testing, we found when insert
1453 * single NOA is done, we see a get stats request which turns the flag
1454 * gLimRspReqd to false; now when we actually start the saved scan req
1455 * for init scan after getting NOA started, the gLimRspReqd being a
1456 * global flag is showing false instead of true value for this saved
1457 * scan req. Since all scan reqs coming to lim require a response,
1458 * there is no harm in setting the global flag gLimRspReqd to true here.
1459 */
1460 mac_ctx->lim.gLimRspReqd = true;
1461
1462 /*
1463 * copy the Self MAC address from SmeReq to the globalplace,
1464 * used for sending probe req
1465 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001466 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1467 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1469
1470 if (!valid_req || mac_ctx->lim.scan_disabled) {
1471 lim_log(mac_ctx, LOGE,
1472 FL("Scan disabled %d, Valid Scan Req %d"),
1473 mac_ctx->lim.scan_disabled, valid_req);
1474
1475 if (mac_ctx->lim.gLimRspReqd) {
1476 mac_ctx->lim.gLimRspReqd = false;
1477
1478 lim_send_sme_scan_rsp(mac_ctx,
1479 eSIR_SME_INVALID_PARAMETERS,
1480 scan_req->sessionId,
1481 scan_req->transactionId,
1482 scan_req->scan_id);
1483 }
1484 return;
1485 }
1486
1487 /*
1488 * If scan request is received in idle, joinFailed
1489 * states or in link established state (in STA role)
1490 * or in normal state (in STA-in-IBSS/AP role) with
1491 * 'return fresh scan results' request from HDD or
1492 * it is periodic background scanning request,
1493 * trigger fresh scan request to MLM
1494 */
1495 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1496
1497 mac_ctx->lim.gLim24Band11dScanDone = 0;
1498 mac_ctx->lim.gLim50Band11dScanDone = 0;
1499 mac_ctx->lim.gLimReturnAfterFirstMatch =
1500 scan_req->returnAfterFirstMatch;
1501 mac_ctx->lim.gLimReturnUniqueResults =
1502 ((scan_req->returnUniqueResults) > 0 ? true : false);
1503
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301504 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 lim_send_hal_start_scan_offload_req(mac_ctx,
1506 scan_req)) {
1507 lim_log(mac_ctx, LOGE, FL(
1508 "Couldn't send Offload scan request"));
1509 lim_send_sme_scan_rsp(mac_ctx,
1510 eSIR_SME_INVALID_PARAMETERS,
1511 scan_req->sessionId,
1512 scan_req->transactionId,
1513 scan_req->scan_id);
1514 return;
1515 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301516 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 /* In all other cases return 'cached' scan results */
1518 if (mac_ctx->lim.gLimRspReqd) {
1519 mac_ctx->lim.gLimRspReqd = false;
1520 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1521 scan_req->sessionId,
1522 scan_req->transactionId, scan_req->scan_id);
1523 }
1524 }
1525}
1526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527/**
1528 * __lim_process_clear_dfs_channel_list()
1529 *
1530 ***FUNCTION:
1531 ***Clear DFS channel list when country is changed/aquired.
1532 .*This message is sent from SME.
1533 *
1534 ***LOGIC:
1535 *
1536 ***ASSUMPTIONS:
1537 *
1538 ***NOTE:
1539 *
1540 * @param pMac Pointer to Global MAC structure
1541 * @param *pMsgBuf A pointer to the SME message buffer
1542 * @return None
1543 */
1544static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1545{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301546 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547}
1548
1549/**
1550 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1551 * @mac_ctx: Pointer to Global MAC structure
1552 * @msg_buf: A pointer to the SME message buffer
1553 *
1554 * This function is called to process SME_JOIN_REQ message
1555 * from HDD or upper layer application.
1556 *
1557 * Return: None
1558 */
1559static void
1560__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1561{
1562 tpSirSmeJoinReq sme_join_req = NULL;
1563 tLimMlmJoinReq *mlm_join_req;
1564 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1565 uint32_t val = 0;
1566 uint16_t n_size;
1567 uint8_t session_id;
1568 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301569 uint8_t sme_session_id = 0;
1570 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001571 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 uint16_t ie_len;
1573 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001574 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001575 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576
Arif Hussain995fcaf2016-07-18 11:28:22 -07001577 if (!mac_ctx || !msg_buf) {
1578 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1579 FL("JOIN REQ with invalid data"));
1580 return;
1581 }
1582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583/* FEATURE_WLAN_DIAG_SUPPORT */
1584#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1585 /*
1586 * Not sending any session, since it is not created yet.
1587 * The response whould have correct state.
1588 */
1589 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1590#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1591
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 /*
1593 * Expect Join request in idle state.
1594 * Reassociate request is expected in link established state.
1595 */
1596
1597 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1598 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1599 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1600 msg_buf);
1601
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301602 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 if (NULL == sme_join_req) {
1604 lim_log(mac_ctx, LOGP,
1605 FL("AllocateMemory failed for sme_join_req"));
1606 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301607 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301609 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1610 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 n_size);
1612
1613 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1614 /* Received invalid eWNI_SME_JOIN_REQ */
1615 /* Log the event */
1616 lim_log(mac_ctx, LOGW,
1617 FL("SessionId:%d JOIN REQ with invalid data"),
1618 sme_join_req->sessionId);
1619 ret_code = eSIR_SME_INVALID_PARAMETERS;
1620 goto end;
1621 }
1622
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001623 /*
1624 * Update the capability here itself as this is used in
1625 * lim_extract_ap_capability() below. If not updated issues
1626 * like not honoring power constraint on 1st association after
1627 * driver loading might occur.
1628 */
1629 lim_update_rrm_capability(mac_ctx, sme_join_req);
1630
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001631 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001633 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 &session_id);
1635
1636 if (session != NULL) {
1637 lim_log(mac_ctx, LOGE,
1638 FL("Session(%d) Already exists for BSSID: "
1639 MAC_ADDRESS_STR " in limSmeState = %X"),
1640 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001641 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 session->limSmeState);
1643
1644 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1645 session->smeSessionId == sme_join_req->sessionId) {
1646 /*
1647 * Received eWNI_SME_JOIN_REQ for same
1648 * BSS as currently associated.
1649 * Log the event and send success
1650 */
1651 lim_log(mac_ctx, LOGW,
1652 FL("SessionId: %d"), session_id);
1653 lim_log(mac_ctx, LOGW,
1654 FL("JOIN_REQ for current joined BSS"));
1655 /* Send Join success response to host */
1656 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1657 session = NULL;
1658 goto end;
1659 } else {
1660 lim_log(mac_ctx, LOGE,
1661 FL("JOIN_REQ not for current joined BSS"));
1662 ret_code = eSIR_SME_REFUSED;
1663 session = NULL;
1664 goto end;
1665 }
1666 } else {
1667 /*
1668 * Session Entry does not exist for given BSSId
1669 * Try to Create a new session
1670 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001671 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 &session_id, mac_ctx->lim.maxStation,
1673 eSIR_INFRASTRUCTURE_MODE);
1674 if (session == NULL) {
1675 lim_log(mac_ctx, LOGE,
1676 FL("Session Can not be created "));
1677 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1678 goto end;
1679 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301680 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 FL("SessionId:%d New session created"),
1682 session_id);
1683 }
1684 session->isAmsduSupportInAMPDU =
1685 sme_join_req->isAmsduSupportInAMPDU;
1686
1687 /*
1688 * Store Session related parameters
1689 * Store PE session Id in session Table
1690 */
1691 session->peSessionId = session_id;
1692
1693 /* store the smejoin req handle in session table */
1694 session->pLimJoinReq = sme_join_req;
1695
1696 /* Store SME session Id in sessionTable */
1697 session->smeSessionId = sme_join_req->sessionId;
1698
1699 /* Store SME transaction Id in session Table */
1700 session->transactionId = sme_join_req->transactionId;
1701
1702 /* Store beaconInterval */
1703 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001704 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301706 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 sizeof(session->htConfig));
1708
Sandeep Puligilla98917432016-06-10 13:50:28 -07001709 qdf_mem_copy(&(session->vht_config),
1710 &(sme_join_req->vht_config),
1711 sizeof(session->vht_config));
1712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 /* Copying of bssId is already done, while creating session */
1714 sir_copy_mac_addr(session->selfMacAddr,
1715 sme_join_req->selfMacAddr);
1716 session->bssType = sme_join_req->bsstype;
1717
1718 session->statypeForBss = STA_ENTRY_PEER;
1719 session->limWmeEnabled = sme_join_req->isWMEenabled;
1720 session->limQosEnabled = sme_join_req->isQosEnabled;
1721
1722 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001723 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1725
1726 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1727 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001728 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729
1730 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001731 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 session->isCiscoVendorAP = true;
1733 } else {
1734 session->isCiscoVendorAP = false;
1735 }
1736
1737 /* Copy the dot 11 mode in to the session table */
1738
1739 session->dot11mode = sme_join_req->dot11mode;
1740#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1741 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1742#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001743 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1745 session->enableHtSmps = sme_join_req->enableHtSmps;
1746 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001747 session->send_smps_action =
1748 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001749 /*
1750 * By default supported NSS 1x1 is set to true
1751 * and later on updated while determining session
1752 * supported rates which is the intersection of
1753 * self and peer rates
1754 */
1755 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301756 /*Store Persona */
1757 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001758 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301759 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001760 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001761 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001762 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301763 session->supported_nss_1x1,
1764 session->pePersona,
1765 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001766
1767 /*Store Persona */
1768 session->pePersona = sme_join_req->staPersona;
1769 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1770 FL("PE PERSONA=%d cbMode %u"),
1771 session->pePersona, sme_join_req->cbMode);
1772 /* Copy The channel Id to the session Table */
1773 session->currentOperChannel = bss_desc->channelId;
1774 if (IS_5G_CH(session->currentOperChannel))
1775 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001777 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1778 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1779 session->vdev_nss = vdev_type_nss->p2p_cli;
1780 else
1781 session->vdev_nss = vdev_type_nss->sta;
1782 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 session->vhtCapability =
1784 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301786 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 session->txBFIniFeatureEnabled =
1788 sme_join_req->txBFIniFeatureEnabled;
1789 } else {
1790 session->txBFIniFeatureEnabled = 0;
1791 }
1792 session->txMuBformee = sme_join_req->txMuBformee;
1793 session->enableVhtpAid =
1794 sme_join_req->enableVhtpAid;
1795 session->enableVhtGid =
1796 sme_join_req->enableVhtGid;
1797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 if (wlan_cfg_get_int(mac_ctx,
1799 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1800 eSIR_SUCCESS)
1801 lim_log(mac_ctx, LOGE, FL(
1802 "cfg get vht su bformer failed"));
1803
1804 session->enable_su_tx_bformer = val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
1806 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1807 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1808 session->txBFIniFeatureEnabled) !=
1809 eSIR_SUCCESS) {
1810 /*
1811 * Set failed for
1812 * CFG_VHT_SU_BEAMFORMEE_CAP
1813 */
1814 lim_log(mac_ctx, LOGP,
1815 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1816 ret_code = eSIR_LOGP_EXCEPTION;
1817 goto end;
1818 }
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001819 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 }
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301821 lim_log(mac_ctx, LOG1,
1822 FL("vhtCapability: %d txBFIniFeatureEnabled: %d txbf_csn_value: %d su_tx_bformer %d"),
1823 session->vhtCapability,
1824 session->txBFIniFeatureEnabled,
1825 session->txbf_csn_value,
1826 session->enable_su_tx_bformer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001828 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 /* cbMode is already merged value of peer and self -
1831 * done by csr in csr_get_cb_mode_from_ies */
1832 session->htSupportedChannelWidthSet =
1833 (sme_join_req->cbMode) ? 1 : 0;
1834 session->htRecommendedTxWidthSet =
1835 session->htSupportedChannelWidthSet;
1836 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1837
1838 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1839 session->ch_center_freq_seg0 =
1840 session->currentOperChannel - 2;
1841 session->ch_width = CH_WIDTH_40MHZ;
1842 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1843 sme_join_req->cbMode) {
1844 session->ch_center_freq_seg0 =
1845 session->currentOperChannel + 2;
1846 session->ch_width = CH_WIDTH_40MHZ;
1847 } else {
1848 session->ch_center_freq_seg0 = 0;
1849 session->ch_width = CH_WIDTH_20MHZ;
1850 }
1851
1852 /* Record if management frames need to be protected */
1853#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001854 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001856 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858#endif
1859
1860#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001861 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862#endif
1863
1864 /* Copy the SSID from smejoinreq to session entry */
1865 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301866 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 session->ssId.length);
1868
1869 /*
1870 * Determin 11r or ESE connection based on input from SME
1871 * which inturn is dependent on the profile the user wants
1872 * to connect to, So input is coming from supplicant
1873 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875#ifdef FEATURE_WLAN_ESE
1876 session->isESEconnection = sme_join_req->isESEconnection;
1877#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 session->isFastTransitionEnabled =
1879 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 session->isFastRoamIniFeatureEnabled =
1882 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 session->txLdpcIniFeatureEnabled =
1884 sme_join_req->txLdpcIniFeatureEnabled;
1885
1886 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1887 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 } else {
1889 /*
1890 * Throw an error and return and make
1891 * sure to delete the session.
1892 */
1893 lim_log(mac_ctx, LOGE,
1894 FL("recvd JOIN_REQ with invalid bss type %d"),
1895 session->bssType);
1896 ret_code = eSIR_SME_INVALID_PARAMETERS;
1897 goto end;
1898 }
1899
1900 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301901 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 &sme_join_req->addIEScan, sizeof(tSirAddie));
1903
1904 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301905 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1907
1908 val = sizeof(tLimMlmJoinReq) +
1909 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301910 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 if (NULL == mlm_join_req) {
1912 lim_log(mac_ctx, LOGP,
1913 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301914 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1915 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301917 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918
1919 /* PE SessionId is stored as a part of JoinReq */
1920 mlm_join_req->sessionId = session->peSessionId;
1921
1922 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1923 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1924 eSIR_SUCCESS) {
1925 lim_log(mac_ctx, LOGP,
1926 FL("couldn't retrieve JoinFailureTimer value"
1927 " setting to default value"));
1928 mlm_join_req->joinFailureTimeout =
1929 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1930 }
1931
1932 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301933 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934 (void *)&sme_join_req->operationalRateSet,
1935 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301936 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 (void *)&sme_join_req->extendedRateSet,
1938 sizeof(tSirMacRateSet));
1939 /*
1940 * this may not be needed anymore now, as rateSet is now
1941 * included in the session entry and MLM has session context.
1942 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301943 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 (void *)&session->rateSet,
1945 sizeof(tSirMacRateSet));
1946
1947 session->encryptType = sme_join_req->UCEncryptionType;
1948
1949 mlm_join_req->bssDescription.length =
1950 session->pLimJoinReq->bssDescription.length;
1951
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301952 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 (uint8_t *)
1954 &session->pLimJoinReq->bssDescription.bssId,
1955 session->pLimJoinReq->bssDescription.length + 2);
1956
1957 session->limCurrentBssCaps =
1958 session->pLimJoinReq->bssDescription.capabilityInfo;
1959
1960 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1961 session->currentOperChannel);
1962 local_power_constraint = reg_max;
1963
1964 lim_extract_ap_capability(mac_ctx,
1965 (uint8_t *)
1966 session->pLimJoinReq->bssDescription.ieFields,
1967 lim_get_ielen_from_bss_description(
1968 &session->pLimJoinReq->bssDescription),
1969 &session->limCurrentBssQosCaps,
1970 &session->limCurrentBssPropCap,
1971 &session->gLimCurrentBssUapsd,
1972 &local_power_constraint, session);
1973
1974#ifdef FEATURE_WLAN_ESE
1975 session->maxTxPower = lim_get_max_tx_power(reg_max,
1976 local_power_constraint,
1977 mac_ctx->roam.configParam.nTxPowerCap);
1978#else
1979 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301980 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301982 lim_log(mac_ctx, LOG1,
1983 FL("Reg max = %d, local power con = %d, max tx = %d"),
1984 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985
1986 if (session->gLimCurrentBssUapsd) {
1987 session->gUapsdPerAcBitmask =
1988 session->pLimJoinReq->uapsdPerAcBitmask;
1989 lim_log(mac_ctx, LOG1,
1990 FL("UAPSD flag for all AC - 0x%2x"),
1991 session->gUapsdPerAcBitmask);
1992
1993 /* resetting the dynamic uapsd mask */
1994 session->gUapsdPerAcDeliveryEnableMask = 0;
1995 session->gUapsdPerAcTriggerEnableMask = 0;
1996 }
1997
1998 session->limRFBand =
1999 lim_get_rf_band(session->currentOperChannel);
2000
2001 /* Initialize 11h Enable Flag */
2002 if (SIR_BAND_5_GHZ == session->limRFBand) {
2003 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
2004 &val) != eSIR_SUCCESS) {
2005 lim_log(mac_ctx, LOGP,
2006 FL("Fail to get WNI_CFG_11H_ENABLED "));
2007 session->lim11hEnable =
2008 WNI_CFG_11H_ENABLED_STADEF;
2009 } else {
2010 session->lim11hEnable = val;
2011 }
2012 } else {
2013 session->lim11hEnable = 0;
2014 }
2015
2016 /*
2017 * To care of the scenario when STA transitions from
2018 * IBSS to Infrastructure mode.
2019 */
2020 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2021
2022 session->limPrevSmeState = session->limSmeState;
2023 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2024 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2025 session->peSessionId,
2026 session->limSmeState));
2027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 /* Indicate whether spectrum management is enabled */
2029 session->spectrumMgtEnabled =
2030 sme_join_req->spectrumMgtIndicator;
2031
2032 /* Enable the spectrum management if this is a DFS channel */
2033 if (session->country_info_present &&
2034 lim_isconnected_on_dfs_channel(
2035 session->currentOperChannel))
2036 session->spectrumMgtEnabled = true;
2037
2038 session->isOSENConnection = sme_join_req->isOSENConnection;
2039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 /* Issue LIM_MLM_JOIN_REQ to MLM */
2041 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2042 (uint32_t *) mlm_join_req);
2043 return;
2044
2045 } else {
2046 /* Received eWNI_SME_JOIN_REQ un expected state */
2047 lim_log(mac_ctx, LOGE,
2048 FL("received unexpected SME_JOIN_REQ in state %X"),
2049 mac_ctx->lim.gLimSmeState);
2050 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2051 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2052 session = NULL;
2053 goto end;
2054 }
2055
2056end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302057 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2058 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059
2060 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302061 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 sme_join_req = NULL;
2063 if (NULL != session)
2064 session->pLimJoinReq = NULL;
2065 }
2066 if (ret_code != eSIR_SME_SUCCESS) {
2067 if (NULL != session) {
2068 pe_delete_session(mac_ctx, session);
2069 session = NULL;
2070 }
2071 }
2072 lim_log(mac_ctx, LOG1,
2073 FL("Send failure status on sessionid: %d with ret_code = %d"),
2074 sme_session_id, ret_code);
2075 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2076 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2077 sme_transaction_id);
2078}
2079
Amar Singhala297bfa2015-10-15 15:07:29 -07002080uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 uint8_t iniTxPower)
2082{
2083 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302084 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2085 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2087 maxTxPower = txPower;
2088 else if (txPower < MIN_TX_PWR_CAP)
2089 maxTxPower = MIN_TX_PWR_CAP;
2090 else
2091 maxTxPower = MAX_TX_PWR_CAP;
2092
2093 return maxTxPower;
2094}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095
2096/**
2097 * __lim_process_sme_reassoc_req() - process reassoc req
2098 *
2099 * @mac_ctx: Pointer to Global MAC structure
2100 * @msg_buf: pointer to the SME message buffer
2101 *
2102 * This function is called to process SME_REASSOC_REQ message
2103 * from HDD or upper layer application.
2104 *
2105 * Return: None
2106 */
2107
2108static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2109 uint32_t *msg_buf)
2110{
2111 uint16_t caps;
2112 uint32_t val;
2113 tpSirSmeJoinReq reassoc_req = NULL;
2114 tLimMlmReassocReq *mlm_reassoc_req;
2115 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2116 tpPESession session_entry = NULL;
2117 uint8_t session_id;
2118 uint8_t sme_session_id;
2119 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002120 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 uint32_t tele_bcn_en = 0;
2122 uint16_t size;
2123
2124 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2125
2126 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302127 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 if (NULL == reassoc_req) {
2129 lim_log(mac_ctx, LOGP,
2130 FL("call to AllocateMemory failed for reassoc_req"));
2131
2132 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2133 goto end;
2134 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302135 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2136 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137
2138 if (!lim_is_sme_join_req_valid(mac_ctx,
2139 (tpSirSmeJoinReq)reassoc_req)) {
2140 /*
2141 * Received invalid eWNI_SME_REASSOC_REQ
2142 */
2143 lim_log(mac_ctx, LOGW,
2144 FL("received SME_REASSOC_REQ with invalid data"));
2145
2146 ret_code = eSIR_SME_INVALID_PARAMETERS;
2147 goto end;
2148 }
2149
2150 session_entry = pe_find_session_by_bssid(mac_ctx,
2151 reassoc_req->bssDescription.bssId,
2152 &session_id);
2153 if (session_entry == NULL) {
2154 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2155 LOGE);
2156 lim_log(mac_ctx, LOGE,
2157 FL("Session does not exist for given bssId"));
2158 ret_code = eSIR_SME_INVALID_PARAMETERS;
2159 goto end;
2160 }
2161#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2162 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2163 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2164#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2165 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2166
2167 /* Store the reassoc handle in the session Table */
2168 session_entry->pLimReAssocReq = reassoc_req;
2169
2170 session_entry->dot11mode = reassoc_req->dot11mode;
2171 session_entry->vhtCapability =
2172 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002173
2174 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2175 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002176 session_entry->send_smps_action =
2177 reassoc_req->send_smps_action;
2178 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002179 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002180 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002181 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002182 session_entry->send_smps_action,
2183 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 /*
2185 * Reassociate request is expected
2186 * in link established state only.
2187 */
2188
2189 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2191 /*
2192 * May be from 11r FT pre-auth. So lets check it
2193 * before we bail out
2194 */
2195 lim_log(mac_ctx, LOG1, FL(
2196 "Session in reassoc state is %d"),
2197 session_entry->peSessionId);
2198
2199 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302200 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 session_entry->limReAssocbssId,
2202 6)) {
2203 lim_print_mac_addr(mac_ctx,
2204 reassoc_req->bssDescription.
2205 bssId, LOGE);
2206 lim_log(mac_ctx, LOGP,
2207 FL("Unknown bssId in reassoc state"));
2208 ret_code = eSIR_SME_INVALID_PARAMETERS;
2209 goto end;
2210 }
2211
2212 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2213 session_entry);
2214 return;
2215 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 /*
2217 * Should not have received eWNI_SME_REASSOC_REQ
2218 */
2219 lim_log(mac_ctx, LOGE,
2220 FL("received unexpected SME_REASSOC_REQ in state %X"),
2221 session_entry->limSmeState);
2222 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2223
2224 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2225 goto end;
2226 }
2227
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 session_entry->pLimReAssocReq->bssDescription.bssId,
2230 sizeof(tSirMacAddr));
2231
2232 session_entry->limReassocChannelId =
2233 session_entry->pLimReAssocReq->bssDescription.channelId;
2234
2235 session_entry->reAssocHtSupportedChannelWidthSet =
2236 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2237 session_entry->reAssocHtRecommendedTxWidthSet =
2238 session_entry->reAssocHtSupportedChannelWidthSet;
2239 session_entry->reAssocHtSecondaryChannelOffset =
2240 session_entry->pLimReAssocReq->cbMode;
2241
2242 session_entry->limReassocBssCaps =
2243 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2244 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2245 session_entry->currentOperChannel);
2246 local_pwr_constraint = reg_max;
2247
2248 lim_extract_ap_capability(mac_ctx,
2249 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2250 lim_get_ielen_from_bss_description(
2251 &session_entry->pLimReAssocReq->bssDescription),
2252 &session_entry->limReassocBssQosCaps,
2253 &session_entry->limReassocBssPropCap,
2254 &session_entry->gLimCurrentBssUapsd,
2255 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302256 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302258 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2259 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 /* Copy the SSID from session entry to local variable */
2261 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302262 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 reassoc_req->ssId.ssId,
2264 session_entry->limReassocSSID.length);
2265 if (session_entry->gLimCurrentBssUapsd) {
2266 session_entry->gUapsdPerAcBitmask =
2267 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2268 lim_log(mac_ctx, LOG1,
2269 FL("UAPSD flag for all AC - 0x%2x"),
2270 session_entry->gUapsdPerAcBitmask);
2271 }
2272
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302273 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274 if (NULL == mlm_reassoc_req) {
2275 lim_log(mac_ctx, LOGP,
2276 FL("call to AllocateMemory failed for mlmReassocReq"));
2277
2278 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2279 goto end;
2280 }
2281
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302282 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2284
2285 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2286 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2287 eSIR_SUCCESS) {
2288 /*
2289 * Could not get ReassocFailureTimeout value
2290 * from CFG. Log error.
2291 */
2292 lim_log(mac_ctx, LOGP,
2293 FL("could not retrieve ReassocFailureTimeout value"));
2294 }
2295
2296 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2297 eSIR_SUCCESS) {
2298 /*
2299 * Could not get Capabilities value
2300 * from CFG. Log error.
2301 */
2302 lim_log(mac_ctx, LOGP, FL(
2303 "could not retrieve Capabilities value"));
2304 }
2305 mlm_reassoc_req->capabilityInfo = caps;
2306
2307 /* Update PE session_id */
2308 mlm_reassoc_req->sessionId = session_id;
2309
2310 /*
2311 * If telescopic beaconing is enabled, set listen interval to
2312 * WNI_CFG_TELE_BCN_MAX_LI
2313 */
2314 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2315 &tele_bcn_en) != eSIR_SUCCESS)
2316 lim_log(mac_ctx, LOGP,
2317 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2318
2319 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2320
2321 if (tele_bcn_en) {
2322 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2323 eSIR_SUCCESS)
2324 /*
2325 * Could not get ListenInterval value
2326 * from CFG. Log error.
2327 */
2328 lim_log(mac_ctx, LOGP,
2329 FL("could not retrieve ListenInterval"));
2330 } else {
2331 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2332 eSIR_SUCCESS)
2333 /*
2334 * Could not get ListenInterval value
2335 * from CFG. Log error.
2336 */
2337 lim_log(mac_ctx, LOGP,
2338 FL("could not retrieve ListenInterval"));
2339 }
2340
2341 mlm_reassoc_req->listenInterval = (uint16_t) val;
2342
2343 /* Indicate whether spectrum management is enabled */
2344 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2345
2346 /* Enable the spectrum management if this is a DFS channel */
2347 if (session_entry->country_info_present &&
2348 lim_isconnected_on_dfs_channel(
2349 session_entry->currentOperChannel))
2350 session_entry->spectrumMgtEnabled = true;
2351
2352 session_entry->limPrevSmeState = session_entry->limSmeState;
2353 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2354
2355 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2356 session_entry->peSessionId,
2357 session_entry->limSmeState));
2358
2359 lim_post_mlm_message(mac_ctx,
2360 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2361 return;
2362end:
2363 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302364 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 if (session_entry)
2366 session_entry->pLimReAssocReq = NULL;
2367 }
2368
2369 if (session_entry) {
2370 /*
2371 * error occurred after we determined the session so extract
2372 * session and transaction info from there
2373 */
2374 sme_session_id = session_entry->smeSessionId;
2375 transaction_id = session_entry->transactionId;
2376 } else
2377 /*
2378 * error occurred before or during the time we determined
2379 * the session so extract the session and transaction info
2380 * from the message
2381 */
2382 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2383 &sme_session_id, &transaction_id);
2384
2385 /*
2386 * Send Reassoc failure response to host
2387 * (note session_entry may be NULL, but that's OK)
2388 */
2389 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2390 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2391 session_entry, sme_session_id,
2392 transaction_id);
2393}
2394
2395bool send_disassoc_frame = 1;
2396/**
2397 * __lim_process_sme_disassoc_req()
2398 *
2399 ***FUNCTION:
2400 * This function is called to process SME_DISASSOC_REQ message
2401 * from HDD or upper layer application.
2402 *
2403 ***LOGIC:
2404 *
2405 ***ASSUMPTIONS:
2406 *
2407 ***NOTE:
2408 *
2409 * @param pMac Pointer to Global MAC structure
2410 * @param *pMsgBuf A pointer to the SME message buffer
2411 * @return None
2412 */
2413
2414static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2415{
2416 uint16_t disassocTrigger, reasonCode;
2417 tLimMlmDisassocReq *pMlmDisassocReq;
2418 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2419 tSirSmeDisassocReq smeDisassocReq;
2420 tpPESession psessionEntry = NULL;
2421 uint8_t sessionId;
2422 uint8_t smesessionId;
2423 uint16_t smetransactionId;
2424
2425 if (pMsgBuf == NULL) {
2426 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2427 return;
2428 }
2429
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302430 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 smesessionId = smeDisassocReq.sessionId;
2432 smetransactionId = smeDisassocReq.transactionId;
2433 if (!lim_is_sme_disassoc_req_valid(pMac,
2434 &smeDisassocReq,
2435 psessionEntry)) {
2436 PELOGE(lim_log(pMac, LOGE,
2437 FL("received invalid SME_DISASSOC_REQ message"));)
2438 if (pMac->lim.gLimRspReqd) {
2439 pMac->lim.gLimRspReqd = false;
2440
2441 retCode = eSIR_SME_INVALID_PARAMETERS;
2442 disassocTrigger = eLIM_HOST_DISASSOC;
2443 goto sendDisassoc;
2444 }
2445
2446 return;
2447 }
2448
2449 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002450 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 &sessionId);
2452 if (psessionEntry == NULL) {
2453 lim_log(pMac, LOGE,
2454 FL("session does not exist for given bssId "
2455 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002456 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 retCode = eSIR_SME_INVALID_PARAMETERS;
2458 disassocTrigger = eLIM_HOST_DISASSOC;
2459 goto sendDisassoc;
2460 }
2461 lim_log(pMac, LOG1,
2462 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2463 MAC_ADDRESS_STR), smesessionId,
2464 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2465 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002466 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467
2468#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2469 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2470 0, smeDisassocReq.reasonCode);
2471#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2472
2473 /* Update SME session Id and SME transaction ID */
2474
2475 psessionEntry->smeSessionId = smesessionId;
2476 psessionEntry->transactionId = smetransactionId;
2477
2478 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2479 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 switch (psessionEntry->limSmeState) {
2481 case eLIM_SME_ASSOCIATED_STATE:
2482 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002483 lim_log(pMac, LOG1,
2484 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2485 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 psessionEntry->limPrevSmeState =
2487 psessionEntry->limSmeState;
2488 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2489#ifdef FEATURE_WLAN_TDLS
2490 /* Delete all TDLS peers connected before leaving BSS */
2491 lim_delete_tdls_peers(pMac, psessionEntry);
2492#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002493 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2494 psessionEntry->peSessionId,
2495 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 break;
2497
2498 case eLIM_SME_WT_DEAUTH_STATE:
2499 /* PE shall still process the DISASSOC_REQ and proceed with
2500 * link tear down even if it had already sent a DEAUTH_IND to
2501 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2502 * its been set when PE entered WT_DEAUTH_STATE.
2503 */
2504 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2505 MTRACE(mac_trace
2506 (pMac, TRACE_CODE_SME_STATE,
2507 psessionEntry->peSessionId,
2508 psessionEntry->limSmeState));
2509 lim_log(pMac, LOG1,
2510 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2511 break;
2512
2513 case eLIM_SME_WT_DISASSOC_STATE:
2514 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2515 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2516 * PE can continue processing DISASSOC_REQ and send the response instead
2517 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2518 * for disassoc frame.
2519 *
2520 * It will send a disassoc, which is ok. However, we can use the global flag
2521 * sendDisassoc to not send disassoc frame.
2522 */
2523 lim_log(pMac, LOG1,
2524 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2525 break;
2526
2527 case eLIM_SME_JOIN_FAILURE_STATE: {
2528 /* Already in Disconnected State, return success */
2529 lim_log(pMac, LOG1,
2530 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2531 if (pMac->lim.gLimRspReqd) {
2532 retCode = eSIR_SME_SUCCESS;
2533 disassocTrigger = eLIM_HOST_DISASSOC;
2534 goto sendDisassoc;
2535 }
2536 }
2537 break;
2538 default:
2539 /**
2540 * STA is not currently associated.
2541 * Log error and send response to host
2542 */
2543 lim_log(pMac, LOGE,
2544 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2545 psessionEntry->limSmeState);
2546 lim_print_sme_state(pMac, LOGE,
2547 psessionEntry->limSmeState);
2548
2549 if (pMac->lim.gLimRspReqd) {
2550 if (psessionEntry->limSmeState !=
2551 eLIM_SME_WT_ASSOC_STATE)
2552 pMac->lim.gLimRspReqd = false;
2553
2554 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2555 disassocTrigger = eLIM_HOST_DISASSOC;
2556 goto sendDisassoc;
2557 }
2558
2559 return;
2560 }
2561
2562 break;
2563
2564 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 /* Fall through */
2566 break;
2567
2568 case eLIM_STA_IN_IBSS_ROLE:
2569 default:
2570 /* eLIM_UNKNOWN_ROLE */
2571 lim_log(pMac, LOGE,
2572 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2573 GET_LIM_SYSTEM_ROLE(psessionEntry));
2574
2575 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2576 disassocTrigger = eLIM_HOST_DISASSOC;
2577 goto sendDisassoc;
2578 } /* end switch (pMac->lim.gLimSystemRole) */
2579
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302580 disassocTrigger = eLIM_HOST_DISASSOC;
2581 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582
2583 if (smeDisassocReq.doNotSendOverTheAir) {
2584 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2585 send_disassoc_frame = 0;
2586 }
2587 /* Trigger Disassociation frame to peer MAC entity */
2588 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2589 " : %d, reasonCode : %d"),
2590 disassocTrigger, reasonCode);
2591
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302592 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 if (NULL == pMlmDisassocReq) {
2594 /* Log error */
2595 lim_log(pMac, LOGP,
2596 FL("call to AllocateMemory failed for mlmDisassocReq"));
2597
2598 return;
2599 }
2600
Anurag Chouhanc5548422016-02-24 18:33:27 +05302601 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002602 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603
2604 pMlmDisassocReq->reasonCode = reasonCode;
2605 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2606
2607 /* Update PE session ID */
2608 pMlmDisassocReq->sessionId = sessionId;
2609
2610 lim_post_mlm_message(pMac,
2611 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2612 return;
2613
2614sendDisassoc:
2615 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002616 lim_send_sme_disassoc_ntf(pMac,
2617 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 retCode,
2619 disassocTrigger,
2620 1, smesessionId, smetransactionId,
2621 psessionEntry);
2622 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002623 lim_send_sme_disassoc_ntf(pMac,
2624 smeDisassocReq.peer_macaddr.bytes,
2625 retCode, disassocTrigger, 1,
2626 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627
2628} /*** end __lim_process_sme_disassoc_req() ***/
2629
2630/** -----------------------------------------------------------------
2631 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2632
2633 This function is called to process SME_DISASSOC_CNF message
2634 from HDD or upper layer application.
2635
2636 \param pMac - global mac structure
2637 \param pStaDs - station dph hash node
2638 \return none
2639 \sa
2640 ----------------------------------------------------------------- */
2641static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2642{
2643 tSirSmeDisassocCnf smeDisassocCnf;
2644 uint16_t aid;
2645 tpDphHashNode pStaDs;
2646 tpPESession psessionEntry;
2647 uint8_t sessionId;
2648
2649 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2650
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302651 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 sizeof(struct sSirSmeDisassocCnf));
2653
2654 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002655 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 &sessionId);
2657 if (psessionEntry == NULL) {
2658 lim_log(pMac, LOGE,
2659 FL("session does not exist for given bssId"));
2660 return;
2661 }
2662
2663 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2664 lim_log(pMac, LOGE,
2665 FL("received invalid SME_DISASSOC_CNF message"));
2666 return;
2667 }
2668#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2669 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2670 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2671 psessionEntry,
2672 (uint16_t) smeDisassocCnf.statusCode, 0);
2673 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2674 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2675 psessionEntry,
2676 (uint16_t) smeDisassocCnf.statusCode, 0);
2677#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2678
2679 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2680 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2682 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2683 && (psessionEntry->limSmeState !=
2684 eLIM_SME_WT_DEAUTH_STATE)) {
2685 lim_log(pMac, LOGE,
2686 FL
2687 ("received unexp SME_DISASSOC_CNF in state %X"),
2688 psessionEntry->limSmeState);
2689 lim_print_sme_state(pMac, LOGE,
2690 psessionEntry->limSmeState);
2691 return;
2692 }
2693 break;
2694
2695 case eLIM_AP_ROLE:
2696 /* Fall through */
2697 break;
2698
2699 case eLIM_STA_IN_IBSS_ROLE:
2700 default: /* eLIM_UNKNOWN_ROLE */
2701 lim_log(pMac, LOGE,
2702 FL("received unexpected SME_DISASSOC_CNF role %d"),
2703 GET_LIM_SYSTEM_ROLE(psessionEntry));
2704
2705 return;
2706 }
2707
2708 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2709 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2710 LIM_IS_AP_ROLE(psessionEntry)) {
2711 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002712 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 &psessionEntry->dph.dphHashTable);
2714 if (pStaDs == NULL) {
2715 lim_log(pMac, LOGE,
2716 FL("DISASSOC_CNF for a STA with no context, addr= "
2717 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002718 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 return;
2720 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302721
2722 if ((pStaDs->mlmStaContext.mlmState ==
2723 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2724 (pStaDs->mlmStaContext.mlmState ==
2725 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2726 lim_log(pMac, LOGE,
2727 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002728 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302729 pStaDs->mlmStaContext.mlmState);
2730 return;
2731 }
2732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 /* Delete FT session if there exists one */
2734 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2736
2737 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002738 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 }
2740
2741 return;
2742}
2743
2744/**
2745 * __lim_process_sme_deauth_req() - process sme deauth req
2746 * @mac_ctx: Pointer to Global MAC structure
2747 * @msg_buf: pointer to the SME message buffer
2748 *
2749 * This function is called to process SME_DEAUTH_REQ message
2750 * from HDD or upper layer application.
2751 *
2752 * Return: None
2753 */
2754
2755static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2756 uint32_t *msg_buf)
2757{
2758 uint16_t deauth_trigger, reason_code;
2759 tLimMlmDeauthReq *mlm_deauth_req;
2760 tSirSmeDeauthReq sme_deauth_req;
2761 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2762 tpPESession session_entry;
2763 uint8_t session_id; /* PE sessionId */
2764 uint8_t sme_session_id;
2765 uint16_t sme_transaction_id;
2766
2767 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2768
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302769 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 sme_session_id = sme_deauth_req.sessionId;
2771 sme_transaction_id = sme_deauth_req.transactionId;
2772
2773 /*
2774 * We need to get a session first but we don't even know
2775 * if the message is correct.
2776 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002777 session_entry = pe_find_session_by_bssid(mac_ctx,
2778 sme_deauth_req.bssid.bytes,
2779 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 if (session_entry == NULL) {
2781 lim_log(mac_ctx, LOGE,
2782 FL("session does not exist for given bssId"));
2783 ret_code = eSIR_SME_INVALID_PARAMETERS;
2784 deauth_trigger = eLIM_HOST_DEAUTH;
2785 goto send_deauth;
2786 }
2787
2788 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2789 session_entry)) {
2790 lim_log(mac_ctx, LOGE,
2791 FL("received invalid SME_DEAUTH_REQ message"));
2792 mac_ctx->lim.gLimRspReqd = false;
2793
2794 ret_code = eSIR_SME_INVALID_PARAMETERS;
2795 deauth_trigger = eLIM_HOST_DEAUTH;
2796 goto send_deauth;
2797 }
2798 lim_log(mac_ctx, LOG1,
2799 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2800 MAC_ADDRESS_STR), sme_session_id,
2801 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2802 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002803 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2805 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2806 session_entry, 0, sme_deauth_req.reasonCode);
2807#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2808
2809 /* Update SME session ID and Transaction ID */
2810 session_entry->smeSessionId = sme_session_id;
2811 session_entry->transactionId = sme_transaction_id;
2812
2813 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2814 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 switch (session_entry->limSmeState) {
2816 case eLIM_SME_ASSOCIATED_STATE:
2817 case eLIM_SME_LINK_EST_STATE:
2818 case eLIM_SME_WT_ASSOC_STATE:
2819 case eLIM_SME_JOIN_FAILURE_STATE:
2820 case eLIM_SME_IDLE_STATE:
2821 session_entry->limPrevSmeState =
2822 session_entry->limSmeState;
2823 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2824 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2825 session_entry->peSessionId,
2826 session_entry->limSmeState));
2827 /* Send Deauthentication request to MLM below */
2828 break;
2829 case eLIM_SME_WT_DEAUTH_STATE:
2830 case eLIM_SME_WT_DISASSOC_STATE:
2831 /*
2832 * PE Recieved a Deauth/Disassoc frame. Normally it get
2833 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2834 * Which means host is also trying to disconnect.
2835 * PE can continue processing DEAUTH_REQ and send
2836 * the response instead of failing the request.
2837 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2838 * was sent for deauth/disassoc frame.
2839 */
2840 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2841 lim_log(mac_ctx, LOG1, FL(
2842 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2843 break;
2844 default:
2845 /*
2846 * STA is not in a state to deauthenticate with
2847 * peer. Log error and send response to host.
2848 */
2849 lim_log(mac_ctx, LOGE, FL(
2850 "received unexp SME_DEAUTH_REQ in state %X"),
2851 session_entry->limSmeState);
2852 lim_print_sme_state(mac_ctx, LOGE,
2853 session_entry->limSmeState);
2854
2855 if (mac_ctx->lim.gLimRspReqd) {
2856 mac_ctx->lim.gLimRspReqd = false;
2857
2858 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2859 deauth_trigger = eLIM_HOST_DEAUTH;
2860
2861 /*
2862 * here we received deauth request from AP so sme state
2863 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2864 * delSta then mlm state should be
2865 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2866 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2867 * so the below condition captures the state where
2868 * delSta not done and firmware still in
2869 * connected state.
2870 */
2871 if (session_entry->limSmeState ==
2872 eLIM_SME_WT_DEAUTH_STATE &&
2873 session_entry->limMlmState !=
2874 eLIM_MLM_IDLE_STATE &&
2875 session_entry->limMlmState !=
2876 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2877 ret_code = eSIR_SME_DEAUTH_STATUS;
2878 goto send_deauth;
2879 }
2880 return;
2881 }
2882 break;
2883
2884 case eLIM_STA_IN_IBSS_ROLE:
2885 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2886 if (mac_ctx->lim.gLimRspReqd) {
2887 mac_ctx->lim.gLimRspReqd = false;
2888 ret_code = eSIR_SME_INVALID_PARAMETERS;
2889 deauth_trigger = eLIM_HOST_DEAUTH;
2890 goto send_deauth;
2891 }
2892 return;
2893 case eLIM_AP_ROLE:
2894 break;
2895 default:
2896 lim_log(mac_ctx, LOGE,
2897 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2898 GET_LIM_SYSTEM_ROLE(session_entry));
2899 if (mac_ctx->lim.gLimRspReqd) {
2900 mac_ctx->lim.gLimRspReqd = false;
2901 ret_code = eSIR_SME_INVALID_PARAMETERS;
2902 deauth_trigger = eLIM_HOST_DEAUTH;
2903 goto send_deauth;
2904 }
2905 return;
2906 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2907
2908 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2909 /* Deauthentication is triggered by Link Monitoring */
2910 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2911 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2912 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2913 } else {
2914 deauth_trigger = eLIM_HOST_DEAUTH;
2915 reason_code = sme_deauth_req.reasonCode;
2916 }
2917
2918 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302919 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 if (NULL == mlm_deauth_req) {
2921 lim_log(mac_ctx, LOGP,
2922 FL("call to AllocateMemory failed for mlmDeauthReq"));
2923 if (mac_ctx->lim.gLimRspReqd) {
2924 mac_ctx->lim.gLimRspReqd = false;
2925 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2926 deauth_trigger = eLIM_HOST_DEAUTH;
2927 goto send_deauth;
2928 }
2929 return;
2930 }
2931
Anurag Chouhanc5548422016-02-24 18:33:27 +05302932 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002933 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934
2935 mlm_deauth_req->reasonCode = reason_code;
2936 mlm_deauth_req->deauthTrigger = deauth_trigger;
2937
2938 /* Update PE session Id */
2939 mlm_deauth_req->sessionId = session_id;
2940
2941 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2942 (uint32_t *)mlm_deauth_req);
2943 return;
2944
2945send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002946 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2947 ret_code, deauth_trigger, 1,
2948 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949}
2950
2951/**
2952 * __lim_process_sme_set_context_req()
2953 *
2954 * @mac_ctx: Pointer to Global MAC structure
2955 * @msg_buf: pointer to the SME message buffer
2956 *
2957 * This function is called to process SME_SETCONTEXT_REQ message
2958 * from HDD or upper layer application.
2959 *
2960 * Return: None
2961 */
2962
2963static void
2964__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2965{
2966 tpSirSmeSetContextReq set_context_req;
2967 tLimMlmSetKeysReq *mlm_set_key_req;
2968 tpPESession session_entry;
2969 uint8_t session_id; /* PE sessionID */
2970 uint8_t sme_session_id;
2971 uint16_t sme_transaction_id;
2972
2973 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2974
2975 if (msg_buf == NULL) {
2976 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2977 return;
2978 }
2979
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302980 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 if (NULL == set_context_req) {
2982 lim_log(mac_ctx, LOGP, FL(
2983 "call to AllocateMemory failed for set_context_req"));
2984 return;
2985 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302986 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 sizeof(struct sSirSmeSetContextReq));
2988 sme_session_id = set_context_req->sessionId;
2989 sme_transaction_id = set_context_req->transactionId;
2990
2991 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2992 lim_log(mac_ctx, LOGW,
2993 FL("received invalid SME_SETCONTEXT_REQ message"));
2994 goto end;
2995 }
2996
2997 if (set_context_req->keyMaterial.numKeys >
2998 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2999 lim_log(mac_ctx, LOGE, FL(
3000 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3001 set_context_req->keyMaterial.numKeys);
3002 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003003 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 eSIR_SME_INVALID_PARAMETERS, NULL,
3005 sme_session_id, sme_transaction_id);
3006 goto end;
3007 }
3008
3009 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003010 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 if (session_entry == NULL) {
3012 lim_log(mac_ctx, LOGW,
3013 FL("Session does not exist for given BSSID"));
3014 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003015 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 eSIR_SME_INVALID_PARAMETERS, NULL,
3017 sme_session_id, sme_transaction_id);
3018 goto end;
3019 }
3020#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3021 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3022 session_entry, 0, 0);
3023#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3024
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003025 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3027 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003028 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3030 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303031 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 if (NULL == mlm_set_key_req) {
3033 lim_log(mac_ctx, LOGP, FL(
3034 "mem alloc failed for mlmSetKeysReq"));
3035 goto end;
3036 }
3037 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3038 mlm_set_key_req->numKeys =
3039 set_context_req->keyMaterial.numKeys;
3040 if (mlm_set_key_req->numKeys >
3041 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3042 lim_log(mac_ctx, LOGP, FL(
3043 "no.of keys exceeded max num of default keys limit"));
3044 goto end;
3045 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303046 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003047 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303049 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 (uint8_t *) &set_context_req->keyMaterial.key,
3051 sizeof(tSirKeys) *
3052 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3053 numKeys : 1));
3054
3055 mlm_set_key_req->sessionId = session_id;
3056 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 lim_log(mac_ctx, LOG1, FL(
3058 "received SETCONTEXT_REQ message sessionId=%d"),
3059 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060
3061 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3062 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3063 LIM_IS_AP_ROLE(session_entry)) {
3064 if (set_context_req->keyMaterial.key[0].keyLength) {
3065 uint8_t key_id;
3066 key_id =
3067 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303068 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 &session_entry->WEPKeyMaterial[key_id],
3070 (uint8_t *) &set_context_req->keyMaterial,
3071 sizeof(tSirKeyMaterial));
3072 } else {
3073 uint32_t i;
3074 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3075 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303076 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 &mlm_set_key_req->key[i],
3078 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3079 sizeof(tSirKeys));
3080 }
3081 }
3082 }
3083 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3084 (uint32_t *) mlm_set_key_req);
3085 } else {
3086 lim_log(mac_ctx, LOGE, FL(
3087 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3088 GET_LIM_SYSTEM_ROLE(session_entry),
3089 session_entry->limSmeState);
3090 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3091
3092 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003093 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3095 session_entry, sme_session_id,
3096 sme_transaction_id);
3097 }
3098end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303099 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 return;
3101}
3102
3103/**
3104 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3105 *
3106 * @mac_ctx: Pointer to Global MAC structure
3107 * @msg_buf: pointer to the SME message buffer
3108 *
3109 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3110 * from HDD or upper layer application.
3111 *
3112 * Return: None
3113 */
3114
3115void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3116 uint32_t *msg_buf)
3117{
3118 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3119 tpDphHashNode sta_ds = NULL;
3120 tpPESession session_entry = NULL;
3121 tSap_Event sap_event;
3122 tpWLAN_SAPEventCB sap_event_cb = NULL;
3123 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3124 uint8_t session_id = CSR_SESSION_ID_INVALID;
3125 uint8_t assoc_id = 0;
3126 uint8_t sta_cnt = 0;
3127
3128 if (msg_buf == NULL) {
3129 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3130 return;
3131 }
3132
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303133 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 sizeof(struct sSirSmeGetAssocSTAsReq));
3135 /*
3136 * Get Associated stations from PE.
3137 * Find PE session Entry
3138 */
3139 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003140 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 &session_id);
3142 if (session_entry == NULL) {
3143 lim_log(mac_ctx, LOGE,
3144 FL("session does not exist for given bssId"));
3145 goto lim_assoc_sta_end;
3146 }
3147
3148 if (!LIM_IS_AP_ROLE(session_entry)) {
3149 lim_log(mac_ctx, LOGE, FL(
3150 "Received unexpected message in state %X, in role %X"),
3151 session_entry->limSmeState,
3152 GET_LIM_SYSTEM_ROLE(session_entry));
3153 goto lim_assoc_sta_end;
3154 }
3155 /* Retrieve values obtained in the request message */
3156 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3157 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3158
3159 if (NULL == assoc_sta_tmp)
3160 goto lim_assoc_sta_end;
3161 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3162 assoc_id++) {
3163 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3164 &session_entry->dph.dphHashTable);
3165 if (NULL == sta_ds)
3166 continue;
3167 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303168 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303170 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3172 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3173
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303174 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 (uint8_t *)&sta_ds->supportedRates,
3176 sizeof(tSirSupportedRates));
3177 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3178 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3179 assoc_sta_tmp->Support40Mhz =
3180 sta_ds->htDsssCckRate40MHzSupport;
3181
3182 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3183 sta_cnt + 1);
3184 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3185 MAC_ADDR_ARRAY(sta_ds->staAddr));
3186 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3187 sta_ds->assocId);
3188 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3189 sta_ds->staIndex);
3190 assoc_sta_tmp++;
3191 sta_cnt++;
3192 }
3193 }
3194lim_assoc_sta_end:
3195 /*
3196 * Call hdd callback with sap event to send the list of
3197 * associated stations from PE
3198 */
3199 if (sap_event_cb != NULL) {
3200 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3201 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303202 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3204 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3205 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3206 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3207 }
3208}
3209
3210/**
3211 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3212 *
3213 * @mac_ctx: Pointer to Global MAC structure
3214 * @msg_buf: pointer to WPS PBC overlap query message
3215 *
3216 * This function parses get WPS PBC overlap information
3217 * message and call callback to pass WPS PBC overlap
3218 * information back to hdd.
3219 *
3220 * Return: None
3221 */
3222void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3223 uint32_t *msg_buf)
3224{
3225 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3226 tpPESession session_entry = NULL;
3227 tSap_Event sap_event;
3228 tpWLAN_SAPEventCB sap_event_cb = NULL;
3229 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3231
3232 if (msg_buf == NULL) {
3233 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3234 return;
3235 }
3236
3237 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303238 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303240 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3242 /*
3243 * Get Associated stations from PE
3244 * Find PE session Entry
3245 */
3246 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003247 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 if (session_entry == NULL) {
3249 lim_log(mac_ctx, LOGE,
3250 FL("session does not exist for given bssId"));
3251 goto lim_get_wpspbc_sessions_end;
3252 }
3253
3254 if (!LIM_IS_AP_ROLE(session_entry)) {
3255 lim_log(mac_ctx, LOGE,
3256 FL("Received unexpected message in role %X"),
3257 GET_LIM_SYSTEM_ROLE(session_entry));
3258 goto lim_get_wpspbc_sessions_end;
3259 }
3260 /*
3261 * Call hdd callback with sap event to send the
3262 * WPS PBC overlap information
3263 */
3264 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303265 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266
Anurag Chouhanc5548422016-02-24 18:33:27 +05303267 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003269 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 sap_get_wpspbc_event->UUID_E,
3271 &sap_get_wpspbc_event->wpsPBCOverlap,
3272 session_entry);
3273 } else {
3274 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003275 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 session_entry);
3277 /* don't have to inform the HDD/Host */
3278 return;
3279 }
3280
3281 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3282 sap_get_wpspbc_event->wpsPBCOverlap);
3283 lim_print_mac_addr(mac_ctx,
3284 sap_get_wpspbc_event->addr.bytes, LOG4);
3285
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303286 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287
3288lim_get_wpspbc_sessions_end:
3289 sap_event_cb =
3290 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3291 if (NULL != sap_event_cb)
3292 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3293}
3294
3295/**
3296 * __lim_counter_measures()
3297 *
3298 * FUNCTION:
3299 * This function is called to "implement" MIC counter measure
3300 * and is *temporary* only
3301 *
3302 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3303 * we don't do the proper STA disassoc sequence since the
3304 * BSS will be stoped anyway
3305 *
3306 ***ASSUMPTIONS:
3307 *
3308 ***NOTE:
3309 *
3310 * @param pMac Pointer to Global MAC structure
3311 * @return None
3312 */
3313
3314static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3315{
3316 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003317 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3319 mac, psessionEntry, false);
3320};
3321
3322void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3323{
3324 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3325 tpPESession psessionEntry;
3326 uint8_t sessionId; /* PE sessionId */
3327
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303328 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 sizeof(struct sSirSmeTkipCntrMeasReq));
3330
3331 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003332 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 if (NULL == psessionEntry) {
3334 lim_log(pMac, LOGE,
3335 FL("session does not exist for given BSSID "));
3336 return;
3337 }
3338
3339 if (tkipCntrMeasReq.bEnable)
3340 __lim_counter_measures(pMac, psessionEntry);
3341
3342 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3343}
3344
3345static void
3346__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3347{
3348 tSirSmeStopBssReq stopBssReq;
3349 tSirRetStatus status;
3350 tLimSmeStates prevState;
3351 tpPESession psessionEntry;
3352 uint8_t smesessionId;
3353 uint8_t sessionId;
3354 uint16_t smetransactionId;
3355 uint8_t i = 0;
3356 tpDphHashNode pStaDs = NULL;
3357
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303358 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 smesessionId = stopBssReq.sessionId;
3360 smetransactionId = stopBssReq.transactionId;
3361
3362 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3363 PELOGW(lim_log(pMac, LOGW,
3364 FL("received invalid SME_STOP_BSS_REQ message"));)
3365 /* Send Stop BSS response to host */
3366 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3367 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3368 smetransactionId);
3369 return;
3370 }
3371
3372 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003373 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 &sessionId);
3375 if (psessionEntry == NULL) {
3376 lim_log(pMac, LOGW,
3377 FL("session does not exist for given BSSID "));
3378 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3379 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3380 smetransactionId);
3381 return;
3382 }
3383#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3384 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3385 0, 0);
3386#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3387
3388 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3389 LIM_IS_STA_ROLE(psessionEntry)) {
3390 /**
3391 * Should not have received STOP_BSS_REQ in states
3392 * other than 'normal' state or on STA in Infrastructure
3393 * mode. Log error and return response to host.
3394 */
3395 lim_log(pMac, LOGE,
3396 FL
3397 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3398 psessionEntry->limSmeState,
3399 GET_LIM_SYSTEM_ROLE(psessionEntry));
3400 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3401 /* / Send Stop BSS response to host */
3402 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3403 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3404 smetransactionId);
3405 return;
3406 }
3407
3408 if (LIM_IS_AP_ROLE(psessionEntry))
3409 lim_wpspbc_close(pMac, psessionEntry);
3410
3411 lim_log(pMac, LOGW,
3412 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3413 stopBssReq.reasonCode);
3414
3415 prevState = psessionEntry->limSmeState;
3416
3417 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3418 MTRACE(mac_trace
3419 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3420 psessionEntry->limSmeState));
3421
3422 /* Update SME session Id and Transaction Id */
3423 psessionEntry->smeSessionId = smesessionId;
3424 psessionEntry->transactionId = smetransactionId;
3425
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003426 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3427 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3428 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3430 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3431 /* Send disassoc all stations associated thru TKIP */
3432 __lim_counter_measures(pMac, psessionEntry);
3433 else
3434 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003435 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3436 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 }
3438
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003439 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3440 /* Free the buffer allocated in START_BSS_REQ */
3441 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3442 psessionEntry->addIeParams.probeRespDataLen = 0;
3443 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003445 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3446 psessionEntry->addIeParams.assocRespDataLen = 0;
3447 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003449 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3450 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3451 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003453 /*
3454 * lim_del_bss is also called as part of coalescing,
3455 * when we send DEL BSS followed by Add Bss msg.
3456 */
3457 pMac->lim.gLimIbssCoalescingHappened = false;
3458 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3460 pStaDs =
3461 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3462 if (NULL == pStaDs)
3463 continue;
3464 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3465 if (eSIR_SUCCESS == status) {
3466 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3467 pStaDs->assocId, psessionEntry);
3468 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3469 } else {
3470 lim_log(pMac, LOGE,
3471 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303472 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 }
3474 }
3475 /* send a delBss to HAL and wait for a response */
3476 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3477
3478 if (status != eSIR_SUCCESS) {
3479 PELOGE(lim_log
3480 (pMac, LOGE, FL("delBss failed for bss %d"),
3481 psessionEntry->bssIdx);
3482 )
3483 psessionEntry->limSmeState = prevState;
3484
3485 MTRACE(mac_trace
3486 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3487 psessionEntry->limSmeState));
3488
3489 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3490 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3491 smetransactionId);
3492 }
3493}
3494
3495/**
3496 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3497 * @pMac: Global MAC context
3498 * @pMsg: Message from SME
3499 *
3500 * Wrapper for the function __lim_handle_sme_stop_bss_request
3501 * This message will be defered until softmac come out of
3502 * scan mode. Message should be handled even if we have
3503 * detected radar in the current operating channel.
3504 *
3505 * Return: true - If we consumed the buffer
3506 * false - If have defered the message.
3507 */
3508
3509static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3510{
3511 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3512 /**
3513 * If message defered, buffer is not consumed yet.
3514 * So return false
3515 */
3516 return false;
3517 }
3518 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3519 return true;
3520} /*** end __lim_process_sme_stop_bss_req() ***/
3521
3522void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3523 uint32_t body, tpPESession psessionEntry)
3524{
3525
3526 (void)body;
3527 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3528 lim_ibss_delete(pMac, psessionEntry);
3529 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3530 lim_delete_pre_auth_list(pMac);
3531 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3532 psessionEntry->smeSessionId,
3533 psessionEntry->transactionId);
3534 return;
3535}
3536
3537/**
3538 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3539 *
3540 * @mac_ctx: pointer to mac context
3541 * @msg_type: message type
3542 * @msg_buf: pointer to the SME message buffer
3543 *
3544 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3545 * in BTAMP AP.
3546 *
3547 * Return: None
3548 */
3549
3550void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3551 uint32_t *msg_buf)
3552{
3553 tSirSmeAssocCnf assoc_cnf;
3554 tpDphHashNode sta_ds = NULL;
3555 tpPESession session_entry = NULL;
3556 uint8_t session_id;
3557 tpSirAssocReq assoc_req;
3558
3559 if (msg_buf == NULL) {
3560 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3561 goto end;
3562 }
3563
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303564 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3566 lim_log(mac_ctx, LOGE,
3567 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3568 goto end;
3569 }
3570
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003571 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 &session_id);
3573 if (session_entry == NULL) {
3574 lim_log(mac_ctx, LOGE,
3575 FL("session does not exist for given bssId"));
3576 goto end;
3577 }
3578
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003579 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3581 (session_entry->limSmeState !=
3582 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3583 lim_log(mac_ctx, LOGE, FL(
3584 "Rcvd unexpected msg %X in state %X, in role %X"),
3585 msg_type, session_entry->limSmeState,
3586 GET_LIM_SYSTEM_ROLE(session_entry));
3587 goto end;
3588 }
3589 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3590 &session_entry->dph.dphHashTable);
3591 if (sta_ds == NULL) {
3592 lim_log(mac_ctx, LOGE, FL(
3593 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3594 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003595 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596
3597 /*
3598 * send a DISASSOC_IND message to WSM to make sure
3599 * the state in WSM and LIM is the same
3600 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003601 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602 eSIR_SME_STA_NOT_ASSOCIATED,
3603 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3604 session_entry->smeSessionId,
3605 session_entry->transactionId,
3606 session_entry);
3607 goto end;
3608 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303609 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003610 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303611 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 lim_log(mac_ctx, LOG1, FL(
3613 "peerMacAddr mismatched for aid %d, peer "),
3614 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003615 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 goto end;
3617 }
3618
3619 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3620 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3621 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3622 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3623 (msg_type != eWNI_SME_ASSOC_CNF))) {
3624 lim_log(mac_ctx, LOG1, FL(
3625 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3626 "StaD mlmState : %d"),
3627 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003628 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 goto end;
3630 }
3631 /*
3632 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3633 * has been received
3634 */
3635 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3636 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3637 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3638
3639 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3640 /*
3641 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3642 * when it had received Assoc Request frame. Now, PE just needs
3643 * to send association rsp frame to the requesting BTAMP-STA.
3644 */
3645 sta_ds->mlmStaContext.mlmState =
3646 eLIM_MLM_LINK_ESTABLISHED_STATE;
3647 lim_log(mac_ctx, LOG1,
3648 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3649 sta_ds->assocId);
3650 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3651 sta_ds->assocId, sta_ds->staAddr,
3652 sta_ds->mlmStaContext.subType, sta_ds,
3653 session_entry);
3654 goto end;
3655 } else {
3656 /*
3657 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3658 * to be associated since the HAL sta entry is created for
3659 * denied STA we need to remove this HAL entry.
3660 * So to do that set updateContext to 1
3661 */
3662 if (!sta_ds->mlmStaContext.updateContext)
3663 sta_ds->mlmStaContext.updateContext = 1;
3664 lim_log(mac_ctx, LOG1,
3665 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3666 assoc_cnf.statusCode, sta_ds->assocId);
3667 lim_reject_association(mac_ctx, sta_ds->staAddr,
3668 sta_ds->mlmStaContext.subType,
3669 true, sta_ds->mlmStaContext.authType,
3670 sta_ds->assocId, true,
3671 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3672 session_entry);
3673 }
3674end:
3675 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3676 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3677 assoc_req = (tpSirAssocReq)
3678 session_entry->parsedAssocReq[sta_ds->assocId];
3679 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303680 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 assoc_req->assocReqFrame = NULL;
3682 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303683 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3685 }
3686}
3687
3688static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3689{
3690 tpDphHashNode pStaDs;
3691 tSirMacAddr peerMac;
3692 tpSirAddtsReq pSirAddts;
3693 uint32_t timeout;
3694 tpPESession psessionEntry;
3695 uint8_t sessionId; /* PE sessionId */
3696 uint8_t smesessionId;
3697 uint16_t smetransactionId;
3698
3699 if (pMsgBuf == NULL) {
3700 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3701 return;
3702 }
3703
3704 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3705 &smetransactionId);
3706
3707 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3708
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003709 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3710 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 if (psessionEntry == NULL) {
3712 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3713 return;
3714 }
3715#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3716 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3717 0);
3718#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3719
3720 /* if sta
3721 * - verify assoc state
3722 * - send addts request to ap
3723 * - wait for addts response from ap
3724 * if ap, just ignore with error log
3725 */
3726 PELOG1(lim_log(pMac, LOG1,
3727 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3728 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3729 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3730 )
3731
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003732 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3734 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3735 psessionEntry, pSirAddts->req.tspec,
3736 smesessionId, smetransactionId);
3737 return;
3738 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739
3740 pStaDs =
3741 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3742 &psessionEntry->dph.dphHashTable);
3743
3744 if (pStaDs == NULL) {
3745 PELOGE(lim_log
3746 (pMac, LOGE, "Cannot find AP context for addts req");
3747 )
3748 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3749 psessionEntry, pSirAddts->req.tspec,
3750 smesessionId, smetransactionId);
3751 return;
3752 }
3753
3754 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3755 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3756 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3757 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3758 psessionEntry, pSirAddts->req.tspec,
3759 smesessionId, smetransactionId);
3760 return;
3761 }
3762
3763 pSirAddts->req.wsmTspecPresent = 0;
3764 pSirAddts->req.wmeTspecPresent = 0;
3765 pSirAddts->req.lleTspecPresent = 0;
3766
3767 if ((pStaDs->wsmEnabled) &&
3768 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3769 SIR_MAC_ACCESSPOLICY_EDCA))
3770 pSirAddts->req.wsmTspecPresent = 1;
3771 else if (pStaDs->wmeEnabled)
3772 pSirAddts->req.wmeTspecPresent = 1;
3773 else if (pStaDs->lleEnabled)
3774 pSirAddts->req.lleTspecPresent = 1;
3775 else {
3776 PELOGW(lim_log
3777 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3778 )
3779 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3780 psessionEntry, pSirAddts->req.tspec,
3781 smesessionId, smetransactionId);
3782 return;
3783 }
3784
3785 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3786 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3787 lim_log(pMac, LOGE,
3788 "AddTs received in invalid LIMsme state (%d)",
3789 psessionEntry->limSmeState);
3790 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3791 psessionEntry, pSirAddts->req.tspec,
3792 smesessionId, smetransactionId);
3793 return;
3794 }
3795
3796 if (pMac->lim.gLimAddtsSent) {
3797 lim_log(pMac, LOGE,
3798 "Addts (token %d, tsid %d, up %d) is still pending",
3799 pMac->lim.gLimAddtsReq.req.dialogToken,
3800 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3801 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3802 userPrio);
3803 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3804 psessionEntry, pSirAddts->req.tspec,
3805 smesessionId, smetransactionId);
3806 return;
3807 }
3808
3809 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3810
3811 /* save the addts request */
3812 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303813 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3815
3816 /* ship out the message now */
3817 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3818 psessionEntry);
3819 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3820 /* start a timer to wait for the response */
3821 if (pSirAddts->timeout)
3822 timeout = pSirAddts->timeout;
3823 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3824 eSIR_SUCCESS) {
3825 lim_log(pMac, LOGP,
3826 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3827 WNI_CFG_ADDTS_RSP_TIMEOUT);
3828 return;
3829 }
3830
3831 timeout = SYS_MS_TO_TICKS(timeout);
3832 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3833 != TX_SUCCESS) {
3834 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3835 return;
3836 }
3837 pMac->lim.gLimAddtsRspTimerCount++;
3838 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3839 pMac->lim.gLimAddtsRspTimerCount) !=
3840 TX_SUCCESS) {
3841 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3842 return;
3843 }
3844 MTRACE(mac_trace
3845 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3846 eLIM_ADDTS_RSP_TIMER));
3847
3848 /* add the sessionId to the timer object */
3849 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3850 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3851 TX_SUCCESS) {
3852 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3853 return;
3854 }
3855 return;
3856}
3857
3858static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3859{
3860 tSirMacAddr peerMacAddr;
3861 uint8_t ac;
3862 tSirMacTSInfo *pTsinfo;
3863 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3864 tpDphHashNode pStaDs = NULL;
3865 tpPESession psessionEntry;
3866 uint8_t sessionId;
3867 uint32_t status = eSIR_SUCCESS;
3868 uint8_t smesessionId;
3869 uint16_t smetransactionId;
3870
3871 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3872 &smetransactionId);
3873
3874 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003875 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 &sessionId);
3877 if (psessionEntry == NULL) {
3878 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3879 status = eSIR_FAILURE;
3880 goto end;
3881 }
3882#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3883 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3884 0);
3885#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3886
3887 if (eSIR_SUCCESS !=
3888 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3889 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3890 status = eSIR_FAILURE;
3891 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3892 smesessionId, smetransactionId);
3893 return;
3894 }
3895
3896 lim_log(pMac, LOG1,
3897 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3898 MAC_ADDRESS_STR),
3899 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3900
3901 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3902 pDeltsReq->req.wmeTspecPresent,
3903 &pDeltsReq->req.tsinfo,
3904 &pDeltsReq->req.tspec, psessionEntry);
3905
3906 pTsinfo =
3907 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3908 tsinfo : &pDeltsReq->req.tsinfo;
3909
3910 /* We've successfully send DELTS frame to AP. Update the
3911 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3912 * is no longer trigger enabled or delivery enabled
3913 */
3914 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3915 pTsinfo, CLEAR_UAPSD_MASK);
3916
3917 /* We're deleting the TSPEC, so this particular AC is no longer
3918 * admitted. PE needs to downgrade the EDCA
3919 * parameters(for the AC for which TS is being deleted) to the
3920 * next best AC for which ACM is not enabled, and send the
3921 * updated values to HAL.
3922 */
3923 ac = upToAc(pTsinfo->traffic.userPrio);
3924
3925 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3926 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3927 ~(1 << ac);
3928 } else if (pTsinfo->traffic.direction ==
3929 SIR_MAC_DIRECTION_DNLINK) {
3930 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3931 ~(1 << ac);
3932 } else if (pTsinfo->traffic.direction ==
3933 SIR_MAC_DIRECTION_BIDIR) {
3934 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3935 ~(1 << ac);
3936 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3937 ~(1 << ac);
3938 }
3939
3940 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3941 psessionEntry);
3942
3943 pStaDs =
3944 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3945 &psessionEntry->dph.dphHashTable);
3946 if (pStaDs != NULL) {
3947 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3948 pStaDs->bssId);
3949 status = eSIR_SUCCESS;
3950 } else {
3951 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3952 status = eSIR_FAILURE;
3953 }
3954#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003956#endif
3957
3958 /* send an sme response back */
3959end:
3960 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3961 smesessionId, smetransactionId);
3962}
3963
3964void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3965{
3966 /* fetch the sessionEntry based on the sessionId */
3967 tpPESession psessionEntry;
3968 psessionEntry = pe_find_session_by_session_id(pMac,
3969 pMac->lim.limTimers.gLimAddtsRspTimer.
3970 sessionId);
3971 if (psessionEntry == NULL) {
3972 lim_log(pMac, LOGP,
3973 FL("Session Does not exist for given sessionID"));
3974 return;
3975 }
3976
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003977 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3979 GET_LIM_SYSTEM_ROLE(psessionEntry));
3980 pMac->lim.gLimAddtsSent = false;
3981 return;
3982 }
3983
3984 if (!pMac->lim.gLimAddtsSent) {
3985 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3986 return;
3987 }
3988
3989 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3990 lim_log(pMac, LOGE,
3991 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3992 pMac->lim.gLimAddtsRspTimerCount);
3993 return;
3994 }
3995 /* this a real response timeout */
3996 pMac->lim.gLimAddtsSent = false;
3997 pMac->lim.gLimAddtsRspTimerCount++;
3998
3999 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4000 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4001 psessionEntry->smeSessionId,
4002 psessionEntry->transactionId);
4003}
4004
4005/**
4006 * __lim_process_sme_get_statistics_request()
4007 *
4008 ***FUNCTION:
4009 *
4010 *
4011 ***NOTE:
4012 *
4013 * @param pMac Pointer to Global MAC structure
4014 * @param *pMsgBuf A pointer to the SME message buffer
4015 * @return None
4016 */
4017static void
4018__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4019{
4020 tpAniGetPEStatsReq pPEStatsReq;
4021 tSirMsgQ msgQ;
4022
4023 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4024
4025 msgQ.type = WMA_GET_STATISTICS_REQ;
4026
4027 msgQ.reserved = 0;
4028 msgQ.bodyptr = pMsgBuf;
4029 msgQ.bodyval = 0;
4030 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4031
4032 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304033 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 pMsgBuf = NULL;
4035 lim_log(pMac, LOGP, "Unable to forward request");
4036 return;
4037 }
4038
4039 return;
4040}
4041
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004042#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004044 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004046 * @pMac: Pointer to Global MAC structure
4047 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004049 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 */
4051static void
4052__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4053{
4054 tSirMsgQ msgQ;
4055
4056 msgQ.type = WMA_TSM_STATS_REQ;
4057 msgQ.reserved = 0;
4058 msgQ.bodyptr = pMsgBuf;
4059 msgQ.bodyval = 0;
4060 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4061
4062 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304063 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 pMsgBuf = NULL;
4065 lim_log(pMac, LOGP, "Unable to forward request");
4066 return;
4067 }
4068}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004069#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070
4071static void
4072__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4073{
4074 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4075 tpPESession psessionEntry;
4076 uint8_t sessionId; /* PE sessionID */
4077
4078 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4079
4080 if (pMsgBuf == NULL) {
4081 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4082 return;
4083 }
4084
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304085 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 if (NULL == pUpdateAPWPSIEsReq) {
4087 lim_log(pMac, LOGP,
4088 FL
4089 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4090 return;
4091 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 sizeof(struct sSirUpdateAPWPSIEsReq));
4094
4095 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004096 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 &sessionId);
4098 if (psessionEntry == NULL) {
4099 lim_log(pMac, LOGW,
4100 FL("Session does not exist for given BSSID"));
4101 goto end;
4102 }
4103
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304104 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 sizeof(tSirAPWPSIEs));
4106
4107 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4108 lim_send_beacon_ind(pMac, psessionEntry);
4109
4110end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304111 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 return;
4113}
4114
4115void
4116lim_send_vdev_restart(tpAniSirGlobal pMac,
4117 tpPESession psessionEntry, uint8_t sessionId)
4118{
4119 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4120 tSirMsgQ msgQ;
4121 tSirRetStatus retCode = eSIR_SUCCESS;
4122
4123 if (psessionEntry == NULL) {
4124 PELOGE(lim_log
4125 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4126 __LINE__);
4127 )
4128 return;
4129 }
4130
4131 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304132 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 if (NULL == pHalHiddenSsidVdevRestart) {
4134 PELOGE(lim_log
4135 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4136 __func__, __LINE__);
4137 )
4138 return;
4139 }
4140
4141 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4142 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4143
4144 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4145 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4146 msgQ.bodyval = 0;
4147
4148 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4149 if (eSIR_SUCCESS != retCode) {
4150 PELOGE(lim_log
4151 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4152 __LINE__);
4153 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304154 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 }
4156}
4157
4158static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4159{
4160 tpSirUpdateParams pUpdateParams;
4161 tpPESession psessionEntry;
4162
4163 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4164
4165 if (pMsgBuf == NULL) {
4166 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4167 return;
4168 }
4169
4170 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4171
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004172 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 pUpdateParams->sessionId);
4174 if (psessionEntry == NULL) {
4175 lim_log(pMac, LOGW,
4176 "Session does not exist for given sessionId %d",
4177 pUpdateParams->sessionId);
4178 return;
4179 }
4180
4181 /* Update the session entry */
4182 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4183
4184 /* Send vdev restart */
4185 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4186
4187 /* Update beacon */
4188 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4189 lim_send_beacon_ind(pMac, psessionEntry);
4190
4191 return;
4192} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4193
4194static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4195{
4196 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4197 tpPESession psessionEntry;
4198 uint8_t sessionId; /* PE sessionID */
4199
4200 if (pMsgBuf == NULL) {
4201 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4202 return;
4203 }
4204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304205 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 if (NULL == pUpdateAPWPARSNIEsReq) {
4207 lim_log(pMac, LOGP,
4208 FL
4209 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4210 return;
4211 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304212 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4214
4215 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004216 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 &sessionId);
4218 if (psessionEntry == NULL) {
4219 lim_log(pMac, LOGW,
4220 FL("Session does not exist for given BSSID"));
4221 goto end;
4222 }
4223
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304224 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4226
4227 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4228 &psessionEntry->
4229 pLimStartBssReq->rsnIE,
4230 psessionEntry);
4231
4232 psessionEntry->pLimStartBssReq->privacy = 1;
4233 psessionEntry->privacy = 1;
4234
4235 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4236 lim_send_beacon_ind(pMac, psessionEntry);
4237
4238end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304239 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 return;
4241} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4242
4243/*
4244 Update the beacon Interval dynamically if beaconInterval is different in MCC
4245 */
4246static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4247{
4248 tpSirChangeBIParams pChangeBIParams;
4249 tpPESession psessionEntry;
4250 uint8_t sessionId = 0;
4251 tUpdateBeaconParams beaconParams;
4252
4253 PELOG1(lim_log(pMac, LOG1,
4254 FL("received Update Beacon Interval message"));
4255 );
4256
4257 if (pMsgBuf == NULL) {
4258 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4259 return;
4260 }
4261
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304262 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4264
4265 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004266 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 &sessionId);
4268 if (psessionEntry == NULL) {
4269 lim_log(pMac, LOGE,
4270 FL("Session does not exist for given BSSID"));
4271 return;
4272 }
4273
4274 /*Update sessionEntry Beacon Interval */
4275 if (psessionEntry->beaconParams.beaconInterval !=
4276 pChangeBIParams->beaconInterval) {
4277 psessionEntry->beaconParams.beaconInterval =
4278 pChangeBIParams->beaconInterval;
4279 }
4280
4281 /*Update sch beaconInterval */
4282 if (pMac->sch.schObject.gSchBeaconInterval !=
4283 pChangeBIParams->beaconInterval) {
4284 pMac->sch.schObject.gSchBeaconInterval =
4285 pChangeBIParams->beaconInterval;
4286
4287 PELOG1(lim_log(pMac, LOG1,
4288 FL
4289 ("LIM send update BeaconInterval Indication : %d"),
4290 pChangeBIParams->beaconInterval);
4291 );
4292
4293 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4294 /* Update beacon */
4295 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4296
4297 beaconParams.bssIdx = psessionEntry->bssIdx;
4298 /* Set change in beacon Interval */
4299 beaconParams.beaconInterval =
4300 pChangeBIParams->beaconInterval;
4301 beaconParams.paramChangeBitmap =
4302 PARAM_BCN_INTERVAL_CHANGED;
4303 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4304 }
4305 }
4306
4307 return;
4308} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4309
4310#ifdef QCA_HT_2040_COEX
4311static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4312 uint32_t *pMsgBuf)
4313{
4314 tpSirSetHT2040Mode pSetHT2040Mode;
4315 tpPESession psessionEntry;
4316 uint8_t sessionId = 0;
4317 cds_msg_t msg;
4318 tUpdateVHTOpMode *pHtOpMode = NULL;
4319 uint16_t staId = 0;
4320 tpDphHashNode pStaDs = NULL;
4321
4322 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4323 if (pMsgBuf == NULL) {
4324 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4325 return;
4326 }
4327
4328 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4329
4330 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004331 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 &sessionId);
4333 if (psessionEntry == NULL) {
4334 lim_log(pMac, LOG1,
4335 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004336 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 return;
4338 }
4339
4340 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4341 pSetHT2040Mode->cbMode);
4342 /*Update sessionEntry HT related fields */
4343 switch (pSetHT2040Mode->cbMode) {
4344 case PHY_SINGLE_CHANNEL_CENTERED:
4345 psessionEntry->htSecondaryChannelOffset =
4346 PHY_SINGLE_CHANNEL_CENTERED;
4347 psessionEntry->htRecommendedTxWidthSet = 0;
4348 if (pSetHT2040Mode->obssEnabled)
4349 psessionEntry->htSupportedChannelWidthSet
4350 = eHT_CHANNEL_WIDTH_40MHZ;
4351 else
4352 psessionEntry->htSupportedChannelWidthSet
4353 = eHT_CHANNEL_WIDTH_20MHZ;
4354 break;
4355 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4356 psessionEntry->htSecondaryChannelOffset =
4357 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4358 psessionEntry->htRecommendedTxWidthSet = 1;
4359 break;
4360 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4361 psessionEntry->htSecondaryChannelOffset =
4362 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4363 psessionEntry->htRecommendedTxWidthSet = 1;
4364 break;
4365 default:
4366 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4367 return;
4368 }
4369
4370 /* Update beacon */
4371 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4372 lim_send_beacon_ind(pMac, psessionEntry);
4373
4374 /* update OP Mode for each associated peer */
4375 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4376 pStaDs = dph_get_hash_entry(pMac, staId,
4377 &psessionEntry->dph.dphHashTable);
4378 if (NULL == pStaDs)
4379 continue;
4380
4381 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304382 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 if (NULL == pHtOpMode) {
4384 lim_log(pMac, LOGE,
4385 FL
4386 ("%s: Not able to allocate memory for setting OP mode"),
4387 __func__);
4388 return;
4389 }
4390 pHtOpMode->opMode =
4391 (psessionEntry->htSecondaryChannelOffset ==
4392 PHY_SINGLE_CHANNEL_CENTERED) ?
4393 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4394 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304395 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 sizeof(tSirMacAddr));
4397 pHtOpMode->smesessionId = sessionId;
4398
4399 msg.type = WMA_UPDATE_OP_MODE;
4400 msg.reserved = 0;
4401 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304402 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304403 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 lim_log(pMac, LOGE,
4405 FL
4406 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4407 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304408 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 return;
4410 }
4411 lim_log(pMac, LOG1,
4412 FL
4413 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4414 __func__, pHtOpMode->opMode, staId);
4415
4416 } else
4417 lim_log(pMac, LOG1,
4418 FL("%s: station %d does not support HT40\n"),
4419 __func__, staId);
4420 }
4421
4422 return;
4423}
4424#endif
4425
4426/* -------------------------------------------------------------------- */
4427/**
4428 * __lim_process_report_message
4429 *
4430 * FUNCTION: Processes the next received Radio Resource Management message
4431 *
4432 * LOGIC:
4433 *
4434 * ASSUMPTIONS:
4435 *
4436 * NOTE:
4437 *
4438 * @param None
4439 * @return None
4440 */
4441
4442void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4443{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 switch (pMsg->type) {
4445 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4446 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4447 break;
4448 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004450 break;
4451 default:
4452 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454}
4455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456/* -------------------------------------------------------------------- */
4457/**
4458 * lim_send_set_max_tx_power_req
4459 *
4460 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4461 *
4462 * LOGIC:
4463 *
4464 * ASSUMPTIONS:
4465 *
4466 * NOTE:
4467 *
4468 * @param txPower txPower to be set.
4469 * @param pSessionEntry session entry.
4470 * @return None
4471 */
4472tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004473lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474 tpPESession pSessionEntry)
4475{
4476 tpMaxTxPowerParams pMaxTxParams = NULL;
4477 tSirRetStatus retCode = eSIR_SUCCESS;
4478 tSirMsgQ msgQ;
4479
4480 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304481 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 return eSIR_FAILURE;
4483 }
4484
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304485 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 if (NULL == pMaxTxParams) {
4487 lim_log(pMac, LOGP,
4488 FL("Unable to allocate memory for pMaxTxParams "));
4489 return eSIR_MEM_ALLOC_FAILED;
4490
4491 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304493 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304494 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304495 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004496 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304497 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498
4499 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4500 msgQ.bodyptr = pMaxTxParams;
4501 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304502 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4504 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4505 if (eSIR_SUCCESS != retCode) {
4506 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304507 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 }
4509 return retCode;
4510}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511
4512/**
4513 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4514 *
4515 * @mac_ctx: Pointer to Global MAC structure
4516 * @msg_buf: pointer to the SME message buffer
4517 *
4518 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4519 * from SME. It Register this information within PE.
4520 *
4521 * Return: None
4522 */
4523static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4524 uint32_t *msg_buf)
4525{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304526 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4528 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4529 struct mgmt_frm_reg_info *next = NULL;
4530 bool match = false;
4531
4532 lim_log(mac_ctx, LOG1, FL(
4533 "registerFrame %d, frameType %d, matchLen %d"),
4534 sme_req->registerFrame, sme_req->frameType,
4535 sme_req->matchLen);
4536 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304537 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304538 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4539 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304540 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541
4542 while (lim_mgmt_regn != NULL) {
4543 if (lim_mgmt_regn->frameType != sme_req->frameType)
4544 goto skip_match;
4545 if (sme_req->matchLen) {
4546 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304547 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 sme_req->matchData,
4549 lim_mgmt_regn->matchLen))) {
4550 /* found match! */
4551 match = true;
4552 break;
4553 }
4554 } else {
4555 /* found match! */
4556 match = true;
4557 break;
4558 }
4559skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304560 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304561 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304563 (qdf_list_node_t *)lim_mgmt_regn,
4564 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304565 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 lim_mgmt_regn = next;
4567 next = NULL;
4568 }
4569 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304570 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304571 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304573 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304574 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304575 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 }
4577
4578 if (sme_req->registerFrame) {
4579 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304580 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 sme_req->matchLen);
4582 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304583 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 sizeof(struct mgmt_frm_reg_info) +
4585 sme_req->matchLen, 0);
4586 lim_mgmt_regn->frameType = sme_req->frameType;
4587 lim_mgmt_regn->matchLen = sme_req->matchLen;
4588 lim_mgmt_regn->sessionId = sme_req->sessionId;
4589 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304590 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 sme_req->matchData,
4592 sme_req->matchLen);
4593 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304594 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304596 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 gLimMgmtFrameRegistratinQueue,
4598 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304599 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 &mac_ctx->lim.lim_frame_register_lock);
4601 }
4602 }
4603 return;
4604}
4605
4606static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4607{
4608 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4609 pMac->lim.gDeferMsgTypeForNOA);
4610 pMac->lim.gDeferMsgTypeForNOA = 0;
4611 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4612 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304613 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4615 }
4616}
4617
4618/**
4619 * lim_process_regd_defd_sme_req_after_noa_start()
4620 *
4621 * mac_ctx: Pointer to Global MAC structure
4622 *
4623 * This function is called to process deferred sme req message
4624 * after noa start.
4625 *
4626 * Return: None
4627 */
4628void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4629{
4630 bool buf_consumed = true;
4631
4632 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4633 mac_ctx->lim.gDeferMsgTypeForNOA);
4634
4635 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4636 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4637 lim_log(mac_ctx, LOGW,
4638 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4639 lim_log(mac_ctx, LOGW,
4640 FL("It may happen when NOA start ind and timeout happen at the same time"));
4641 return;
4642 }
4643 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4644 case eWNI_SME_SCAN_REQ:
4645 __lim_process_sme_scan_req(mac_ctx,
4646 mac_ctx->lim.gpDefdSmeMsgForNOA);
4647 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4649 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4650 mac_ctx->lim.gpDefdSmeMsgForNOA);
4651 /*
4652 * lim_process_remain_on_chnl_req doesnt want us to free
4653 * the buffer since it is freed in lim_remain_on_chn_rsp.
4654 * this change is to avoid "double free"
4655 */
4656 if (false == buf_consumed)
4657 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4658 break;
4659 case eWNI_SME_JOIN_REQ:
4660 __lim_process_sme_join_req(mac_ctx,
4661 mac_ctx->lim.gpDefdSmeMsgForNOA);
4662 break;
4663 default:
4664 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4665 mac_ctx->lim.gDeferMsgTypeForNOA);
4666 break;
4667 }
4668 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4669}
4670
4671static void
4672__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4673{
4674 tpSirResetAPCapsChange pResetCapsChange;
4675 tpPESession psessionEntry;
4676 uint8_t sessionId = 0;
4677 if (pMsgBuf == NULL) {
4678 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4679 return;
4680 }
4681
4682 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4683 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004684 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4685 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 if (psessionEntry == NULL) {
4687 lim_log(pMac, LOGE,
4688 FL("Session does not exist for given BSSID"));
4689 return;
4690 }
4691
4692 psessionEntry->limSentCapsChangeNtf = false;
4693 return;
4694}
4695
4696/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304697 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4698 * indication callback in PE.
4699 * @mac_ptr: Mac pointer
4700 * @msg_buf: Msg pointer containing the callback
4701 *
4702 * This function is used save the Management frame
4703 * indication callback in PE.
4704 *
4705 * Return: None
4706 */
4707static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4708 uint32_t *msg_buf)
4709{
4710 struct sir_sme_mgmt_frame_cb_req *sme_req =
4711 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4712
4713 if (NULL == msg_buf) {
4714 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4715 return;
4716 }
4717 if (sme_req->callback)
4718 mac_ctx->mgmt_frame_ind_cb =
4719 (sir_mgmt_frame_ind_callback)sme_req->callback;
4720 else
4721 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4722}
4723
4724/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004725 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4726 * @mac_ctx: Pointer to Global MAC structure
4727 * @pdev_id: pdev id to set the IE.
4728 * @nss: Nss values to prepare the HT IE.
4729 *
4730 * Prepares the HT IE with self capabilities for different
4731 * Nss values and sends the set HT IE req to FW.
4732 *
4733 * Return: None
4734 */
4735static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4736 uint8_t nss)
4737{
4738 struct set_ie_param *ie_params;
4739 tSirMsgQ msg;
4740 tSirRetStatus rc = eSIR_SUCCESS;
4741 uint8_t *p_ie = NULL;
4742 tHtCaps *p_ht_cap;
4743 int i;
4744
4745 for (i = nss; i > 0; i--) {
4746 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4747 if (NULL == ie_params) {
4748 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4749 return;
4750 }
4751 ie_params->nss = i;
4752 ie_params->pdev_id = pdev_id;
4753 ie_params->ie_type = DOT11_HT_IE;
4754 /* 2 for IE len and EID */
4755 ie_params->ie_len = 2 + sizeof(tHtCaps);
4756 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4757 if (NULL == ie_params->ie_ptr) {
4758 qdf_mem_free(ie_params);
4759 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4760 return;
4761 }
4762 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4763 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4764 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4765 ie_params->ie_len);
4766
4767 if (NSS_1x1_MODE == i) {
4768 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4769 ie_params->ie_len,
4770 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004771 if (NULL == p_ie) {
4772 qdf_mem_free(ie_params->ie_ptr);
4773 qdf_mem_free(ie_params);
4774 lim_log(mac_ctx, LOGE,
4775 FL("failed to get IE ptr"));
4776 return;
4777 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004778 p_ht_cap = (tHtCaps *)&p_ie[2];
4779 p_ht_cap->supportedMCSSet[1] = 0;
4780 p_ht_cap->txSTBC = 0;
4781 }
4782
4783 msg.type = WMA_SET_PDEV_IE_REQ;
4784 msg.bodyptr = ie_params;
4785 msg.bodyval = 0;
4786
4787 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4788 if (rc != eSIR_SUCCESS) {
4789 lim_log(mac_ctx, LOGE,
4790 FL("wma_post_ctrl_msg() return failure"));
4791 qdf_mem_free(ie_params->ie_ptr);
4792 qdf_mem_free(ie_params);
4793 return;
4794 }
4795 }
4796}
4797
4798/**
4799 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4800 * @mac_ctx: Pointer to Global MAC structure
4801 * @pdev_id: pdev id to set the IE.
4802 * @nss: Nss values to prepare the VHT IE.
4803 *
4804 * Prepares the VHT IE with self capabilities for different
4805 * Nss values and sends the set VHT IE req to FW.
4806 *
4807 * Return: None
4808 */
4809static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4810 uint8_t nss)
4811{
4812 struct set_ie_param *ie_params;
4813 tSirMsgQ msg;
4814 tSirRetStatus rc = eSIR_SUCCESS;
4815 uint8_t *p_ie = NULL;
4816 tSirMacVHTCapabilityInfo *vht_cap;
4817 int i;
4818 tSirVhtMcsInfo *vht_mcs;
4819
4820 for (i = nss; i > 0; i--) {
4821 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4822 if (NULL == ie_params) {
4823 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4824 return;
4825 }
4826 ie_params->nss = i;
4827 ie_params->pdev_id = pdev_id;
4828 ie_params->ie_type = DOT11_VHT_IE;
4829 /* 2 for IE len and EID */
4830 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4831 sizeof(tSirVhtMcsInfo);
4832 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4833 if (NULL == ie_params->ie_ptr) {
4834 qdf_mem_free(ie_params);
4835 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4836 return;
4837 }
4838 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4839 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4840 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4841 ie_params->ie_len);
4842
4843 if (NSS_1x1_MODE == i) {
4844 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4845 ie_params->ie_len,
4846 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004847 if (NULL == p_ie) {
4848 qdf_mem_free(ie_params->ie_ptr);
4849 qdf_mem_free(ie_params);
4850 lim_log(mac_ctx, LOGE,
4851 FL("failed to get IE ptr"));
4852 return;
4853 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004854 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4855 vht_cap->txSTBC = 0;
4856 vht_mcs =
4857 (tSirVhtMcsInfo *)&p_ie[2 +
4858 sizeof(tSirMacVHTCapabilityInfo)];
4859 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4860 vht_mcs->rxHighest =
4861 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4862 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4863 vht_mcs->txHighest =
4864 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4865 }
4866 msg.type = WMA_SET_PDEV_IE_REQ;
4867 msg.bodyptr = ie_params;
4868 msg.bodyval = 0;
4869
4870 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4871 if (rc != eSIR_SUCCESS) {
4872 lim_log(mac_ctx, LOGE,
4873 FL("wma_post_ctrl_msg failure"));
4874 qdf_mem_free(ie_params->ie_ptr);
4875 qdf_mem_free(ie_params);
4876 return;
4877 }
4878 }
4879}
4880
4881/**
4882 * lim_process_set_pdev_IEs() - process the set pdev IE req
4883 * @mac_ctx: Pointer to Global MAC structure
4884 * @msg_buf: Pointer to the SME message buffer
4885 *
4886 * This function is called by limProcessMessageQueue(). This
4887 * function sets the PDEV IEs to the FW.
4888 *
4889 * Return: None
4890 */
4891static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4892{
4893 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4894
4895 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4896
4897 if (NULL == ht_vht_cfg) {
4898 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
4899 return;
4900 }
4901
4902 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
4903 ht_vht_cfg->nss);
4904 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4905
4906 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4907 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4908 ht_vht_cfg->nss);
4909}
4910
4911/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 * lim_process_sme_req_messages()
4913 *
4914 ***FUNCTION:
4915 * This function is called by limProcessMessageQueue(). This
4916 * function processes SME request messages from HDD or upper layer
4917 * application.
4918 *
4919 ***LOGIC:
4920 *
4921 ***ASSUMPTIONS:
4922 *
4923 ***NOTE:
4924 *
4925 * @param pMac Pointer to Global MAC structure
4926 * @param msgType Indicates the SME message type
4927 * @param *pMsgBuf A pointer to the SME message buffer
4928 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4929 * false - if pMsgBuf is not to be freed.
4930 */
4931
4932bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4933{
4934 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4935 uint32_t *pMsgBuf = pMsg->bodyptr;
4936 tpSirSmeScanReq pScanReq;
4937 PELOG1(lim_log
4938 (pMac, LOG1,
4939 FL
4940 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4941 lim_msg_str(pMsg->type), pMsg->type,
4942 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4943 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4944 )
4945
4946 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4947 /* If no insert NOA required then execute the code below */
4948
4949 switch (pMsg->type) {
4950 case eWNI_SME_SYS_READY_IND:
4951 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4952 break;
4953
4954 case eWNI_SME_START_BSS_REQ:
4955 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4956 break;
4957
4958 case eWNI_SME_SCAN_REQ:
4959 __lim_process_sme_scan_req(pMac, pMsgBuf);
4960 break;
4961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4963 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4964 break;
4965
4966 case eWNI_SME_UPDATE_NOA:
4967 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4968 break;
4969 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4970 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4971 break;
4972 case eWNI_SME_JOIN_REQ:
4973 __lim_process_sme_join_req(pMac, pMsgBuf);
4974 break;
4975
4976 case eWNI_SME_REASSOC_REQ:
4977 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4978 break;
4979
4980 case eWNI_SME_DISASSOC_REQ:
4981 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4982 break;
4983
4984 case eWNI_SME_DISASSOC_CNF:
4985 case eWNI_SME_DEAUTH_CNF:
4986 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4987 break;
4988
4989 case eWNI_SME_DEAUTH_REQ:
4990 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4991 break;
4992
4993 case eWNI_SME_SETCONTEXT_REQ:
4994 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4995 break;
4996
4997 case eWNI_SME_STOP_BSS_REQ:
4998 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4999 break;
5000
5001 case eWNI_SME_ASSOC_CNF:
5002 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5003 PELOG1(lim_log(pMac,
5004 LOG1, FL("Received ASSOC_CNF message"));)
5005 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5006 pMsgBuf);
5007 break;
5008
5009 case eWNI_SME_ADDTS_REQ:
5010 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5011 __lim_process_sme_addts_req(pMac, pMsgBuf);
5012 break;
5013
5014 case eWNI_SME_DELTS_REQ:
5015 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5016 __lim_process_sme_delts_req(pMac, pMsgBuf);
5017 break;
5018
5019 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5020 PELOG1(lim_log
5021 (pMac, LOG1,
5022 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5023 )
5024 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5025 break;
5026
5027 case eWNI_SME_GET_STATISTICS_REQ:
5028 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5029 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5030 bufConsumed = false;
5031 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005032#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 case eWNI_SME_GET_TSM_STATS_REQ:
5034 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5035 bufConsumed = false;
5036 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005037#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 case eWNI_SME_GET_ASSOC_STAS_REQ:
5039 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5040 break;
5041 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5042 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5043 break;
5044
5045 case eWNI_SME_HIDE_SSID_REQ:
5046 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5047 break;
5048 case eWNI_SME_UPDATE_APWPSIE_REQ:
5049 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5050 break;
5051 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5052 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5053 break;
5054
5055 case eWNI_SME_SET_APWPARSNIEs_REQ:
5056 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5057 break;
5058
5059 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5060 /* Update the beaconInterval */
5061 __lim_process_sme_change_bi(pMac, pMsgBuf);
5062 break;
5063
5064#ifdef QCA_HT_2040_COEX
5065 case eWNI_SME_SET_HT_2040_MODE:
5066 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5067 break;
5068#endif
5069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5071 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5072 __lim_process_report_message(pMac, pMsg);
5073 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 case eWNI_SME_FT_PRE_AUTH_REQ:
5076 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5077 break;
5078 case eWNI_SME_FT_UPDATE_KEY:
5079 lim_process_ft_update_key(pMac, pMsgBuf);
5080 break;
5081
5082 case eWNI_SME_FT_AGGR_QOS_REQ:
5083 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5084 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085
5086 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5087 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5088 break;
5089#ifdef FEATURE_WLAN_TDLS
5090 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5091 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5092 break;
5093 case eWNI_SME_TDLS_ADD_STA_REQ:
5094 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5095 break;
5096 case eWNI_SME_TDLS_DEL_STA_REQ:
5097 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5098 break;
5099 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5100 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5101 break;
5102#endif
5103 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5104 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5105 break;
5106
5107 case eWNI_SME_CHANNEL_CHANGE_REQ:
5108 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5109 break;
5110
5111 case eWNI_SME_START_BEACON_REQ:
5112 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5113 break;
5114
5115 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5116 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5117 break;
5118
5119 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5120 lim_process_update_add_ies(pMac, pMsgBuf);
5121 break;
5122
5123 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5124 lim_process_modify_add_ies(pMac, pMsgBuf);
5125 break;
5126 case eWNI_SME_SET_HW_MODE_REQ:
5127 lim_process_set_hw_mode(pMac, pMsgBuf);
5128 break;
5129 case eWNI_SME_NSS_UPDATE_REQ:
5130 lim_process_nss_update_request(pMac, pMsgBuf);
5131 break;
5132 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5133 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5134 break;
5135 case eWNI_SME_SET_IE_REQ:
5136 lim_process_set_ie_req(pMac, pMsgBuf);
5137 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305138 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5139 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5140 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305141 case eWNI_SME_EXT_CHANGE_CHANNEL:
5142 lim_process_ext_change_channel(pMac, pMsgBuf);
5143 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005144 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5145 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5146 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005147 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5148 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawatf28315c2016-06-29 18:06:02 -07005149 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005150 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005151 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005152 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005153 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305155 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 pMsg->bodyptr = NULL;
5157 break;
5158 } /* switch (msgType) */
5159
5160 return bufConsumed;
5161} /*** end lim_process_sme_req_messages() ***/
5162
5163/**
5164 * lim_process_sme_start_beacon_req()
5165 *
5166 ***FUNCTION:
5167 * This function is called by limProcessMessageQueue(). This
5168 * function processes SME request messages from HDD or upper layer
5169 * application.
5170 *
5171 ***LOGIC:
5172 *
5173 ***ASSUMPTIONS:
5174 *
5175 ***NOTE:
5176 *
5177 * @param pMac Pointer to Global MAC structure
5178 * @param msgType Indicates the SME message type
5179 * @param *pMsgBuf A pointer to the SME message buffer
5180 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5181 * false - if pMsgBuf is not to be freed.
5182 */
5183static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5184{
5185 tpSirStartBeaconIndication pBeaconStartInd;
5186 tpPESession psessionEntry;
5187 uint8_t sessionId; /* PE sessionID */
5188
5189 if (pMsg == NULL) {
5190 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5191 return;
5192 }
5193
5194 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5195 psessionEntry = pe_find_session_by_bssid(pMac,
5196 pBeaconStartInd->bssid,
5197 &sessionId);
5198 if (psessionEntry == NULL) {
5199 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5200 lim_log(pMac, LOGE,
5201 FL("Session does not exist for given bssId"));
5202 return;
5203 }
5204
5205 if (pBeaconStartInd->beaconStartStatus == true) {
5206 /*
5207 * Currently this Indication comes from SAP
5208 * to start Beacon Tx on a DFS channel
5209 * since beaconing has to be done on DFS
5210 * channel only after CAC WAIT is completed.
5211 * On a DFS Channel LIM does not start beacon
5212 * Tx right after the WMA_ADD_BSS_RSP.
5213 */
5214 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305215 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 FL("Start Beacon with ssid %s Ch %d"),
5217 psessionEntry->ssId.ssId,
5218 psessionEntry->currentOperChannel);
5219 lim_send_beacon_ind(pMac, psessionEntry);
5220 } else {
5221 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5222 return;
5223 }
5224}
5225
5226/**
5227 * lim_process_sme_channel_change_request() - process sme ch change req
5228 *
5229 * @mac_ctx: Pointer to Global MAC structure
5230 * @msg_buf: pointer to the SME message buffer
5231 *
5232 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5233 *
5234 * Return: None
5235 */
5236static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5237 uint32_t *msg_buf)
5238{
5239 tpSirChanChangeRequest ch_change_req;
5240 tpPESession session_entry;
5241 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005242 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 uint32_t val = 0;
5244
5245 if (msg_buf == NULL) {
5246 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5247 return;
5248 }
5249 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5250
5251 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5252 ch_change_req->targetChannel);
5253
5254 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5255 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5256 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5257 return;
5258 }
5259
5260 session_entry = pe_find_session_by_bssid(mac_ctx,
5261 ch_change_req->bssid, &session_id);
5262 if (session_entry == NULL) {
5263 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5264 lim_log(mac_ctx, LOGE, FL(
5265 "Session does not exist for given bssId"));
5266 return;
5267 }
5268
5269 if (session_entry->currentOperChannel ==
5270 ch_change_req->targetChannel) {
5271 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5272 return;
5273 }
5274
5275 if (LIM_IS_AP_ROLE(session_entry))
5276 session_entry->channelChangeReasonCode =
5277 LIM_SWITCH_CHANNEL_SAP_DFS;
5278 else
5279 session_entry->channelChangeReasonCode =
5280 LIM_SWITCH_CHANNEL_OPERATION;
5281
5282 lim_log(mac_ctx, LOGW, FL(
5283 "switch old chnl %d to new chnl %d, ch_bw %d"),
5284 session_entry->currentOperChannel,
5285 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005286 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287
5288 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005289 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 session_entry->ch_center_freq_seg0 =
5291 ch_change_req->center_freq_seg_0;
5292 session_entry->ch_center_freq_seg1 =
5293 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005294 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005296 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 session_entry->htRecommendedTxWidthSet =
5298 session_entry->htSupportedChannelWidthSet;
5299 session_entry->currentOperChannel =
5300 ch_change_req->targetChannel;
5301 session_entry->limRFBand =
5302 lim_get_rf_band(session_entry->currentOperChannel);
5303 /* Initialize 11h Enable Flag */
5304 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5305 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5306 eSIR_SUCCESS)
5307 lim_log(mac_ctx, LOGP,
5308 FL("Fail to get WNI_CFG_11H_ENABLED"));
5309 }
5310
5311 session_entry->lim11hEnable = val;
5312 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305313 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 &ch_change_req->operational_rateset,
5315 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305316 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 &ch_change_req->extended_rateset,
5318 sizeof(session_entry->extRateSet));
5319 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5320 session_entry->ch_center_freq_seg0,
5321 session_entry->ch_center_freq_seg1,
5322 session_entry->ch_width,
5323 max_tx_pwr, session_entry->peSessionId);
5324}
5325
5326/******************************************************************************
5327* lim_start_bss_update_add_ie_buffer()
5328*
5329***FUNCTION:
5330* This function checks the src buffer and its length and then malloc for
5331* dst buffer update the same
5332*
5333***LOGIC:
5334*
5335***ASSUMPTIONS:
5336*
5337***NOTE:
5338*
5339* @param pMac Pointer to Global MAC structure
5340* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5341* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5342* @param *pSrcData_buff A pointer of uint8_t src buffer
5343* @param srcDataLen src buffer length
5344******************************************************************************/
5345
5346static void
5347lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5348 uint8_t **pDstData_buff,
5349 uint16_t *pDstDataLen,
5350 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5351{
5352
5353 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5354 *pDstDataLen = srcDataLen;
5355
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305356 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357
5358 if (NULL == *pDstData_buff) {
5359 lim_log(pMac, LOGE,
5360 FL("AllocateMemory failed for pDstData_buff"));
5361 return;
5362 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305363 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364 } else {
5365 *pDstData_buff = NULL;
5366 *pDstDataLen = 0;
5367 }
5368}
5369
5370/******************************************************************************
5371* lim_update_add_ie_buffer()
5372*
5373***FUNCTION:
5374* This function checks the src buffer and length if src buffer length more
5375* than dst buffer length then free the dst buffer and malloc for the new src
5376* length, and update the dst buffer and length. But if dst buffer is bigger
5377* than src buffer length then it just update the dst buffer and length
5378*
5379***LOGIC:
5380*
5381***ASSUMPTIONS:
5382*
5383***NOTE:
5384*
5385* @param pMac Pointer to Global MAC structure
5386* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5387* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5388* @param *pSrcData_buff A pointer of uint8_t src buffer
5389* @param srcDataLen src buffer length
5390******************************************************************************/
5391
5392static void
5393lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5394 uint8_t **pDstData_buff,
5395 uint16_t *pDstDataLen,
5396 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5397{
5398
5399 if (NULL == pSrcData_buff) {
5400 lim_log(pMac, LOGE, FL("src buffer is null."));
5401 return;
5402 }
5403
5404 if (srcDataLen > *pDstDataLen) {
5405 *pDstDataLen = srcDataLen;
5406 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305407 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305409 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410
5411 if (NULL == *pDstData_buff) {
5412 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5413 *pDstDataLen = 0;
5414 return;
5415 }
5416 }
5417
5418 /* copy the content of buffer into dst buffer
5419 */
5420 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305421 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422
5423}
5424
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005425/**
5426 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5427 * @pMac : Pointer to Global MAC structure
5428 * @pDstData_buff : A pointer to pointer of dst buffer
5429 * @pDstDataLen : A pointer to pointer of dst buffer length
5430 * @pModifyIE : A pointer to tSirModifyIE
5431 *
5432 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5433 *
5434 * Return:
5435 * True or false depending upon whether IE is updated or not
5436 */
5437static bool
5438lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5439 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5440{
5441 int32_t oui_length;
5442 uint8_t *ibss_ie = NULL;
5443
5444 ibss_ie = pModifyIE->pIEBuffer;
5445 oui_length = pModifyIE->oui_length;
5446
5447 if ((0 == oui_length) || (NULL == ibss_ie)) {
5448 PELOGE(lim_log(pMac, LOGE,
5449 FL("Invalid set IBSS vendor IE command length %d "),
5450 oui_length);)
5451 return false;
5452 }
5453
5454 lim_update_add_ie_buffer(pMac,
5455 pDstData_buff,
5456 pDstDataLen,
5457 pModifyIE->pIEBuffer,
5458 pModifyIE->ieBufferlength);
5459
5460 return true;
5461}
5462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463/*
5464* lim_process_modify_add_ies() - process modify additional IE req.
5465*
5466* @mac_ctx: Pointer to Global MAC structure
5467* @msg_buf: pointer to the SME message buffer
5468*
5469* This function update the PE buffers for additional IEs.
5470*
5471* Return: None
5472*/
5473static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5474 uint32_t *msg_buf)
5475{
5476 tpSirModifyIEsInd modify_add_ies;
5477 tpPESession session_entry;
5478 uint8_t session_id;
5479 bool ret = false;
5480 tSirAddIeParams *add_ie_params;
5481
5482 if (msg_buf == NULL) {
5483 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5484 return;
5485 }
5486
5487 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5488 /* Incoming message has smeSession, use BSSID to find PE session */
5489 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005490 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491
5492 if (NULL == session_entry) {
5493 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5494 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005495 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 goto end;
5497 }
5498 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5499 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5500 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5501 lim_log(mac_ctx, LOGE,
5502 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5503 modify_add_ies->modifyIE.pIEBuffer,
5504 modify_add_ies->modifyIE.ieBufferlength,
5505 modify_add_ies->modifyIE.ieID,
5506 modify_add_ies->modifyIE.ieIDLen,
5507 modify_add_ies->updateType);
5508 goto end;
5509 }
5510 add_ie_params = &session_entry->addIeParams;
5511 switch (modify_add_ies->updateType) {
5512 case eUPDATE_IE_PROBE_RESP:
5513 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005514 if (LIM_IS_IBSS_ROLE(session_entry)) {
5515 lim_update_ibss_prop_add_ies(mac_ctx,
5516 &add_ie_params->probeRespData_buff,
5517 &add_ie_params->probeRespDataLen,
5518 &modify_add_ies->modifyIE);
5519 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 break;
5521 case eUPDATE_IE_ASSOC_RESP:
5522 /* assoc resp IE */
5523 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305524 QDF_TRACE(QDF_MODULE_ID_PE,
5525 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 "assoc resp add ie not present %d"),
5527 add_ie_params->assocRespDataLen);
5528 }
5529 /* search through the buffer and modify the IE */
5530 break;
5531 case eUPDATE_IE_PROBE_BCN:
5532 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005533 if (LIM_IS_IBSS_ROLE(session_entry)) {
5534 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5535 &add_ie_params->probeRespBCNData_buff,
5536 &add_ie_params->probeRespBCNDataLen,
5537 &modify_add_ies->modifyIE);
5538 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 if (ret == true && modify_add_ies->modifyIE.notify) {
5540 lim_handle_param_update(mac_ctx,
5541 modify_add_ies->updateType);
5542 }
5543 break;
5544 default:
5545 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5546 modify_add_ies->updateType);
5547 break;
5548 }
5549end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305550 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551 modify_add_ies->modifyIE.pIEBuffer = NULL;
5552}
5553
5554/*
5555* lim_process_update_add_ies() - process additional IE update req
5556*
5557* @mac_ctx: Pointer to Global MAC structure
5558* @msg_buf: pointer to the SME message buffer
5559*
5560* This function update the PE buffers for additional IEs.
5561*
5562* Return: None
5563*/
5564static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5565 uint32_t *msg_buf)
5566{
5567 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5568 uint8_t session_id;
5569 tpPESession session_entry;
5570 tSirAddIeParams *addn_ie;
5571 uint16_t new_length = 0;
5572 uint8_t *new_ptr = NULL;
5573 tSirUpdateIE *update_ie;
5574
5575 if (msg_buf == NULL) {
5576 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5577 return;
5578 }
5579 update_ie = &update_add_ies->updateIE;
5580 /* incoming message has smeSession, use BSSID to find PE session */
5581 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005582 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583
5584 if (NULL == session_entry) {
5585 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5586 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005587 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 goto end;
5589 }
5590 addn_ie = &session_entry->addIeParams;
5591 /* if len is 0, upper layer requested freeing of buffer */
5592 if (0 == update_ie->ieBufferlength) {
5593 switch (update_add_ies->updateType) {
5594 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305595 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 addn_ie->probeRespData_buff = NULL;
5597 addn_ie->probeRespDataLen = 0;
5598 break;
5599 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305600 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601 addn_ie->assocRespData_buff = NULL;
5602 addn_ie->assocRespDataLen = 0;
5603 break;
5604 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305605 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 addn_ie->probeRespBCNData_buff = NULL;
5607 addn_ie->probeRespBCNDataLen = 0;
5608
5609 if (update_ie->notify)
5610 lim_handle_param_update(mac_ctx,
5611 update_add_ies->updateType);
5612 break;
5613 default:
5614 break;
5615 }
5616 return;
5617 }
5618 switch (update_add_ies->updateType) {
5619 case eUPDATE_IE_PROBE_RESP:
5620 if (update_ie->append) {
5621 /*
5622 * In case of append, allocate new memory
5623 * with combined length
5624 */
5625 new_length = update_ie->ieBufferlength +
5626 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305627 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 if (NULL == new_ptr) {
5629 lim_log(mac_ctx, LOGE, FL(
5630 "Memory allocation failed."));
5631 goto end;
5632 }
5633 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305634 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305636 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 update_ie->pAdditionIEBuffer,
5638 update_ie->ieBufferlength);
5639 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305640 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641 /* adjust length accordingly */
5642 addn_ie->probeRespDataLen = new_length;
5643 /* save refernece of local buffer in PE session */
5644 addn_ie->probeRespData_buff = new_ptr;
5645 goto end;
5646 }
5647 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5648 &addn_ie->probeRespDataLen,
5649 update_ie->pAdditionIEBuffer,
5650 update_ie->ieBufferlength);
5651 break;
5652 case eUPDATE_IE_ASSOC_RESP:
5653 /* assoc resp IE */
5654 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5655 &addn_ie->assocRespDataLen,
5656 update_ie->pAdditionIEBuffer,
5657 update_ie->ieBufferlength);
5658 break;
5659 case eUPDATE_IE_PROBE_BCN:
5660 /* probe resp Bcn IE */
5661 lim_update_add_ie_buffer(mac_ctx,
5662 &addn_ie->probeRespBCNData_buff,
5663 &addn_ie->probeRespBCNDataLen,
5664 update_ie->pAdditionIEBuffer,
5665 update_ie->ieBufferlength);
5666 if (update_ie->notify)
5667 lim_handle_param_update(mac_ctx,
5668 update_add_ies->updateType);
5669 break;
5670 default:
5671 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5672 update_add_ies->updateType);
5673 break;
5674 }
5675end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305676 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 update_ie->pAdditionIEBuffer = NULL;
5678}
5679
5680/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305681 * send_extended_chan_switch_action_frame()- function to send ECSA
5682 * action frame for each sta connected to SAP/GO and AP in case of
5683 * STA .
5684 * @mac_ctx: pointer to global mac structure
5685 * @new_channel: new channel to switch to.
5686 * @ch_bandwidth: BW of channel to calculate op_class
5687 * @session_entry: pe session
5688 *
5689 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5690 *
5691 * Return: void
5692 */
5693
5694static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5695 uint16_t new_channel, uint8_t ch_bandwidth,
5696 tpPESession session_entry)
5697{
5698 uint16_t op_class;
5699 uint8_t switch_mode = 0, i;
5700 tpDphHashNode psta;
5701
5702
Amar Singhal22995112016-01-22 10:42:33 -08005703 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305704 mac_ctx->scan.countryCodeCurrent,
5705 new_channel,
5706 ch_bandwidth);
5707
5708 if (LIM_IS_AP_ROLE(session_entry) &&
5709 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5710 switch_mode = 1;
5711
5712 if (LIM_IS_AP_ROLE(session_entry)) {
5713 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5714 psta =
5715 session_entry->dph.dphHashTable.pDphNodeArray + i;
5716 if (psta && psta->added)
5717 lim_send_extended_chan_switch_action_frame(
5718 mac_ctx,
5719 psta->staAddr,
5720 switch_mode, op_class, new_channel,
5721 LIM_MAX_CSA_IE_UPDATES, session_entry);
5722 }
5723 } else if (LIM_IS_STA_ROLE(session_entry)) {
5724 lim_send_extended_chan_switch_action_frame(mac_ctx,
5725 session_entry->bssId,
5726 switch_mode, op_class, new_channel,
5727 LIM_MAX_CSA_IE_UPDATES, session_entry);
5728 }
5729
5730}
5731
5732/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5734 *
5735 * @mac_ctx: Pointer to Global MAC structure
5736 * @msg_buf: pointer to the SME message buffer
5737 *
5738 * This function processes SME request messages from HDD or upper layer
5739 * application.
5740 *
5741 * Return: None
5742 */
5743static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5744 uint32_t *msg_buf)
5745{
5746 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5747 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 uint8_t session_id;
5749 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005750 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751
5752 if (msg_buf == NULL) {
5753 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5754 return;
5755 }
5756
5757 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5758 session_entry = pe_find_session_by_bssid(mac_ctx,
5759 dfs_csa_ie_req->bssid, &session_id);
5760 if (session_entry == NULL) {
5761 lim_log(mac_ctx, LOGE, FL(
5762 "Session not found for given BSSID" MAC_ADDRESS_STR),
5763 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5764 return;
5765 }
5766
5767 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5768 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5769 GET_LIM_SYSTEM_ROLE(session_entry));
5770 return;
5771 }
5772
5773 /* target channel */
5774 session_entry->gLimChannelSwitch.primaryChannel =
5775 dfs_csa_ie_req->targetChannel;
5776
5777 /* Channel switch announcement needs to be included in beacon */
5778 session_entry->dfsIncludeChanSwIe = true;
5779 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5780 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005781 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305782 session_entry->gLimChannelSwitch.sec_ch_offset =
5783 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5785 session_entry->gLimChannelSwitch.switchMode = 1;
5786
5787 /*
5788 * Validate if SAP is operating HT or VHT mode and set the Channel
5789 * Switch Wrapper element with the Wide Band Switch subelement.
5790 */
5791 if (true != session_entry->vhtCapability)
5792 goto skip_vht;
5793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 /* Now encode the Wider Ch BW element depending on the ch width */
5795 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005796 switch (dfs_csa_ie_req->ch_params.ch_width) {
5797 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 /*
5799 * Wide channel BW sublement in channel wrapper element is not
5800 * required in case of 20 Mhz operation. Currently It is set
5801 * only set in case of 40/80 Mhz Operation.
5802 */
5803 session_entry->dfsIncludeChanWrapperIe = false;
5804 wider_bw_ch_switch->newChanWidth =
5805 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5806 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005807 case CH_WIDTH_40MHZ:
5808 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 wider_bw_ch_switch->newChanWidth =
5810 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5811 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005812 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 session_entry->dfsIncludeChanWrapperIe = true;
5814 wider_bw_ch_switch->newChanWidth =
5815 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5816 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005817 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 session_entry->dfsIncludeChanWrapperIe = true;
5819 wider_bw_ch_switch->newChanWidth =
5820 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5821 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005822 case CH_WIDTH_80P80MHZ:
5823 session_entry->dfsIncludeChanWrapperIe = true;
5824 wider_bw_ch_switch->newChanWidth =
5825 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005826 /*
5827 * This is not applicable for 20/40/80 Mhz.
5828 * Only used when we support 80+80 Mhz operation.
5829 * In case of 80+80 Mhz, this parameter indicates
5830 * center channel frequency index of 80 Mhz channel of
5831 * frequency segment 1.
5832 */
5833 wider_bw_ch_switch->newCenterChanFreq1 =
5834 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005835 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 default:
5837 session_entry->dfsIncludeChanWrapperIe = false;
5838 /*
5839 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5840 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5841 */
5842 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5843 break;
5844 }
5845 /* Fetch the center channel based on the channel width */
5846 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005847 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848skip_vht:
5849 /* Send CSA IE request from here */
5850 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5851 eSIR_SUCCESS) {
5852 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5853 return;
5854 }
5855
5856 /*
5857 * First beacon update request is sent here, the remaining updates are
5858 * done when the FW responds back after sending the first beacon after
5859 * the template update
5860 */
5861 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305862
5863 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5864 ch_offset = BW80;
5865 else
5866 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5867
5868 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5869 session_entry->gLimChannelSwitch.switchCount,
5870 session_entry->gLimChannelSwitch.primaryChannel,
5871 session_entry->gLimChannelSwitch.ch_width,
5872 session_entry->dfsIncludeChanWrapperIe,
5873 ch_offset);
5874
Abhishek Singh518323d2015-10-19 17:42:01 +05305875 /* Send ECSA Action frame after updating the beacon */
5876 send_extended_chan_switch_action_frame(mac_ctx,
5877 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305878 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 session_entry->gLimChannelSwitch.switchCount--;
5880}
5881
5882/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305883 * lim_process_ext_change_channel()- function to send ECSA
5884 * action frame for STA/CLI .
5885 * @mac_ctx: pointer to global mac structure
5886 * @msg: params from sme for new channel.
5887 *
5888 * This function is called to send ECSA frame for STA/CLI.
5889 *
5890 * Return: void
5891 */
5892
5893static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5894 uint32_t *msg)
5895{
5896 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5897 (struct sir_sme_ext_cng_chan_req *) msg;
5898 tpPESession session_entry = NULL;
5899
5900 if (NULL == msg) {
5901 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5902 return;
5903 }
5904 session_entry =
5905 pe_find_session_by_sme_session_id(mac_ctx,
5906 ext_chng_channel->session_id);
5907 if (NULL == session_entry) {
5908 lim_log(mac_ctx, LOGE,
5909 FL("Session not found for given session %d"),
5910 ext_chng_channel->session_id);
5911 return;
5912 }
5913 if (LIM_IS_AP_ROLE(session_entry)) {
5914 lim_log(mac_ctx, LOGE,
5915 FL("not an STA/CLI session"));
5916 return;
5917 }
5918 send_extended_chan_switch_action_frame(mac_ctx,
5919 ext_chng_channel->new_channel,
5920 0, session_entry);
5921}
5922
5923/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924 * lim_process_nss_update_request() - process sme nss update req
5925 *
5926 * @mac_ctx: Pointer to Global MAC structure
5927 * @msg_buf: pointer to the SME message buffer
5928 *
5929 * This function processes SME request messages from HDD or upper layer
5930 * application.
5931 *
5932 * Return: None
5933 */
5934static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5935 uint32_t *msg_buf)
5936{
5937 struct sir_nss_update_request *nss_update_req_ptr;
5938 tpPESession session_entry = NULL;
5939
5940 if (msg_buf == NULL) {
5941 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5942 return;
5943 }
5944
5945 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305946 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 nss_update_req_ptr->vdev_id);
5948 if (session_entry == NULL) {
5949 lim_log(mac_ctx, LOGE, FL(
5950 "Session not found for given session_id %d"),
5951 nss_update_req_ptr->vdev_id);
5952 return;
5953 }
5954
5955 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5956 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5957 GET_LIM_SYSTEM_ROLE(session_entry));
5958 return;
5959 }
5960
5961 /* populate nss field in the beacon */
5962 session_entry->gLimOperatingMode.present = 1;
5963 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5964 /* Send nss update request from here */
5965 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5966 eSIR_SUCCESS) {
5967 lim_log(mac_ctx, LOGE,
5968 FL("Unable to set op mode IE in beacon"));
5969 return;
5970 }
5971
5972 lim_send_beacon_ind(mac_ctx, session_entry);
5973}
5974
5975/**
5976 * lim_process_set_ie_req() - process sme set IE request
5977 *
5978 * @mac_ctx: Pointer to Global MAC structure
5979 * @msg_buf: pointer to the SME message buffer
5980 *
5981 * This function processes SME request messages from HDD or upper layer
5982 * application.
5983 *
5984 * Return: None
5985 */
5986static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5987{
5988 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305989 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990
5991 if (msg_buf == NULL) {
5992 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5993 return;
5994 }
5995
5996 msg = (struct send_extcap_ie *)msg_buf;
5997 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305998 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6000
6001}