blob: 0d480b6c17ab2f13f482c69d661f711d1e84a488 [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61#include "sap_api.h"
62
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070065#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/*
68 * This overhead is time for sending NOA start to host in case of GO/sending
69 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
70 * with init scan req/rsp plus in case of concurrency, taking care of sending
71 * null data and receiving ACK to/from AP/Also SetChannel with calibration
72 * is taking around 7ms .
73 */
74#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
75#define JOIN_NOA_DURATION 2000 /* in msecs */
76#define OEM_DATA_NOA_DURATION 60 /* in msecs */
77#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
78
79#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
80
81/* SME REQ processing function templates */
82static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
83static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
84static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
85static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
91static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
92static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
93 uint32_t *pMsg);
94static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98
99static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
100 uint8_t **pDstData_buff,
101 uint16_t *pDstDataLen,
102 uint8_t *pSrcData_buff,
103 uint16_t srcDataLen);
104
105static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
106 uint8_t **pDstData_buff,
107 uint16_t *pDstDataLen,
108 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800109static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
114
115static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
116
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800117extern void pe_register_wma_handle(tpAniSirGlobal pMac,
118 tSirSmeReadyReq *ready_req);
Abhishek Singh518323d2015-10-19 17:42:01 +0530119static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
120 uint32_t *msg);
121
122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123/**
124 * lim_process_set_hw_mode() - Send set HW mode command to WMA
125 * @mac: Globacl MAC pointer
126 * @msg: Message containing the hw mode index
127 *
128 * Send the set HW mode command to WMA
129 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530130 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530134 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135 cds_msg_t cds_message;
136 struct sir_hw_mode *req_msg;
137 uint32_t len;
138 struct s_sir_set_hw_mode *buf;
139 tSirMsgQ resp_msg;
140 struct sir_set_hw_mode_resp *param;
141
142 buf = (struct s_sir_set_hw_mode *) msg;
143 if (!buf) {
144 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
145 /* To free the active command list */
146 goto fail;
147 }
148
149 len = sizeof(*req_msg);
150
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530151 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 /* Free the active command list
155 * Probably the malloc is going to fail there as well?!
156 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530157 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 }
159
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530160 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161
162 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530163 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 /* Other parameters are not needed for WMA */
165
166 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530167 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
169 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
170 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530171 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 lim_log(mac, LOGE,
173 FL("vos_mq_post_message failed!(err=%d)"),
174 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 goto fail;
177 }
178 return status;
179fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530180 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 if (!param) {
182 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530183 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 }
185 param->status = SET_HW_MODE_STATUS_ECANCELED;
186 param->cfgd_hw_mode_index = 0;
187 param->num_vdev_mac_entries = 0;
188 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
189 resp_msg.bodyptr = param;
190 resp_msg.bodyval = 0;
191 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193}
194
195/**
196 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
197 * @mac: Global MAC pointer
198 * @msg: Message containing the dual mac config parameter
199 *
200 * Send the set dual mac config command to WMA
201 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 uint32_t *msg)
206{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 cds_msg_t cds_message;
209 struct sir_dual_mac_config *req_msg;
210 uint32_t len;
211 struct sir_set_dual_mac_cfg *buf;
212 tSirMsgQ resp_msg;
213 struct sir_dual_mac_config_resp *param;
214
215 buf = (struct sir_set_dual_mac_cfg *) msg;
216 if (!buf) {
217 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
218 /* To free the active command list */
219 goto fail;
220 }
221
222 len = sizeof(*req_msg);
223
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530224 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700226 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 /* Free the active command list
228 * Probably the malloc is going to fail there as well?!
229 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530230 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 }
232
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530233 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234
235 req_msg->scan_config = buf->set_dual_mac.scan_config;
236 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
237 /* Other parameters are not needed for WMA */
238
239 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530240 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241
242 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530243 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 req_msg->scan_config, req_msg->fw_mode_config);
245 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530246 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 lim_log(mac, LOGE,
248 FL("vos_mq_post_message failed!(err=%d)"),
249 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530250 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 goto fail;
252 }
253 return status;
254fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530255 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 if (!param) {
257 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530258 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 }
260 param->status = SET_HW_MODE_STATUS_ECANCELED;
261 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
262 resp_msg.bodyptr = param;
263 resp_msg.bodyval = 0;
264 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530265 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266}
267
268/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800269 * lim_process_set_antenna_mode_req() - Set antenna mode command
270 * to WMA
271 * @mac: Global MAC pointer
272 * @msg: Message containing the antenna mode parameter
273 *
274 * Send the set antenna mode command to WMA
275 *
276 * Return: QDF_STATUS_SUCCESS if message posting is successful
277 */
278static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
279 uint32_t *msg)
280{
281 QDF_STATUS status = QDF_STATUS_SUCCESS;
282 cds_msg_t cds_message;
283 struct sir_antenna_mode_param *req_msg;
284 struct sir_set_antenna_mode *buf;
285 tSirMsgQ resp_msg;
286 struct sir_antenna_mode_resp *param;
287
288 buf = (struct sir_set_antenna_mode *) msg;
289 if (!buf) {
290 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
291 /* To free the active command list */
292 goto fail;
293 }
294
295 req_msg = qdf_mem_malloc(sizeof(*req_msg));
296 if (!req_msg) {
297 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
298 return QDF_STATUS_E_NOMEM;
299 }
300
301 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
302 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
303
304 cds_message.bodyptr = req_msg;
305 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
306
307 lim_log(mac, LOG1,
308 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
309 req_msg->num_rx_chains,
310 req_msg->num_tx_chains);
311 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
312 if (!QDF_IS_STATUS_SUCCESS(status)) {
313 lim_log(mac, LOGE,
314 FL("vos_mq_post_message failed!(err=%d)"),
315 status);
316 qdf_mem_free(req_msg);
317 goto fail;
318 }
319 return status;
320fail:
321 param = qdf_mem_malloc(sizeof(*param));
322 if (!param) {
323 lim_log(mac, LOGE, FL("antenna mode resp failed"));
324 return QDF_STATUS_E_NOMEM;
325 }
326 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
327 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
328 resp_msg.bodyptr = param;
329 resp_msg.bodyval = 0;
330 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
331 return QDF_STATUS_SUCCESS;
332}
333
334/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
336 * @mac_ctx: Pointer to Global MAC structure
337 * @return_fresh_results: Trigger fresh scan.
338 *
339 * PE will do fresh scan, if all of the active sessions are in
340 * good state (Link Est or BSS Started). If one of the sessions
341 * is not in one of the above states, then PE does not do fresh
342 * scan. If no session exists (scanning very first time),
343 * then PE will always do fresh scan if SME asks it to do that.
344 *
345 * Return: true for fresh scan results, false if in invalid state.
346 */
347static uint8_t
348__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
349{
350 uint8_t valid_state = true;
351 int i;
352
353 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
354 mac_ctx->lim.gLimSmeState, return_fresh_results);
355
356 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
357 lim_log(mac_ctx, LOG1, FL("return FALSE"));
358 return false;
359 }
360
361 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
362 lim_log(mac_ctx, LOG1,
363 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
364 i, mac_ctx->lim.gpSession[i].bssType,
365 mac_ctx->lim.gpSession[i].limSystemRole,
366 mac_ctx->lim.gpSession[i].limSmeState);
367 if (mac_ctx->lim.gpSession[i].valid == true) {
368 if (!((((mac_ctx->lim.gpSession[i].bssType ==
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700369 eSIR_INFRASTRUCTURE_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 (mac_ctx->lim.gpSession[i].limSmeState ==
371 eLIM_SME_LINK_EST_STATE)) ||
372 (((mac_ctx->lim.gpSession[i].bssType ==
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700373 eSIR_IBSS_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 (mac_ctx->lim.gpSession[i].limSmeState ==
375 eLIM_SME_NORMAL_STATE)) ||
376 ((((mac_ctx->lim.gpSession[i].bssType ==
377 eSIR_INFRA_AP_MODE) &&
378 (mac_ctx->lim.gpSession[i].pePersona ==
Anurag Chouhan6d760662016-02-20 16:05:43 +0530379 QDF_P2P_GO_MODE)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 (mac_ctx->lim.gpSession[i].limSystemRole ==
381 eLIM_AP_ROLE)) &&
382 (mac_ctx->lim.gpSession[i].limSmeState ==
383 eLIM_SME_NORMAL_STATE)))) {
384 valid_state = false;
385 break;
386 }
387 }
388 }
389
390 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
391
392 if ((valid_state) &&
393 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
394 return true;
395 else
396 return false;
397}
398
399/**
400 * __lim_is_sme_assoc_cnf_valid()
401 *
402 ***FUNCTION:
403 * This function is called by __lim_process_sme_assoc_cnf_new() upon
404 * receiving SME_ASSOC_CNF.
405 *
406 ***LOGIC:
407 * Message validity checks are performed in this function
408 *
409 ***ASSUMPTIONS:
410 *
411 ***NOTE:
412 *
413 * @param pMeasReq Pointer to Received ASSOC_CNF message
414 * @return true When received SME_ASSOC_CNF is formatted
415 * correctly
416 * false otherwise
417 */
418
419static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
420{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530421 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 return false;
423 else
424 return true;
425} /*** end __lim_is_sme_assoc_cnf_valid() ***/
426
427/**
428 * __lim_get_sme_join_req_size_for_alloc()
429 *
430 ***FUNCTION:
431 * This function is called in various places to get IE length
432 * from tSirBssDescription structure
433 * number being scanned.
434 *
435 ***PARAMS:
436 *
437 ***LOGIC:
438 *
439 ***ASSUMPTIONS:
440 * NA
441 *
442 ***NOTE:
443 * NA
444 *
445 * @param pBssDescr
446 * @return Total IE length
447 */
448
449static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
450{
451 uint16_t len = 0;
452
453 if (!pBuf)
454 return len;
455
456 pBuf += sizeof(uint16_t);
457 len = lim_get_u16(pBuf);
458 return len + sizeof(uint16_t);
459}
460
461/**
462 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
463 * @pMac: Global MAC context
464 * @pMsg: Pointer to message posted from SME to LIM.
465 *
466 * Has role only if 11h is enabled. Not used on STA side.
467 * Defers the message if SME is in learn state and brings
468 * the LIM back to normal mode.
469 *
470 * Return: true - If defered false - Otherwise
471 */
472
473static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
474{
475 if (lim_is_system_in_scan_state(pMac)) {
476 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
477 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
478 pMsg->type);
479 return false;
480 }
481 lim_log(pMac, LOG1,
482 FL("Defer the message, in learn mode type = %d"),
483 pMsg->type);
484 return true;
485 }
486 return false;
487}
488
489/**
490 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
491 * @mac_ctx: Pointer to Global MAC structure
492 * @message: Pointer to message posted from SME to LIM.
493 *
494 * Has role only if 11h is enabled. Not used on STA side.
495 * Defers the message if radar is detected.
496 *
497 * Return: true, if defered otherwise return false.
498 */
499static bool
500__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
501{
502 /*
503 * fRadarDetCurOperChan will be set only if we
504 * detect radar in current operating channel and
505 * System Role == AP ROLE
506 *
507 * TODO: Need to take care radar detection.
508 *
509 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
510 */
511 if (0) {
512 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
513 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
514 message->type);
515 return false;
516 }
517 lim_log(mac_ctx, LOG1,
518 FL("Defer the message, in learn mode type = %d"),
519 message->type);
520 return true;
521 }
522 return false;
523}
524
525/**
526 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
527 * @pMac: Global MAC context
528 * @pMsgBuf: Message from WMA
529 *
530 * handles the notification from HDD. PE just forwards this message to HAL.
531 *
532 * Return: true-Posting to HAL failed, so PE will consume the buffer.
533 * false-Posting to HAL successful, so HAL will consume the buffer.
534 */
535
536static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
537{
538 tSirMsgQ msg;
539 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
540
541 msg.type = WMA_SYS_READY_IND;
542 msg.reserved = 0;
543 msg.bodyptr = pMsgBuf;
544 msg.bodyval = 0;
545
546 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800547 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
548 pe_register_wma_handle(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
550 }
551 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
552 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
553
554 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
555 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
556 return true;
557 }
558 return false;
559}
560
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561/**
562 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
563 *@mac_ctx: Pointer to Global MAC structure
564 *@session: A pointer to session entry
565 *@sme_start_bss_req: Start BSS Request from upper layers.
566 *
567 * This function is used to configure the start bss parameters
568 * in to the session.
569 *
570 * Return: None.
571 */
572static void
573lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
574 tpSirSmeStartBssReq sme_start_bss_req)
575{
576 session->limSystemRole = eLIM_AP_ROLE;
577 session->privacy = sme_start_bss_req->privacy;
578 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
579 session->authType = sme_start_bss_req->authType;
580 /* Store the DTIM period */
581 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
582 /* Enable/disable UAPSD */
583 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530584 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 session->proxyProbeRspEn = 0;
586 } else {
587 /*
588 * To detect PBC overlap in SAP WPS mode,
589 * Host handles Probe Requests.
590 */
591 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
592 session->proxyProbeRspEn = 1;
593 else
594 session->proxyProbeRspEn = 0;
595 }
596 session->ssidHidden = sme_start_bss_req->ssidHidden;
597 session->wps_state = sme_start_bss_req->wps_state;
598 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
599 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
600 &session->shortSlotTimeSupported);
601 session->isCoalesingInIBSSAllowed =
602 sme_start_bss_req->isCoalesingInIBSSAllowed;
603
604}
605
606/**
607 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
608 *@mac_ctx: Pointer to Global MAC structure
609 *@msg_buf: A pointer to the SME message buffer
610 *
611 * This function is called to process SME_START_BSS_REQ message
612 * from HDD or upper layer application.
613 *
614 * Return: None
615 */
616static void
617__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
618{
619 uint16_t size;
620 uint32_t val = 0;
621 tSirRetStatus ret_status;
622 tSirMacChanNum channel_number;
623 tLimMlmStartReq *mlm_start_req = NULL;
624 tpSirSmeStartBssReq sme_start_bss_req = NULL;
625 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
626 /* Flag Used in case of IBSS to Auto generate BSSID. */
627 uint32_t auto_gen_bssid = false;
628 uint8_t session_id;
629 tpPESession session = NULL;
630 uint8_t sme_session_id = 0;
631 uint16_t sme_transaction_id = 0;
632 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700633 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
635
636/* FEATURE_WLAN_DIAG_SUPPORT */
637#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
638 /*
639 * Since the session is not created yet, sending NULL.
640 * The response should have the correct state.
641 */
642 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
643 NULL, 0, 0);
644#endif /* FEATURE_WLAN_DIAG_SUPPORT */
645
646 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
647
648 /*
649 * Global Sme state and mlm states are not defined yet,
650 * for BT-AMP Suppoprt . TO BE DONE
651 */
652 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
653 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
654 size = sizeof(tSirSmeStartBssReq);
655
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530656 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 if (NULL == sme_start_bss_req) {
658 lim_log(mac_ctx, LOGE,
659 FL("Allocate Memory fail for LimStartBssReq"));
660 /* Send failure response to host */
661 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
662 goto end;
663 }
664
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530665 qdf_mem_set((void *)sme_start_bss_req, size, 0);
666 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 sizeof(tSirSmeStartBssReq));
668 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
669 sme_start_bss_req)) {
670 lim_log(mac_ctx, LOGW,
671 FL("Received invalid eWNI_SME_START_BSS_REQ"));
672 ret_code = eSIR_SME_INVALID_PARAMETERS;
673 goto free;
674 }
675
676 /*
677 * This is the place where PE is going to create a session.
678 * If session is not existed, then create a new session
679 */
680 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800681 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 if (session != NULL) {
683 lim_log(mac_ctx, LOGW,
684 FL("Session Already exists for given BSSID"));
685 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
686 session = NULL;
687 goto free;
688 } else {
689 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800690 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 &session_id, mac_ctx->lim.maxStation,
692 sme_start_bss_req->bssType);
693 if (session == NULL) {
694 lim_log(mac_ctx, LOGW,
695 FL("Session Can not be created "));
696 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
697 goto free;
698 }
699 }
700
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700701 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
702 /* Probe resp add ie */
703 lim_start_bss_update_add_ie_buffer(mac_ctx,
704 &session->addIeParams.probeRespData_buff,
705 &session->addIeParams.probeRespDataLen,
706 sme_start_bss_req->addIeParams.
707 probeRespData_buff,
708 sme_start_bss_req->addIeParams.
709 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700711 /* Probe Beacon add ie */
712 lim_start_bss_update_add_ie_buffer(mac_ctx,
713 &session->addIeParams.probeRespBCNData_buff,
714 &session->addIeParams.probeRespBCNDataLen,
715 sme_start_bss_req->addIeParams.
716 probeRespBCNData_buff,
717 sme_start_bss_req->addIeParams.
718 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700720 /* Assoc resp IE */
721 lim_start_bss_update_add_ie_buffer(mac_ctx,
722 &session->addIeParams.assocRespData_buff,
723 &session->addIeParams.assocRespDataLen,
724 sme_start_bss_req->addIeParams.
725 assocRespData_buff,
726 sme_start_bss_req->addIeParams.
727 assocRespDataLen);
728 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 /* Store the session related params in newly created session */
730 session->pLimStartBssReq = sme_start_bss_req;
731
732 /* Store PE session_id in session Table */
733 session->peSessionId = session_id;
734
735 /* Store SME session Id in sessionTable */
736 session->smeSessionId = sme_start_bss_req->sessionId;
737
738 session->transactionId = sme_start_bss_req->transactionId;
739
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530740 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 &(sme_start_bss_req->htConfig),
742 sizeof(session->htConfig));
743
744 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800745 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746
747 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530748 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 (uint8_t *) &sme_start_bss_req->ssId,
750 (sme_start_bss_req->ssId.length + 1));
751
752 session->bssType = sme_start_bss_req->bssType;
753
754 session->nwType = sme_start_bss_req->nwType;
755
756 session->beaconParams.beaconInterval =
757 sme_start_bss_req->beaconInterval;
758
759 /* Store the channel number in session Table */
760 session->currentOperChannel =
761 sme_start_bss_req->channelId;
762
763 /* Store Persona */
764 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530765 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 FL("PE PERSONA=%d"), session->pePersona);
767
768 /* Update the phymode */
769 session->gLimPhyMode = sme_start_bss_req->nwType;
770
771 session->maxTxPower =
772 cfg_get_regulatory_max_transmit_power(mac_ctx,
773 session->currentOperChannel);
774 /* Store the dot 11 mode in to the session Table */
775 session->dot11mode = sme_start_bss_req->dot11mode;
776#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
777 session->cc_switch_mode =
778 sme_start_bss_req->cc_switch_mode;
779#endif
780 session->htCapability =
781 IS_DOT11_MODE_HT(session->dot11mode);
782 session->vhtCapability =
783 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530784 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 FL("*****session->vhtCapability = %d"),
786 session->vhtCapability);
787 session->txLdpcIniFeatureEnabled =
788 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789#ifdef WLAN_FEATURE_11W
790 session->limRmfEnabled =
791 sme_start_bss_req->pmfCapable ? 1 : 0;
792 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
793 session->limRmfEnabled);
794#endif
795
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 (void *)&sme_start_bss_req->operationalRateSet,
798 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530799 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 (void *)&sme_start_bss_req->extendedRateSet,
801 sizeof(tSirMacRateSet));
802
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700803 if (IS_5G_CH(session->currentOperChannel))
804 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
805 else
806 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 switch (sme_start_bss_req->bssType) {
809 case eSIR_INFRA_AP_MODE:
810 lim_configure_ap_start_bss_session(mac_ctx, session,
811 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530812 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800813 session->txBFIniFeatureEnabled =
814 sme_start_bss_req->txbf_ini_enabled;
815 session->txbf_csn_value =
816 sme_start_bss_req->txbf_csn_val;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700817 session->vdev_nss = vdev_type_nss->sap;
818 } else {
819 session->vdev_nss = vdev_type_nss->p2p_go;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800820 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 break;
822 case eSIR_IBSS_MODE:
823 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
824 lim_get_short_slot_from_phy_mode(mac_ctx, session,
825 session->gLimPhyMode,
826 &session->shortSlotTimeSupported);
827
828 /*
829 * initialize to "OPEN".
830 * will be updated upon key installation
831 */
832 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700833 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834
835 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700836 case eSIR_NDI_MODE:
837 session->limSystemRole = eLIM_NDI_ROLE;
838 break;
839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 /*
842 * There is one more mode called auto mode.
843 * which is used no where
844 */
845
846 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
847
848 default:
849 /* not used anywhere...used in scan function */
850 break;
851 }
852
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700853 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
854 session->pePersona, session->vdev_nss);
855 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700857 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 * parsed (Re)Assoc request structure
859 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700860 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530862 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700863 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 if (NULL == session->parsedAssocReq) {
865 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700866 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
868 goto free;
869 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700871 (session->dph.dphHashTable.size *
872 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 }
874
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700875 if (!sme_start_bss_req->channelId &&
876 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 lim_log(mac_ctx, LOGE,
878 FL("Received invalid eWNI_SME_START_BSS_REQ"));
879 ret_code = eSIR_SME_INVALID_PARAMETERS;
880 goto free;
881 }
882 channel_number = sme_start_bss_req->channelId;
883#ifdef QCA_HT_2040_COEX
884 if (sme_start_bss_req->obssEnabled)
885 session->htSupportedChannelWidthSet =
886 session->htCapability;
887 else
888#endif
889 session->htSupportedChannelWidthSet =
890 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
891 session->htSecondaryChannelOffset =
892 sme_start_bss_req->sec_ch_offset;
893 session->htRecommendedTxWidthSet =
894 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530895 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 FL("cbMode %u"), sme_start_bss_req->cbMode);
897 if (session->vhtCapability || session->htCapability) {
898 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800899 lim_log(mac_ctx, LOG1,
900 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
901 sme_start_bss_req->vht_channel_width,
902 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 session->ch_width = chanwidth;
904 if (session->htSupportedChannelWidthSet) {
905 session->ch_center_freq_seg0 =
906 sme_start_bss_req->center_freq_seg0;
907 session->ch_center_freq_seg1 =
908 sme_start_bss_req->center_freq_seg1;
909 } else {
910 session->ch_center_freq_seg0 = 0;
911 session->ch_center_freq_seg1 = 0;
912 }
913 }
914
915 if (session->vhtCapability &&
916 (CH_WIDTH_160MHZ > session->ch_width)) {
917 if (wlan_cfg_get_int(mac_ctx,
918 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
919 eSIR_SUCCESS)
920 lim_log(mac_ctx, LOGE, FL(
921 "cfg get vht su bformer failed"));
922
923 session->enable_su_tx_bformer = val;
924 } else {
925 session->nss = 1;
926 }
927 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
928
929 /* Delete pre-auth list if any */
930 lim_delete_pre_auth_list(mac_ctx);
931
932 /*
933 * keep the RSN/WPA IE information in PE Session Entry
934 * later will be using this to check when received (Re)Assoc req
935 */
936 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
937 &sme_start_bss_req->rsnIE, session);
938
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700939 if (LIM_IS_AP_ROLE(session) ||
940 LIM_IS_IBSS_ROLE(session) ||
941 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 session->gLimProtectionControl =
943 sme_start_bss_req->protEnabled;
944 /*
945 * each byte will have the following info
946 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
947 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
948 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530949 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 (void *)&sme_start_bss_req->ht_capab,
951 sizeof(uint16_t));
952 /* Initialize WPS PBC session link list */
953 session->pAPWPSPBCSession = NULL;
954 }
955 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530956 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 if (NULL == mlm_start_req) {
958 lim_log(mac_ctx, LOGP,
959 FL("Allocate Memory failed for mlmStartReq"));
960 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
961 goto free;
962 }
963
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
966 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530967 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 (uint8_t *) &sme_start_bss_req->ssId,
969 sme_start_bss_req->ssId.length + 1);
970 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
971 mlm_start_req->obssProtEnabled =
972 sme_start_bss_req->obssProtEnabled;
973
974 mlm_start_req->bssType = session->bssType;
975
976 /* Fill PE session Id from the session Table */
977 mlm_start_req->sessionId = session->peSessionId;
978
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700979 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
980 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 /*
982 * Copy the BSSId from sessionTable to
983 * mlmStartReq struct
984 */
985 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
986 } else {
987 /* ibss mode */
988 mac_ctx->lim.gLimIbssCoalescingHappened = false;
989
990 ret_status = wlan_cfg_get_int(mac_ctx,
991 WNI_CFG_IBSS_AUTO_BSSID,
992 &auto_gen_bssid);
993 if (ret_status != eSIR_SUCCESS) {
994 lim_log(mac_ctx, LOGP,
995 FL("Get Auto Gen BSSID fail,Status=%d"),
996 ret_status);
997 ret_code = eSIR_LOGP_EXCEPTION;
998 goto free;
999 }
1000
1001 if (!auto_gen_bssid) {
1002 /*
1003 * We're not auto generating BSSID.
1004 * Instead, get it from session entry
1005 */
1006 sir_copy_mac_addr(mlm_start_req->bssId,
1007 session->bssId);
1008 /*
1009 * Start IBSS group BSSID
1010 * Auto Generating BSSID.
1011 */
1012 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1013 0x01) ? true : false);
1014 }
1015
1016 if (auto_gen_bssid) {
1017 /*
1018 * if BSSID is not any uc id.
1019 * then use locally generated BSSID.
1020 * Autogenerate the BSSID
1021 */
1022 lim_get_random_bssid(mac_ctx,
1023 mlm_start_req->bssId);
1024 mlm_start_req->bssId[0] = 0x02;
1025
1026 /*
1027 * Copy randomly generated BSSID
1028 * to the session Table
1029 */
1030 sir_copy_mac_addr(session->bssId,
1031 mlm_start_req->bssId);
1032 }
1033 }
1034 /* store the channel num in mlmstart req structure */
1035 mlm_start_req->channelNumber = session->currentOperChannel;
1036 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1037 mlm_start_req->beaconPeriod =
1038 session->beaconParams.beaconInterval;
1039
1040 if (LIM_IS_AP_ROLE(session)) {
1041 mlm_start_req->dtimPeriod = session->dtimPeriod;
1042 mlm_start_req->wps_state = session->wps_state;
1043
1044 } else {
1045 if (wlan_cfg_get_int(mac_ctx,
1046 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1047 lim_log(mac_ctx, LOGP,
1048 FL("could not retrieve DTIM Period"));
1049 mlm_start_req->dtimPeriod = (uint8_t) val;
1050 }
1051
1052 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1053 eSIR_SUCCESS)
1054 lim_log(mac_ctx, LOGP,
1055 FL("could not retrieve Beacon interval"));
1056 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1057
1058 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1059 eSIR_SUCCESS)
1060 lim_log(mac_ctx, LOGP,
1061 FL("could not retrieve CFPMaxDuration"));
1062 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1063
1064 /*
1065 * this may not be needed anymore now,
1066 * as rateSet is now included in the
1067 * session entry and MLM has session context.
1068 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301069 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 (void *)&session->rateSet,
1071 sizeof(tSirMacRateSet));
1072
1073 /* Now populate the 11n related parameters */
1074 mlm_start_req->nwType = session->nwType;
1075 mlm_start_req->htCapable = session->htCapability;
1076
1077 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1078 /* Unused */
1079 mlm_start_req->dualCTSProtection =
1080 mac_ctx->lim.gHTDualCTSProtection;
1081 mlm_start_req->txChannelWidthSet =
1082 session->htRecommendedTxWidthSet;
1083
1084 session->limRFBand = lim_get_rf_band(channel_number);
1085
1086 /* Initialize 11h Enable Flag */
1087 session->lim11hEnable = 0;
1088 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1089 (SIR_BAND_5_GHZ == session->limRFBand)) {
1090 if (wlan_cfg_get_int(mac_ctx,
1091 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1092 lim_log(mac_ctx, LOGP,
1093 FL("Fail to get WNI_CFG_11H_ENABLED "));
1094 else
1095 session->lim11hEnable = val;
1096
1097 if (session->lim11hEnable &&
1098 (eSIR_INFRA_AP_MODE ==
1099 mlm_start_req->bssType)) {
1100 cfg_get_wmi_dfs_master_param =
1101 wlan_cfg_get_int(mac_ctx,
1102 WNI_CFG_DFS_MASTER_ENABLED,
1103 &val);
1104 session->lim11hEnable = val;
1105 }
1106 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1107 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1108 lim_log(mac_ctx, LOGE,
1109 FL("Get Fail, CFG DFS ENABLE"));
1110 }
1111
1112 if (!session->lim11hEnable) {
1113 if (cfg_set_int(mac_ctx,
1114 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1115 eSIR_SUCCESS)
1116 /*
1117 * Failed to set the CFG param
1118 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1119 */
1120 lim_log(mac_ctx, LOGE,
1121 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1122 }
1123
1124 session->limPrevSmeState = session->limSmeState;
1125 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1126 MTRACE(mac_trace
1127 (mac_ctx, TRACE_CODE_SME_STATE,
1128 session->peSessionId,
1129 session->limSmeState));
1130
1131 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1132 (uint32_t *) mlm_start_req);
1133 return;
1134 } else {
1135
1136 lim_log(mac_ctx, LOGE,
1137 FL("Received unexpected START_BSS_REQ, in state %X"),
1138 mac_ctx->lim.gLimSmeState);
1139 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1140 goto end;
1141 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1142
1143free:
1144 if ((session != NULL) &&
1145 (session->pLimStartBssReq == sme_start_bss_req)) {
1146 session->pLimStartBssReq = NULL;
1147 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301148 qdf_mem_free(sme_start_bss_req);
1149 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150
1151end:
1152 if (sme_start_bss_req != NULL) {
1153 sme_session_id = sme_start_bss_req->sessionId;
1154 sme_transaction_id = sme_start_bss_req->transactionId;
1155 }
1156 if (NULL != session) {
1157 pe_delete_session(mac_ctx, session);
1158 session = NULL;
1159 }
1160 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1161 session, sme_session_id, sme_transaction_id);
1162}
1163
1164/**
1165 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1166 *
1167 * @pMac: Global MAC context
1168 * @pMsg: Message pointer
1169 *
1170 * Wrapper for the function __lim_handle_sme_start_bss_request
1171 * This message will be defered until softmac come out of
1172 * scan mode or if we have detected radar on the current
1173 * operating channel.
1174 *
1175 * return true - If we consumed the buffer
1176 * false - If have defered the message.
1177 */
1178static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1179{
1180 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1181 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1182 /**
1183 * If message defered, buffer is not consumed yet.
1184 * So return false
1185 */
1186 return false;
1187 }
1188
1189 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1190 return true;
1191}
1192
1193/**
1194 * lim_get_random_bssid()
1195 *
1196 * FUNCTION:This function is called to process generate the random number for bssid
1197 * This function is called to process SME_SCAN_REQ message
1198 * from HDD or upper layer application.
1199 *
1200 * LOGIC:
1201 *
1202 * ASSUMPTIONS:
1203 *
1204 * NOTE:
1205 * 1. geneartes the unique random number for bssid in ibss
1206 *
1207 * @param pMac Pointer to Global MAC structure
1208 * @param *data Pointer to bssid buffer
1209 * @return None
1210 */
1211void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1212{
1213 uint32_t random[2];
1214 random[0] = tx_time_get();
1215 random[0] |= (random[0] << 15);
1216 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301217 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218}
1219
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301220static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 tpSirSmeScanReq pScanReq)
1222{
1223 tSirScanOffloadReq *pScanOffloadReq;
1224 uint8_t *p;
1225 uint8_t *ht_cap_ie;
1226 tSirMsgQ msg;
1227 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001228 uint16_t ht_cap_len = 0;
1229 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 uint8_t *vht_cap_ie;
1231 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 tSirRetStatus status, rc = eSIR_SUCCESS;
1233 tDot11fIEExtCap extracted_extcap = {0};
1234 bool extcap_present = true;
1235
1236 if (pScanReq->uIEFieldLen) {
1237 status = lim_strip_extcap_update_struct(pMac,
1238 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1239 &pScanReq->uIEFieldLen, &extracted_extcap);
1240
1241 if (eSIR_SUCCESS != status) {
1242 extcap_present = false;
1243 lim_log(pMac, LOG1,
1244 FL("Unable to Strip ExtCap IE from Scan Req"));
1245 }
1246
1247 if (extcap_present) {
1248 lim_log(pMac, LOG1,
1249 FL("Extcap was part of SCAN IE - Updating FW"));
1250 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1251 &extracted_extcap, true);
1252 }
1253 } else {
1254 lim_log(pMac, LOG1,
1255 FL("No IEs in the scan request from supplicant"));
1256 }
1257
1258 /**
1259 * The tSirScanOffloadReq will reserve the space for first channel,
1260 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1261 */
1262 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001263 (pScanReq->channelList.numChannels - 1) +
1264 pScanReq->uIEFieldLen;
1265 if (!pMac->per_band_chainmask_supp) {
1266 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1267 lim_log(pMac, LOG1, FL(
1268 "Adding HT Caps IE since dot11mode=%d"),
1269 pScanReq->dot11mode);
1270 /* 2 bytes for EID and Length */
1271 ht_cap_len = 2 + sizeof(tHtCaps);
1272 len += ht_cap_len;
1273 addn_ie_len += ht_cap_len;
1274 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001276 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1277 lim_log(pMac, LOG1, FL(
1278 "Adding VHT Caps IE since dot11mode=%d"),
1279 pScanReq->dot11mode);
1280 /* 2 bytes for EID and Length */
1281 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1282 sizeof(tSirVhtMcsInfo);
1283 len += vht_cap_len;
1284 addn_ie_len += vht_cap_len;
1285 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 if (NULL == pScanOffloadReq) {
1289 lim_log(pMac, LOGE,
1290 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301291 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 }
1293
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301294 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295
1296 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1297 msg.bodyptr = pScanOffloadReq;
1298 msg.bodyval = 0;
1299
Anurag Chouhanc5548422016-02-24 18:33:27 +05301300 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301
1302 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1303 lim_log(pMac, LOGE,
1304 FL("Invalid value (%d) for numSsid"),
1305 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301306 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301307 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 }
1309
1310 pScanOffloadReq->numSsid = pScanReq->numSsid;
1311 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1312 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301313 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 (uint8_t *) pScanReq->ssId[i].ssId,
1315 pScanOffloadReq->ssId[i].length);
1316 }
1317
1318 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301319 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 pScanOffloadReq->bssType = pScanReq->bssType;
1321 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1322 pScanOffloadReq->scanType = pScanReq->scanType;
1323 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1324 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1325 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301326 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1327 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301328 pScanOffloadReq->scan_adaptive_dwell_mode =
1329 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330
1331 /* for normal scan, the value for p2pScanType should be 0
1332 always */
1333 if (pScanReq->p2pSearch)
1334 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1335
1336 pScanOffloadReq->sessionId = pScanReq->sessionId;
1337 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001338 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301339 pScanOffloadReq->scan_adaptive_dwell_mode =
1340 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341
1342 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1343 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1344 pScanOffloadReq->sessionId);
1345
1346 pScanOffloadReq->channelList.numChannels =
1347 pScanReq->channelList.numChannels;
1348 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1349 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1350 p[i] = pScanReq->channelList.channelNumber[i];
1351
1352 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1353 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1354 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 pScanOffloadReq->uIEFieldOffset,
1357 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1358 pScanReq->uIEFieldLen);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001359 if (!pMac->per_band_chainmask_supp) {
1360 /* Copy HT Capability info if dot11mode is HT */
1361 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1362 /* Populate EID and Length field here */
1363 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1364 pScanOffloadReq->uIEFieldOffset +
1365 pScanOffloadReq->uIEFieldLen;
1366 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
1367 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1368 *(ht_cap_ie + 1) = ht_cap_len - 2;
1369 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1370 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1371 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001373 /* Copy VHT Capability info if dot11mode is VHT Capable */
1374 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1375 /* Populate EID and Length field here */
1376 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1377 pScanOffloadReq->uIEFieldOffset +
1378 pScanOffloadReq->uIEFieldLen;
1379 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
1380 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1381 *(vht_cap_ie + 1) = vht_cap_len - 2;
1382 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1383 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 rc = wma_post_ctrl_msg(pMac, &msg);
1387 if (rc != eSIR_SUCCESS) {
1388 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301389 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301390 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 }
1392
1393 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1394
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301395 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396}
1397
1398/**
1399 * __lim_process_sme_scan_req() - Process the SME Scan Request
1400 * @mac_ctx: Global MAC Context
1401 * @msg_buf: Buffer which contains the request and pertinent parameters
1402 *
1403 * This function is called to process SME_SCAN_REQ message
1404 * from HDD or upper layer application.
1405 *
1406 * Return: None
1407 */
1408
1409static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1410 uint32_t *msg_buf)
1411{
1412 tpSirSmeScanReq scan_req;
1413 uint8_t valid_req = 0;
1414
1415#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1416 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1417 eSIR_SUCCESS, eSIR_SUCCESS);
1418#endif
1419
1420 scan_req = (tpSirSmeScanReq) msg_buf;
1421 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301422 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 -08001423 scan_req->scan_id, scan_req->channelList.numChannels,
1424 scan_req->minChannelTime, scan_req->maxChannelTime,
1425 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1426 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301427 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1429 /*
1430 * Since scan req always requires a response, we will overwrite response
1431 * required here. This is added esp to take care of the condition where
1432 * in p2p go case, we hold the scan req and insert single NOA. We send
1433 * the held scan request to FW later on getting start NOA ind from FW so
1434 * we lose state of the gLimRspReqd flag for the scan req if any other
1435 * request comes by then. e.g. While unit testing, we found when insert
1436 * single NOA is done, we see a get stats request which turns the flag
1437 * gLimRspReqd to false; now when we actually start the saved scan req
1438 * for init scan after getting NOA started, the gLimRspReqd being a
1439 * global flag is showing false instead of true value for this saved
1440 * scan req. Since all scan reqs coming to lim require a response,
1441 * there is no harm in setting the global flag gLimRspReqd to true here.
1442 */
1443 mac_ctx->lim.gLimRspReqd = true;
1444
1445 /*
1446 * copy the Self MAC address from SmeReq to the globalplace,
1447 * used for sending probe req
1448 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001449 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1450 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1452
1453 if (!valid_req || mac_ctx->lim.scan_disabled) {
1454 lim_log(mac_ctx, LOGE,
1455 FL("Scan disabled %d, Valid Scan Req %d"),
1456 mac_ctx->lim.scan_disabled, valid_req);
1457
1458 if (mac_ctx->lim.gLimRspReqd) {
1459 mac_ctx->lim.gLimRspReqd = false;
1460
1461 lim_send_sme_scan_rsp(mac_ctx,
1462 eSIR_SME_INVALID_PARAMETERS,
1463 scan_req->sessionId,
1464 scan_req->transactionId,
1465 scan_req->scan_id);
1466 }
1467 return;
1468 }
1469
1470 /*
1471 * If scan request is received in idle, joinFailed
1472 * states or in link established state (in STA role)
1473 * or in normal state (in STA-in-IBSS/AP role) with
1474 * 'return fresh scan results' request from HDD or
1475 * it is periodic background scanning request,
1476 * trigger fresh scan request to MLM
1477 */
1478 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1479
1480 mac_ctx->lim.gLim24Band11dScanDone = 0;
1481 mac_ctx->lim.gLim50Band11dScanDone = 0;
1482 mac_ctx->lim.gLimReturnAfterFirstMatch =
1483 scan_req->returnAfterFirstMatch;
1484 mac_ctx->lim.gLimReturnUniqueResults =
1485 ((scan_req->returnUniqueResults) > 0 ? true : false);
1486
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301487 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 lim_send_hal_start_scan_offload_req(mac_ctx,
1489 scan_req)) {
1490 lim_log(mac_ctx, LOGE, FL(
1491 "Couldn't send Offload scan request"));
1492 lim_send_sme_scan_rsp(mac_ctx,
1493 eSIR_SME_INVALID_PARAMETERS,
1494 scan_req->sessionId,
1495 scan_req->transactionId,
1496 scan_req->scan_id);
1497 return;
1498 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301499 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 /* In all other cases return 'cached' scan results */
1501 if (mac_ctx->lim.gLimRspReqd) {
1502 mac_ctx->lim.gLimRspReqd = false;
1503 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1504 scan_req->sessionId,
1505 scan_req->transactionId, scan_req->scan_id);
1506 }
1507 }
1508}
1509
1510#ifdef FEATURE_OEM_DATA_SUPPORT
1511
1512static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1513{
1514 tpSirOemDataReq pOemDataReq;
1515 tLimMlmOemDataReq *pMlmOemDataReq;
1516
1517 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1518
1519 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301520 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 if (NULL == pMlmOemDataReq) {
1522 lim_log(pMac, LOGP,
1523 FL("AllocateMemory failed for mlmOemDataReq"));
1524 return;
1525 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301526 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001527 if (!pMlmOemDataReq->data) {
1528 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301529 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001530 return;
1531 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532
Anurag Chouhanc5548422016-02-24 18:33:27 +05301533 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001534 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001535 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301536 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001537 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001538 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301539 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1541 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1542 (uint32_t *) pMlmOemDataReq);
1543
1544 return;
1545
1546} /*** end __lim_process_sme_oem_data_req() ***/
1547
1548#endif /* FEATURE_OEM_DATA_SUPPORT */
1549
1550/**
1551 * __lim_process_clear_dfs_channel_list()
1552 *
1553 ***FUNCTION:
1554 ***Clear DFS channel list when country is changed/aquired.
1555 .*This message is sent from SME.
1556 *
1557 ***LOGIC:
1558 *
1559 ***ASSUMPTIONS:
1560 *
1561 ***NOTE:
1562 *
1563 * @param pMac Pointer to Global MAC structure
1564 * @param *pMsgBuf A pointer to the SME message buffer
1565 * @return None
1566 */
1567static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1568{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301569 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570}
1571
1572/**
1573 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1574 * @mac_ctx: Pointer to Global MAC structure
1575 * @msg_buf: A pointer to the SME message buffer
1576 *
1577 * This function is called to process SME_JOIN_REQ message
1578 * from HDD or upper layer application.
1579 *
1580 * Return: None
1581 */
1582static void
1583__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1584{
1585 tpSirSmeJoinReq sme_join_req = NULL;
1586 tLimMlmJoinReq *mlm_join_req;
1587 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1588 uint32_t val = 0;
1589 uint16_t n_size;
1590 uint8_t session_id;
1591 tpPESession session = NULL;
1592 uint8_t sme_session_id;
1593 uint16_t sme_transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001594 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 uint16_t ie_len;
1596 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001597 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001598 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599
1600/* FEATURE_WLAN_DIAG_SUPPORT */
1601#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1602 /*
1603 * Not sending any session, since it is not created yet.
1604 * The response whould have correct state.
1605 */
1606 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1607#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 /*
1610 * Expect Join request in idle state.
1611 * Reassociate request is expected in link established state.
1612 */
1613
1614 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1615 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1616 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1617 msg_buf);
1618
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301619 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 if (NULL == sme_join_req) {
1621 lim_log(mac_ctx, LOGP,
1622 FL("AllocateMemory failed for sme_join_req"));
1623 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1624 return;
1625 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301626 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1627 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 n_size);
1629
1630 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1631 /* Received invalid eWNI_SME_JOIN_REQ */
1632 /* Log the event */
1633 lim_log(mac_ctx, LOGW,
1634 FL("SessionId:%d JOIN REQ with invalid data"),
1635 sme_join_req->sessionId);
1636 ret_code = eSIR_SME_INVALID_PARAMETERS;
1637 goto end;
1638 }
1639
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001640 /*
1641 * Update the capability here itself as this is used in
1642 * lim_extract_ap_capability() below. If not updated issues
1643 * like not honoring power constraint on 1st association after
1644 * driver loading might occur.
1645 */
1646 lim_update_rrm_capability(mac_ctx, sme_join_req);
1647
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001648 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001650 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 &session_id);
1652
1653 if (session != NULL) {
1654 lim_log(mac_ctx, LOGE,
1655 FL("Session(%d) Already exists for BSSID: "
1656 MAC_ADDRESS_STR " in limSmeState = %X"),
1657 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001658 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 session->limSmeState);
1660
1661 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1662 session->smeSessionId == sme_join_req->sessionId) {
1663 /*
1664 * Received eWNI_SME_JOIN_REQ for same
1665 * BSS as currently associated.
1666 * Log the event and send success
1667 */
1668 lim_log(mac_ctx, LOGW,
1669 FL("SessionId: %d"), session_id);
1670 lim_log(mac_ctx, LOGW,
1671 FL("JOIN_REQ for current joined BSS"));
1672 /* Send Join success response to host */
1673 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1674 session = NULL;
1675 goto end;
1676 } else {
1677 lim_log(mac_ctx, LOGE,
1678 FL("JOIN_REQ not for current joined BSS"));
1679 ret_code = eSIR_SME_REFUSED;
1680 session = NULL;
1681 goto end;
1682 }
1683 } else {
1684 /*
1685 * Session Entry does not exist for given BSSId
1686 * Try to Create a new session
1687 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001688 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 &session_id, mac_ctx->lim.maxStation,
1690 eSIR_INFRASTRUCTURE_MODE);
1691 if (session == NULL) {
1692 lim_log(mac_ctx, LOGE,
1693 FL("Session Can not be created "));
1694 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1695 goto end;
1696 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301697 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 FL("SessionId:%d New session created"),
1699 session_id);
1700 }
1701 session->isAmsduSupportInAMPDU =
1702 sme_join_req->isAmsduSupportInAMPDU;
1703
1704 /*
1705 * Store Session related parameters
1706 * Store PE session Id in session Table
1707 */
1708 session->peSessionId = session_id;
1709
1710 /* store the smejoin req handle in session table */
1711 session->pLimJoinReq = sme_join_req;
1712
1713 /* Store SME session Id in sessionTable */
1714 session->smeSessionId = sme_join_req->sessionId;
1715
1716 /* Store SME transaction Id in session Table */
1717 session->transactionId = sme_join_req->transactionId;
1718
1719 /* Store beaconInterval */
1720 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001721 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301723 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 sizeof(session->htConfig));
1725
1726 /* Copying of bssId is already done, while creating session */
1727 sir_copy_mac_addr(session->selfMacAddr,
1728 sme_join_req->selfMacAddr);
1729 session->bssType = sme_join_req->bsstype;
1730
1731 session->statypeForBss = STA_ENTRY_PEER;
1732 session->limWmeEnabled = sme_join_req->isWMEenabled;
1733 session->limQosEnabled = sme_join_req->isQosEnabled;
1734
1735 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001736 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1738
1739 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1740 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001741 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742
1743 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001744 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 session->isCiscoVendorAP = true;
1746 } else {
1747 session->isCiscoVendorAP = false;
1748 }
1749
1750 /* Copy the dot 11 mode in to the session table */
1751
1752 session->dot11mode = sme_join_req->dot11mode;
1753#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1754 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1755#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001756 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1758 session->enableHtSmps = sme_join_req->enableHtSmps;
1759 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001760 session->send_smps_action =
1761 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001762 /*
1763 * By default supported NSS 1x1 is set to true
1764 * and later on updated while determining session
1765 * supported rates which is the intersection of
1766 * self and peer rates
1767 */
1768 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301769 /*Store Persona */
1770 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001771 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301772 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001773 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001774 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001775 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301776 session->supported_nss_1x1,
1777 session->pePersona,
1778 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001779
1780 /*Store Persona */
1781 session->pePersona = sme_join_req->staPersona;
1782 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1783 FL("PE PERSONA=%d cbMode %u"),
1784 session->pePersona, sme_join_req->cbMode);
1785 /* Copy The channel Id to the session Table */
1786 session->currentOperChannel = bss_desc->channelId;
1787 if (IS_5G_CH(session->currentOperChannel))
1788 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001790 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1791 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1792 session->vdev_nss = vdev_type_nss->p2p_cli;
1793 else
1794 session->vdev_nss = vdev_type_nss->sta;
1795 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 session->vhtCapability =
1797 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301799 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 session->txBFIniFeatureEnabled =
1801 sme_join_req->txBFIniFeatureEnabled;
1802 } else {
1803 session->txBFIniFeatureEnabled = 0;
1804 }
1805 session->txMuBformee = sme_join_req->txMuBformee;
1806 session->enableVhtpAid =
1807 sme_join_req->enableVhtpAid;
1808 session->enableVhtGid =
1809 sme_join_req->enableVhtGid;
1810
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 if (wlan_cfg_get_int(mac_ctx,
1812 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1813 eSIR_SUCCESS)
1814 lim_log(mac_ctx, LOGE, FL(
1815 "cfg get vht su bformer failed"));
1816
1817 session->enable_su_tx_bformer = val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 }
1819 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1820 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1821 session->txBFIniFeatureEnabled) !=
1822 eSIR_SUCCESS) {
1823 /*
1824 * Set failed for
1825 * CFG_VHT_SU_BEAMFORMEE_CAP
1826 */
1827 lim_log(mac_ctx, LOGP,
1828 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1829 ret_code = eSIR_LOGP_EXCEPTION;
1830 goto end;
1831 }
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001832 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 }
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301834 lim_log(mac_ctx, LOG1,
1835 FL("vhtCapability: %d txBFIniFeatureEnabled: %d txbf_csn_value: %d su_tx_bformer %d"),
1836 session->vhtCapability,
1837 session->txBFIniFeatureEnabled,
1838 session->txbf_csn_value,
1839 session->enable_su_tx_bformer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001841 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 /* cbMode is already merged value of peer and self -
1844 * done by csr in csr_get_cb_mode_from_ies */
1845 session->htSupportedChannelWidthSet =
1846 (sme_join_req->cbMode) ? 1 : 0;
1847 session->htRecommendedTxWidthSet =
1848 session->htSupportedChannelWidthSet;
1849 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1850
1851 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1852 session->ch_center_freq_seg0 =
1853 session->currentOperChannel - 2;
1854 session->ch_width = CH_WIDTH_40MHZ;
1855 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1856 sme_join_req->cbMode) {
1857 session->ch_center_freq_seg0 =
1858 session->currentOperChannel + 2;
1859 session->ch_width = CH_WIDTH_40MHZ;
1860 } else {
1861 session->ch_center_freq_seg0 = 0;
1862 session->ch_width = CH_WIDTH_20MHZ;
1863 }
1864
1865 /* Record if management frames need to be protected */
1866#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001867 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001869 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871#endif
1872
1873#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001874 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875#endif
1876
1877 /* Copy the SSID from smejoinreq to session entry */
1878 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301879 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 session->ssId.length);
1881
1882 /*
1883 * Determin 11r or ESE connection based on input from SME
1884 * which inturn is dependent on the profile the user wants
1885 * to connect to, So input is coming from supplicant
1886 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888#ifdef FEATURE_WLAN_ESE
1889 session->isESEconnection = sme_join_req->isESEconnection;
1890#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 session->isFastTransitionEnabled =
1892 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 session->isFastRoamIniFeatureEnabled =
1895 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 session->txLdpcIniFeatureEnabled =
1897 sme_join_req->txLdpcIniFeatureEnabled;
1898
1899 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1900 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 } else {
1902 /*
1903 * Throw an error and return and make
1904 * sure to delete the session.
1905 */
1906 lim_log(mac_ctx, LOGE,
1907 FL("recvd JOIN_REQ with invalid bss type %d"),
1908 session->bssType);
1909 ret_code = eSIR_SME_INVALID_PARAMETERS;
1910 goto end;
1911 }
1912
1913 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301914 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 &sme_join_req->addIEScan, sizeof(tSirAddie));
1916
1917 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301918 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1920
1921 val = sizeof(tLimMlmJoinReq) +
1922 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301923 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 if (NULL == mlm_join_req) {
1925 lim_log(mac_ctx, LOGP,
1926 FL("AllocateMemory failed for mlmJoinReq"));
1927 return;
1928 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301929 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930
1931 /* PE SessionId is stored as a part of JoinReq */
1932 mlm_join_req->sessionId = session->peSessionId;
1933
1934 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1935 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1936 eSIR_SUCCESS) {
1937 lim_log(mac_ctx, LOGP,
1938 FL("couldn't retrieve JoinFailureTimer value"
1939 " setting to default value"));
1940 mlm_join_req->joinFailureTimeout =
1941 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1942 }
1943
1944 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301945 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 (void *)&sme_join_req->operationalRateSet,
1947 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301948 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 (void *)&sme_join_req->extendedRateSet,
1950 sizeof(tSirMacRateSet));
1951 /*
1952 * this may not be needed anymore now, as rateSet is now
1953 * included in the session entry and MLM has session context.
1954 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301955 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 (void *)&session->rateSet,
1957 sizeof(tSirMacRateSet));
1958
1959 session->encryptType = sme_join_req->UCEncryptionType;
1960
1961 mlm_join_req->bssDescription.length =
1962 session->pLimJoinReq->bssDescription.length;
1963
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301964 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 (uint8_t *)
1966 &session->pLimJoinReq->bssDescription.bssId,
1967 session->pLimJoinReq->bssDescription.length + 2);
1968
1969 session->limCurrentBssCaps =
1970 session->pLimJoinReq->bssDescription.capabilityInfo;
1971
1972 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1973 session->currentOperChannel);
1974 local_power_constraint = reg_max;
1975
1976 lim_extract_ap_capability(mac_ctx,
1977 (uint8_t *)
1978 session->pLimJoinReq->bssDescription.ieFields,
1979 lim_get_ielen_from_bss_description(
1980 &session->pLimJoinReq->bssDescription),
1981 &session->limCurrentBssQosCaps,
1982 &session->limCurrentBssPropCap,
1983 &session->gLimCurrentBssUapsd,
1984 &local_power_constraint, session);
1985
1986#ifdef FEATURE_WLAN_ESE
1987 session->maxTxPower = lim_get_max_tx_power(reg_max,
1988 local_power_constraint,
1989 mac_ctx->roam.configParam.nTxPowerCap);
1990#else
1991 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301992 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301994 lim_log(mac_ctx, LOG1,
1995 FL("Reg max = %d, local power con = %d, max tx = %d"),
1996 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997
1998 if (session->gLimCurrentBssUapsd) {
1999 session->gUapsdPerAcBitmask =
2000 session->pLimJoinReq->uapsdPerAcBitmask;
2001 lim_log(mac_ctx, LOG1,
2002 FL("UAPSD flag for all AC - 0x%2x"),
2003 session->gUapsdPerAcBitmask);
2004
2005 /* resetting the dynamic uapsd mask */
2006 session->gUapsdPerAcDeliveryEnableMask = 0;
2007 session->gUapsdPerAcTriggerEnableMask = 0;
2008 }
2009
2010 session->limRFBand =
2011 lim_get_rf_band(session->currentOperChannel);
2012
2013 /* Initialize 11h Enable Flag */
2014 if (SIR_BAND_5_GHZ == session->limRFBand) {
2015 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
2016 &val) != eSIR_SUCCESS) {
2017 lim_log(mac_ctx, LOGP,
2018 FL("Fail to get WNI_CFG_11H_ENABLED "));
2019 session->lim11hEnable =
2020 WNI_CFG_11H_ENABLED_STADEF;
2021 } else {
2022 session->lim11hEnable = val;
2023 }
2024 } else {
2025 session->lim11hEnable = 0;
2026 }
2027
2028 /*
2029 * To care of the scenario when STA transitions from
2030 * IBSS to Infrastructure mode.
2031 */
2032 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2033
2034 session->limPrevSmeState = session->limSmeState;
2035 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2036 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2037 session->peSessionId,
2038 session->limSmeState));
2039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 /* Indicate whether spectrum management is enabled */
2041 session->spectrumMgtEnabled =
2042 sme_join_req->spectrumMgtIndicator;
2043
2044 /* Enable the spectrum management if this is a DFS channel */
2045 if (session->country_info_present &&
2046 lim_isconnected_on_dfs_channel(
2047 session->currentOperChannel))
2048 session->spectrumMgtEnabled = true;
2049
2050 session->isOSENConnection = sme_join_req->isOSENConnection;
2051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 /* Issue LIM_MLM_JOIN_REQ to MLM */
2053 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2054 (uint32_t *) mlm_join_req);
2055 return;
2056
2057 } else {
2058 /* Received eWNI_SME_JOIN_REQ un expected state */
2059 lim_log(mac_ctx, LOGE,
2060 FL("received unexpected SME_JOIN_REQ in state %X"),
2061 mac_ctx->lim.gLimSmeState);
2062 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2063 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2064 session = NULL;
2065 goto end;
2066 }
2067
2068end:
2069 sme_session_id = sme_join_req->sessionId;
2070 sme_transaction_id = sme_join_req->transactionId;
2071
2072 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302073 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 sme_join_req = NULL;
2075 if (NULL != session)
2076 session->pLimJoinReq = NULL;
2077 }
2078 if (ret_code != eSIR_SME_SUCCESS) {
2079 if (NULL != session) {
2080 pe_delete_session(mac_ctx, session);
2081 session = NULL;
2082 }
2083 }
2084 lim_log(mac_ctx, LOG1,
2085 FL("Send failure status on sessionid: %d with ret_code = %d"),
2086 sme_session_id, ret_code);
2087 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2088 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2089 sme_transaction_id);
2090}
2091
Amar Singhala297bfa2015-10-15 15:07:29 -07002092uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 uint8_t iniTxPower)
2094{
2095 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302096 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2097 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2099 maxTxPower = txPower;
2100 else if (txPower < MIN_TX_PWR_CAP)
2101 maxTxPower = MIN_TX_PWR_CAP;
2102 else
2103 maxTxPower = MAX_TX_PWR_CAP;
2104
2105 return maxTxPower;
2106}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107
2108/**
2109 * __lim_process_sme_reassoc_req() - process reassoc req
2110 *
2111 * @mac_ctx: Pointer to Global MAC structure
2112 * @msg_buf: pointer to the SME message buffer
2113 *
2114 * This function is called to process SME_REASSOC_REQ message
2115 * from HDD or upper layer application.
2116 *
2117 * Return: None
2118 */
2119
2120static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2121 uint32_t *msg_buf)
2122{
2123 uint16_t caps;
2124 uint32_t val;
2125 tpSirSmeJoinReq reassoc_req = NULL;
2126 tLimMlmReassocReq *mlm_reassoc_req;
2127 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2128 tpPESession session_entry = NULL;
2129 uint8_t session_id;
2130 uint8_t sme_session_id;
2131 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002132 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 uint32_t tele_bcn_en = 0;
2134 uint16_t size;
2135
2136 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2137
2138 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302139 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 if (NULL == reassoc_req) {
2141 lim_log(mac_ctx, LOGP,
2142 FL("call to AllocateMemory failed for reassoc_req"));
2143
2144 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2145 goto end;
2146 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302147 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2148 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149
2150 if (!lim_is_sme_join_req_valid(mac_ctx,
2151 (tpSirSmeJoinReq)reassoc_req)) {
2152 /*
2153 * Received invalid eWNI_SME_REASSOC_REQ
2154 */
2155 lim_log(mac_ctx, LOGW,
2156 FL("received SME_REASSOC_REQ with invalid data"));
2157
2158 ret_code = eSIR_SME_INVALID_PARAMETERS;
2159 goto end;
2160 }
2161
2162 session_entry = pe_find_session_by_bssid(mac_ctx,
2163 reassoc_req->bssDescription.bssId,
2164 &session_id);
2165 if (session_entry == NULL) {
2166 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2167 LOGE);
2168 lim_log(mac_ctx, LOGE,
2169 FL("Session does not exist for given bssId"));
2170 ret_code = eSIR_SME_INVALID_PARAMETERS;
2171 goto end;
2172 }
2173#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2174 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2175 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2176#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2177 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2178
2179 /* Store the reassoc handle in the session Table */
2180 session_entry->pLimReAssocReq = reassoc_req;
2181
2182 session_entry->dot11mode = reassoc_req->dot11mode;
2183 session_entry->vhtCapability =
2184 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002185
2186 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2187 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002188 session_entry->send_smps_action =
2189 reassoc_req->send_smps_action;
2190 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002191 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002192 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002193 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002194 session_entry->send_smps_action,
2195 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 /*
2197 * Reassociate request is expected
2198 * in link established state only.
2199 */
2200
2201 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2203 /*
2204 * May be from 11r FT pre-auth. So lets check it
2205 * before we bail out
2206 */
2207 lim_log(mac_ctx, LOG1, FL(
2208 "Session in reassoc state is %d"),
2209 session_entry->peSessionId);
2210
2211 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 session_entry->limReAssocbssId,
2214 6)) {
2215 lim_print_mac_addr(mac_ctx,
2216 reassoc_req->bssDescription.
2217 bssId, LOGE);
2218 lim_log(mac_ctx, LOGP,
2219 FL("Unknown bssId in reassoc state"));
2220 ret_code = eSIR_SME_INVALID_PARAMETERS;
2221 goto end;
2222 }
2223
2224 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2225 session_entry);
2226 return;
2227 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 /*
2229 * Should not have received eWNI_SME_REASSOC_REQ
2230 */
2231 lim_log(mac_ctx, LOGE,
2232 FL("received unexpected SME_REASSOC_REQ in state %X"),
2233 session_entry->limSmeState);
2234 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2235
2236 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2237 goto end;
2238 }
2239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302240 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 session_entry->pLimReAssocReq->bssDescription.bssId,
2242 sizeof(tSirMacAddr));
2243
2244 session_entry->limReassocChannelId =
2245 session_entry->pLimReAssocReq->bssDescription.channelId;
2246
2247 session_entry->reAssocHtSupportedChannelWidthSet =
2248 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2249 session_entry->reAssocHtRecommendedTxWidthSet =
2250 session_entry->reAssocHtSupportedChannelWidthSet;
2251 session_entry->reAssocHtSecondaryChannelOffset =
2252 session_entry->pLimReAssocReq->cbMode;
2253
2254 session_entry->limReassocBssCaps =
2255 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2256 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2257 session_entry->currentOperChannel);
2258 local_pwr_constraint = reg_max;
2259
2260 lim_extract_ap_capability(mac_ctx,
2261 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2262 lim_get_ielen_from_bss_description(
2263 &session_entry->pLimReAssocReq->bssDescription),
2264 &session_entry->limReassocBssQosCaps,
2265 &session_entry->limReassocBssPropCap,
2266 &session_entry->gLimCurrentBssUapsd,
2267 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302268 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302270 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2271 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 /* Copy the SSID from session entry to local variable */
2273 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302274 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 reassoc_req->ssId.ssId,
2276 session_entry->limReassocSSID.length);
2277 if (session_entry->gLimCurrentBssUapsd) {
2278 session_entry->gUapsdPerAcBitmask =
2279 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2280 lim_log(mac_ctx, LOG1,
2281 FL("UAPSD flag for all AC - 0x%2x"),
2282 session_entry->gUapsdPerAcBitmask);
2283 }
2284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302285 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 if (NULL == mlm_reassoc_req) {
2287 lim_log(mac_ctx, LOGP,
2288 FL("call to AllocateMemory failed for mlmReassocReq"));
2289
2290 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2291 goto end;
2292 }
2293
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302294 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2296
2297 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2298 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2299 eSIR_SUCCESS) {
2300 /*
2301 * Could not get ReassocFailureTimeout value
2302 * from CFG. Log error.
2303 */
2304 lim_log(mac_ctx, LOGP,
2305 FL("could not retrieve ReassocFailureTimeout value"));
2306 }
2307
2308 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2309 eSIR_SUCCESS) {
2310 /*
2311 * Could not get Capabilities value
2312 * from CFG. Log error.
2313 */
2314 lim_log(mac_ctx, LOGP, FL(
2315 "could not retrieve Capabilities value"));
2316 }
2317 mlm_reassoc_req->capabilityInfo = caps;
2318
2319 /* Update PE session_id */
2320 mlm_reassoc_req->sessionId = session_id;
2321
2322 /*
2323 * If telescopic beaconing is enabled, set listen interval to
2324 * WNI_CFG_TELE_BCN_MAX_LI
2325 */
2326 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2327 &tele_bcn_en) != eSIR_SUCCESS)
2328 lim_log(mac_ctx, LOGP,
2329 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2330
2331 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2332
2333 if (tele_bcn_en) {
2334 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2335 eSIR_SUCCESS)
2336 /*
2337 * Could not get ListenInterval value
2338 * from CFG. Log error.
2339 */
2340 lim_log(mac_ctx, LOGP,
2341 FL("could not retrieve ListenInterval"));
2342 } else {
2343 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2344 eSIR_SUCCESS)
2345 /*
2346 * Could not get ListenInterval value
2347 * from CFG. Log error.
2348 */
2349 lim_log(mac_ctx, LOGP,
2350 FL("could not retrieve ListenInterval"));
2351 }
2352
2353 mlm_reassoc_req->listenInterval = (uint16_t) val;
2354
2355 /* Indicate whether spectrum management is enabled */
2356 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2357
2358 /* Enable the spectrum management if this is a DFS channel */
2359 if (session_entry->country_info_present &&
2360 lim_isconnected_on_dfs_channel(
2361 session_entry->currentOperChannel))
2362 session_entry->spectrumMgtEnabled = true;
2363
2364 session_entry->limPrevSmeState = session_entry->limSmeState;
2365 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2366
2367 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2368 session_entry->peSessionId,
2369 session_entry->limSmeState));
2370
2371 lim_post_mlm_message(mac_ctx,
2372 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2373 return;
2374end:
2375 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302376 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 if (session_entry)
2378 session_entry->pLimReAssocReq = NULL;
2379 }
2380
2381 if (session_entry) {
2382 /*
2383 * error occurred after we determined the session so extract
2384 * session and transaction info from there
2385 */
2386 sme_session_id = session_entry->smeSessionId;
2387 transaction_id = session_entry->transactionId;
2388 } else
2389 /*
2390 * error occurred before or during the time we determined
2391 * the session so extract the session and transaction info
2392 * from the message
2393 */
2394 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2395 &sme_session_id, &transaction_id);
2396
2397 /*
2398 * Send Reassoc failure response to host
2399 * (note session_entry may be NULL, but that's OK)
2400 */
2401 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2402 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2403 session_entry, sme_session_id,
2404 transaction_id);
2405}
2406
2407bool send_disassoc_frame = 1;
2408/**
2409 * __lim_process_sme_disassoc_req()
2410 *
2411 ***FUNCTION:
2412 * This function is called to process SME_DISASSOC_REQ message
2413 * from HDD or upper layer application.
2414 *
2415 ***LOGIC:
2416 *
2417 ***ASSUMPTIONS:
2418 *
2419 ***NOTE:
2420 *
2421 * @param pMac Pointer to Global MAC structure
2422 * @param *pMsgBuf A pointer to the SME message buffer
2423 * @return None
2424 */
2425
2426static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2427{
2428 uint16_t disassocTrigger, reasonCode;
2429 tLimMlmDisassocReq *pMlmDisassocReq;
2430 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2431 tSirSmeDisassocReq smeDisassocReq;
2432 tpPESession psessionEntry = NULL;
2433 uint8_t sessionId;
2434 uint8_t smesessionId;
2435 uint16_t smetransactionId;
2436
2437 if (pMsgBuf == NULL) {
2438 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2439 return;
2440 }
2441
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302442 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 smesessionId = smeDisassocReq.sessionId;
2444 smetransactionId = smeDisassocReq.transactionId;
2445 if (!lim_is_sme_disassoc_req_valid(pMac,
2446 &smeDisassocReq,
2447 psessionEntry)) {
2448 PELOGE(lim_log(pMac, LOGE,
2449 FL("received invalid SME_DISASSOC_REQ message"));)
2450 if (pMac->lim.gLimRspReqd) {
2451 pMac->lim.gLimRspReqd = false;
2452
2453 retCode = eSIR_SME_INVALID_PARAMETERS;
2454 disassocTrigger = eLIM_HOST_DISASSOC;
2455 goto sendDisassoc;
2456 }
2457
2458 return;
2459 }
2460
2461 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002462 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 &sessionId);
2464 if (psessionEntry == NULL) {
2465 lim_log(pMac, LOGE,
2466 FL("session does not exist for given bssId "
2467 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002468 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 retCode = eSIR_SME_INVALID_PARAMETERS;
2470 disassocTrigger = eLIM_HOST_DISASSOC;
2471 goto sendDisassoc;
2472 }
2473 lim_log(pMac, LOG1,
2474 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2475 MAC_ADDRESS_STR), smesessionId,
2476 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2477 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002478 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479
2480#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2481 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2482 0, smeDisassocReq.reasonCode);
2483#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2484
2485 /* Update SME session Id and SME transaction ID */
2486
2487 psessionEntry->smeSessionId = smesessionId;
2488 psessionEntry->transactionId = smetransactionId;
2489
2490 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2491 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 switch (psessionEntry->limSmeState) {
2493 case eLIM_SME_ASSOCIATED_STATE:
2494 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002495 lim_log(pMac, LOG1,
2496 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2497 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 psessionEntry->limPrevSmeState =
2499 psessionEntry->limSmeState;
2500 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2501#ifdef FEATURE_WLAN_TDLS
2502 /* Delete all TDLS peers connected before leaving BSS */
2503 lim_delete_tdls_peers(pMac, psessionEntry);
2504#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002505 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2506 psessionEntry->peSessionId,
2507 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 break;
2509
2510 case eLIM_SME_WT_DEAUTH_STATE:
2511 /* PE shall still process the DISASSOC_REQ and proceed with
2512 * link tear down even if it had already sent a DEAUTH_IND to
2513 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2514 * its been set when PE entered WT_DEAUTH_STATE.
2515 */
2516 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2517 MTRACE(mac_trace
2518 (pMac, TRACE_CODE_SME_STATE,
2519 psessionEntry->peSessionId,
2520 psessionEntry->limSmeState));
2521 lim_log(pMac, LOG1,
2522 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2523 break;
2524
2525 case eLIM_SME_WT_DISASSOC_STATE:
2526 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2527 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2528 * PE can continue processing DISASSOC_REQ and send the response instead
2529 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2530 * for disassoc frame.
2531 *
2532 * It will send a disassoc, which is ok. However, we can use the global flag
2533 * sendDisassoc to not send disassoc frame.
2534 */
2535 lim_log(pMac, LOG1,
2536 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2537 break;
2538
2539 case eLIM_SME_JOIN_FAILURE_STATE: {
2540 /* Already in Disconnected State, return success */
2541 lim_log(pMac, LOG1,
2542 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2543 if (pMac->lim.gLimRspReqd) {
2544 retCode = eSIR_SME_SUCCESS;
2545 disassocTrigger = eLIM_HOST_DISASSOC;
2546 goto sendDisassoc;
2547 }
2548 }
2549 break;
2550 default:
2551 /**
2552 * STA is not currently associated.
2553 * Log error and send response to host
2554 */
2555 lim_log(pMac, LOGE,
2556 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2557 psessionEntry->limSmeState);
2558 lim_print_sme_state(pMac, LOGE,
2559 psessionEntry->limSmeState);
2560
2561 if (pMac->lim.gLimRspReqd) {
2562 if (psessionEntry->limSmeState !=
2563 eLIM_SME_WT_ASSOC_STATE)
2564 pMac->lim.gLimRspReqd = false;
2565
2566 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2567 disassocTrigger = eLIM_HOST_DISASSOC;
2568 goto sendDisassoc;
2569 }
2570
2571 return;
2572 }
2573
2574 break;
2575
2576 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 /* Fall through */
2578 break;
2579
2580 case eLIM_STA_IN_IBSS_ROLE:
2581 default:
2582 /* eLIM_UNKNOWN_ROLE */
2583 lim_log(pMac, LOGE,
2584 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2585 GET_LIM_SYSTEM_ROLE(psessionEntry));
2586
2587 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2588 disassocTrigger = eLIM_HOST_DISASSOC;
2589 goto sendDisassoc;
2590 } /* end switch (pMac->lim.gLimSystemRole) */
2591
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302592 disassocTrigger = eLIM_HOST_DISASSOC;
2593 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594
2595 if (smeDisassocReq.doNotSendOverTheAir) {
2596 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2597 send_disassoc_frame = 0;
2598 }
2599 /* Trigger Disassociation frame to peer MAC entity */
2600 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2601 " : %d, reasonCode : %d"),
2602 disassocTrigger, reasonCode);
2603
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302604 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 if (NULL == pMlmDisassocReq) {
2606 /* Log error */
2607 lim_log(pMac, LOGP,
2608 FL("call to AllocateMemory failed for mlmDisassocReq"));
2609
2610 return;
2611 }
2612
Anurag Chouhanc5548422016-02-24 18:33:27 +05302613 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002614 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615
2616 pMlmDisassocReq->reasonCode = reasonCode;
2617 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2618
2619 /* Update PE session ID */
2620 pMlmDisassocReq->sessionId = sessionId;
2621
2622 lim_post_mlm_message(pMac,
2623 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2624 return;
2625
2626sendDisassoc:
2627 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002628 lim_send_sme_disassoc_ntf(pMac,
2629 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 retCode,
2631 disassocTrigger,
2632 1, smesessionId, smetransactionId,
2633 psessionEntry);
2634 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002635 lim_send_sme_disassoc_ntf(pMac,
2636 smeDisassocReq.peer_macaddr.bytes,
2637 retCode, disassocTrigger, 1,
2638 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639
2640} /*** end __lim_process_sme_disassoc_req() ***/
2641
2642/** -----------------------------------------------------------------
2643 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2644
2645 This function is called to process SME_DISASSOC_CNF message
2646 from HDD or upper layer application.
2647
2648 \param pMac - global mac structure
2649 \param pStaDs - station dph hash node
2650 \return none
2651 \sa
2652 ----------------------------------------------------------------- */
2653static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2654{
2655 tSirSmeDisassocCnf smeDisassocCnf;
2656 uint16_t aid;
2657 tpDphHashNode pStaDs;
2658 tpPESession psessionEntry;
2659 uint8_t sessionId;
2660
2661 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2662
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 sizeof(struct sSirSmeDisassocCnf));
2665
2666 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002667 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 &sessionId);
2669 if (psessionEntry == NULL) {
2670 lim_log(pMac, LOGE,
2671 FL("session does not exist for given bssId"));
2672 return;
2673 }
2674
2675 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2676 lim_log(pMac, LOGE,
2677 FL("received invalid SME_DISASSOC_CNF message"));
2678 return;
2679 }
2680#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2681 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2682 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2683 psessionEntry,
2684 (uint16_t) smeDisassocCnf.statusCode, 0);
2685 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2686 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2687 psessionEntry,
2688 (uint16_t) smeDisassocCnf.statusCode, 0);
2689#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2690
2691 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2692 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2694 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2695 && (psessionEntry->limSmeState !=
2696 eLIM_SME_WT_DEAUTH_STATE)) {
2697 lim_log(pMac, LOGE,
2698 FL
2699 ("received unexp SME_DISASSOC_CNF in state %X"),
2700 psessionEntry->limSmeState);
2701 lim_print_sme_state(pMac, LOGE,
2702 psessionEntry->limSmeState);
2703 return;
2704 }
2705 break;
2706
2707 case eLIM_AP_ROLE:
2708 /* Fall through */
2709 break;
2710
2711 case eLIM_STA_IN_IBSS_ROLE:
2712 default: /* eLIM_UNKNOWN_ROLE */
2713 lim_log(pMac, LOGE,
2714 FL("received unexpected SME_DISASSOC_CNF role %d"),
2715 GET_LIM_SYSTEM_ROLE(psessionEntry));
2716
2717 return;
2718 }
2719
2720 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2721 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2722 LIM_IS_AP_ROLE(psessionEntry)) {
2723 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002724 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 &psessionEntry->dph.dphHashTable);
2726 if (pStaDs == NULL) {
2727 lim_log(pMac, LOGE,
2728 FL("DISASSOC_CNF for a STA with no context, addr= "
2729 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002730 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 return;
2732 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302733
2734 if ((pStaDs->mlmStaContext.mlmState ==
2735 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2736 (pStaDs->mlmStaContext.mlmState ==
2737 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2738 lim_log(pMac, LOGE,
2739 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002740 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302741 pStaDs->mlmStaContext.mlmState);
2742 return;
2743 }
2744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 /* Delete FT session if there exists one */
2746 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2748
2749 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002750 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 }
2752
2753 return;
2754}
2755
2756/**
2757 * __lim_process_sme_deauth_req() - process sme deauth req
2758 * @mac_ctx: Pointer to Global MAC structure
2759 * @msg_buf: pointer to the SME message buffer
2760 *
2761 * This function is called to process SME_DEAUTH_REQ message
2762 * from HDD or upper layer application.
2763 *
2764 * Return: None
2765 */
2766
2767static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2768 uint32_t *msg_buf)
2769{
2770 uint16_t deauth_trigger, reason_code;
2771 tLimMlmDeauthReq *mlm_deauth_req;
2772 tSirSmeDeauthReq sme_deauth_req;
2773 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2774 tpPESession session_entry;
2775 uint8_t session_id; /* PE sessionId */
2776 uint8_t sme_session_id;
2777 uint16_t sme_transaction_id;
2778
2779 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2780
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302781 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 sme_session_id = sme_deauth_req.sessionId;
2783 sme_transaction_id = sme_deauth_req.transactionId;
2784
2785 /*
2786 * We need to get a session first but we don't even know
2787 * if the message is correct.
2788 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002789 session_entry = pe_find_session_by_bssid(mac_ctx,
2790 sme_deauth_req.bssid.bytes,
2791 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 if (session_entry == NULL) {
2793 lim_log(mac_ctx, LOGE,
2794 FL("session does not exist for given bssId"));
2795 ret_code = eSIR_SME_INVALID_PARAMETERS;
2796 deauth_trigger = eLIM_HOST_DEAUTH;
2797 goto send_deauth;
2798 }
2799
2800 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2801 session_entry)) {
2802 lim_log(mac_ctx, LOGE,
2803 FL("received invalid SME_DEAUTH_REQ message"));
2804 mac_ctx->lim.gLimRspReqd = false;
2805
2806 ret_code = eSIR_SME_INVALID_PARAMETERS;
2807 deauth_trigger = eLIM_HOST_DEAUTH;
2808 goto send_deauth;
2809 }
2810 lim_log(mac_ctx, LOG1,
2811 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2812 MAC_ADDRESS_STR), sme_session_id,
2813 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2814 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002815 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2817 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2818 session_entry, 0, sme_deauth_req.reasonCode);
2819#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2820
2821 /* Update SME session ID and Transaction ID */
2822 session_entry->smeSessionId = sme_session_id;
2823 session_entry->transactionId = sme_transaction_id;
2824
2825 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2826 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 switch (session_entry->limSmeState) {
2828 case eLIM_SME_ASSOCIATED_STATE:
2829 case eLIM_SME_LINK_EST_STATE:
2830 case eLIM_SME_WT_ASSOC_STATE:
2831 case eLIM_SME_JOIN_FAILURE_STATE:
2832 case eLIM_SME_IDLE_STATE:
2833 session_entry->limPrevSmeState =
2834 session_entry->limSmeState;
2835 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2836 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2837 session_entry->peSessionId,
2838 session_entry->limSmeState));
2839 /* Send Deauthentication request to MLM below */
2840 break;
2841 case eLIM_SME_WT_DEAUTH_STATE:
2842 case eLIM_SME_WT_DISASSOC_STATE:
2843 /*
2844 * PE Recieved a Deauth/Disassoc frame. Normally it get
2845 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2846 * Which means host is also trying to disconnect.
2847 * PE can continue processing DEAUTH_REQ and send
2848 * the response instead of failing the request.
2849 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2850 * was sent for deauth/disassoc frame.
2851 */
2852 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2853 lim_log(mac_ctx, LOG1, FL(
2854 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2855 break;
2856 default:
2857 /*
2858 * STA is not in a state to deauthenticate with
2859 * peer. Log error and send response to host.
2860 */
2861 lim_log(mac_ctx, LOGE, FL(
2862 "received unexp SME_DEAUTH_REQ in state %X"),
2863 session_entry->limSmeState);
2864 lim_print_sme_state(mac_ctx, LOGE,
2865 session_entry->limSmeState);
2866
2867 if (mac_ctx->lim.gLimRspReqd) {
2868 mac_ctx->lim.gLimRspReqd = false;
2869
2870 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2871 deauth_trigger = eLIM_HOST_DEAUTH;
2872
2873 /*
2874 * here we received deauth request from AP so sme state
2875 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2876 * delSta then mlm state should be
2877 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2878 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2879 * so the below condition captures the state where
2880 * delSta not done and firmware still in
2881 * connected state.
2882 */
2883 if (session_entry->limSmeState ==
2884 eLIM_SME_WT_DEAUTH_STATE &&
2885 session_entry->limMlmState !=
2886 eLIM_MLM_IDLE_STATE &&
2887 session_entry->limMlmState !=
2888 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2889 ret_code = eSIR_SME_DEAUTH_STATUS;
2890 goto send_deauth;
2891 }
2892 return;
2893 }
2894 break;
2895
2896 case eLIM_STA_IN_IBSS_ROLE:
2897 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2898 if (mac_ctx->lim.gLimRspReqd) {
2899 mac_ctx->lim.gLimRspReqd = false;
2900 ret_code = eSIR_SME_INVALID_PARAMETERS;
2901 deauth_trigger = eLIM_HOST_DEAUTH;
2902 goto send_deauth;
2903 }
2904 return;
2905 case eLIM_AP_ROLE:
2906 break;
2907 default:
2908 lim_log(mac_ctx, LOGE,
2909 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2910 GET_LIM_SYSTEM_ROLE(session_entry));
2911 if (mac_ctx->lim.gLimRspReqd) {
2912 mac_ctx->lim.gLimRspReqd = false;
2913 ret_code = eSIR_SME_INVALID_PARAMETERS;
2914 deauth_trigger = eLIM_HOST_DEAUTH;
2915 goto send_deauth;
2916 }
2917 return;
2918 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2919
2920 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2921 /* Deauthentication is triggered by Link Monitoring */
2922 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2923 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2924 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2925 } else {
2926 deauth_trigger = eLIM_HOST_DEAUTH;
2927 reason_code = sme_deauth_req.reasonCode;
2928 }
2929
2930 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302931 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 if (NULL == mlm_deauth_req) {
2933 lim_log(mac_ctx, LOGP,
2934 FL("call to AllocateMemory failed for mlmDeauthReq"));
2935 if (mac_ctx->lim.gLimRspReqd) {
2936 mac_ctx->lim.gLimRspReqd = false;
2937 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2938 deauth_trigger = eLIM_HOST_DEAUTH;
2939 goto send_deauth;
2940 }
2941 return;
2942 }
2943
Anurag Chouhanc5548422016-02-24 18:33:27 +05302944 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002945 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946
2947 mlm_deauth_req->reasonCode = reason_code;
2948 mlm_deauth_req->deauthTrigger = deauth_trigger;
2949
2950 /* Update PE session Id */
2951 mlm_deauth_req->sessionId = session_id;
2952
2953 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2954 (uint32_t *)mlm_deauth_req);
2955 return;
2956
2957send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002958 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2959 ret_code, deauth_trigger, 1,
2960 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961}
2962
2963/**
2964 * __lim_process_sme_set_context_req()
2965 *
2966 * @mac_ctx: Pointer to Global MAC structure
2967 * @msg_buf: pointer to the SME message buffer
2968 *
2969 * This function is called to process SME_SETCONTEXT_REQ message
2970 * from HDD or upper layer application.
2971 *
2972 * Return: None
2973 */
2974
2975static void
2976__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2977{
2978 tpSirSmeSetContextReq set_context_req;
2979 tLimMlmSetKeysReq *mlm_set_key_req;
2980 tpPESession session_entry;
2981 uint8_t session_id; /* PE sessionID */
2982 uint8_t sme_session_id;
2983 uint16_t sme_transaction_id;
2984
2985 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2986
2987 if (msg_buf == NULL) {
2988 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2989 return;
2990 }
2991
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302992 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 if (NULL == set_context_req) {
2994 lim_log(mac_ctx, LOGP, FL(
2995 "call to AllocateMemory failed for set_context_req"));
2996 return;
2997 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302998 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999 sizeof(struct sSirSmeSetContextReq));
3000 sme_session_id = set_context_req->sessionId;
3001 sme_transaction_id = set_context_req->transactionId;
3002
3003 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3004 lim_log(mac_ctx, LOGW,
3005 FL("received invalid SME_SETCONTEXT_REQ message"));
3006 goto end;
3007 }
3008
3009 if (set_context_req->keyMaterial.numKeys >
3010 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3011 lim_log(mac_ctx, LOGE, FL(
3012 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3013 set_context_req->keyMaterial.numKeys);
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
3021 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003022 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 if (session_entry == NULL) {
3024 lim_log(mac_ctx, LOGW,
3025 FL("Session does not exist for given BSSID"));
3026 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003027 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 eSIR_SME_INVALID_PARAMETERS, NULL,
3029 sme_session_id, sme_transaction_id);
3030 goto end;
3031 }
3032#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3033 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3034 session_entry, 0, 0);
3035#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3036
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003037 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3039 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003040 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3042 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303043 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 if (NULL == mlm_set_key_req) {
3045 lim_log(mac_ctx, LOGP, FL(
3046 "mem alloc failed for mlmSetKeysReq"));
3047 goto end;
3048 }
3049 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3050 mlm_set_key_req->numKeys =
3051 set_context_req->keyMaterial.numKeys;
3052 if (mlm_set_key_req->numKeys >
3053 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3054 lim_log(mac_ctx, LOGP, FL(
3055 "no.of keys exceeded max num of default keys limit"));
3056 goto end;
3057 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303058 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003059 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303061 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 (uint8_t *) &set_context_req->keyMaterial.key,
3063 sizeof(tSirKeys) *
3064 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3065 numKeys : 1));
3066
3067 mlm_set_key_req->sessionId = session_id;
3068 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 lim_log(mac_ctx, LOG1, FL(
3070 "received SETCONTEXT_REQ message sessionId=%d"),
3071 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072
3073 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3074 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3075 LIM_IS_AP_ROLE(session_entry)) {
3076 if (set_context_req->keyMaterial.key[0].keyLength) {
3077 uint8_t key_id;
3078 key_id =
3079 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303080 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 &session_entry->WEPKeyMaterial[key_id],
3082 (uint8_t *) &set_context_req->keyMaterial,
3083 sizeof(tSirKeyMaterial));
3084 } else {
3085 uint32_t i;
3086 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3087 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303088 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 &mlm_set_key_req->key[i],
3090 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3091 sizeof(tSirKeys));
3092 }
3093 }
3094 }
3095 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3096 (uint32_t *) mlm_set_key_req);
3097 } else {
3098 lim_log(mac_ctx, LOGE, FL(
3099 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3100 GET_LIM_SYSTEM_ROLE(session_entry),
3101 session_entry->limSmeState);
3102 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3103
3104 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003105 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3107 session_entry, sme_session_id,
3108 sme_transaction_id);
3109 }
3110end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303111 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 return;
3113}
3114
3115/**
3116 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3117 *
3118 * @mac_ctx: Pointer to Global MAC structure
3119 * @msg_buf: pointer to the SME message buffer
3120 *
3121 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3122 * from HDD or upper layer application.
3123 *
3124 * Return: None
3125 */
3126
3127void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3128 uint32_t *msg_buf)
3129{
3130 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3131 tpDphHashNode sta_ds = NULL;
3132 tpPESession session_entry = NULL;
3133 tSap_Event sap_event;
3134 tpWLAN_SAPEventCB sap_event_cb = NULL;
3135 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3136 uint8_t session_id = CSR_SESSION_ID_INVALID;
3137 uint8_t assoc_id = 0;
3138 uint8_t sta_cnt = 0;
3139
3140 if (msg_buf == NULL) {
3141 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3142 return;
3143 }
3144
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303145 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 sizeof(struct sSirSmeGetAssocSTAsReq));
3147 /*
3148 * Get Associated stations from PE.
3149 * Find PE session Entry
3150 */
3151 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003152 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 &session_id);
3154 if (session_entry == NULL) {
3155 lim_log(mac_ctx, LOGE,
3156 FL("session does not exist for given bssId"));
3157 goto lim_assoc_sta_end;
3158 }
3159
3160 if (!LIM_IS_AP_ROLE(session_entry)) {
3161 lim_log(mac_ctx, LOGE, FL(
3162 "Received unexpected message in state %X, in role %X"),
3163 session_entry->limSmeState,
3164 GET_LIM_SYSTEM_ROLE(session_entry));
3165 goto lim_assoc_sta_end;
3166 }
3167 /* Retrieve values obtained in the request message */
3168 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3169 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3170
3171 if (NULL == assoc_sta_tmp)
3172 goto lim_assoc_sta_end;
3173 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3174 assoc_id++) {
3175 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3176 &session_entry->dph.dphHashTable);
3177 if (NULL == sta_ds)
3178 continue;
3179 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303180 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303182 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3184 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3185
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303186 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 (uint8_t *)&sta_ds->supportedRates,
3188 sizeof(tSirSupportedRates));
3189 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3190 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3191 assoc_sta_tmp->Support40Mhz =
3192 sta_ds->htDsssCckRate40MHzSupport;
3193
3194 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3195 sta_cnt + 1);
3196 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3197 MAC_ADDR_ARRAY(sta_ds->staAddr));
3198 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3199 sta_ds->assocId);
3200 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3201 sta_ds->staIndex);
3202 assoc_sta_tmp++;
3203 sta_cnt++;
3204 }
3205 }
3206lim_assoc_sta_end:
3207 /*
3208 * Call hdd callback with sap event to send the list of
3209 * associated stations from PE
3210 */
3211 if (sap_event_cb != NULL) {
3212 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3213 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303214 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3216 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3217 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3218 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3219 }
3220}
3221
3222/**
3223 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3224 *
3225 * @mac_ctx: Pointer to Global MAC structure
3226 * @msg_buf: pointer to WPS PBC overlap query message
3227 *
3228 * This function parses get WPS PBC overlap information
3229 * message and call callback to pass WPS PBC overlap
3230 * information back to hdd.
3231 *
3232 * Return: None
3233 */
3234void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3235 uint32_t *msg_buf)
3236{
3237 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3238 tpPESession session_entry = NULL;
3239 tSap_Event sap_event;
3240 tpWLAN_SAPEventCB sap_event_cb = NULL;
3241 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3243
3244 if (msg_buf == NULL) {
3245 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3246 return;
3247 }
3248
3249 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303250 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303252 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3254 /*
3255 * Get Associated stations from PE
3256 * Find PE session Entry
3257 */
3258 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003259 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 if (session_entry == NULL) {
3261 lim_log(mac_ctx, LOGE,
3262 FL("session does not exist for given bssId"));
3263 goto lim_get_wpspbc_sessions_end;
3264 }
3265
3266 if (!LIM_IS_AP_ROLE(session_entry)) {
3267 lim_log(mac_ctx, LOGE,
3268 FL("Received unexpected message in role %X"),
3269 GET_LIM_SYSTEM_ROLE(session_entry));
3270 goto lim_get_wpspbc_sessions_end;
3271 }
3272 /*
3273 * Call hdd callback with sap event to send the
3274 * WPS PBC overlap information
3275 */
3276 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303277 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278
Anurag Chouhanc5548422016-02-24 18:33:27 +05303279 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003281 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 sap_get_wpspbc_event->UUID_E,
3283 &sap_get_wpspbc_event->wpsPBCOverlap,
3284 session_entry);
3285 } else {
3286 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003287 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 session_entry);
3289 /* don't have to inform the HDD/Host */
3290 return;
3291 }
3292
3293 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3294 sap_get_wpspbc_event->wpsPBCOverlap);
3295 lim_print_mac_addr(mac_ctx,
3296 sap_get_wpspbc_event->addr.bytes, LOG4);
3297
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303298 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
3300lim_get_wpspbc_sessions_end:
3301 sap_event_cb =
3302 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3303 if (NULL != sap_event_cb)
3304 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3305}
3306
3307/**
3308 * __lim_counter_measures()
3309 *
3310 * FUNCTION:
3311 * This function is called to "implement" MIC counter measure
3312 * and is *temporary* only
3313 *
3314 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3315 * we don't do the proper STA disassoc sequence since the
3316 * BSS will be stoped anyway
3317 *
3318 ***ASSUMPTIONS:
3319 *
3320 ***NOTE:
3321 *
3322 * @param pMac Pointer to Global MAC structure
3323 * @return None
3324 */
3325
3326static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3327{
3328 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003329 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3331 mac, psessionEntry, false);
3332};
3333
3334void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3335{
3336 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3337 tpPESession psessionEntry;
3338 uint8_t sessionId; /* PE sessionId */
3339
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303340 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 sizeof(struct sSirSmeTkipCntrMeasReq));
3342
3343 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003344 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 if (NULL == psessionEntry) {
3346 lim_log(pMac, LOGE,
3347 FL("session does not exist for given BSSID "));
3348 return;
3349 }
3350
3351 if (tkipCntrMeasReq.bEnable)
3352 __lim_counter_measures(pMac, psessionEntry);
3353
3354 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3355}
3356
3357static void
3358__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3359{
3360 tSirSmeStopBssReq stopBssReq;
3361 tSirRetStatus status;
3362 tLimSmeStates prevState;
3363 tpPESession psessionEntry;
3364 uint8_t smesessionId;
3365 uint8_t sessionId;
3366 uint16_t smetransactionId;
3367 uint8_t i = 0;
3368 tpDphHashNode pStaDs = NULL;
3369
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303370 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 smesessionId = stopBssReq.sessionId;
3372 smetransactionId = stopBssReq.transactionId;
3373
3374 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3375 PELOGW(lim_log(pMac, LOGW,
3376 FL("received invalid SME_STOP_BSS_REQ message"));)
3377 /* Send Stop BSS response to host */
3378 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3379 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3380 smetransactionId);
3381 return;
3382 }
3383
3384 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003385 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 &sessionId);
3387 if (psessionEntry == NULL) {
3388 lim_log(pMac, LOGW,
3389 FL("session does not exist for given BSSID "));
3390 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3391 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3392 smetransactionId);
3393 return;
3394 }
3395#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3396 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3397 0, 0);
3398#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3399
3400 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3401 LIM_IS_STA_ROLE(psessionEntry)) {
3402 /**
3403 * Should not have received STOP_BSS_REQ in states
3404 * other than 'normal' state or on STA in Infrastructure
3405 * mode. Log error and return response to host.
3406 */
3407 lim_log(pMac, LOGE,
3408 FL
3409 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3410 psessionEntry->limSmeState,
3411 GET_LIM_SYSTEM_ROLE(psessionEntry));
3412 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3413 /* / Send Stop BSS response to host */
3414 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3415 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3416 smetransactionId);
3417 return;
3418 }
3419
3420 if (LIM_IS_AP_ROLE(psessionEntry))
3421 lim_wpspbc_close(pMac, psessionEntry);
3422
3423 lim_log(pMac, LOGW,
3424 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3425 stopBssReq.reasonCode);
3426
3427 prevState = psessionEntry->limSmeState;
3428
3429 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3430 MTRACE(mac_trace
3431 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3432 psessionEntry->limSmeState));
3433
3434 /* Update SME session Id and Transaction Id */
3435 psessionEntry->smeSessionId = smesessionId;
3436 psessionEntry->transactionId = smetransactionId;
3437
3438 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003439 if (!LIM_IS_IBSS_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3441 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3442 /* Send disassoc all stations associated thru TKIP */
3443 __lim_counter_measures(pMac, psessionEntry);
3444 else
3445 lim_send_disassoc_mgmt_frame(pMac,
3446 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3447 bcAddr, psessionEntry, false);
3448 }
3449
3450 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303451 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 psessionEntry->addIeParams.probeRespDataLen = 0;
3453 psessionEntry->addIeParams.probeRespData_buff = NULL;
3454
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303455 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 psessionEntry->addIeParams.assocRespDataLen = 0;
3457 psessionEntry->addIeParams.assocRespData_buff = NULL;
3458
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303459 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3461 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3462
3463 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3464 pMac->lim.gLimIbssCoalescingHappened = false;
3465
3466 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3467 pStaDs =
3468 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3469 if (NULL == pStaDs)
3470 continue;
3471 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3472 if (eSIR_SUCCESS == status) {
3473 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3474 pStaDs->assocId, psessionEntry);
3475 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3476 } else {
3477 lim_log(pMac, LOGE,
3478 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303479 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 }
3481 }
3482 /* send a delBss to HAL and wait for a response */
3483 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3484
3485 if (status != eSIR_SUCCESS) {
3486 PELOGE(lim_log
3487 (pMac, LOGE, FL("delBss failed for bss %d"),
3488 psessionEntry->bssIdx);
3489 )
3490 psessionEntry->limSmeState = prevState;
3491
3492 MTRACE(mac_trace
3493 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3494 psessionEntry->limSmeState));
3495
3496 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3497 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3498 smetransactionId);
3499 }
3500}
3501
3502/**
3503 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3504 * @pMac: Global MAC context
3505 * @pMsg: Message from SME
3506 *
3507 * Wrapper for the function __lim_handle_sme_stop_bss_request
3508 * This message will be defered until softmac come out of
3509 * scan mode. Message should be handled even if we have
3510 * detected radar in the current operating channel.
3511 *
3512 * Return: true - If we consumed the buffer
3513 * false - If have defered the message.
3514 */
3515
3516static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3517{
3518 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3519 /**
3520 * If message defered, buffer is not consumed yet.
3521 * So return false
3522 */
3523 return false;
3524 }
3525 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3526 return true;
3527} /*** end __lim_process_sme_stop_bss_req() ***/
3528
3529void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3530 uint32_t body, tpPESession psessionEntry)
3531{
3532
3533 (void)body;
3534 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3535 lim_ibss_delete(pMac, psessionEntry);
3536 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3537 lim_delete_pre_auth_list(pMac);
3538 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3539 psessionEntry->smeSessionId,
3540 psessionEntry->transactionId);
3541 return;
3542}
3543
3544/**
3545 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3546 *
3547 * @mac_ctx: pointer to mac context
3548 * @msg_type: message type
3549 * @msg_buf: pointer to the SME message buffer
3550 *
3551 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3552 * in BTAMP AP.
3553 *
3554 * Return: None
3555 */
3556
3557void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3558 uint32_t *msg_buf)
3559{
3560 tSirSmeAssocCnf assoc_cnf;
3561 tpDphHashNode sta_ds = NULL;
3562 tpPESession session_entry = NULL;
3563 uint8_t session_id;
3564 tpSirAssocReq assoc_req;
3565
3566 if (msg_buf == NULL) {
3567 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3568 goto end;
3569 }
3570
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303571 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3573 lim_log(mac_ctx, LOGE,
3574 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3575 goto end;
3576 }
3577
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003578 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 &session_id);
3580 if (session_entry == NULL) {
3581 lim_log(mac_ctx, LOGE,
3582 FL("session does not exist for given bssId"));
3583 goto end;
3584 }
3585
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003586 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3588 (session_entry->limSmeState !=
3589 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3590 lim_log(mac_ctx, LOGE, FL(
3591 "Rcvd unexpected msg %X in state %X, in role %X"),
3592 msg_type, session_entry->limSmeState,
3593 GET_LIM_SYSTEM_ROLE(session_entry));
3594 goto end;
3595 }
3596 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3597 &session_entry->dph.dphHashTable);
3598 if (sta_ds == NULL) {
3599 lim_log(mac_ctx, LOGE, FL(
3600 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3601 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003602 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603
3604 /*
3605 * send a DISASSOC_IND message to WSM to make sure
3606 * the state in WSM and LIM is the same
3607 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003608 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 eSIR_SME_STA_NOT_ASSOCIATED,
3610 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3611 session_entry->smeSessionId,
3612 session_entry->transactionId,
3613 session_entry);
3614 goto end;
3615 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303616 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003617 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303618 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 lim_log(mac_ctx, LOG1, FL(
3620 "peerMacAddr mismatched for aid %d, peer "),
3621 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003622 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 goto end;
3624 }
3625
3626 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3627 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3628 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3629 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3630 (msg_type != eWNI_SME_ASSOC_CNF))) {
3631 lim_log(mac_ctx, LOG1, FL(
3632 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3633 "StaD mlmState : %d"),
3634 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003635 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 goto end;
3637 }
3638 /*
3639 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3640 * has been received
3641 */
3642 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3643 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3644 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3645
3646 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3647 /*
3648 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3649 * when it had received Assoc Request frame. Now, PE just needs
3650 * to send association rsp frame to the requesting BTAMP-STA.
3651 */
3652 sta_ds->mlmStaContext.mlmState =
3653 eLIM_MLM_LINK_ESTABLISHED_STATE;
3654 lim_log(mac_ctx, LOG1,
3655 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3656 sta_ds->assocId);
3657 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3658 sta_ds->assocId, sta_ds->staAddr,
3659 sta_ds->mlmStaContext.subType, sta_ds,
3660 session_entry);
3661 goto end;
3662 } else {
3663 /*
3664 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3665 * to be associated since the HAL sta entry is created for
3666 * denied STA we need to remove this HAL entry.
3667 * So to do that set updateContext to 1
3668 */
3669 if (!sta_ds->mlmStaContext.updateContext)
3670 sta_ds->mlmStaContext.updateContext = 1;
3671 lim_log(mac_ctx, LOG1,
3672 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3673 assoc_cnf.statusCode, sta_ds->assocId);
3674 lim_reject_association(mac_ctx, sta_ds->staAddr,
3675 sta_ds->mlmStaContext.subType,
3676 true, sta_ds->mlmStaContext.authType,
3677 sta_ds->assocId, true,
3678 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3679 session_entry);
3680 }
3681end:
3682 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3683 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3684 assoc_req = (tpSirAssocReq)
3685 session_entry->parsedAssocReq[sta_ds->assocId];
3686 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303687 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688 assoc_req->assocReqFrame = NULL;
3689 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303690 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3692 }
3693}
3694
3695static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3696{
3697 tpDphHashNode pStaDs;
3698 tSirMacAddr peerMac;
3699 tpSirAddtsReq pSirAddts;
3700 uint32_t timeout;
3701 tpPESession psessionEntry;
3702 uint8_t sessionId; /* PE sessionId */
3703 uint8_t smesessionId;
3704 uint16_t smetransactionId;
3705
3706 if (pMsgBuf == NULL) {
3707 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3708 return;
3709 }
3710
3711 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3712 &smetransactionId);
3713
3714 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3715
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003716 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3717 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 if (psessionEntry == NULL) {
3719 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3720 return;
3721 }
3722#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3723 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3724 0);
3725#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3726
3727 /* if sta
3728 * - verify assoc state
3729 * - send addts request to ap
3730 * - wait for addts response from ap
3731 * if ap, just ignore with error log
3732 */
3733 PELOG1(lim_log(pMac, LOG1,
3734 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3735 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3736 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3737 )
3738
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003739 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3741 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3742 psessionEntry, pSirAddts->req.tspec,
3743 smesessionId, smetransactionId);
3744 return;
3745 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746
3747 pStaDs =
3748 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3749 &psessionEntry->dph.dphHashTable);
3750
3751 if (pStaDs == NULL) {
3752 PELOGE(lim_log
3753 (pMac, LOGE, "Cannot find AP context for addts req");
3754 )
3755 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3756 psessionEntry, pSirAddts->req.tspec,
3757 smesessionId, smetransactionId);
3758 return;
3759 }
3760
3761 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3762 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3763 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3764 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3765 psessionEntry, pSirAddts->req.tspec,
3766 smesessionId, smetransactionId);
3767 return;
3768 }
3769
3770 pSirAddts->req.wsmTspecPresent = 0;
3771 pSirAddts->req.wmeTspecPresent = 0;
3772 pSirAddts->req.lleTspecPresent = 0;
3773
3774 if ((pStaDs->wsmEnabled) &&
3775 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3776 SIR_MAC_ACCESSPOLICY_EDCA))
3777 pSirAddts->req.wsmTspecPresent = 1;
3778 else if (pStaDs->wmeEnabled)
3779 pSirAddts->req.wmeTspecPresent = 1;
3780 else if (pStaDs->lleEnabled)
3781 pSirAddts->req.lleTspecPresent = 1;
3782 else {
3783 PELOGW(lim_log
3784 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3785 )
3786 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3787 psessionEntry, pSirAddts->req.tspec,
3788 smesessionId, smetransactionId);
3789 return;
3790 }
3791
3792 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3793 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3794 lim_log(pMac, LOGE,
3795 "AddTs received in invalid LIMsme state (%d)",
3796 psessionEntry->limSmeState);
3797 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3798 psessionEntry, pSirAddts->req.tspec,
3799 smesessionId, smetransactionId);
3800 return;
3801 }
3802
3803 if (pMac->lim.gLimAddtsSent) {
3804 lim_log(pMac, LOGE,
3805 "Addts (token %d, tsid %d, up %d) is still pending",
3806 pMac->lim.gLimAddtsReq.req.dialogToken,
3807 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3808 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3809 userPrio);
3810 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3811 psessionEntry, pSirAddts->req.tspec,
3812 smesessionId, smetransactionId);
3813 return;
3814 }
3815
3816 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3817
3818 /* save the addts request */
3819 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303820 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3822
3823 /* ship out the message now */
3824 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3825 psessionEntry);
3826 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3827 /* start a timer to wait for the response */
3828 if (pSirAddts->timeout)
3829 timeout = pSirAddts->timeout;
3830 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3831 eSIR_SUCCESS) {
3832 lim_log(pMac, LOGP,
3833 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3834 WNI_CFG_ADDTS_RSP_TIMEOUT);
3835 return;
3836 }
3837
3838 timeout = SYS_MS_TO_TICKS(timeout);
3839 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3840 != TX_SUCCESS) {
3841 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3842 return;
3843 }
3844 pMac->lim.gLimAddtsRspTimerCount++;
3845 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3846 pMac->lim.gLimAddtsRspTimerCount) !=
3847 TX_SUCCESS) {
3848 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3849 return;
3850 }
3851 MTRACE(mac_trace
3852 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3853 eLIM_ADDTS_RSP_TIMER));
3854
3855 /* add the sessionId to the timer object */
3856 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3857 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3858 TX_SUCCESS) {
3859 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3860 return;
3861 }
3862 return;
3863}
3864
3865static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3866{
3867 tSirMacAddr peerMacAddr;
3868 uint8_t ac;
3869 tSirMacTSInfo *pTsinfo;
3870 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3871 tpDphHashNode pStaDs = NULL;
3872 tpPESession psessionEntry;
3873 uint8_t sessionId;
3874 uint32_t status = eSIR_SUCCESS;
3875 uint8_t smesessionId;
3876 uint16_t smetransactionId;
3877
3878 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3879 &smetransactionId);
3880
3881 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003882 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883 &sessionId);
3884 if (psessionEntry == NULL) {
3885 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3886 status = eSIR_FAILURE;
3887 goto end;
3888 }
3889#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3890 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3891 0);
3892#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3893
3894 if (eSIR_SUCCESS !=
3895 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3896 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3897 status = eSIR_FAILURE;
3898 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3899 smesessionId, smetransactionId);
3900 return;
3901 }
3902
3903 lim_log(pMac, LOG1,
3904 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3905 MAC_ADDRESS_STR),
3906 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3907
3908 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3909 pDeltsReq->req.wmeTspecPresent,
3910 &pDeltsReq->req.tsinfo,
3911 &pDeltsReq->req.tspec, psessionEntry);
3912
3913 pTsinfo =
3914 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3915 tsinfo : &pDeltsReq->req.tsinfo;
3916
3917 /* We've successfully send DELTS frame to AP. Update the
3918 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3919 * is no longer trigger enabled or delivery enabled
3920 */
3921 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3922 pTsinfo, CLEAR_UAPSD_MASK);
3923
3924 /* We're deleting the TSPEC, so this particular AC is no longer
3925 * admitted. PE needs to downgrade the EDCA
3926 * parameters(for the AC for which TS is being deleted) to the
3927 * next best AC for which ACM is not enabled, and send the
3928 * updated values to HAL.
3929 */
3930 ac = upToAc(pTsinfo->traffic.userPrio);
3931
3932 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3933 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3934 ~(1 << ac);
3935 } else if (pTsinfo->traffic.direction ==
3936 SIR_MAC_DIRECTION_DNLINK) {
3937 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3938 ~(1 << ac);
3939 } else if (pTsinfo->traffic.direction ==
3940 SIR_MAC_DIRECTION_BIDIR) {
3941 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3942 ~(1 << ac);
3943 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3944 ~(1 << ac);
3945 }
3946
3947 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3948 psessionEntry);
3949
3950 pStaDs =
3951 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3952 &psessionEntry->dph.dphHashTable);
3953 if (pStaDs != NULL) {
3954 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3955 pStaDs->bssId);
3956 status = eSIR_SUCCESS;
3957 } else {
3958 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3959 status = eSIR_FAILURE;
3960 }
3961#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963#endif
3964
3965 /* send an sme response back */
3966end:
3967 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3968 smesessionId, smetransactionId);
3969}
3970
3971void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3972{
3973 /* fetch the sessionEntry based on the sessionId */
3974 tpPESession psessionEntry;
3975 psessionEntry = pe_find_session_by_session_id(pMac,
3976 pMac->lim.limTimers.gLimAddtsRspTimer.
3977 sessionId);
3978 if (psessionEntry == NULL) {
3979 lim_log(pMac, LOGP,
3980 FL("Session Does not exist for given sessionID"));
3981 return;
3982 }
3983
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003984 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3986 GET_LIM_SYSTEM_ROLE(psessionEntry));
3987 pMac->lim.gLimAddtsSent = false;
3988 return;
3989 }
3990
3991 if (!pMac->lim.gLimAddtsSent) {
3992 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3993 return;
3994 }
3995
3996 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3997 lim_log(pMac, LOGE,
3998 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3999 pMac->lim.gLimAddtsRspTimerCount);
4000 return;
4001 }
4002 /* this a real response timeout */
4003 pMac->lim.gLimAddtsSent = false;
4004 pMac->lim.gLimAddtsRspTimerCount++;
4005
4006 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4007 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4008 psessionEntry->smeSessionId,
4009 psessionEntry->transactionId);
4010}
4011
4012/**
4013 * __lim_process_sme_get_statistics_request()
4014 *
4015 ***FUNCTION:
4016 *
4017 *
4018 ***NOTE:
4019 *
4020 * @param pMac Pointer to Global MAC structure
4021 * @param *pMsgBuf A pointer to the SME message buffer
4022 * @return None
4023 */
4024static void
4025__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4026{
4027 tpAniGetPEStatsReq pPEStatsReq;
4028 tSirMsgQ msgQ;
4029
4030 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4031
4032 msgQ.type = WMA_GET_STATISTICS_REQ;
4033
4034 msgQ.reserved = 0;
4035 msgQ.bodyptr = pMsgBuf;
4036 msgQ.bodyval = 0;
4037 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4038
4039 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304040 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 pMsgBuf = NULL;
4042 lim_log(pMac, LOGP, "Unable to forward request");
4043 return;
4044 }
4045
4046 return;
4047}
4048
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004049#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004051 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004053 * @pMac: Pointer to Global MAC structure
4054 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004056 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 */
4058static void
4059__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4060{
4061 tSirMsgQ msgQ;
4062
4063 msgQ.type = WMA_TSM_STATS_REQ;
4064 msgQ.reserved = 0;
4065 msgQ.bodyptr = pMsgBuf;
4066 msgQ.bodyval = 0;
4067 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4068
4069 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 pMsgBuf = NULL;
4072 lim_log(pMac, LOGP, "Unable to forward request");
4073 return;
4074 }
4075}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004076#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077
4078static void
4079__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4080{
4081 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4082 tpPESession psessionEntry;
4083 uint8_t sessionId; /* PE sessionID */
4084
4085 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4086
4087 if (pMsgBuf == NULL) {
4088 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4089 return;
4090 }
4091
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 if (NULL == pUpdateAPWPSIEsReq) {
4094 lim_log(pMac, LOGP,
4095 FL
4096 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4097 return;
4098 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304099 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 sizeof(struct sSirUpdateAPWPSIEsReq));
4101
4102 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004103 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 &sessionId);
4105 if (psessionEntry == NULL) {
4106 lim_log(pMac, LOGW,
4107 FL("Session does not exist for given BSSID"));
4108 goto end;
4109 }
4110
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304111 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 sizeof(tSirAPWPSIEs));
4113
4114 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4115 lim_send_beacon_ind(pMac, psessionEntry);
4116
4117end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304118 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 return;
4120}
4121
4122void
4123lim_send_vdev_restart(tpAniSirGlobal pMac,
4124 tpPESession psessionEntry, uint8_t sessionId)
4125{
4126 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4127 tSirMsgQ msgQ;
4128 tSirRetStatus retCode = eSIR_SUCCESS;
4129
4130 if (psessionEntry == NULL) {
4131 PELOGE(lim_log
4132 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4133 __LINE__);
4134 )
4135 return;
4136 }
4137
4138 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304139 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 if (NULL == pHalHiddenSsidVdevRestart) {
4141 PELOGE(lim_log
4142 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4143 __func__, __LINE__);
4144 )
4145 return;
4146 }
4147
4148 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4149 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4150
4151 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4152 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4153 msgQ.bodyval = 0;
4154
4155 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4156 if (eSIR_SUCCESS != retCode) {
4157 PELOGE(lim_log
4158 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4159 __LINE__);
4160 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304161 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 }
4163}
4164
4165static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4166{
4167 tpSirUpdateParams pUpdateParams;
4168 tpPESession psessionEntry;
4169
4170 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4171
4172 if (pMsgBuf == NULL) {
4173 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4174 return;
4175 }
4176
4177 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4178
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004179 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 pUpdateParams->sessionId);
4181 if (psessionEntry == NULL) {
4182 lim_log(pMac, LOGW,
4183 "Session does not exist for given sessionId %d",
4184 pUpdateParams->sessionId);
4185 return;
4186 }
4187
4188 /* Update the session entry */
4189 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4190
4191 /* Send vdev restart */
4192 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4193
4194 /* Update beacon */
4195 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4196 lim_send_beacon_ind(pMac, psessionEntry);
4197
4198 return;
4199} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4200
4201static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4202{
4203 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4204 tpPESession psessionEntry;
4205 uint8_t sessionId; /* PE sessionID */
4206
4207 if (pMsgBuf == NULL) {
4208 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4209 return;
4210 }
4211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304212 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 if (NULL == pUpdateAPWPARSNIEsReq) {
4214 lim_log(pMac, LOGP,
4215 FL
4216 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4217 return;
4218 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304219 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4221
4222 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004223 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 &sessionId);
4225 if (psessionEntry == NULL) {
4226 lim_log(pMac, LOGW,
4227 FL("Session does not exist for given BSSID"));
4228 goto end;
4229 }
4230
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304231 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4233
4234 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4235 &psessionEntry->
4236 pLimStartBssReq->rsnIE,
4237 psessionEntry);
4238
4239 psessionEntry->pLimStartBssReq->privacy = 1;
4240 psessionEntry->privacy = 1;
4241
4242 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4243 lim_send_beacon_ind(pMac, psessionEntry);
4244
4245end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304246 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 return;
4248} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4249
4250/*
4251 Update the beacon Interval dynamically if beaconInterval is different in MCC
4252 */
4253static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4254{
4255 tpSirChangeBIParams pChangeBIParams;
4256 tpPESession psessionEntry;
4257 uint8_t sessionId = 0;
4258 tUpdateBeaconParams beaconParams;
4259
4260 PELOG1(lim_log(pMac, LOG1,
4261 FL("received Update Beacon Interval message"));
4262 );
4263
4264 if (pMsgBuf == NULL) {
4265 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4266 return;
4267 }
4268
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304269 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4271
4272 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004273 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 &sessionId);
4275 if (psessionEntry == NULL) {
4276 lim_log(pMac, LOGE,
4277 FL("Session does not exist for given BSSID"));
4278 return;
4279 }
4280
4281 /*Update sessionEntry Beacon Interval */
4282 if (psessionEntry->beaconParams.beaconInterval !=
4283 pChangeBIParams->beaconInterval) {
4284 psessionEntry->beaconParams.beaconInterval =
4285 pChangeBIParams->beaconInterval;
4286 }
4287
4288 /*Update sch beaconInterval */
4289 if (pMac->sch.schObject.gSchBeaconInterval !=
4290 pChangeBIParams->beaconInterval) {
4291 pMac->sch.schObject.gSchBeaconInterval =
4292 pChangeBIParams->beaconInterval;
4293
4294 PELOG1(lim_log(pMac, LOG1,
4295 FL
4296 ("LIM send update BeaconInterval Indication : %d"),
4297 pChangeBIParams->beaconInterval);
4298 );
4299
4300 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4301 /* Update beacon */
4302 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4303
4304 beaconParams.bssIdx = psessionEntry->bssIdx;
4305 /* Set change in beacon Interval */
4306 beaconParams.beaconInterval =
4307 pChangeBIParams->beaconInterval;
4308 beaconParams.paramChangeBitmap =
4309 PARAM_BCN_INTERVAL_CHANGED;
4310 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4311 }
4312 }
4313
4314 return;
4315} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4316
4317#ifdef QCA_HT_2040_COEX
4318static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4319 uint32_t *pMsgBuf)
4320{
4321 tpSirSetHT2040Mode pSetHT2040Mode;
4322 tpPESession psessionEntry;
4323 uint8_t sessionId = 0;
4324 cds_msg_t msg;
4325 tUpdateVHTOpMode *pHtOpMode = NULL;
4326 uint16_t staId = 0;
4327 tpDphHashNode pStaDs = NULL;
4328
4329 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4330 if (pMsgBuf == NULL) {
4331 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4332 return;
4333 }
4334
4335 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4336
4337 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004338 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 &sessionId);
4340 if (psessionEntry == NULL) {
4341 lim_log(pMac, LOG1,
4342 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004343 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 return;
4345 }
4346
4347 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4348 pSetHT2040Mode->cbMode);
4349 /*Update sessionEntry HT related fields */
4350 switch (pSetHT2040Mode->cbMode) {
4351 case PHY_SINGLE_CHANNEL_CENTERED:
4352 psessionEntry->htSecondaryChannelOffset =
4353 PHY_SINGLE_CHANNEL_CENTERED;
4354 psessionEntry->htRecommendedTxWidthSet = 0;
4355 if (pSetHT2040Mode->obssEnabled)
4356 psessionEntry->htSupportedChannelWidthSet
4357 = eHT_CHANNEL_WIDTH_40MHZ;
4358 else
4359 psessionEntry->htSupportedChannelWidthSet
4360 = eHT_CHANNEL_WIDTH_20MHZ;
4361 break;
4362 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4363 psessionEntry->htSecondaryChannelOffset =
4364 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4365 psessionEntry->htRecommendedTxWidthSet = 1;
4366 break;
4367 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4368 psessionEntry->htSecondaryChannelOffset =
4369 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4370 psessionEntry->htRecommendedTxWidthSet = 1;
4371 break;
4372 default:
4373 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4374 return;
4375 }
4376
4377 /* Update beacon */
4378 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4379 lim_send_beacon_ind(pMac, psessionEntry);
4380
4381 /* update OP Mode for each associated peer */
4382 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4383 pStaDs = dph_get_hash_entry(pMac, staId,
4384 &psessionEntry->dph.dphHashTable);
4385 if (NULL == pStaDs)
4386 continue;
4387
4388 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304389 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390 if (NULL == pHtOpMode) {
4391 lim_log(pMac, LOGE,
4392 FL
4393 ("%s: Not able to allocate memory for setting OP mode"),
4394 __func__);
4395 return;
4396 }
4397 pHtOpMode->opMode =
4398 (psessionEntry->htSecondaryChannelOffset ==
4399 PHY_SINGLE_CHANNEL_CENTERED) ?
4400 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4401 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304402 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 sizeof(tSirMacAddr));
4404 pHtOpMode->smesessionId = sessionId;
4405
4406 msg.type = WMA_UPDATE_OP_MODE;
4407 msg.reserved = 0;
4408 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304409 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304410 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 lim_log(pMac, LOGE,
4412 FL
4413 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4414 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304415 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 return;
4417 }
4418 lim_log(pMac, LOG1,
4419 FL
4420 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4421 __func__, pHtOpMode->opMode, staId);
4422
4423 } else
4424 lim_log(pMac, LOG1,
4425 FL("%s: station %d does not support HT40\n"),
4426 __func__, staId);
4427 }
4428
4429 return;
4430}
4431#endif
4432
4433/* -------------------------------------------------------------------- */
4434/**
4435 * __lim_process_report_message
4436 *
4437 * FUNCTION: Processes the next received Radio Resource Management message
4438 *
4439 * LOGIC:
4440 *
4441 * ASSUMPTIONS:
4442 *
4443 * NOTE:
4444 *
4445 * @param None
4446 * @return None
4447 */
4448
4449void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4450{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 switch (pMsg->type) {
4452 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4453 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4454 break;
4455 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004457 break;
4458 default:
4459 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461}
4462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463/* -------------------------------------------------------------------- */
4464/**
4465 * lim_send_set_max_tx_power_req
4466 *
4467 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4468 *
4469 * LOGIC:
4470 *
4471 * ASSUMPTIONS:
4472 *
4473 * NOTE:
4474 *
4475 * @param txPower txPower to be set.
4476 * @param pSessionEntry session entry.
4477 * @return None
4478 */
4479tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004480lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 tpPESession pSessionEntry)
4482{
4483 tpMaxTxPowerParams pMaxTxParams = NULL;
4484 tSirRetStatus retCode = eSIR_SUCCESS;
4485 tSirMsgQ msgQ;
4486
4487 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304488 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 return eSIR_FAILURE;
4490 }
4491
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304492 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 if (NULL == pMaxTxParams) {
4494 lim_log(pMac, LOGP,
4495 FL("Unable to allocate memory for pMaxTxParams "));
4496 return eSIR_MEM_ALLOC_FAILED;
4497
4498 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304500 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304501 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304502 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004503 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304504 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505
4506 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4507 msgQ.bodyptr = pMaxTxParams;
4508 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304509 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4511 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4512 if (eSIR_SUCCESS != retCode) {
4513 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304514 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 }
4516 return retCode;
4517}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518
4519/**
4520 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4521 *
4522 * @mac_ctx: Pointer to Global MAC structure
4523 * @msg_buf: pointer to the SME message buffer
4524 *
4525 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4526 * from SME. It Register this information within PE.
4527 *
4528 * Return: None
4529 */
4530static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4531 uint32_t *msg_buf)
4532{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304533 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4535 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4536 struct mgmt_frm_reg_info *next = NULL;
4537 bool match = false;
4538
4539 lim_log(mac_ctx, LOG1, FL(
4540 "registerFrame %d, frameType %d, matchLen %d"),
4541 sme_req->registerFrame, sme_req->frameType,
4542 sme_req->matchLen);
4543 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304544 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304545 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4546 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304547 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548
4549 while (lim_mgmt_regn != NULL) {
4550 if (lim_mgmt_regn->frameType != sme_req->frameType)
4551 goto skip_match;
4552 if (sme_req->matchLen) {
4553 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304554 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 sme_req->matchData,
4556 lim_mgmt_regn->matchLen))) {
4557 /* found match! */
4558 match = true;
4559 break;
4560 }
4561 } else {
4562 /* found match! */
4563 match = true;
4564 break;
4565 }
4566skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304567 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304568 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304570 (qdf_list_node_t *)lim_mgmt_regn,
4571 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304572 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 lim_mgmt_regn = next;
4574 next = NULL;
4575 }
4576 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304577 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304578 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304580 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304581 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304582 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 }
4584
4585 if (sme_req->registerFrame) {
4586 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304587 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 sme_req->matchLen);
4589 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304590 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 sizeof(struct mgmt_frm_reg_info) +
4592 sme_req->matchLen, 0);
4593 lim_mgmt_regn->frameType = sme_req->frameType;
4594 lim_mgmt_regn->matchLen = sme_req->matchLen;
4595 lim_mgmt_regn->sessionId = sme_req->sessionId;
4596 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304597 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 sme_req->matchData,
4599 sme_req->matchLen);
4600 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304601 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304603 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 gLimMgmtFrameRegistratinQueue,
4605 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304606 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 &mac_ctx->lim.lim_frame_register_lock);
4608 }
4609 }
4610 return;
4611}
4612
4613static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4614{
4615 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4616 pMac->lim.gDeferMsgTypeForNOA);
4617 pMac->lim.gDeferMsgTypeForNOA = 0;
4618 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4619 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304620 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4622 }
4623}
4624
4625/**
4626 * lim_process_regd_defd_sme_req_after_noa_start()
4627 *
4628 * mac_ctx: Pointer to Global MAC structure
4629 *
4630 * This function is called to process deferred sme req message
4631 * after noa start.
4632 *
4633 * Return: None
4634 */
4635void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4636{
4637 bool buf_consumed = true;
4638
4639 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4640 mac_ctx->lim.gDeferMsgTypeForNOA);
4641
4642 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4643 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4644 lim_log(mac_ctx, LOGW,
4645 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4646 lim_log(mac_ctx, LOGW,
4647 FL("It may happen when NOA start ind and timeout happen at the same time"));
4648 return;
4649 }
4650 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4651 case eWNI_SME_SCAN_REQ:
4652 __lim_process_sme_scan_req(mac_ctx,
4653 mac_ctx->lim.gpDefdSmeMsgForNOA);
4654 break;
4655#ifdef FEATURE_OEM_DATA_SUPPORT
4656 case eWNI_SME_OEM_DATA_REQ:
4657 __lim_process_sme_oem_data_req(mac_ctx,
4658 mac_ctx->lim.gpDefdSmeMsgForNOA);
4659 break;
4660#endif
4661 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4662 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4663 mac_ctx->lim.gpDefdSmeMsgForNOA);
4664 /*
4665 * lim_process_remain_on_chnl_req doesnt want us to free
4666 * the buffer since it is freed in lim_remain_on_chn_rsp.
4667 * this change is to avoid "double free"
4668 */
4669 if (false == buf_consumed)
4670 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4671 break;
4672 case eWNI_SME_JOIN_REQ:
4673 __lim_process_sme_join_req(mac_ctx,
4674 mac_ctx->lim.gpDefdSmeMsgForNOA);
4675 break;
4676 default:
4677 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4678 mac_ctx->lim.gDeferMsgTypeForNOA);
4679 break;
4680 }
4681 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4682}
4683
4684static void
4685__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4686{
4687 tpSirResetAPCapsChange pResetCapsChange;
4688 tpPESession psessionEntry;
4689 uint8_t sessionId = 0;
4690 if (pMsgBuf == NULL) {
4691 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4692 return;
4693 }
4694
4695 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4696 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004697 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4698 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 if (psessionEntry == NULL) {
4700 lim_log(pMac, LOGE,
4701 FL("Session does not exist for given BSSID"));
4702 return;
4703 }
4704
4705 psessionEntry->limSentCapsChangeNtf = false;
4706 return;
4707}
4708
4709/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304710 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4711 * indication callback in PE.
4712 * @mac_ptr: Mac pointer
4713 * @msg_buf: Msg pointer containing the callback
4714 *
4715 * This function is used save the Management frame
4716 * indication callback in PE.
4717 *
4718 * Return: None
4719 */
4720static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4721 uint32_t *msg_buf)
4722{
4723 struct sir_sme_mgmt_frame_cb_req *sme_req =
4724 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4725
4726 if (NULL == msg_buf) {
4727 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4728 return;
4729 }
4730 if (sme_req->callback)
4731 mac_ctx->mgmt_frame_ind_cb =
4732 (sir_mgmt_frame_ind_callback)sme_req->callback;
4733 else
4734 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4735}
4736
4737/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004738 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4739 * @mac_ctx: Pointer to Global MAC structure
4740 * @pdev_id: pdev id to set the IE.
4741 * @nss: Nss values to prepare the HT IE.
4742 *
4743 * Prepares the HT IE with self capabilities for different
4744 * Nss values and sends the set HT IE req to FW.
4745 *
4746 * Return: None
4747 */
4748static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4749 uint8_t nss)
4750{
4751 struct set_ie_param *ie_params;
4752 tSirMsgQ msg;
4753 tSirRetStatus rc = eSIR_SUCCESS;
4754 uint8_t *p_ie = NULL;
4755 tHtCaps *p_ht_cap;
4756 int i;
4757
4758 for (i = nss; i > 0; i--) {
4759 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4760 if (NULL == ie_params) {
4761 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4762 return;
4763 }
4764 ie_params->nss = i;
4765 ie_params->pdev_id = pdev_id;
4766 ie_params->ie_type = DOT11_HT_IE;
4767 /* 2 for IE len and EID */
4768 ie_params->ie_len = 2 + sizeof(tHtCaps);
4769 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4770 if (NULL == ie_params->ie_ptr) {
4771 qdf_mem_free(ie_params);
4772 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4773 return;
4774 }
4775 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4776 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4777 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4778 ie_params->ie_len);
4779
4780 if (NSS_1x1_MODE == i) {
4781 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4782 ie_params->ie_len,
4783 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004784 if (NULL == p_ie) {
4785 qdf_mem_free(ie_params->ie_ptr);
4786 qdf_mem_free(ie_params);
4787 lim_log(mac_ctx, LOGE,
4788 FL("failed to get IE ptr"));
4789 return;
4790 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004791 p_ht_cap = (tHtCaps *)&p_ie[2];
4792 p_ht_cap->supportedMCSSet[1] = 0;
4793 p_ht_cap->txSTBC = 0;
4794 }
4795
4796 msg.type = WMA_SET_PDEV_IE_REQ;
4797 msg.bodyptr = ie_params;
4798 msg.bodyval = 0;
4799
4800 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4801 if (rc != eSIR_SUCCESS) {
4802 lim_log(mac_ctx, LOGE,
4803 FL("wma_post_ctrl_msg() return failure"));
4804 qdf_mem_free(ie_params->ie_ptr);
4805 qdf_mem_free(ie_params);
4806 return;
4807 }
4808 }
4809}
4810
4811/**
4812 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4813 * @mac_ctx: Pointer to Global MAC structure
4814 * @pdev_id: pdev id to set the IE.
4815 * @nss: Nss values to prepare the VHT IE.
4816 *
4817 * Prepares the VHT IE with self capabilities for different
4818 * Nss values and sends the set VHT IE req to FW.
4819 *
4820 * Return: None
4821 */
4822static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4823 uint8_t nss)
4824{
4825 struct set_ie_param *ie_params;
4826 tSirMsgQ msg;
4827 tSirRetStatus rc = eSIR_SUCCESS;
4828 uint8_t *p_ie = NULL;
4829 tSirMacVHTCapabilityInfo *vht_cap;
4830 int i;
4831 tSirVhtMcsInfo *vht_mcs;
4832
4833 for (i = nss; i > 0; i--) {
4834 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4835 if (NULL == ie_params) {
4836 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4837 return;
4838 }
4839 ie_params->nss = i;
4840 ie_params->pdev_id = pdev_id;
4841 ie_params->ie_type = DOT11_VHT_IE;
4842 /* 2 for IE len and EID */
4843 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4844 sizeof(tSirVhtMcsInfo);
4845 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4846 if (NULL == ie_params->ie_ptr) {
4847 qdf_mem_free(ie_params);
4848 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4849 return;
4850 }
4851 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4852 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4853 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4854 ie_params->ie_len);
4855
4856 if (NSS_1x1_MODE == i) {
4857 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4858 ie_params->ie_len,
4859 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004860 if (NULL == p_ie) {
4861 qdf_mem_free(ie_params->ie_ptr);
4862 qdf_mem_free(ie_params);
4863 lim_log(mac_ctx, LOGE,
4864 FL("failed to get IE ptr"));
4865 return;
4866 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004867 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4868 vht_cap->txSTBC = 0;
4869 vht_mcs =
4870 (tSirVhtMcsInfo *)&p_ie[2 +
4871 sizeof(tSirMacVHTCapabilityInfo)];
4872 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4873 vht_mcs->rxHighest =
4874 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4875 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4876 vht_mcs->txHighest =
4877 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4878 }
4879 msg.type = WMA_SET_PDEV_IE_REQ;
4880 msg.bodyptr = ie_params;
4881 msg.bodyval = 0;
4882
4883 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4884 if (rc != eSIR_SUCCESS) {
4885 lim_log(mac_ctx, LOGE,
4886 FL("wma_post_ctrl_msg failure"));
4887 qdf_mem_free(ie_params->ie_ptr);
4888 qdf_mem_free(ie_params);
4889 return;
4890 }
4891 }
4892}
4893
4894/**
4895 * lim_process_set_pdev_IEs() - process the set pdev IE req
4896 * @mac_ctx: Pointer to Global MAC structure
4897 * @msg_buf: Pointer to the SME message buffer
4898 *
4899 * This function is called by limProcessMessageQueue(). This
4900 * function sets the PDEV IEs to the FW.
4901 *
4902 * Return: None
4903 */
4904static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4905{
4906 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4907
4908 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4909
4910 if (NULL == ht_vht_cfg) {
4911 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
4912 return;
4913 }
4914
4915 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
4916 ht_vht_cfg->nss);
4917 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4918
4919 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4920 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4921 ht_vht_cfg->nss);
4922}
4923
4924/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 * lim_process_sme_req_messages()
4926 *
4927 ***FUNCTION:
4928 * This function is called by limProcessMessageQueue(). This
4929 * function processes SME request messages from HDD or upper layer
4930 * application.
4931 *
4932 ***LOGIC:
4933 *
4934 ***ASSUMPTIONS:
4935 *
4936 ***NOTE:
4937 *
4938 * @param pMac Pointer to Global MAC structure
4939 * @param msgType Indicates the SME message type
4940 * @param *pMsgBuf A pointer to the SME message buffer
4941 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4942 * false - if pMsgBuf is not to be freed.
4943 */
4944
4945bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4946{
4947 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4948 uint32_t *pMsgBuf = pMsg->bodyptr;
4949 tpSirSmeScanReq pScanReq;
4950 PELOG1(lim_log
4951 (pMac, LOG1,
4952 FL
4953 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4954 lim_msg_str(pMsg->type), pMsg->type,
4955 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4956 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4957 )
4958
4959 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4960 /* If no insert NOA required then execute the code below */
4961
4962 switch (pMsg->type) {
4963 case eWNI_SME_SYS_READY_IND:
4964 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4965 break;
4966
4967 case eWNI_SME_START_BSS_REQ:
4968 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4969 break;
4970
4971 case eWNI_SME_SCAN_REQ:
4972 __lim_process_sme_scan_req(pMac, pMsgBuf);
4973 break;
4974
4975#ifdef FEATURE_OEM_DATA_SUPPORT
4976 case eWNI_SME_OEM_DATA_REQ:
4977 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4978 break;
4979#endif
4980 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4981 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4982 break;
4983
4984 case eWNI_SME_UPDATE_NOA:
4985 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4986 break;
4987 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4988 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4989 break;
4990 case eWNI_SME_JOIN_REQ:
4991 __lim_process_sme_join_req(pMac, pMsgBuf);
4992 break;
4993
4994 case eWNI_SME_REASSOC_REQ:
4995 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4996 break;
4997
4998 case eWNI_SME_DISASSOC_REQ:
4999 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5000 break;
5001
5002 case eWNI_SME_DISASSOC_CNF:
5003 case eWNI_SME_DEAUTH_CNF:
5004 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5005 break;
5006
5007 case eWNI_SME_DEAUTH_REQ:
5008 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5009 break;
5010
5011 case eWNI_SME_SETCONTEXT_REQ:
5012 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5013 break;
5014
5015 case eWNI_SME_STOP_BSS_REQ:
5016 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5017 break;
5018
5019 case eWNI_SME_ASSOC_CNF:
5020 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5021 PELOG1(lim_log(pMac,
5022 LOG1, FL("Received ASSOC_CNF message"));)
5023 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5024 pMsgBuf);
5025 break;
5026
5027 case eWNI_SME_ADDTS_REQ:
5028 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5029 __lim_process_sme_addts_req(pMac, pMsgBuf);
5030 break;
5031
5032 case eWNI_SME_DELTS_REQ:
5033 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5034 __lim_process_sme_delts_req(pMac, pMsgBuf);
5035 break;
5036
5037 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5038 PELOG1(lim_log
5039 (pMac, LOG1,
5040 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5041 )
5042 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5043 break;
5044
5045 case eWNI_SME_GET_STATISTICS_REQ:
5046 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5047 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5048 bufConsumed = false;
5049 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005050#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 case eWNI_SME_GET_TSM_STATS_REQ:
5052 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5053 bufConsumed = false;
5054 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005055#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056 case eWNI_SME_GET_ASSOC_STAS_REQ:
5057 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5058 break;
5059 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5060 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5061 break;
5062
5063 case eWNI_SME_HIDE_SSID_REQ:
5064 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5065 break;
5066 case eWNI_SME_UPDATE_APWPSIE_REQ:
5067 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5068 break;
5069 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5070 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5071 break;
5072
5073 case eWNI_SME_SET_APWPARSNIEs_REQ:
5074 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5075 break;
5076
5077 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5078 /* Update the beaconInterval */
5079 __lim_process_sme_change_bi(pMac, pMsgBuf);
5080 break;
5081
5082#ifdef QCA_HT_2040_COEX
5083 case eWNI_SME_SET_HT_2040_MODE:
5084 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5085 break;
5086#endif
5087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5089 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5090 __lim_process_report_message(pMac, pMsg);
5091 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 case eWNI_SME_FT_PRE_AUTH_REQ:
5094 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5095 break;
5096 case eWNI_SME_FT_UPDATE_KEY:
5097 lim_process_ft_update_key(pMac, pMsgBuf);
5098 break;
5099
5100 case eWNI_SME_FT_AGGR_QOS_REQ:
5101 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5102 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103
5104 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5105 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5106 break;
5107#ifdef FEATURE_WLAN_TDLS
5108 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5109 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5110 break;
5111 case eWNI_SME_TDLS_ADD_STA_REQ:
5112 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5113 break;
5114 case eWNI_SME_TDLS_DEL_STA_REQ:
5115 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5116 break;
5117 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5118 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5119 break;
5120#endif
5121 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5122 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5123 break;
5124
5125 case eWNI_SME_CHANNEL_CHANGE_REQ:
5126 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5127 break;
5128
5129 case eWNI_SME_START_BEACON_REQ:
5130 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5131 break;
5132
5133 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5134 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5135 break;
5136
5137 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5138 lim_process_update_add_ies(pMac, pMsgBuf);
5139 break;
5140
5141 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5142 lim_process_modify_add_ies(pMac, pMsgBuf);
5143 break;
5144 case eWNI_SME_SET_HW_MODE_REQ:
5145 lim_process_set_hw_mode(pMac, pMsgBuf);
5146 break;
5147 case eWNI_SME_NSS_UPDATE_REQ:
5148 lim_process_nss_update_request(pMac, pMsgBuf);
5149 break;
5150 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5151 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5152 break;
5153 case eWNI_SME_SET_IE_REQ:
5154 lim_process_set_ie_req(pMac, pMsgBuf);
5155 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305156 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5157 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5158 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305159 case eWNI_SME_EXT_CHANGE_CHANNEL:
5160 lim_process_ext_change_channel(pMac, pMsgBuf);
5161 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005162 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5163 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5164 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005165 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5166 lim_process_set_pdev_IEs(pMac, pMsgBuf);
5167 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305169 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170 pMsg->bodyptr = NULL;
5171 break;
5172 } /* switch (msgType) */
5173
5174 return bufConsumed;
5175} /*** end lim_process_sme_req_messages() ***/
5176
5177/**
5178 * lim_process_sme_start_beacon_req()
5179 *
5180 ***FUNCTION:
5181 * This function is called by limProcessMessageQueue(). This
5182 * function processes SME request messages from HDD or upper layer
5183 * application.
5184 *
5185 ***LOGIC:
5186 *
5187 ***ASSUMPTIONS:
5188 *
5189 ***NOTE:
5190 *
5191 * @param pMac Pointer to Global MAC structure
5192 * @param msgType Indicates the SME message type
5193 * @param *pMsgBuf A pointer to the SME message buffer
5194 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5195 * false - if pMsgBuf is not to be freed.
5196 */
5197static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5198{
5199 tpSirStartBeaconIndication pBeaconStartInd;
5200 tpPESession psessionEntry;
5201 uint8_t sessionId; /* PE sessionID */
5202
5203 if (pMsg == NULL) {
5204 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5205 return;
5206 }
5207
5208 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5209 psessionEntry = pe_find_session_by_bssid(pMac,
5210 pBeaconStartInd->bssid,
5211 &sessionId);
5212 if (psessionEntry == NULL) {
5213 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5214 lim_log(pMac, LOGE,
5215 FL("Session does not exist for given bssId"));
5216 return;
5217 }
5218
5219 if (pBeaconStartInd->beaconStartStatus == true) {
5220 /*
5221 * Currently this Indication comes from SAP
5222 * to start Beacon Tx on a DFS channel
5223 * since beaconing has to be done on DFS
5224 * channel only after CAC WAIT is completed.
5225 * On a DFS Channel LIM does not start beacon
5226 * Tx right after the WMA_ADD_BSS_RSP.
5227 */
5228 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305229 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 FL("Start Beacon with ssid %s Ch %d"),
5231 psessionEntry->ssId.ssId,
5232 psessionEntry->currentOperChannel);
5233 lim_send_beacon_ind(pMac, psessionEntry);
5234 } else {
5235 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5236 return;
5237 }
5238}
5239
5240/**
5241 * lim_process_sme_channel_change_request() - process sme ch change req
5242 *
5243 * @mac_ctx: Pointer to Global MAC structure
5244 * @msg_buf: pointer to the SME message buffer
5245 *
5246 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5247 *
5248 * Return: None
5249 */
5250static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5251 uint32_t *msg_buf)
5252{
5253 tpSirChanChangeRequest ch_change_req;
5254 tpPESession session_entry;
5255 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005256 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 uint32_t val = 0;
5258
5259 if (msg_buf == NULL) {
5260 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5261 return;
5262 }
5263 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5264
5265 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5266 ch_change_req->targetChannel);
5267
5268 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5269 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5270 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5271 return;
5272 }
5273
5274 session_entry = pe_find_session_by_bssid(mac_ctx,
5275 ch_change_req->bssid, &session_id);
5276 if (session_entry == NULL) {
5277 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5278 lim_log(mac_ctx, LOGE, FL(
5279 "Session does not exist for given bssId"));
5280 return;
5281 }
5282
5283 if (session_entry->currentOperChannel ==
5284 ch_change_req->targetChannel) {
5285 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5286 return;
5287 }
5288
5289 if (LIM_IS_AP_ROLE(session_entry))
5290 session_entry->channelChangeReasonCode =
5291 LIM_SWITCH_CHANNEL_SAP_DFS;
5292 else
5293 session_entry->channelChangeReasonCode =
5294 LIM_SWITCH_CHANNEL_OPERATION;
5295
5296 lim_log(mac_ctx, LOGW, FL(
5297 "switch old chnl %d to new chnl %d, ch_bw %d"),
5298 session_entry->currentOperChannel,
5299 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005300 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301
5302 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005303 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 session_entry->ch_center_freq_seg0 =
5305 ch_change_req->center_freq_seg_0;
5306 session_entry->ch_center_freq_seg1 =
5307 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005308 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005310 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 session_entry->htRecommendedTxWidthSet =
5312 session_entry->htSupportedChannelWidthSet;
5313 session_entry->currentOperChannel =
5314 ch_change_req->targetChannel;
5315 session_entry->limRFBand =
5316 lim_get_rf_band(session_entry->currentOperChannel);
5317 /* Initialize 11h Enable Flag */
5318 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5319 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5320 eSIR_SUCCESS)
5321 lim_log(mac_ctx, LOGP,
5322 FL("Fail to get WNI_CFG_11H_ENABLED"));
5323 }
5324
5325 session_entry->lim11hEnable = val;
5326 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305327 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 &ch_change_req->operational_rateset,
5329 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305330 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 &ch_change_req->extended_rateset,
5332 sizeof(session_entry->extRateSet));
5333 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5334 session_entry->ch_center_freq_seg0,
5335 session_entry->ch_center_freq_seg1,
5336 session_entry->ch_width,
5337 max_tx_pwr, session_entry->peSessionId);
5338}
5339
5340/******************************************************************************
5341* lim_start_bss_update_add_ie_buffer()
5342*
5343***FUNCTION:
5344* This function checks the src buffer and its length and then malloc for
5345* dst buffer update the same
5346*
5347***LOGIC:
5348*
5349***ASSUMPTIONS:
5350*
5351***NOTE:
5352*
5353* @param pMac Pointer to Global MAC structure
5354* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5355* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5356* @param *pSrcData_buff A pointer of uint8_t src buffer
5357* @param srcDataLen src buffer length
5358******************************************************************************/
5359
5360static void
5361lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5362 uint8_t **pDstData_buff,
5363 uint16_t *pDstDataLen,
5364 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5365{
5366
5367 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5368 *pDstDataLen = srcDataLen;
5369
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305370 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371
5372 if (NULL == *pDstData_buff) {
5373 lim_log(pMac, LOGE,
5374 FL("AllocateMemory failed for pDstData_buff"));
5375 return;
5376 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305377 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 } else {
5379 *pDstData_buff = NULL;
5380 *pDstDataLen = 0;
5381 }
5382}
5383
5384/******************************************************************************
5385* lim_update_add_ie_buffer()
5386*
5387***FUNCTION:
5388* This function checks the src buffer and length if src buffer length more
5389* than dst buffer length then free the dst buffer and malloc for the new src
5390* length, and update the dst buffer and length. But if dst buffer is bigger
5391* than src buffer length then it just update the dst buffer and length
5392*
5393***LOGIC:
5394*
5395***ASSUMPTIONS:
5396*
5397***NOTE:
5398*
5399* @param pMac Pointer to Global MAC structure
5400* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5401* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5402* @param *pSrcData_buff A pointer of uint8_t src buffer
5403* @param srcDataLen src buffer length
5404******************************************************************************/
5405
5406static void
5407lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5408 uint8_t **pDstData_buff,
5409 uint16_t *pDstDataLen,
5410 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5411{
5412
5413 if (NULL == pSrcData_buff) {
5414 lim_log(pMac, LOGE, FL("src buffer is null."));
5415 return;
5416 }
5417
5418 if (srcDataLen > *pDstDataLen) {
5419 *pDstDataLen = srcDataLen;
5420 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305421 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305423 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424
5425 if (NULL == *pDstData_buff) {
5426 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5427 *pDstDataLen = 0;
5428 return;
5429 }
5430 }
5431
5432 /* copy the content of buffer into dst buffer
5433 */
5434 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305435 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436
5437}
5438
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005439/**
5440 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5441 * @pMac : Pointer to Global MAC structure
5442 * @pDstData_buff : A pointer to pointer of dst buffer
5443 * @pDstDataLen : A pointer to pointer of dst buffer length
5444 * @pModifyIE : A pointer to tSirModifyIE
5445 *
5446 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5447 *
5448 * Return:
5449 * True or false depending upon whether IE is updated or not
5450 */
5451static bool
5452lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5453 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5454{
5455 int32_t oui_length;
5456 uint8_t *ibss_ie = NULL;
5457
5458 ibss_ie = pModifyIE->pIEBuffer;
5459 oui_length = pModifyIE->oui_length;
5460
5461 if ((0 == oui_length) || (NULL == ibss_ie)) {
5462 PELOGE(lim_log(pMac, LOGE,
5463 FL("Invalid set IBSS vendor IE command length %d "),
5464 oui_length);)
5465 return false;
5466 }
5467
5468 lim_update_add_ie_buffer(pMac,
5469 pDstData_buff,
5470 pDstDataLen,
5471 pModifyIE->pIEBuffer,
5472 pModifyIE->ieBufferlength);
5473
5474 return true;
5475}
5476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477/*
5478* lim_process_modify_add_ies() - process modify additional IE req.
5479*
5480* @mac_ctx: Pointer to Global MAC structure
5481* @msg_buf: pointer to the SME message buffer
5482*
5483* This function update the PE buffers for additional IEs.
5484*
5485* Return: None
5486*/
5487static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5488 uint32_t *msg_buf)
5489{
5490 tpSirModifyIEsInd modify_add_ies;
5491 tpPESession session_entry;
5492 uint8_t session_id;
5493 bool ret = false;
5494 tSirAddIeParams *add_ie_params;
5495
5496 if (msg_buf == NULL) {
5497 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5498 return;
5499 }
5500
5501 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5502 /* Incoming message has smeSession, use BSSID to find PE session */
5503 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005504 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505
5506 if (NULL == session_entry) {
5507 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5508 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005509 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510 goto end;
5511 }
5512 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5513 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5514 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5515 lim_log(mac_ctx, LOGE,
5516 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5517 modify_add_ies->modifyIE.pIEBuffer,
5518 modify_add_ies->modifyIE.ieBufferlength,
5519 modify_add_ies->modifyIE.ieID,
5520 modify_add_ies->modifyIE.ieIDLen,
5521 modify_add_ies->updateType);
5522 goto end;
5523 }
5524 add_ie_params = &session_entry->addIeParams;
5525 switch (modify_add_ies->updateType) {
5526 case eUPDATE_IE_PROBE_RESP:
5527 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005528 if (LIM_IS_IBSS_ROLE(session_entry)) {
5529 lim_update_ibss_prop_add_ies(mac_ctx,
5530 &add_ie_params->probeRespData_buff,
5531 &add_ie_params->probeRespDataLen,
5532 &modify_add_ies->modifyIE);
5533 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 break;
5535 case eUPDATE_IE_ASSOC_RESP:
5536 /* assoc resp IE */
5537 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305538 QDF_TRACE(QDF_MODULE_ID_PE,
5539 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540 "assoc resp add ie not present %d"),
5541 add_ie_params->assocRespDataLen);
5542 }
5543 /* search through the buffer and modify the IE */
5544 break;
5545 case eUPDATE_IE_PROBE_BCN:
5546 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005547 if (LIM_IS_IBSS_ROLE(session_entry)) {
5548 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5549 &add_ie_params->probeRespBCNData_buff,
5550 &add_ie_params->probeRespBCNDataLen,
5551 &modify_add_ies->modifyIE);
5552 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 if (ret == true && modify_add_ies->modifyIE.notify) {
5554 lim_handle_param_update(mac_ctx,
5555 modify_add_ies->updateType);
5556 }
5557 break;
5558 default:
5559 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5560 modify_add_ies->updateType);
5561 break;
5562 }
5563end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305564 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 modify_add_ies->modifyIE.pIEBuffer = NULL;
5566}
5567
5568/*
5569* lim_process_update_add_ies() - process additional IE update req
5570*
5571* @mac_ctx: Pointer to Global MAC structure
5572* @msg_buf: pointer to the SME message buffer
5573*
5574* This function update the PE buffers for additional IEs.
5575*
5576* Return: None
5577*/
5578static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5579 uint32_t *msg_buf)
5580{
5581 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5582 uint8_t session_id;
5583 tpPESession session_entry;
5584 tSirAddIeParams *addn_ie;
5585 uint16_t new_length = 0;
5586 uint8_t *new_ptr = NULL;
5587 tSirUpdateIE *update_ie;
5588
5589 if (msg_buf == NULL) {
5590 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5591 return;
5592 }
5593 update_ie = &update_add_ies->updateIE;
5594 /* incoming message has smeSession, use BSSID to find PE session */
5595 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005596 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597
5598 if (NULL == session_entry) {
5599 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5600 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005601 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 goto end;
5603 }
5604 addn_ie = &session_entry->addIeParams;
5605 /* if len is 0, upper layer requested freeing of buffer */
5606 if (0 == update_ie->ieBufferlength) {
5607 switch (update_add_ies->updateType) {
5608 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305609 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 addn_ie->probeRespData_buff = NULL;
5611 addn_ie->probeRespDataLen = 0;
5612 break;
5613 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 addn_ie->assocRespData_buff = NULL;
5616 addn_ie->assocRespDataLen = 0;
5617 break;
5618 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305619 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 addn_ie->probeRespBCNData_buff = NULL;
5621 addn_ie->probeRespBCNDataLen = 0;
5622
5623 if (update_ie->notify)
5624 lim_handle_param_update(mac_ctx,
5625 update_add_ies->updateType);
5626 break;
5627 default:
5628 break;
5629 }
5630 return;
5631 }
5632 switch (update_add_ies->updateType) {
5633 case eUPDATE_IE_PROBE_RESP:
5634 if (update_ie->append) {
5635 /*
5636 * In case of append, allocate new memory
5637 * with combined length
5638 */
5639 new_length = update_ie->ieBufferlength +
5640 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305641 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 if (NULL == new_ptr) {
5643 lim_log(mac_ctx, LOGE, FL(
5644 "Memory allocation failed."));
5645 goto end;
5646 }
5647 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305648 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305650 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 update_ie->pAdditionIEBuffer,
5652 update_ie->ieBufferlength);
5653 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305654 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 /* adjust length accordingly */
5656 addn_ie->probeRespDataLen = new_length;
5657 /* save refernece of local buffer in PE session */
5658 addn_ie->probeRespData_buff = new_ptr;
5659 goto end;
5660 }
5661 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5662 &addn_ie->probeRespDataLen,
5663 update_ie->pAdditionIEBuffer,
5664 update_ie->ieBufferlength);
5665 break;
5666 case eUPDATE_IE_ASSOC_RESP:
5667 /* assoc resp IE */
5668 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5669 &addn_ie->assocRespDataLen,
5670 update_ie->pAdditionIEBuffer,
5671 update_ie->ieBufferlength);
5672 break;
5673 case eUPDATE_IE_PROBE_BCN:
5674 /* probe resp Bcn IE */
5675 lim_update_add_ie_buffer(mac_ctx,
5676 &addn_ie->probeRespBCNData_buff,
5677 &addn_ie->probeRespBCNDataLen,
5678 update_ie->pAdditionIEBuffer,
5679 update_ie->ieBufferlength);
5680 if (update_ie->notify)
5681 lim_handle_param_update(mac_ctx,
5682 update_add_ies->updateType);
5683 break;
5684 default:
5685 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5686 update_add_ies->updateType);
5687 break;
5688 }
5689end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305690 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 update_ie->pAdditionIEBuffer = NULL;
5692}
5693
5694/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305695 * send_extended_chan_switch_action_frame()- function to send ECSA
5696 * action frame for each sta connected to SAP/GO and AP in case of
5697 * STA .
5698 * @mac_ctx: pointer to global mac structure
5699 * @new_channel: new channel to switch to.
5700 * @ch_bandwidth: BW of channel to calculate op_class
5701 * @session_entry: pe session
5702 *
5703 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5704 *
5705 * Return: void
5706 */
5707
5708static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5709 uint16_t new_channel, uint8_t ch_bandwidth,
5710 tpPESession session_entry)
5711{
5712 uint16_t op_class;
5713 uint8_t switch_mode = 0, i;
5714 tpDphHashNode psta;
5715
5716
Amar Singhal22995112016-01-22 10:42:33 -08005717 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305718 mac_ctx->scan.countryCodeCurrent,
5719 new_channel,
5720 ch_bandwidth);
5721
5722 if (LIM_IS_AP_ROLE(session_entry) &&
5723 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5724 switch_mode = 1;
5725
5726 if (LIM_IS_AP_ROLE(session_entry)) {
5727 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5728 psta =
5729 session_entry->dph.dphHashTable.pDphNodeArray + i;
5730 if (psta && psta->added)
5731 lim_send_extended_chan_switch_action_frame(
5732 mac_ctx,
5733 psta->staAddr,
5734 switch_mode, op_class, new_channel,
5735 LIM_MAX_CSA_IE_UPDATES, session_entry);
5736 }
5737 } else if (LIM_IS_STA_ROLE(session_entry)) {
5738 lim_send_extended_chan_switch_action_frame(mac_ctx,
5739 session_entry->bssId,
5740 switch_mode, op_class, new_channel,
5741 LIM_MAX_CSA_IE_UPDATES, session_entry);
5742 }
5743
5744}
5745
5746/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5748 *
5749 * @mac_ctx: Pointer to Global MAC structure
5750 * @msg_buf: pointer to the SME message buffer
5751 *
5752 * This function processes SME request messages from HDD or upper layer
5753 * application.
5754 *
5755 * Return: None
5756 */
5757static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5758 uint32_t *msg_buf)
5759{
5760 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5761 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 uint8_t session_id;
5763 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005764 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765
5766 if (msg_buf == NULL) {
5767 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5768 return;
5769 }
5770
5771 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5772 session_entry = pe_find_session_by_bssid(mac_ctx,
5773 dfs_csa_ie_req->bssid, &session_id);
5774 if (session_entry == NULL) {
5775 lim_log(mac_ctx, LOGE, FL(
5776 "Session not found for given BSSID" MAC_ADDRESS_STR),
5777 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5778 return;
5779 }
5780
5781 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5782 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5783 GET_LIM_SYSTEM_ROLE(session_entry));
5784 return;
5785 }
5786
5787 /* target channel */
5788 session_entry->gLimChannelSwitch.primaryChannel =
5789 dfs_csa_ie_req->targetChannel;
5790
5791 /* Channel switch announcement needs to be included in beacon */
5792 session_entry->dfsIncludeChanSwIe = true;
5793 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5794 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005795 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305796 session_entry->gLimChannelSwitch.sec_ch_offset =
5797 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5799 session_entry->gLimChannelSwitch.switchMode = 1;
5800
5801 /*
5802 * Validate if SAP is operating HT or VHT mode and set the Channel
5803 * Switch Wrapper element with the Wide Band Switch subelement.
5804 */
5805 if (true != session_entry->vhtCapability)
5806 goto skip_vht;
5807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 /* Now encode the Wider Ch BW element depending on the ch width */
5809 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005810 switch (dfs_csa_ie_req->ch_params.ch_width) {
5811 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 /*
5813 * Wide channel BW sublement in channel wrapper element is not
5814 * required in case of 20 Mhz operation. Currently It is set
5815 * only set in case of 40/80 Mhz Operation.
5816 */
5817 session_entry->dfsIncludeChanWrapperIe = false;
5818 wider_bw_ch_switch->newChanWidth =
5819 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5820 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005821 case CH_WIDTH_40MHZ:
5822 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 wider_bw_ch_switch->newChanWidth =
5824 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5825 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005826 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 session_entry->dfsIncludeChanWrapperIe = true;
5828 wider_bw_ch_switch->newChanWidth =
5829 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5830 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005831 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 session_entry->dfsIncludeChanWrapperIe = true;
5833 wider_bw_ch_switch->newChanWidth =
5834 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5835 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005836 case CH_WIDTH_80P80MHZ:
5837 session_entry->dfsIncludeChanWrapperIe = true;
5838 wider_bw_ch_switch->newChanWidth =
5839 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005840 /*
5841 * This is not applicable for 20/40/80 Mhz.
5842 * Only used when we support 80+80 Mhz operation.
5843 * In case of 80+80 Mhz, this parameter indicates
5844 * center channel frequency index of 80 Mhz channel of
5845 * frequency segment 1.
5846 */
5847 wider_bw_ch_switch->newCenterChanFreq1 =
5848 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005849 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 default:
5851 session_entry->dfsIncludeChanWrapperIe = false;
5852 /*
5853 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5854 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5855 */
5856 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5857 break;
5858 }
5859 /* Fetch the center channel based on the channel width */
5860 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005861 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862skip_vht:
5863 /* Send CSA IE request from here */
5864 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5865 eSIR_SUCCESS) {
5866 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5867 return;
5868 }
5869
5870 /*
5871 * First beacon update request is sent here, the remaining updates are
5872 * done when the FW responds back after sending the first beacon after
5873 * the template update
5874 */
5875 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305876
5877 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5878 ch_offset = BW80;
5879 else
5880 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5881
5882 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5883 session_entry->gLimChannelSwitch.switchCount,
5884 session_entry->gLimChannelSwitch.primaryChannel,
5885 session_entry->gLimChannelSwitch.ch_width,
5886 session_entry->dfsIncludeChanWrapperIe,
5887 ch_offset);
5888
Abhishek Singh518323d2015-10-19 17:42:01 +05305889 /* Send ECSA Action frame after updating the beacon */
5890 send_extended_chan_switch_action_frame(mac_ctx,
5891 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305892 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893 session_entry->gLimChannelSwitch.switchCount--;
5894}
5895
5896/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305897 * lim_process_ext_change_channel()- function to send ECSA
5898 * action frame for STA/CLI .
5899 * @mac_ctx: pointer to global mac structure
5900 * @msg: params from sme for new channel.
5901 *
5902 * This function is called to send ECSA frame for STA/CLI.
5903 *
5904 * Return: void
5905 */
5906
5907static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5908 uint32_t *msg)
5909{
5910 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5911 (struct sir_sme_ext_cng_chan_req *) msg;
5912 tpPESession session_entry = NULL;
5913
5914 if (NULL == msg) {
5915 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5916 return;
5917 }
5918 session_entry =
5919 pe_find_session_by_sme_session_id(mac_ctx,
5920 ext_chng_channel->session_id);
5921 if (NULL == session_entry) {
5922 lim_log(mac_ctx, LOGE,
5923 FL("Session not found for given session %d"),
5924 ext_chng_channel->session_id);
5925 return;
5926 }
5927 if (LIM_IS_AP_ROLE(session_entry)) {
5928 lim_log(mac_ctx, LOGE,
5929 FL("not an STA/CLI session"));
5930 return;
5931 }
5932 send_extended_chan_switch_action_frame(mac_ctx,
5933 ext_chng_channel->new_channel,
5934 0, session_entry);
5935}
5936
5937/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 * lim_process_nss_update_request() - process sme nss update req
5939 *
5940 * @mac_ctx: Pointer to Global MAC structure
5941 * @msg_buf: pointer to the SME message buffer
5942 *
5943 * This function processes SME request messages from HDD or upper layer
5944 * application.
5945 *
5946 * Return: None
5947 */
5948static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5949 uint32_t *msg_buf)
5950{
5951 struct sir_nss_update_request *nss_update_req_ptr;
5952 tpPESession session_entry = NULL;
5953
5954 if (msg_buf == NULL) {
5955 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5956 return;
5957 }
5958
5959 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305960 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 nss_update_req_ptr->vdev_id);
5962 if (session_entry == NULL) {
5963 lim_log(mac_ctx, LOGE, FL(
5964 "Session not found for given session_id %d"),
5965 nss_update_req_ptr->vdev_id);
5966 return;
5967 }
5968
5969 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5970 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5971 GET_LIM_SYSTEM_ROLE(session_entry));
5972 return;
5973 }
5974
5975 /* populate nss field in the beacon */
5976 session_entry->gLimOperatingMode.present = 1;
5977 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5978 /* Send nss update request from here */
5979 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5980 eSIR_SUCCESS) {
5981 lim_log(mac_ctx, LOGE,
5982 FL("Unable to set op mode IE in beacon"));
5983 return;
5984 }
5985
5986 lim_send_beacon_ind(mac_ctx, session_entry);
5987}
5988
5989/**
5990 * lim_process_set_ie_req() - process sme set IE request
5991 *
5992 * @mac_ctx: Pointer to Global MAC structure
5993 * @msg_buf: pointer to the SME message buffer
5994 *
5995 * This function processes SME request messages from HDD or upper layer
5996 * application.
5997 *
5998 * Return: None
5999 */
6000static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6001{
6002 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306003 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004
6005 if (msg_buf == NULL) {
6006 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6007 return;
6008 }
6009
6010 msg = (struct send_extcap_ie *)msg_buf;
6011 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306012 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6014
6015}