blob: 679cee43708ea4dea82718517e927992c6d91696 [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>
Abhishek Singh518323d2015-10-19 17:42:01 +053065#include "cds_regdomain_common.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);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119
Abhishek Singh518323d2015-10-19 17:42:01 +0530120static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
121 uint32_t *msg);
122
123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124/**
125 * lim_process_set_hw_mode() - Send set HW mode command to WMA
126 * @mac: Globacl MAC pointer
127 * @msg: Message containing the hw mode index
128 *
129 * Send the set HW mode command to WMA
130 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530131 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530133static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530135 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136 cds_msg_t cds_message;
137 struct sir_hw_mode *req_msg;
138 uint32_t len;
139 struct s_sir_set_hw_mode *buf;
140 tSirMsgQ resp_msg;
141 struct sir_set_hw_mode_resp *param;
142
143 buf = (struct s_sir_set_hw_mode *) msg;
144 if (!buf) {
145 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
146 /* To free the active command list */
147 goto fail;
148 }
149
150 len = sizeof(*req_msg);
151
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530152 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530154 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 /* Free the active command list
156 * Probably the malloc is going to fail there as well?!
157 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530158 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 }
160
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530161 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162
163 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530164 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 /* Other parameters are not needed for WMA */
166
167 cds_message.bodyptr = req_msg;
168 cds_message.type = SIR_HAL_SOC_SET_HW_MODE;
169
170 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
171 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530172 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 lim_log(mac, LOGE,
174 FL("vos_mq_post_message failed!(err=%d)"),
175 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530176 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 goto fail;
178 }
179 return status;
180fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530181 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 if (!param) {
183 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530184 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 }
186 param->status = SET_HW_MODE_STATUS_ECANCELED;
187 param->cfgd_hw_mode_index = 0;
188 param->num_vdev_mac_entries = 0;
189 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
190 resp_msg.bodyptr = param;
191 resp_msg.bodyval = 0;
192 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530193 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194}
195
196/**
197 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
198 * @mac: Global MAC pointer
199 * @msg: Message containing the dual mac config parameter
200 *
201 * Send the set dual mac config command to WMA
202 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530203 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 uint32_t *msg)
207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530208 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 cds_msg_t cds_message;
210 struct sir_dual_mac_config *req_msg;
211 uint32_t len;
212 struct sir_set_dual_mac_cfg *buf;
213 tSirMsgQ resp_msg;
214 struct sir_dual_mac_config_resp *param;
215
216 buf = (struct sir_set_dual_mac_cfg *) msg;
217 if (!buf) {
218 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
219 /* To free the active command list */
220 goto fail;
221 }
222
223 len = sizeof(*req_msg);
224
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530225 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 if (!req_msg) {
227 lim_log(mac, LOGE, FL("vos_mem_malloc failed"));
228 /* Free the active command list
229 * Probably the malloc is going to fail there as well?!
230 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530231 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 }
233
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530234 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
236 req_msg->scan_config = buf->set_dual_mac.scan_config;
237 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
238 /* Other parameters are not needed for WMA */
239
240 cds_message.bodyptr = req_msg;
241 cds_message.type = SIR_HAL_SOC_DUAL_MAC_CFG_REQ;
242
243 lim_log(mac, LOG1,
244 FL("Post SIR_HAL_SOC_DUAL_MAC_CFG_REQ to WMA: %x %x"),
245 req_msg->scan_config, req_msg->fw_mode_config);
246 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 lim_log(mac, LOGE,
249 FL("vos_mq_post_message failed!(err=%d)"),
250 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530251 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 goto fail;
253 }
254 return status;
255fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530256 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 if (!param) {
258 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530259 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 }
261 param->status = SET_HW_MODE_STATUS_ECANCELED;
262 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
263 resp_msg.bodyptr = param;
264 resp_msg.bodyval = 0;
265 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530266 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267}
268
269/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800270 * lim_process_set_antenna_mode_req() - Set antenna mode command
271 * to WMA
272 * @mac: Global MAC pointer
273 * @msg: Message containing the antenna mode parameter
274 *
275 * Send the set antenna mode command to WMA
276 *
277 * Return: QDF_STATUS_SUCCESS if message posting is successful
278 */
279static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
280 uint32_t *msg)
281{
282 QDF_STATUS status = QDF_STATUS_SUCCESS;
283 cds_msg_t cds_message;
284 struct sir_antenna_mode_param *req_msg;
285 struct sir_set_antenna_mode *buf;
286 tSirMsgQ resp_msg;
287 struct sir_antenna_mode_resp *param;
288
289 buf = (struct sir_set_antenna_mode *) msg;
290 if (!buf) {
291 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
292 /* To free the active command list */
293 goto fail;
294 }
295
296 req_msg = qdf_mem_malloc(sizeof(*req_msg));
297 if (!req_msg) {
298 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
299 return QDF_STATUS_E_NOMEM;
300 }
301
302 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
303 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
304
305 cds_message.bodyptr = req_msg;
306 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
307
308 lim_log(mac, LOG1,
309 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
310 req_msg->num_rx_chains,
311 req_msg->num_tx_chains);
312 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
313 if (!QDF_IS_STATUS_SUCCESS(status)) {
314 lim_log(mac, LOGE,
315 FL("vos_mq_post_message failed!(err=%d)"),
316 status);
317 qdf_mem_free(req_msg);
318 goto fail;
319 }
320 return status;
321fail:
322 param = qdf_mem_malloc(sizeof(*param));
323 if (!param) {
324 lim_log(mac, LOGE, FL("antenna mode resp failed"));
325 return QDF_STATUS_E_NOMEM;
326 }
327 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
328 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
329 resp_msg.bodyptr = param;
330 resp_msg.bodyval = 0;
331 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
332 return QDF_STATUS_SUCCESS;
333}
334
335/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
337 * @mac_ctx: Pointer to Global MAC structure
338 * @return_fresh_results: Trigger fresh scan.
339 *
340 * PE will do fresh scan, if all of the active sessions are in
341 * good state (Link Est or BSS Started). If one of the sessions
342 * is not in one of the above states, then PE does not do fresh
343 * scan. If no session exists (scanning very first time),
344 * then PE will always do fresh scan if SME asks it to do that.
345 *
346 * Return: true for fresh scan results, false if in invalid state.
347 */
348static uint8_t
349__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
350{
351 uint8_t valid_state = true;
352 int i;
353
354 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
355 mac_ctx->lim.gLimSmeState, return_fresh_results);
356
357 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
358 lim_log(mac_ctx, LOG1, FL("return FALSE"));
359 return false;
360 }
361
362 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
363 lim_log(mac_ctx, LOG1,
364 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
365 i, mac_ctx->lim.gpSession[i].bssType,
366 mac_ctx->lim.gpSession[i].limSystemRole,
367 mac_ctx->lim.gpSession[i].limSmeState);
368 if (mac_ctx->lim.gpSession[i].valid == true) {
369 if (!((((mac_ctx->lim.gpSession[i].bssType ==
370 eSIR_INFRASTRUCTURE_MODE) ||
371 (mac_ctx->lim.gpSession[i].limSystemRole ==
372 eLIM_BT_AMP_STA_ROLE)) &&
373 (mac_ctx->lim.gpSession[i].limSmeState ==
374 eLIM_SME_LINK_EST_STATE)) ||
375 (((mac_ctx->lim.gpSession[i].bssType ==
376 eSIR_IBSS_MODE) ||
377 (mac_ctx->lim.gpSession[i].limSystemRole ==
378 eLIM_BT_AMP_AP_ROLE) ||
379 (mac_ctx->lim.gpSession[i].limSystemRole ==
380 eLIM_BT_AMP_STA_ROLE)) &&
381 (mac_ctx->lim.gpSession[i].limSmeState ==
382 eLIM_SME_NORMAL_STATE)) ||
383 ((((mac_ctx->lim.gpSession[i].bssType ==
384 eSIR_INFRA_AP_MODE) &&
385 (mac_ctx->lim.gpSession[i].pePersona ==
Anurag Chouhan6d760662016-02-20 16:05:43 +0530386 QDF_P2P_GO_MODE)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 (mac_ctx->lim.gpSession[i].limSystemRole ==
388 eLIM_AP_ROLE)) &&
389 (mac_ctx->lim.gpSession[i].limSmeState ==
390 eLIM_SME_NORMAL_STATE)))) {
391 valid_state = false;
392 break;
393 }
394 }
395 }
396
397 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
398
399 if ((valid_state) &&
400 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
401 return true;
402 else
403 return false;
404}
405
406/**
407 * __lim_is_sme_assoc_cnf_valid()
408 *
409 ***FUNCTION:
410 * This function is called by __lim_process_sme_assoc_cnf_new() upon
411 * receiving SME_ASSOC_CNF.
412 *
413 ***LOGIC:
414 * Message validity checks are performed in this function
415 *
416 ***ASSUMPTIONS:
417 *
418 ***NOTE:
419 *
420 * @param pMeasReq Pointer to Received ASSOC_CNF message
421 * @return true When received SME_ASSOC_CNF is formatted
422 * correctly
423 * false otherwise
424 */
425
426static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
427{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530428 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 return false;
430 else
431 return true;
432} /*** end __lim_is_sme_assoc_cnf_valid() ***/
433
434/**
435 * __lim_get_sme_join_req_size_for_alloc()
436 *
437 ***FUNCTION:
438 * This function is called in various places to get IE length
439 * from tSirBssDescription structure
440 * number being scanned.
441 *
442 ***PARAMS:
443 *
444 ***LOGIC:
445 *
446 ***ASSUMPTIONS:
447 * NA
448 *
449 ***NOTE:
450 * NA
451 *
452 * @param pBssDescr
453 * @return Total IE length
454 */
455
456static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
457{
458 uint16_t len = 0;
459
460 if (!pBuf)
461 return len;
462
463 pBuf += sizeof(uint16_t);
464 len = lim_get_u16(pBuf);
465 return len + sizeof(uint16_t);
466}
467
468/**
469 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
470 * @pMac: Global MAC context
471 * @pMsg: Pointer to message posted from SME to LIM.
472 *
473 * Has role only if 11h is enabled. Not used on STA side.
474 * Defers the message if SME is in learn state and brings
475 * the LIM back to normal mode.
476 *
477 * Return: true - If defered false - Otherwise
478 */
479
480static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
481{
482 if (lim_is_system_in_scan_state(pMac)) {
483 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
484 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
485 pMsg->type);
486 return false;
487 }
488 lim_log(pMac, LOG1,
489 FL("Defer the message, in learn mode type = %d"),
490 pMsg->type);
491 return true;
492 }
493 return false;
494}
495
496/**
497 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
498 * @mac_ctx: Pointer to Global MAC structure
499 * @message: Pointer to message posted from SME to LIM.
500 *
501 * Has role only if 11h is enabled. Not used on STA side.
502 * Defers the message if radar is detected.
503 *
504 * Return: true, if defered otherwise return false.
505 */
506static bool
507__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
508{
509 /*
510 * fRadarDetCurOperChan will be set only if we
511 * detect radar in current operating channel and
512 * System Role == AP ROLE
513 *
514 * TODO: Need to take care radar detection.
515 *
516 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
517 */
518 if (0) {
519 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
520 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
521 message->type);
522 return false;
523 }
524 lim_log(mac_ctx, LOG1,
525 FL("Defer the message, in learn mode type = %d"),
526 message->type);
527 return true;
528 }
529 return false;
530}
531
532/**
533 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
534 * @pMac: Global MAC context
535 * @pMsgBuf: Message from WMA
536 *
537 * handles the notification from HDD. PE just forwards this message to HAL.
538 *
539 * Return: true-Posting to HAL failed, so PE will consume the buffer.
540 * false-Posting to HAL successful, so HAL will consume the buffer.
541 */
542
543static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
544{
545 tSirMsgQ msg;
546 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
547
548 msg.type = WMA_SYS_READY_IND;
549 msg.reserved = 0;
550 msg.bodyptr = pMsgBuf;
551 msg.bodyval = 0;
552
553 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800554 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
555 pe_register_wma_handle(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
557 }
558 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
559 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
560
561 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
562 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
563 return true;
564 }
565 return false;
566}
567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568/**
569 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
570 *@mac_ctx: Pointer to Global MAC structure
571 *@session: A pointer to session entry
572 *@sme_start_bss_req: Start BSS Request from upper layers.
573 *
574 * This function is used to configure the start bss parameters
575 * in to the session.
576 *
577 * Return: None.
578 */
579static void
580lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
581 tpSirSmeStartBssReq sme_start_bss_req)
582{
583 session->limSystemRole = eLIM_AP_ROLE;
584 session->privacy = sme_start_bss_req->privacy;
585 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
586 session->authType = sme_start_bss_req->authType;
587 /* Store the DTIM period */
588 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
589 /* Enable/disable UAPSD */
590 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530591 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 session->proxyProbeRspEn = 0;
593 } else {
594 /*
595 * To detect PBC overlap in SAP WPS mode,
596 * Host handles Probe Requests.
597 */
598 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
599 session->proxyProbeRspEn = 1;
600 else
601 session->proxyProbeRspEn = 0;
602 }
603 session->ssidHidden = sme_start_bss_req->ssidHidden;
604 session->wps_state = sme_start_bss_req->wps_state;
605 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
606 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
607 &session->shortSlotTimeSupported);
608 session->isCoalesingInIBSSAllowed =
609 sme_start_bss_req->isCoalesingInIBSSAllowed;
610
611}
612
613/**
614 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
615 *@mac_ctx: Pointer to Global MAC structure
616 *@msg_buf: A pointer to the SME message buffer
617 *
618 * This function is called to process SME_START_BSS_REQ message
619 * from HDD or upper layer application.
620 *
621 * Return: None
622 */
623static void
624__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
625{
626 uint16_t size;
627 uint32_t val = 0;
628 tSirRetStatus ret_status;
629 tSirMacChanNum channel_number;
630 tLimMlmStartReq *mlm_start_req = NULL;
631 tpSirSmeStartBssReq sme_start_bss_req = NULL;
632 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
633 /* Flag Used in case of IBSS to Auto generate BSSID. */
634 uint32_t auto_gen_bssid = false;
635 uint8_t session_id;
636 tpPESession session = NULL;
637 uint8_t sme_session_id = 0;
638 uint16_t sme_transaction_id = 0;
639 uint32_t chanwidth;
640 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
641
642/* FEATURE_WLAN_DIAG_SUPPORT */
643#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
644 /*
645 * Since the session is not created yet, sending NULL.
646 * The response should have the correct state.
647 */
648 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
649 NULL, 0, 0);
650#endif /* FEATURE_WLAN_DIAG_SUPPORT */
651
652 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
653
654 /*
655 * Global Sme state and mlm states are not defined yet,
656 * for BT-AMP Suppoprt . TO BE DONE
657 */
658 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
659 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
660 size = sizeof(tSirSmeStartBssReq);
661
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530662 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 if (NULL == sme_start_bss_req) {
664 lim_log(mac_ctx, LOGE,
665 FL("Allocate Memory fail for LimStartBssReq"));
666 /* Send failure response to host */
667 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
668 goto end;
669 }
670
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530671 qdf_mem_set((void *)sme_start_bss_req, size, 0);
672 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 sizeof(tSirSmeStartBssReq));
674 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
675 sme_start_bss_req)) {
676 lim_log(mac_ctx, LOGW,
677 FL("Received invalid eWNI_SME_START_BSS_REQ"));
678 ret_code = eSIR_SME_INVALID_PARAMETERS;
679 goto free;
680 }
681
682 /*
683 * This is the place where PE is going to create a session.
684 * If session is not existed, then create a new session
685 */
686 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800687 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 if (session != NULL) {
689 lim_log(mac_ctx, LOGW,
690 FL("Session Already exists for given BSSID"));
691 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
692 session = NULL;
693 goto free;
694 } else {
695 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800696 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 &session_id, mac_ctx->lim.maxStation,
698 sme_start_bss_req->bssType);
699 if (session == NULL) {
700 lim_log(mac_ctx, LOGW,
701 FL("Session Can not be created "));
702 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
703 goto free;
704 }
705 }
706
707 /* Probe resp add ie */
708 lim_start_bss_update_add_ie_buffer(mac_ctx,
709 &session->addIeParams.probeRespData_buff,
710 &session->addIeParams.probeRespDataLen,
711 sme_start_bss_req->addIeParams.probeRespData_buff,
712 sme_start_bss_req->addIeParams.probeRespDataLen);
713
714 /* Probe Beacon add ie */
715 lim_start_bss_update_add_ie_buffer(mac_ctx,
716 &session->addIeParams.probeRespBCNData_buff,
717 &session->addIeParams.probeRespBCNDataLen,
718 sme_start_bss_req->addIeParams.probeRespBCNData_buff,
719 sme_start_bss_req->addIeParams.probeRespBCNDataLen);
720
721 /* Assoc resp IE */
722 lim_start_bss_update_add_ie_buffer(mac_ctx,
723 &session->addIeParams.assocRespData_buff,
724 &session->addIeParams.assocRespDataLen,
725 sme_start_bss_req->addIeParams.assocRespData_buff,
726 sme_start_bss_req->addIeParams.assocRespDataLen);
727
728 /* Store the session related params in newly created session */
729 session->pLimStartBssReq = sme_start_bss_req;
730
731 /* Store PE session_id in session Table */
732 session->peSessionId = session_id;
733
734 /* Store SME session Id in sessionTable */
735 session->smeSessionId = sme_start_bss_req->sessionId;
736
737 session->transactionId = sme_start_bss_req->transactionId;
738
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530739 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 &(sme_start_bss_req->htConfig),
741 sizeof(session->htConfig));
742
743 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800744 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745
746 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 (uint8_t *) &sme_start_bss_req->ssId,
749 (sme_start_bss_req->ssId.length + 1));
750
751 session->bssType = sme_start_bss_req->bssType;
752
753 session->nwType = sme_start_bss_req->nwType;
754
755 session->beaconParams.beaconInterval =
756 sme_start_bss_req->beaconInterval;
757
758 /* Store the channel number in session Table */
759 session->currentOperChannel =
760 sme_start_bss_req->channelId;
761
762 /* Store Persona */
763 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530764 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 FL("PE PERSONA=%d"), session->pePersona);
766
767 /* Update the phymode */
768 session->gLimPhyMode = sme_start_bss_req->nwType;
769
770 session->maxTxPower =
771 cfg_get_regulatory_max_transmit_power(mac_ctx,
772 session->currentOperChannel);
773 /* Store the dot 11 mode in to the session Table */
774 session->dot11mode = sme_start_bss_req->dot11mode;
775#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
776 session->cc_switch_mode =
777 sme_start_bss_req->cc_switch_mode;
778#endif
779 session->htCapability =
780 IS_DOT11_MODE_HT(session->dot11mode);
781 session->vhtCapability =
782 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530783 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 FL("*****session->vhtCapability = %d"),
785 session->vhtCapability);
786 session->txLdpcIniFeatureEnabled =
787 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 if (mac_ctx->roam.configParam.enable2x2)
789 session->nss = 2;
790 else
791 session->nss = 1;
792#ifdef WLAN_FEATURE_11W
793 session->limRmfEnabled =
794 sme_start_bss_req->pmfCapable ? 1 : 0;
795 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
796 session->limRmfEnabled);
797#endif
798
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530799 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 (void *)&sme_start_bss_req->operationalRateSet,
801 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 (void *)&sme_start_bss_req->extendedRateSet,
804 sizeof(tSirMacRateSet));
805
806 switch (sme_start_bss_req->bssType) {
807 case eSIR_INFRA_AP_MODE:
808 lim_configure_ap_start_bss_session(mac_ctx, session,
809 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530810 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800811 session->txBFIniFeatureEnabled =
812 sme_start_bss_req->txbf_ini_enabled;
813 session->txbf_csn_value =
814 sme_start_bss_req->txbf_csn_val;
815 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 break;
817 case eSIR_IBSS_MODE:
818 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
819 lim_get_short_slot_from_phy_mode(mac_ctx, session,
820 session->gLimPhyMode,
821 &session->shortSlotTimeSupported);
822
823 /*
824 * initialize to "OPEN".
825 * will be updated upon key installation
826 */
827 session->encryptType = eSIR_ED_NONE;
828
829 break;
830
831 case eSIR_BTAMP_AP_MODE:
832 session->limSystemRole = eLIM_BT_AMP_AP_ROLE;
833 break;
834
835 case eSIR_BTAMP_STA_MODE:
836 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
837 break;
838
839 /*
840 * There is one more mode called auto mode.
841 * which is used no where
842 */
843
844 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
845
846 default:
847 /* not used anywhere...used in scan function */
848 break;
849 }
850
851 /*
852 * BT-AMP: Allocate memory for the array of
853 * parsed (Re)Assoc request structure
854 */
855 if ((sme_start_bss_req->bssType == eSIR_BTAMP_AP_MODE) ||
856 (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE)) {
857 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530858 qdf_mem_malloc(session->dph.dphHashTable.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 size * sizeof(tpSirAssocReq));
860 if (NULL == session->parsedAssocReq) {
861 lim_log(mac_ctx, LOGW,
862 FL("AllocateMemory() failed"));
863 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
864 goto free;
865 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530866 qdf_mem_set(session->parsedAssocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 (session->dph.dphHashTable.size *
868 sizeof(tpSirAssocReq)), 0);
869 }
870
871 if (!sme_start_bss_req->channelId) {
872 lim_log(mac_ctx, LOGE,
873 FL("Received invalid eWNI_SME_START_BSS_REQ"));
874 ret_code = eSIR_SME_INVALID_PARAMETERS;
875 goto free;
876 }
877 channel_number = sme_start_bss_req->channelId;
878#ifdef QCA_HT_2040_COEX
879 if (sme_start_bss_req->obssEnabled)
880 session->htSupportedChannelWidthSet =
881 session->htCapability;
882 else
883#endif
884 session->htSupportedChannelWidthSet =
885 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
886 session->htSecondaryChannelOffset =
887 sme_start_bss_req->sec_ch_offset;
888 session->htRecommendedTxWidthSet =
889 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530890 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 FL("cbMode %u"), sme_start_bss_req->cbMode);
892 if (session->vhtCapability || session->htCapability) {
893 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800894 lim_log(mac_ctx, LOG1,
895 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
896 sme_start_bss_req->vht_channel_width,
897 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 session->ch_width = chanwidth;
899 if (session->htSupportedChannelWidthSet) {
900 session->ch_center_freq_seg0 =
901 sme_start_bss_req->center_freq_seg0;
902 session->ch_center_freq_seg1 =
903 sme_start_bss_req->center_freq_seg1;
904 } else {
905 session->ch_center_freq_seg0 = 0;
906 session->ch_center_freq_seg1 = 0;
907 }
908 }
909
910 if (session->vhtCapability &&
911 (CH_WIDTH_160MHZ > session->ch_width)) {
912 if (wlan_cfg_get_int(mac_ctx,
913 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
914 eSIR_SUCCESS)
915 lim_log(mac_ctx, LOGE, FL(
916 "cfg get vht su bformer failed"));
917
918 session->enable_su_tx_bformer = val;
919 } else {
920 session->nss = 1;
921 }
922 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
923
924 /* Delete pre-auth list if any */
925 lim_delete_pre_auth_list(mac_ctx);
926
927 /*
928 * keep the RSN/WPA IE information in PE Session Entry
929 * later will be using this to check when received (Re)Assoc req
930 */
931 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
932 &sme_start_bss_req->rsnIE, session);
933
934 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
935 session->gLimProtectionControl =
936 sme_start_bss_req->protEnabled;
937 /*
938 * each byte will have the following info
939 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
940 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
941 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530942 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 (void *)&sme_start_bss_req->ht_capab,
944 sizeof(uint16_t));
945 /* Initialize WPS PBC session link list */
946 session->pAPWPSPBCSession = NULL;
947 }
948 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530949 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 if (NULL == mlm_start_req) {
951 lim_log(mac_ctx, LOGP,
952 FL("Allocate Memory failed for mlmStartReq"));
953 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
954 goto free;
955 }
956
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530957 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
959 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 (uint8_t *) &sme_start_bss_req->ssId,
962 sme_start_bss_req->ssId.length + 1);
963 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
964 mlm_start_req->obssProtEnabled =
965 sme_start_bss_req->obssProtEnabled;
966
967 mlm_start_req->bssType = session->bssType;
968
969 /* Fill PE session Id from the session Table */
970 mlm_start_req->sessionId = session->peSessionId;
971
972 if ((mlm_start_req->bssType == eSIR_BTAMP_STA_MODE) ||
973 (mlm_start_req->bssType == eSIR_BTAMP_AP_MODE) ||
974 (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)) {
975 /*
976 * Copy the BSSId from sessionTable to
977 * mlmStartReq struct
978 */
979 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
980 } else {
981 /* ibss mode */
982 mac_ctx->lim.gLimIbssCoalescingHappened = false;
983
984 ret_status = wlan_cfg_get_int(mac_ctx,
985 WNI_CFG_IBSS_AUTO_BSSID,
986 &auto_gen_bssid);
987 if (ret_status != eSIR_SUCCESS) {
988 lim_log(mac_ctx, LOGP,
989 FL("Get Auto Gen BSSID fail,Status=%d"),
990 ret_status);
991 ret_code = eSIR_LOGP_EXCEPTION;
992 goto free;
993 }
994
995 if (!auto_gen_bssid) {
996 /*
997 * We're not auto generating BSSID.
998 * Instead, get it from session entry
999 */
1000 sir_copy_mac_addr(mlm_start_req->bssId,
1001 session->bssId);
1002 /*
1003 * Start IBSS group BSSID
1004 * Auto Generating BSSID.
1005 */
1006 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1007 0x01) ? true : false);
1008 }
1009
1010 if (auto_gen_bssid) {
1011 /*
1012 * if BSSID is not any uc id.
1013 * then use locally generated BSSID.
1014 * Autogenerate the BSSID
1015 */
1016 lim_get_random_bssid(mac_ctx,
1017 mlm_start_req->bssId);
1018 mlm_start_req->bssId[0] = 0x02;
1019
1020 /*
1021 * Copy randomly generated BSSID
1022 * to the session Table
1023 */
1024 sir_copy_mac_addr(session->bssId,
1025 mlm_start_req->bssId);
1026 }
1027 }
1028 /* store the channel num in mlmstart req structure */
1029 mlm_start_req->channelNumber = session->currentOperChannel;
1030 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1031 mlm_start_req->beaconPeriod =
1032 session->beaconParams.beaconInterval;
1033
1034 if (LIM_IS_AP_ROLE(session)) {
1035 mlm_start_req->dtimPeriod = session->dtimPeriod;
1036 mlm_start_req->wps_state = session->wps_state;
1037
1038 } else {
1039 if (wlan_cfg_get_int(mac_ctx,
1040 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1041 lim_log(mac_ctx, LOGP,
1042 FL("could not retrieve DTIM Period"));
1043 mlm_start_req->dtimPeriod = (uint8_t) val;
1044 }
1045
1046 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1047 eSIR_SUCCESS)
1048 lim_log(mac_ctx, LOGP,
1049 FL("could not retrieve Beacon interval"));
1050 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1051
1052 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1053 eSIR_SUCCESS)
1054 lim_log(mac_ctx, LOGP,
1055 FL("could not retrieve CFPMaxDuration"));
1056 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1057
1058 /*
1059 * this may not be needed anymore now,
1060 * as rateSet is now included in the
1061 * session entry and MLM has session context.
1062 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301063 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 (void *)&session->rateSet,
1065 sizeof(tSirMacRateSet));
1066
1067 /* Now populate the 11n related parameters */
1068 mlm_start_req->nwType = session->nwType;
1069 mlm_start_req->htCapable = session->htCapability;
1070
1071 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1072 /* Unused */
1073 mlm_start_req->dualCTSProtection =
1074 mac_ctx->lim.gHTDualCTSProtection;
1075 mlm_start_req->txChannelWidthSet =
1076 session->htRecommendedTxWidthSet;
1077
1078 session->limRFBand = lim_get_rf_band(channel_number);
1079
1080 /* Initialize 11h Enable Flag */
1081 session->lim11hEnable = 0;
1082 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1083 (SIR_BAND_5_GHZ == session->limRFBand)) {
1084 if (wlan_cfg_get_int(mac_ctx,
1085 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1086 lim_log(mac_ctx, LOGP,
1087 FL("Fail to get WNI_CFG_11H_ENABLED "));
1088 else
1089 session->lim11hEnable = val;
1090
1091 if (session->lim11hEnable &&
1092 (eSIR_INFRA_AP_MODE ==
1093 mlm_start_req->bssType)) {
1094 cfg_get_wmi_dfs_master_param =
1095 wlan_cfg_get_int(mac_ctx,
1096 WNI_CFG_DFS_MASTER_ENABLED,
1097 &val);
1098 session->lim11hEnable = val;
1099 }
1100 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1101 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1102 lim_log(mac_ctx, LOGE,
1103 FL("Get Fail, CFG DFS ENABLE"));
1104 }
1105
1106 if (!session->lim11hEnable) {
1107 if (cfg_set_int(mac_ctx,
1108 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1109 eSIR_SUCCESS)
1110 /*
1111 * Failed to set the CFG param
1112 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1113 */
1114 lim_log(mac_ctx, LOGE,
1115 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1116 }
1117
1118 session->limPrevSmeState = session->limSmeState;
1119 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1120 MTRACE(mac_trace
1121 (mac_ctx, TRACE_CODE_SME_STATE,
1122 session->peSessionId,
1123 session->limSmeState));
1124
1125 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1126 (uint32_t *) mlm_start_req);
1127 return;
1128 } else {
1129
1130 lim_log(mac_ctx, LOGE,
1131 FL("Received unexpected START_BSS_REQ, in state %X"),
1132 mac_ctx->lim.gLimSmeState);
1133 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1134 goto end;
1135 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1136
1137free:
1138 if ((session != NULL) &&
1139 (session->pLimStartBssReq == sme_start_bss_req)) {
1140 session->pLimStartBssReq = NULL;
1141 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301142 qdf_mem_free(sme_start_bss_req);
1143 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144
1145end:
1146 if (sme_start_bss_req != NULL) {
1147 sme_session_id = sme_start_bss_req->sessionId;
1148 sme_transaction_id = sme_start_bss_req->transactionId;
1149 }
1150 if (NULL != session) {
1151 pe_delete_session(mac_ctx, session);
1152 session = NULL;
1153 }
1154 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1155 session, sme_session_id, sme_transaction_id);
1156}
1157
1158/**
1159 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1160 *
1161 * @pMac: Global MAC context
1162 * @pMsg: Message pointer
1163 *
1164 * Wrapper for the function __lim_handle_sme_start_bss_request
1165 * This message will be defered until softmac come out of
1166 * scan mode or if we have detected radar on the current
1167 * operating channel.
1168 *
1169 * return true - If we consumed the buffer
1170 * false - If have defered the message.
1171 */
1172static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1173{
1174 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1175 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1176 /**
1177 * If message defered, buffer is not consumed yet.
1178 * So return false
1179 */
1180 return false;
1181 }
1182
1183 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1184 return true;
1185}
1186
1187/**
1188 * lim_get_random_bssid()
1189 *
1190 * FUNCTION:This function is called to process generate the random number for bssid
1191 * This function is called to process SME_SCAN_REQ message
1192 * from HDD or upper layer application.
1193 *
1194 * LOGIC:
1195 *
1196 * ASSUMPTIONS:
1197 *
1198 * NOTE:
1199 * 1. geneartes the unique random number for bssid in ibss
1200 *
1201 * @param pMac Pointer to Global MAC structure
1202 * @param *data Pointer to bssid buffer
1203 * @return None
1204 */
1205void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1206{
1207 uint32_t random[2];
1208 random[0] = tx_time_get();
1209 random[0] |= (random[0] << 15);
1210 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301211 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212}
1213
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301214static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 tpSirSmeScanReq pScanReq)
1216{
1217 tSirScanOffloadReq *pScanOffloadReq;
1218 uint8_t *p;
1219 uint8_t *ht_cap_ie;
1220 tSirMsgQ msg;
1221 uint16_t i, len;
1222 uint16_t ht_cap_len = 0, addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 uint8_t *vht_cap_ie;
1224 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 tSirRetStatus status, rc = eSIR_SUCCESS;
1226 tDot11fIEExtCap extracted_extcap = {0};
1227 bool extcap_present = true;
1228
1229 if (pScanReq->uIEFieldLen) {
1230 status = lim_strip_extcap_update_struct(pMac,
1231 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1232 &pScanReq->uIEFieldLen, &extracted_extcap);
1233
1234 if (eSIR_SUCCESS != status) {
1235 extcap_present = false;
1236 lim_log(pMac, LOG1,
1237 FL("Unable to Strip ExtCap IE from Scan Req"));
1238 }
1239
1240 if (extcap_present) {
1241 lim_log(pMac, LOG1,
1242 FL("Extcap was part of SCAN IE - Updating FW"));
1243 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1244 &extracted_extcap, true);
1245 }
1246 } else {
1247 lim_log(pMac, LOG1,
1248 FL("No IEs in the scan request from supplicant"));
1249 }
1250
1251 /**
1252 * The tSirScanOffloadReq will reserve the space for first channel,
1253 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1254 */
1255 len = sizeof(tSirScanOffloadReq) +
1256 (pScanReq->channelList.numChannels - 1) + pScanReq->uIEFieldLen;
1257
1258 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1259 lim_log(pMac, LOG1,
1260 FL("Adding HT Caps IE since dot11mode=%d"),
1261 pScanReq->dot11mode);
1262 /* 2 bytes for EID and Length */
1263 ht_cap_len = 2 + sizeof(tHtCaps);
1264 len += ht_cap_len;
1265 addn_ie_len += ht_cap_len;
1266 }
1267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1269 lim_log(pMac, LOG1,
1270 FL("Adding VHT Caps IE since dot11mode=%d"),
1271 pScanReq->dot11mode);
1272 /* 2 bytes for EID and Length */
1273 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1274 sizeof(tSirVhtMcsInfo);
1275 len += vht_cap_len;
1276 addn_ie_len += vht_cap_len;
1277 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301279 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 if (NULL == pScanOffloadReq) {
1281 lim_log(pMac, LOGE,
1282 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301283 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 }
1285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301286 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287
1288 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1289 msg.bodyptr = pScanOffloadReq;
1290 msg.bodyval = 0;
1291
Anurag Chouhanc5548422016-02-24 18:33:27 +05301292 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
1294 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1295 lim_log(pMac, LOGE,
1296 FL("Invalid value (%d) for numSsid"),
1297 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301298 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301299 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 }
1301
1302 pScanOffloadReq->numSsid = pScanReq->numSsid;
1303 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1304 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301305 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 (uint8_t *) pScanReq->ssId[i].ssId,
1307 pScanOffloadReq->ssId[i].length);
1308 }
1309
1310 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301311 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 pScanOffloadReq->bssType = pScanReq->bssType;
1313 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1314 pScanOffloadReq->scanType = pScanReq->scanType;
1315 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1316 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1317 pScanOffloadReq->restTime = pScanReq->restTime;
1318
1319 /* for normal scan, the value for p2pScanType should be 0
1320 always */
1321 if (pScanReq->p2pSearch)
1322 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1323
1324 pScanOffloadReq->sessionId = pScanReq->sessionId;
1325 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001326 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
1328 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1329 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1330 pScanOffloadReq->sessionId);
1331
1332 pScanOffloadReq->channelList.numChannels =
1333 pScanReq->channelList.numChannels;
1334 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1335 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1336 p[i] = pScanReq->channelList.channelNumber[i];
1337
1338 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1339 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1340 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301341 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 pScanOffloadReq->uIEFieldOffset,
1343 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1344 pScanReq->uIEFieldLen);
1345
1346 /* Copy HT Capability info if dot11mode is HT */
1347 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1348 /* Populate EID and Length field here */
1349 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1350 pScanOffloadReq->uIEFieldOffset +
1351 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301352 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1354 *(ht_cap_ie + 1) = ht_cap_len - 2;
1355 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1356 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1357 }
1358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 /* Copy VHT Capability info if dot11mode is VHT Capable */
1360 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1361 /* Populate EID and Length field here */
1362 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1363 pScanOffloadReq->uIEFieldOffset +
1364 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301365 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1367 *(vht_cap_ie + 1) = vht_cap_len - 2;
1368 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1369 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
1372 rc = wma_post_ctrl_msg(pMac, &msg);
1373 if (rc != eSIR_SUCCESS) {
1374 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301375 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301376 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 }
1378
1379 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1380
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301381 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382}
1383
1384/**
1385 * __lim_process_sme_scan_req() - Process the SME Scan Request
1386 * @mac_ctx: Global MAC Context
1387 * @msg_buf: Buffer which contains the request and pertinent parameters
1388 *
1389 * This function is called to process SME_SCAN_REQ message
1390 * from HDD or upper layer application.
1391 *
1392 * Return: None
1393 */
1394
1395static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1396 uint32_t *msg_buf)
1397{
1398 tpSirSmeScanReq scan_req;
1399 uint8_t valid_req = 0;
1400
1401#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1402 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1403 eSIR_SUCCESS, eSIR_SUCCESS);
1404#endif
1405
1406 scan_req = (tpSirSmeScanReq) msg_buf;
1407 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301408 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 -08001409 scan_req->scan_id, scan_req->channelList.numChannels,
1410 scan_req->minChannelTime, scan_req->maxChannelTime,
1411 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1412 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301413 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1415 /*
1416 * Since scan req always requires a response, we will overwrite response
1417 * required here. This is added esp to take care of the condition where
1418 * in p2p go case, we hold the scan req and insert single NOA. We send
1419 * the held scan request to FW later on getting start NOA ind from FW so
1420 * we lose state of the gLimRspReqd flag for the scan req if any other
1421 * request comes by then. e.g. While unit testing, we found when insert
1422 * single NOA is done, we see a get stats request which turns the flag
1423 * gLimRspReqd to false; now when we actually start the saved scan req
1424 * for init scan after getting NOA started, the gLimRspReqd being a
1425 * global flag is showing false instead of true value for this saved
1426 * scan req. Since all scan reqs coming to lim require a response,
1427 * there is no harm in setting the global flag gLimRspReqd to true here.
1428 */
1429 mac_ctx->lim.gLimRspReqd = true;
1430
1431 /*
1432 * copy the Self MAC address from SmeReq to the globalplace,
1433 * used for sending probe req
1434 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001435 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1436 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1438
1439 if (!valid_req || mac_ctx->lim.scan_disabled) {
1440 lim_log(mac_ctx, LOGE,
1441 FL("Scan disabled %d, Valid Scan Req %d"),
1442 mac_ctx->lim.scan_disabled, valid_req);
1443
1444 if (mac_ctx->lim.gLimRspReqd) {
1445 mac_ctx->lim.gLimRspReqd = false;
1446
1447 lim_send_sme_scan_rsp(mac_ctx,
1448 eSIR_SME_INVALID_PARAMETERS,
1449 scan_req->sessionId,
1450 scan_req->transactionId,
1451 scan_req->scan_id);
1452 }
1453 return;
1454 }
1455
1456 /*
1457 * If scan request is received in idle, joinFailed
1458 * states or in link established state (in STA role)
1459 * or in normal state (in STA-in-IBSS/AP role) with
1460 * 'return fresh scan results' request from HDD or
1461 * it is periodic background scanning request,
1462 * trigger fresh scan request to MLM
1463 */
1464 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1465
1466 mac_ctx->lim.gLim24Band11dScanDone = 0;
1467 mac_ctx->lim.gLim50Band11dScanDone = 0;
1468 mac_ctx->lim.gLimReturnAfterFirstMatch =
1469 scan_req->returnAfterFirstMatch;
1470 mac_ctx->lim.gLimReturnUniqueResults =
1471 ((scan_req->returnUniqueResults) > 0 ? true : false);
1472
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301473 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 lim_send_hal_start_scan_offload_req(mac_ctx,
1475 scan_req)) {
1476 lim_log(mac_ctx, LOGE, FL(
1477 "Couldn't send Offload scan request"));
1478 lim_send_sme_scan_rsp(mac_ctx,
1479 eSIR_SME_INVALID_PARAMETERS,
1480 scan_req->sessionId,
1481 scan_req->transactionId,
1482 scan_req->scan_id);
1483 return;
1484 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301485 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486 /* In all other cases return 'cached' scan results */
1487 if (mac_ctx->lim.gLimRspReqd) {
1488 mac_ctx->lim.gLimRspReqd = false;
1489 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1490 scan_req->sessionId,
1491 scan_req->transactionId, scan_req->scan_id);
1492 }
1493 }
1494}
1495
1496#ifdef FEATURE_OEM_DATA_SUPPORT
1497
1498static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1499{
1500 tpSirOemDataReq pOemDataReq;
1501 tLimMlmOemDataReq *pMlmOemDataReq;
1502
1503 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1504
1505 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301506 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 if (NULL == pMlmOemDataReq) {
1508 lim_log(pMac, LOGP,
1509 FL("AllocateMemory failed for mlmOemDataReq"));
1510 return;
1511 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001513 if (!pMlmOemDataReq->data) {
1514 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301515 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001516 return;
1517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518
Anurag Chouhanc5548422016-02-24 18:33:27 +05301519 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001520 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001521 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301522 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001523 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001524 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1527 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1528 (uint32_t *) pMlmOemDataReq);
1529
1530 return;
1531
1532} /*** end __lim_process_sme_oem_data_req() ***/
1533
1534#endif /* FEATURE_OEM_DATA_SUPPORT */
1535
1536/**
1537 * __lim_process_clear_dfs_channel_list()
1538 *
1539 ***FUNCTION:
1540 ***Clear DFS channel list when country is changed/aquired.
1541 .*This message is sent from SME.
1542 *
1543 ***LOGIC:
1544 *
1545 ***ASSUMPTIONS:
1546 *
1547 ***NOTE:
1548 *
1549 * @param pMac Pointer to Global MAC structure
1550 * @param *pMsgBuf A pointer to the SME message buffer
1551 * @return None
1552 */
1553static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1554{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301555 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556}
1557
1558/**
1559 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1560 * @mac_ctx: Pointer to Global MAC structure
1561 * @msg_buf: A pointer to the SME message buffer
1562 *
1563 * This function is called to process SME_JOIN_REQ message
1564 * from HDD or upper layer application.
1565 *
1566 * Return: None
1567 */
1568static void
1569__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1570{
1571 tpSirSmeJoinReq sme_join_req = NULL;
1572 tLimMlmJoinReq *mlm_join_req;
1573 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1574 uint32_t val = 0;
1575 uint16_t n_size;
1576 uint8_t session_id;
1577 tpPESession session = NULL;
1578 uint8_t sme_session_id;
1579 uint16_t sme_transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001580 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 uint16_t ie_len;
1582 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001583 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584
1585/* FEATURE_WLAN_DIAG_SUPPORT */
1586#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1587 /*
1588 * Not sending any session, since it is not created yet.
1589 * The response whould have correct state.
1590 */
1591 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1592#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1593
1594 lim_log(mac_ctx, LOG1, FL("Received SME_JOIN_REQ"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595
1596 /*
1597 * Expect Join request in idle state.
1598 * Reassociate request is expected in link established state.
1599 */
1600
1601 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1602 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1603 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1604 msg_buf);
1605
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301606 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 if (NULL == sme_join_req) {
1608 lim_log(mac_ctx, LOGP,
1609 FL("AllocateMemory failed for sme_join_req"));
1610 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1611 return;
1612 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301613 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1614 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 n_size);
1616
1617 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1618 /* Received invalid eWNI_SME_JOIN_REQ */
1619 /* Log the event */
1620 lim_log(mac_ctx, LOGW,
1621 FL("SessionId:%d JOIN REQ with invalid data"),
1622 sme_join_req->sessionId);
1623 ret_code = eSIR_SME_INVALID_PARAMETERS;
1624 goto end;
1625 }
1626
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001627 /*
1628 * Update the capability here itself as this is used in
1629 * lim_extract_ap_capability() below. If not updated issues
1630 * like not honoring power constraint on 1st association after
1631 * driver loading might occur.
1632 */
1633 lim_update_rrm_capability(mac_ctx, sme_join_req);
1634
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001635 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001637 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 &session_id);
1639
1640 if (session != NULL) {
1641 lim_log(mac_ctx, LOGE,
1642 FL("Session(%d) Already exists for BSSID: "
1643 MAC_ADDRESS_STR " in limSmeState = %X"),
1644 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001645 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 session->limSmeState);
1647
1648 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1649 session->smeSessionId == sme_join_req->sessionId) {
1650 /*
1651 * Received eWNI_SME_JOIN_REQ for same
1652 * BSS as currently associated.
1653 * Log the event and send success
1654 */
1655 lim_log(mac_ctx, LOGW,
1656 FL("SessionId: %d"), session_id);
1657 lim_log(mac_ctx, LOGW,
1658 FL("JOIN_REQ for current joined BSS"));
1659 /* Send Join success response to host */
1660 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1661 session = NULL;
1662 goto end;
1663 } else {
1664 lim_log(mac_ctx, LOGE,
1665 FL("JOIN_REQ not for current joined BSS"));
1666 ret_code = eSIR_SME_REFUSED;
1667 session = NULL;
1668 goto end;
1669 }
1670 } else {
1671 /*
1672 * Session Entry does not exist for given BSSId
1673 * Try to Create a new session
1674 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001675 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 &session_id, mac_ctx->lim.maxStation,
1677 eSIR_INFRASTRUCTURE_MODE);
1678 if (session == NULL) {
1679 lim_log(mac_ctx, LOGE,
1680 FL("Session Can not be created "));
1681 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1682 goto end;
1683 } else
1684 lim_log(mac_ctx, LOG1,
1685 FL("SessionId:%d New session created"),
1686 session_id);
1687 }
1688 session->isAmsduSupportInAMPDU =
1689 sme_join_req->isAmsduSupportInAMPDU;
1690
1691 /*
1692 * Store Session related parameters
1693 * Store PE session Id in session Table
1694 */
1695 session->peSessionId = session_id;
1696
1697 /* store the smejoin req handle in session table */
1698 session->pLimJoinReq = sme_join_req;
1699
1700 /* Store SME session Id in sessionTable */
1701 session->smeSessionId = sme_join_req->sessionId;
1702
1703 /* Store SME transaction Id in session Table */
1704 session->transactionId = sme_join_req->transactionId;
1705
1706 /* Store beaconInterval */
1707 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001708 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301710 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 sizeof(session->htConfig));
1712
1713 /* Copying of bssId is already done, while creating session */
1714 sir_copy_mac_addr(session->selfMacAddr,
1715 sme_join_req->selfMacAddr);
1716 session->bssType = sme_join_req->bsstype;
1717
1718 session->statypeForBss = STA_ENTRY_PEER;
1719 session->limWmeEnabled = sme_join_req->isWMEenabled;
1720 session->limQosEnabled = sme_join_req->isQosEnabled;
1721
1722 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001723 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1725
1726 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1727 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001728 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729
1730 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001731 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 session->isCiscoVendorAP = true;
1733 } else {
1734 session->isCiscoVendorAP = false;
1735 }
1736
1737 /* Copy the dot 11 mode in to the session table */
1738
1739 session->dot11mode = sme_join_req->dot11mode;
1740#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1741 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1742#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001743 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1745 session->enableHtSmps = sme_join_req->enableHtSmps;
1746 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001747 session->send_smps_action =
1748 sme_join_req->send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001749 lim_log(mac_ctx, LOG1,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001750 FL("enable Smps: %d mode: %d send action: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001751 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001752 session->htSmpsvalue,
1753 session->send_smps_action);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754
1755 /*Store Persona */
1756 session->pePersona = sme_join_req->staPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301757 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 FL("PE PERSONA=%d cbMode %u"),
1759 session->pePersona, sme_join_req->cbMode);
1760 if (mac_ctx->roam.configParam.enable2x2)
1761 session->nss = 2;
1762 else
1763 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 session->vhtCapability =
1765 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301766 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 "***__lim_process_sme_join_req: vhtCapability=%d****",
1768 session->vhtCapability);
1769 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301770 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 session->txBFIniFeatureEnabled =
1772 sme_join_req->txBFIniFeatureEnabled;
1773 } else {
1774 session->txBFIniFeatureEnabled = 0;
1775 }
1776 session->txMuBformee = sme_join_req->txMuBformee;
1777 session->enableVhtpAid =
1778 sme_join_req->enableVhtpAid;
1779 session->enableVhtGid =
1780 sme_join_req->enableVhtGid;
1781
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301782 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 FL("***txBFIniFeatureEnabled=%d***"),
1784 session->txBFIniFeatureEnabled);
1785 if (wlan_cfg_get_int(mac_ctx,
1786 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1787 eSIR_SUCCESS)
1788 lim_log(mac_ctx, LOGE, FL(
1789 "cfg get vht su bformer failed"));
1790
1791 session->enable_su_tx_bformer = val;
1792 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1793 }
1794 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1795 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1796 session->txBFIniFeatureEnabled) !=
1797 eSIR_SUCCESS) {
1798 /*
1799 * Set failed for
1800 * CFG_VHT_SU_BEAMFORMEE_CAP
1801 */
1802 lim_log(mac_ctx, LOGP,
1803 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1804 ret_code = eSIR_LOGP_EXCEPTION;
1805 goto end;
1806 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301807 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 "%s: txBFCsnValue=%d", __func__,
1809 sme_join_req->txBFCsnValue);
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001810 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001813 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 handle_ht_capabilityand_ht_info(mac_ctx, session);
1815 /* Copy The channel Id to the session Table */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001816 session->currentOperChannel = bss_desc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 /* cbMode is already merged value of peer and self -
1818 * done by csr in csr_get_cb_mode_from_ies */
1819 session->htSupportedChannelWidthSet =
1820 (sme_join_req->cbMode) ? 1 : 0;
1821 session->htRecommendedTxWidthSet =
1822 session->htSupportedChannelWidthSet;
1823 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1824
1825 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1826 session->ch_center_freq_seg0 =
1827 session->currentOperChannel - 2;
1828 session->ch_width = CH_WIDTH_40MHZ;
1829 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1830 sme_join_req->cbMode) {
1831 session->ch_center_freq_seg0 =
1832 session->currentOperChannel + 2;
1833 session->ch_width = CH_WIDTH_40MHZ;
1834 } else {
1835 session->ch_center_freq_seg0 = 0;
1836 session->ch_width = CH_WIDTH_20MHZ;
1837 }
1838
1839 /* Record if management frames need to be protected */
1840#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001841 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001843 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845#endif
1846
1847#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001848 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849#endif
1850
1851 /* Copy the SSID from smejoinreq to session entry */
1852 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301853 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 session->ssId.length);
1855
1856 /*
1857 * Determin 11r or ESE connection based on input from SME
1858 * which inturn is dependent on the profile the user wants
1859 * to connect to, So input is coming from supplicant
1860 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862#ifdef FEATURE_WLAN_ESE
1863 session->isESEconnection = sme_join_req->isESEconnection;
1864#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 session->isFastTransitionEnabled =
1866 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 session->isFastRoamIniFeatureEnabled =
1869 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 session->txLdpcIniFeatureEnabled =
1871 sme_join_req->txLdpcIniFeatureEnabled;
1872
1873 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1874 session->limSystemRole = eLIM_STA_ROLE;
1875 } else if (session->bssType == eSIR_BTAMP_AP_MODE) {
1876 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1877 } else {
1878 /*
1879 * Throw an error and return and make
1880 * sure to delete the session.
1881 */
1882 lim_log(mac_ctx, LOGE,
1883 FL("recvd JOIN_REQ with invalid bss type %d"),
1884 session->bssType);
1885 ret_code = eSIR_SME_INVALID_PARAMETERS;
1886 goto end;
1887 }
1888
1889 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301890 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 &sme_join_req->addIEScan, sizeof(tSirAddie));
1892
1893 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301894 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1896
1897 val = sizeof(tLimMlmJoinReq) +
1898 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301899 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 if (NULL == mlm_join_req) {
1901 lim_log(mac_ctx, LOGP,
1902 FL("AllocateMemory failed for mlmJoinReq"));
1903 return;
1904 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301905 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906
1907 /* PE SessionId is stored as a part of JoinReq */
1908 mlm_join_req->sessionId = session->peSessionId;
1909
1910 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1911 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1912 eSIR_SUCCESS) {
1913 lim_log(mac_ctx, LOGP,
1914 FL("couldn't retrieve JoinFailureTimer value"
1915 " setting to default value"));
1916 mlm_join_req->joinFailureTimeout =
1917 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1918 }
1919
1920 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301921 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 (void *)&sme_join_req->operationalRateSet,
1923 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301924 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 (void *)&sme_join_req->extendedRateSet,
1926 sizeof(tSirMacRateSet));
1927 /*
1928 * this may not be needed anymore now, as rateSet is now
1929 * included in the session entry and MLM has session context.
1930 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301931 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 (void *)&session->rateSet,
1933 sizeof(tSirMacRateSet));
1934
1935 session->encryptType = sme_join_req->UCEncryptionType;
1936
1937 mlm_join_req->bssDescription.length =
1938 session->pLimJoinReq->bssDescription.length;
1939
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301940 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 (uint8_t *)
1942 &session->pLimJoinReq->bssDescription.bssId,
1943 session->pLimJoinReq->bssDescription.length + 2);
1944
1945 session->limCurrentBssCaps =
1946 session->pLimJoinReq->bssDescription.capabilityInfo;
1947
1948 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1949 session->currentOperChannel);
1950 local_power_constraint = reg_max;
1951
1952 lim_extract_ap_capability(mac_ctx,
1953 (uint8_t *)
1954 session->pLimJoinReq->bssDescription.ieFields,
1955 lim_get_ielen_from_bss_description(
1956 &session->pLimJoinReq->bssDescription),
1957 &session->limCurrentBssQosCaps,
1958 &session->limCurrentBssPropCap,
1959 &session->gLimCurrentBssUapsd,
1960 &local_power_constraint, session);
1961
1962#ifdef FEATURE_WLAN_ESE
1963 session->maxTxPower = lim_get_max_tx_power(reg_max,
1964 local_power_constraint,
1965 mac_ctx->roam.configParam.nTxPowerCap);
1966#else
1967 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301968 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969#endif
1970#if defined WLAN_VOWIFI_DEBUG
1971 lim_log(mac_ctx, LOGE,
1972 "Regulatory max = %d, local power constraint = %d"
1973 reg_max, local_power_constraint);
1974 lim_log(mac_ctx, LOGE, FL(" max tx = %d"),
1975 session->maxTxPower);
1976#endif
1977
1978 if (session->gLimCurrentBssUapsd) {
1979 session->gUapsdPerAcBitmask =
1980 session->pLimJoinReq->uapsdPerAcBitmask;
1981 lim_log(mac_ctx, LOG1,
1982 FL("UAPSD flag for all AC - 0x%2x"),
1983 session->gUapsdPerAcBitmask);
1984
1985 /* resetting the dynamic uapsd mask */
1986 session->gUapsdPerAcDeliveryEnableMask = 0;
1987 session->gUapsdPerAcTriggerEnableMask = 0;
1988 }
1989
1990 session->limRFBand =
1991 lim_get_rf_band(session->currentOperChannel);
1992
1993 /* Initialize 11h Enable Flag */
1994 if (SIR_BAND_5_GHZ == session->limRFBand) {
1995 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1996 &val) != eSIR_SUCCESS) {
1997 lim_log(mac_ctx, LOGP,
1998 FL("Fail to get WNI_CFG_11H_ENABLED "));
1999 session->lim11hEnable =
2000 WNI_CFG_11H_ENABLED_STADEF;
2001 } else {
2002 session->lim11hEnable = val;
2003 }
2004 } else {
2005 session->lim11hEnable = 0;
2006 }
2007
2008 /*
2009 * To care of the scenario when STA transitions from
2010 * IBSS to Infrastructure mode.
2011 */
2012 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2013
2014 session->limPrevSmeState = session->limSmeState;
2015 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2016 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2017 session->peSessionId,
2018 session->limSmeState));
2019
2020 lim_log(mac_ctx, LOG1,
2021 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
2022 mlm_join_req->sessionId, session->ssId.length,
2023 session->ssId.ssId, session->currentOperChannel,
2024 MAC_ADDR_ARRAY(session->bssId));
2025
2026 /* Indicate whether spectrum management is enabled */
2027 session->spectrumMgtEnabled =
2028 sme_join_req->spectrumMgtIndicator;
2029
2030 /* Enable the spectrum management if this is a DFS channel */
2031 if (session->country_info_present &&
2032 lim_isconnected_on_dfs_channel(
2033 session->currentOperChannel))
2034 session->spectrumMgtEnabled = true;
2035
2036 session->isOSENConnection = sme_join_req->isOSENConnection;
2037
2038 lim_log(mac_ctx, LOG1,
2039 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
2040 mlm_join_req->sessionId);
2041 /* Issue LIM_MLM_JOIN_REQ to MLM */
2042 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2043 (uint32_t *) mlm_join_req);
2044 return;
2045
2046 } else {
2047 /* Received eWNI_SME_JOIN_REQ un expected state */
2048 lim_log(mac_ctx, LOGE,
2049 FL("received unexpected SME_JOIN_REQ in state %X"),
2050 mac_ctx->lim.gLimSmeState);
2051 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2052 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2053 session = NULL;
2054 goto end;
2055 }
2056
2057end:
2058 sme_session_id = sme_join_req->sessionId;
2059 sme_transaction_id = sme_join_req->transactionId;
2060
2061 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302062 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 sme_join_req = NULL;
2064 if (NULL != session)
2065 session->pLimJoinReq = NULL;
2066 }
2067 if (ret_code != eSIR_SME_SUCCESS) {
2068 if (NULL != session) {
2069 pe_delete_session(mac_ctx, session);
2070 session = NULL;
2071 }
2072 }
2073 lim_log(mac_ctx, LOG1,
2074 FL("Send failure status on sessionid: %d with ret_code = %d"),
2075 sme_session_id, ret_code);
2076 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2077 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2078 sme_transaction_id);
2079}
2080
Amar Singhala297bfa2015-10-15 15:07:29 -07002081uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 uint8_t iniTxPower)
2083{
2084 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302085 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2086 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2088 maxTxPower = txPower;
2089 else if (txPower < MIN_TX_PWR_CAP)
2090 maxTxPower = MIN_TX_PWR_CAP;
2091 else
2092 maxTxPower = MAX_TX_PWR_CAP;
2093
2094 return maxTxPower;
2095}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096
2097/**
2098 * __lim_process_sme_reassoc_req() - process reassoc req
2099 *
2100 * @mac_ctx: Pointer to Global MAC structure
2101 * @msg_buf: pointer to the SME message buffer
2102 *
2103 * This function is called to process SME_REASSOC_REQ message
2104 * from HDD or upper layer application.
2105 *
2106 * Return: None
2107 */
2108
2109static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2110 uint32_t *msg_buf)
2111{
2112 uint16_t caps;
2113 uint32_t val;
2114 tpSirSmeJoinReq reassoc_req = NULL;
2115 tLimMlmReassocReq *mlm_reassoc_req;
2116 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2117 tpPESession session_entry = NULL;
2118 uint8_t session_id;
2119 uint8_t sme_session_id;
2120 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002121 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 uint32_t tele_bcn_en = 0;
2123 uint16_t size;
2124
2125 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2126
2127 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302128 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 if (NULL == reassoc_req) {
2130 lim_log(mac_ctx, LOGP,
2131 FL("call to AllocateMemory failed for reassoc_req"));
2132
2133 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2134 goto end;
2135 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302136 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2137 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138
2139 if (!lim_is_sme_join_req_valid(mac_ctx,
2140 (tpSirSmeJoinReq)reassoc_req)) {
2141 /*
2142 * Received invalid eWNI_SME_REASSOC_REQ
2143 */
2144 lim_log(mac_ctx, LOGW,
2145 FL("received SME_REASSOC_REQ with invalid data"));
2146
2147 ret_code = eSIR_SME_INVALID_PARAMETERS;
2148 goto end;
2149 }
2150
2151 session_entry = pe_find_session_by_bssid(mac_ctx,
2152 reassoc_req->bssDescription.bssId,
2153 &session_id);
2154 if (session_entry == NULL) {
2155 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2156 LOGE);
2157 lim_log(mac_ctx, LOGE,
2158 FL("Session does not exist for given bssId"));
2159 ret_code = eSIR_SME_INVALID_PARAMETERS;
2160 goto end;
2161 }
2162#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2163 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2164 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2165#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2166 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2167
2168 /* Store the reassoc handle in the session Table */
2169 session_entry->pLimReAssocReq = reassoc_req;
2170
2171 session_entry->dot11mode = reassoc_req->dot11mode;
2172 session_entry->vhtCapability =
2173 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002174
2175 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2176 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002177 session_entry->send_smps_action =
2178 reassoc_req->send_smps_action;
2179 lim_log(mac_ctx, LOG1,
2180 FL("enableHtSmps: %d htSmps: %d send action: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002181 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002182 session_entry->htSmpsvalue,
2183 session_entry->send_smps_action);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 /*
2185 * Reassociate request is expected
2186 * in link established state only.
2187 */
2188
2189 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2191 /*
2192 * May be from 11r FT pre-auth. So lets check it
2193 * before we bail out
2194 */
2195 lim_log(mac_ctx, LOG1, FL(
2196 "Session in reassoc state is %d"),
2197 session_entry->peSessionId);
2198
2199 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302200 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 session_entry->limReAssocbssId,
2202 6)) {
2203 lim_print_mac_addr(mac_ctx,
2204 reassoc_req->bssDescription.
2205 bssId, LOGE);
2206 lim_log(mac_ctx, LOGP,
2207 FL("Unknown bssId in reassoc state"));
2208 ret_code = eSIR_SME_INVALID_PARAMETERS;
2209 goto end;
2210 }
2211
2212 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2213 session_entry);
2214 return;
2215 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 /*
2217 * Should not have received eWNI_SME_REASSOC_REQ
2218 */
2219 lim_log(mac_ctx, LOGE,
2220 FL("received unexpected SME_REASSOC_REQ in state %X"),
2221 session_entry->limSmeState);
2222 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2223
2224 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2225 goto end;
2226 }
2227
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 session_entry->pLimReAssocReq->bssDescription.bssId,
2230 sizeof(tSirMacAddr));
2231
2232 session_entry->limReassocChannelId =
2233 session_entry->pLimReAssocReq->bssDescription.channelId;
2234
2235 session_entry->reAssocHtSupportedChannelWidthSet =
2236 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2237 session_entry->reAssocHtRecommendedTxWidthSet =
2238 session_entry->reAssocHtSupportedChannelWidthSet;
2239 session_entry->reAssocHtSecondaryChannelOffset =
2240 session_entry->pLimReAssocReq->cbMode;
2241
2242 session_entry->limReassocBssCaps =
2243 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2244 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2245 session_entry->currentOperChannel);
2246 local_pwr_constraint = reg_max;
2247
2248 lim_extract_ap_capability(mac_ctx,
2249 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2250 lim_get_ielen_from_bss_description(
2251 &session_entry->pLimReAssocReq->bssDescription),
2252 &session_entry->limReassocBssQosCaps,
2253 &session_entry->limReassocBssPropCap,
2254 &session_entry->gLimCurrentBssUapsd,
2255 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302256 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257#if defined WLAN_VOWIFI_DEBUG
2258 lim_log(mac_ctx, LOGE,
2259 "Regulatory max = %d, local pwr constraint = %d, max tx = %d",
2260 reg_max, local_pwr_constraint,
2261 session_entry->maxTxPower);
2262#endif
2263 /* Copy the SSID from session entry to local variable */
2264 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302265 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266 reassoc_req->ssId.ssId,
2267 session_entry->limReassocSSID.length);
2268 if (session_entry->gLimCurrentBssUapsd) {
2269 session_entry->gUapsdPerAcBitmask =
2270 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2271 lim_log(mac_ctx, LOG1,
2272 FL("UAPSD flag for all AC - 0x%2x"),
2273 session_entry->gUapsdPerAcBitmask);
2274 }
2275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302276 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 if (NULL == mlm_reassoc_req) {
2278 lim_log(mac_ctx, LOGP,
2279 FL("call to AllocateMemory failed for mlmReassocReq"));
2280
2281 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2282 goto end;
2283 }
2284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302285 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2287
2288 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2289 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2290 eSIR_SUCCESS) {
2291 /*
2292 * Could not get ReassocFailureTimeout value
2293 * from CFG. Log error.
2294 */
2295 lim_log(mac_ctx, LOGP,
2296 FL("could not retrieve ReassocFailureTimeout value"));
2297 }
2298
2299 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2300 eSIR_SUCCESS) {
2301 /*
2302 * Could not get Capabilities value
2303 * from CFG. Log error.
2304 */
2305 lim_log(mac_ctx, LOGP, FL(
2306 "could not retrieve Capabilities value"));
2307 }
2308 mlm_reassoc_req->capabilityInfo = caps;
2309
2310 /* Update PE session_id */
2311 mlm_reassoc_req->sessionId = session_id;
2312
2313 /*
2314 * If telescopic beaconing is enabled, set listen interval to
2315 * WNI_CFG_TELE_BCN_MAX_LI
2316 */
2317 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2318 &tele_bcn_en) != eSIR_SUCCESS)
2319 lim_log(mac_ctx, LOGP,
2320 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2321
2322 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2323
2324 if (tele_bcn_en) {
2325 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2326 eSIR_SUCCESS)
2327 /*
2328 * Could not get ListenInterval value
2329 * from CFG. Log error.
2330 */
2331 lim_log(mac_ctx, LOGP,
2332 FL("could not retrieve ListenInterval"));
2333 } else {
2334 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &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 }
2343
2344 mlm_reassoc_req->listenInterval = (uint16_t) val;
2345
2346 /* Indicate whether spectrum management is enabled */
2347 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2348
2349 /* Enable the spectrum management if this is a DFS channel */
2350 if (session_entry->country_info_present &&
2351 lim_isconnected_on_dfs_channel(
2352 session_entry->currentOperChannel))
2353 session_entry->spectrumMgtEnabled = true;
2354
2355 session_entry->limPrevSmeState = session_entry->limSmeState;
2356 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2357
2358 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2359 session_entry->peSessionId,
2360 session_entry->limSmeState));
2361
2362 lim_post_mlm_message(mac_ctx,
2363 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2364 return;
2365end:
2366 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302367 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 if (session_entry)
2369 session_entry->pLimReAssocReq = NULL;
2370 }
2371
2372 if (session_entry) {
2373 /*
2374 * error occurred after we determined the session so extract
2375 * session and transaction info from there
2376 */
2377 sme_session_id = session_entry->smeSessionId;
2378 transaction_id = session_entry->transactionId;
2379 } else
2380 /*
2381 * error occurred before or during the time we determined
2382 * the session so extract the session and transaction info
2383 * from the message
2384 */
2385 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2386 &sme_session_id, &transaction_id);
2387
2388 /*
2389 * Send Reassoc failure response to host
2390 * (note session_entry may be NULL, but that's OK)
2391 */
2392 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2393 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2394 session_entry, sme_session_id,
2395 transaction_id);
2396}
2397
2398bool send_disassoc_frame = 1;
2399/**
2400 * __lim_process_sme_disassoc_req()
2401 *
2402 ***FUNCTION:
2403 * This function is called to process SME_DISASSOC_REQ message
2404 * from HDD or upper layer application.
2405 *
2406 ***LOGIC:
2407 *
2408 ***ASSUMPTIONS:
2409 *
2410 ***NOTE:
2411 *
2412 * @param pMac Pointer to Global MAC structure
2413 * @param *pMsgBuf A pointer to the SME message buffer
2414 * @return None
2415 */
2416
2417static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2418{
2419 uint16_t disassocTrigger, reasonCode;
2420 tLimMlmDisassocReq *pMlmDisassocReq;
2421 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2422 tSirSmeDisassocReq smeDisassocReq;
2423 tpPESession psessionEntry = NULL;
2424 uint8_t sessionId;
2425 uint8_t smesessionId;
2426 uint16_t smetransactionId;
2427
2428 if (pMsgBuf == NULL) {
2429 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2430 return;
2431 }
2432
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302433 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 smesessionId = smeDisassocReq.sessionId;
2435 smetransactionId = smeDisassocReq.transactionId;
2436 if (!lim_is_sme_disassoc_req_valid(pMac,
2437 &smeDisassocReq,
2438 psessionEntry)) {
2439 PELOGE(lim_log(pMac, LOGE,
2440 FL("received invalid SME_DISASSOC_REQ message"));)
2441 if (pMac->lim.gLimRspReqd) {
2442 pMac->lim.gLimRspReqd = false;
2443
2444 retCode = eSIR_SME_INVALID_PARAMETERS;
2445 disassocTrigger = eLIM_HOST_DISASSOC;
2446 goto sendDisassoc;
2447 }
2448
2449 return;
2450 }
2451
2452 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002453 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 &sessionId);
2455 if (psessionEntry == NULL) {
2456 lim_log(pMac, LOGE,
2457 FL("session does not exist for given bssId "
2458 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002459 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 retCode = eSIR_SME_INVALID_PARAMETERS;
2461 disassocTrigger = eLIM_HOST_DISASSOC;
2462 goto sendDisassoc;
2463 }
2464 lim_log(pMac, LOG1,
2465 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2466 MAC_ADDRESS_STR), smesessionId,
2467 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2468 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002469 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470
2471#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2472 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2473 0, smeDisassocReq.reasonCode);
2474#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2475
2476 /* Update SME session Id and SME transaction ID */
2477
2478 psessionEntry->smeSessionId = smesessionId;
2479 psessionEntry->transactionId = smetransactionId;
2480
2481 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2482 case eLIM_STA_ROLE:
2483 case eLIM_BT_AMP_STA_ROLE:
2484 switch (psessionEntry->limSmeState) {
2485 case eLIM_SME_ASSOCIATED_STATE:
2486 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002487 lim_log(pMac, LOG1,
2488 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2489 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490 psessionEntry->limPrevSmeState =
2491 psessionEntry->limSmeState;
2492 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2493#ifdef FEATURE_WLAN_TDLS
2494 /* Delete all TDLS peers connected before leaving BSS */
2495 lim_delete_tdls_peers(pMac, psessionEntry);
2496#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002497 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2498 psessionEntry->peSessionId,
2499 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 break;
2501
2502 case eLIM_SME_WT_DEAUTH_STATE:
2503 /* PE shall still process the DISASSOC_REQ and proceed with
2504 * link tear down even if it had already sent a DEAUTH_IND to
2505 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2506 * its been set when PE entered WT_DEAUTH_STATE.
2507 */
2508 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2509 MTRACE(mac_trace
2510 (pMac, TRACE_CODE_SME_STATE,
2511 psessionEntry->peSessionId,
2512 psessionEntry->limSmeState));
2513 lim_log(pMac, LOG1,
2514 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2515 break;
2516
2517 case eLIM_SME_WT_DISASSOC_STATE:
2518 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2519 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2520 * PE can continue processing DISASSOC_REQ and send the response instead
2521 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2522 * for disassoc frame.
2523 *
2524 * It will send a disassoc, which is ok. However, we can use the global flag
2525 * sendDisassoc to not send disassoc frame.
2526 */
2527 lim_log(pMac, LOG1,
2528 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2529 break;
2530
2531 case eLIM_SME_JOIN_FAILURE_STATE: {
2532 /* Already in Disconnected State, return success */
2533 lim_log(pMac, LOG1,
2534 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2535 if (pMac->lim.gLimRspReqd) {
2536 retCode = eSIR_SME_SUCCESS;
2537 disassocTrigger = eLIM_HOST_DISASSOC;
2538 goto sendDisassoc;
2539 }
2540 }
2541 break;
2542 default:
2543 /**
2544 * STA is not currently associated.
2545 * Log error and send response to host
2546 */
2547 lim_log(pMac, LOGE,
2548 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2549 psessionEntry->limSmeState);
2550 lim_print_sme_state(pMac, LOGE,
2551 psessionEntry->limSmeState);
2552
2553 if (pMac->lim.gLimRspReqd) {
2554 if (psessionEntry->limSmeState !=
2555 eLIM_SME_WT_ASSOC_STATE)
2556 pMac->lim.gLimRspReqd = false;
2557
2558 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2559 disassocTrigger = eLIM_HOST_DISASSOC;
2560 goto sendDisassoc;
2561 }
2562
2563 return;
2564 }
2565
2566 break;
2567
2568 case eLIM_AP_ROLE:
2569 case eLIM_BT_AMP_AP_ROLE:
2570 /* Fall through */
2571 break;
2572
2573 case eLIM_STA_IN_IBSS_ROLE:
2574 default:
2575 /* eLIM_UNKNOWN_ROLE */
2576 lim_log(pMac, LOGE,
2577 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2578 GET_LIM_SYSTEM_ROLE(psessionEntry));
2579
2580 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2581 disassocTrigger = eLIM_HOST_DISASSOC;
2582 goto sendDisassoc;
2583 } /* end switch (pMac->lim.gLimSystemRole) */
2584
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302585 disassocTrigger = eLIM_HOST_DISASSOC;
2586 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587
2588 if (smeDisassocReq.doNotSendOverTheAir) {
2589 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2590 send_disassoc_frame = 0;
2591 }
2592 /* Trigger Disassociation frame to peer MAC entity */
2593 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2594 " : %d, reasonCode : %d"),
2595 disassocTrigger, reasonCode);
2596
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302597 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 if (NULL == pMlmDisassocReq) {
2599 /* Log error */
2600 lim_log(pMac, LOGP,
2601 FL("call to AllocateMemory failed for mlmDisassocReq"));
2602
2603 return;
2604 }
2605
Anurag Chouhanc5548422016-02-24 18:33:27 +05302606 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002607 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608
2609 pMlmDisassocReq->reasonCode = reasonCode;
2610 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2611
2612 /* Update PE session ID */
2613 pMlmDisassocReq->sessionId = sessionId;
2614
2615 lim_post_mlm_message(pMac,
2616 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2617 return;
2618
2619sendDisassoc:
2620 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002621 lim_send_sme_disassoc_ntf(pMac,
2622 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 retCode,
2624 disassocTrigger,
2625 1, smesessionId, smetransactionId,
2626 psessionEntry);
2627 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002628 lim_send_sme_disassoc_ntf(pMac,
2629 smeDisassocReq.peer_macaddr.bytes,
2630 retCode, disassocTrigger, 1,
2631 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632
2633} /*** end __lim_process_sme_disassoc_req() ***/
2634
2635/** -----------------------------------------------------------------
2636 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2637
2638 This function is called to process SME_DISASSOC_CNF message
2639 from HDD or upper layer application.
2640
2641 \param pMac - global mac structure
2642 \param pStaDs - station dph hash node
2643 \return none
2644 \sa
2645 ----------------------------------------------------------------- */
2646static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2647{
2648 tSirSmeDisassocCnf smeDisassocCnf;
2649 uint16_t aid;
2650 tpDphHashNode pStaDs;
2651 tpPESession psessionEntry;
2652 uint8_t sessionId;
2653
2654 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2655
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302656 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 sizeof(struct sSirSmeDisassocCnf));
2658
2659 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002660 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 &sessionId);
2662 if (psessionEntry == NULL) {
2663 lim_log(pMac, LOGE,
2664 FL("session does not exist for given bssId"));
2665 return;
2666 }
2667
2668 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2669 lim_log(pMac, LOGE,
2670 FL("received invalid SME_DISASSOC_CNF message"));
2671 return;
2672 }
2673#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2674 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2675 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2676 psessionEntry,
2677 (uint16_t) smeDisassocCnf.statusCode, 0);
2678 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2679 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2680 psessionEntry,
2681 (uint16_t) smeDisassocCnf.statusCode, 0);
2682#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2683
2684 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2685 case eLIM_STA_ROLE:
2686 case eLIM_BT_AMP_STA_ROLE: /* To test reconn */
2687 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2688 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2689 && (psessionEntry->limSmeState !=
2690 eLIM_SME_WT_DEAUTH_STATE)) {
2691 lim_log(pMac, LOGE,
2692 FL
2693 ("received unexp SME_DISASSOC_CNF in state %X"),
2694 psessionEntry->limSmeState);
2695 lim_print_sme_state(pMac, LOGE,
2696 psessionEntry->limSmeState);
2697 return;
2698 }
2699 break;
2700
2701 case eLIM_AP_ROLE:
2702 /* Fall through */
2703 break;
2704
2705 case eLIM_STA_IN_IBSS_ROLE:
2706 default: /* eLIM_UNKNOWN_ROLE */
2707 lim_log(pMac, LOGE,
2708 FL("received unexpected SME_DISASSOC_CNF role %d"),
2709 GET_LIM_SYSTEM_ROLE(psessionEntry));
2710
2711 return;
2712 }
2713
2714 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2715 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2716 LIM_IS_AP_ROLE(psessionEntry)) {
2717 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002718 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 &psessionEntry->dph.dphHashTable);
2720 if (pStaDs == NULL) {
2721 lim_log(pMac, LOGE,
2722 FL("DISASSOC_CNF for a STA with no context, addr= "
2723 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002724 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 return;
2726 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302727
2728 if ((pStaDs->mlmStaContext.mlmState ==
2729 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2730 (pStaDs->mlmStaContext.mlmState ==
2731 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2732 lim_log(pMac, LOGE,
2733 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002734 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302735 pStaDs->mlmStaContext.mlmState);
2736 return;
2737 }
2738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 /* Delete FT session if there exists one */
2740 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2742
2743 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002744 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 }
2746
2747 return;
2748}
2749
2750/**
2751 * __lim_process_sme_deauth_req() - process sme deauth req
2752 * @mac_ctx: Pointer to Global MAC structure
2753 * @msg_buf: pointer to the SME message buffer
2754 *
2755 * This function is called to process SME_DEAUTH_REQ message
2756 * from HDD or upper layer application.
2757 *
2758 * Return: None
2759 */
2760
2761static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2762 uint32_t *msg_buf)
2763{
2764 uint16_t deauth_trigger, reason_code;
2765 tLimMlmDeauthReq *mlm_deauth_req;
2766 tSirSmeDeauthReq sme_deauth_req;
2767 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2768 tpPESession session_entry;
2769 uint8_t session_id; /* PE sessionId */
2770 uint8_t sme_session_id;
2771 uint16_t sme_transaction_id;
2772
2773 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2774
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302775 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 sme_session_id = sme_deauth_req.sessionId;
2777 sme_transaction_id = sme_deauth_req.transactionId;
2778
2779 /*
2780 * We need to get a session first but we don't even know
2781 * if the message is correct.
2782 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002783 session_entry = pe_find_session_by_bssid(mac_ctx,
2784 sme_deauth_req.bssid.bytes,
2785 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 if (session_entry == NULL) {
2787 lim_log(mac_ctx, LOGE,
2788 FL("session does not exist for given bssId"));
2789 ret_code = eSIR_SME_INVALID_PARAMETERS;
2790 deauth_trigger = eLIM_HOST_DEAUTH;
2791 goto send_deauth;
2792 }
2793
2794 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2795 session_entry)) {
2796 lim_log(mac_ctx, LOGE,
2797 FL("received invalid SME_DEAUTH_REQ message"));
2798 mac_ctx->lim.gLimRspReqd = false;
2799
2800 ret_code = eSIR_SME_INVALID_PARAMETERS;
2801 deauth_trigger = eLIM_HOST_DEAUTH;
2802 goto send_deauth;
2803 }
2804 lim_log(mac_ctx, LOG1,
2805 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2806 MAC_ADDRESS_STR), sme_session_id,
2807 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2808 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002809 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2811 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2812 session_entry, 0, sme_deauth_req.reasonCode);
2813#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2814
2815 /* Update SME session ID and Transaction ID */
2816 session_entry->smeSessionId = sme_session_id;
2817 session_entry->transactionId = sme_transaction_id;
2818
2819 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2820 case eLIM_STA_ROLE:
2821 case eLIM_BT_AMP_STA_ROLE:
2822
2823 switch (session_entry->limSmeState) {
2824 case eLIM_SME_ASSOCIATED_STATE:
2825 case eLIM_SME_LINK_EST_STATE:
2826 case eLIM_SME_WT_ASSOC_STATE:
2827 case eLIM_SME_JOIN_FAILURE_STATE:
2828 case eLIM_SME_IDLE_STATE:
2829 session_entry->limPrevSmeState =
2830 session_entry->limSmeState;
2831 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2832 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2833 session_entry->peSessionId,
2834 session_entry->limSmeState));
2835 /* Send Deauthentication request to MLM below */
2836 break;
2837 case eLIM_SME_WT_DEAUTH_STATE:
2838 case eLIM_SME_WT_DISASSOC_STATE:
2839 /*
2840 * PE Recieved a Deauth/Disassoc frame. Normally it get
2841 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2842 * Which means host is also trying to disconnect.
2843 * PE can continue processing DEAUTH_REQ and send
2844 * the response instead of failing the request.
2845 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2846 * was sent for deauth/disassoc frame.
2847 */
2848 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2849 lim_log(mac_ctx, LOG1, FL(
2850 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2851 break;
2852 default:
2853 /*
2854 * STA is not in a state to deauthenticate with
2855 * peer. Log error and send response to host.
2856 */
2857 lim_log(mac_ctx, LOGE, FL(
2858 "received unexp SME_DEAUTH_REQ in state %X"),
2859 session_entry->limSmeState);
2860 lim_print_sme_state(mac_ctx, LOGE,
2861 session_entry->limSmeState);
2862
2863 if (mac_ctx->lim.gLimRspReqd) {
2864 mac_ctx->lim.gLimRspReqd = false;
2865
2866 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2867 deauth_trigger = eLIM_HOST_DEAUTH;
2868
2869 /*
2870 * here we received deauth request from AP so sme state
2871 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2872 * delSta then mlm state should be
2873 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2874 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2875 * so the below condition captures the state where
2876 * delSta not done and firmware still in
2877 * connected state.
2878 */
2879 if (session_entry->limSmeState ==
2880 eLIM_SME_WT_DEAUTH_STATE &&
2881 session_entry->limMlmState !=
2882 eLIM_MLM_IDLE_STATE &&
2883 session_entry->limMlmState !=
2884 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2885 ret_code = eSIR_SME_DEAUTH_STATUS;
2886 goto send_deauth;
2887 }
2888 return;
2889 }
2890 break;
2891
2892 case eLIM_STA_IN_IBSS_ROLE:
2893 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2894 if (mac_ctx->lim.gLimRspReqd) {
2895 mac_ctx->lim.gLimRspReqd = false;
2896 ret_code = eSIR_SME_INVALID_PARAMETERS;
2897 deauth_trigger = eLIM_HOST_DEAUTH;
2898 goto send_deauth;
2899 }
2900 return;
2901 case eLIM_AP_ROLE:
2902 break;
2903 default:
2904 lim_log(mac_ctx, LOGE,
2905 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2906 GET_LIM_SYSTEM_ROLE(session_entry));
2907 if (mac_ctx->lim.gLimRspReqd) {
2908 mac_ctx->lim.gLimRspReqd = false;
2909 ret_code = eSIR_SME_INVALID_PARAMETERS;
2910 deauth_trigger = eLIM_HOST_DEAUTH;
2911 goto send_deauth;
2912 }
2913 return;
2914 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2915
2916 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2917 /* Deauthentication is triggered by Link Monitoring */
2918 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2919 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2920 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2921 } else {
2922 deauth_trigger = eLIM_HOST_DEAUTH;
2923 reason_code = sme_deauth_req.reasonCode;
2924 }
2925
2926 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302927 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 if (NULL == mlm_deauth_req) {
2929 lim_log(mac_ctx, LOGP,
2930 FL("call to AllocateMemory failed for mlmDeauthReq"));
2931 if (mac_ctx->lim.gLimRspReqd) {
2932 mac_ctx->lim.gLimRspReqd = false;
2933 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2934 deauth_trigger = eLIM_HOST_DEAUTH;
2935 goto send_deauth;
2936 }
2937 return;
2938 }
2939
Anurag Chouhanc5548422016-02-24 18:33:27 +05302940 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002941 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942
2943 mlm_deauth_req->reasonCode = reason_code;
2944 mlm_deauth_req->deauthTrigger = deauth_trigger;
2945
2946 /* Update PE session Id */
2947 mlm_deauth_req->sessionId = session_id;
2948
2949 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2950 (uint32_t *)mlm_deauth_req);
2951 return;
2952
2953send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002954 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2955 ret_code, deauth_trigger, 1,
2956 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957}
2958
2959/**
2960 * __lim_process_sme_set_context_req()
2961 *
2962 * @mac_ctx: Pointer to Global MAC structure
2963 * @msg_buf: pointer to the SME message buffer
2964 *
2965 * This function is called to process SME_SETCONTEXT_REQ message
2966 * from HDD or upper layer application.
2967 *
2968 * Return: None
2969 */
2970
2971static void
2972__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2973{
2974 tpSirSmeSetContextReq set_context_req;
2975 tLimMlmSetKeysReq *mlm_set_key_req;
2976 tpPESession session_entry;
2977 uint8_t session_id; /* PE sessionID */
2978 uint8_t sme_session_id;
2979 uint16_t sme_transaction_id;
2980
2981 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2982
2983 if (msg_buf == NULL) {
2984 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2985 return;
2986 }
2987
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302988 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 if (NULL == set_context_req) {
2990 lim_log(mac_ctx, LOGP, FL(
2991 "call to AllocateMemory failed for set_context_req"));
2992 return;
2993 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302994 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 sizeof(struct sSirSmeSetContextReq));
2996 sme_session_id = set_context_req->sessionId;
2997 sme_transaction_id = set_context_req->transactionId;
2998
2999 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3000 lim_log(mac_ctx, LOGW,
3001 FL("received invalid SME_SETCONTEXT_REQ message"));
3002 goto end;
3003 }
3004
3005 if (set_context_req->keyMaterial.numKeys >
3006 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3007 lim_log(mac_ctx, LOGE, FL(
3008 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3009 set_context_req->keyMaterial.numKeys);
3010 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003011 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 eSIR_SME_INVALID_PARAMETERS, NULL,
3013 sme_session_id, sme_transaction_id);
3014 goto end;
3015 }
3016
3017 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003018 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 if (session_entry == NULL) {
3020 lim_log(mac_ctx, LOGW,
3021 FL("Session does not exist for given BSSID"));
3022 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003023 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 eSIR_SME_INVALID_PARAMETERS, NULL,
3025 sme_session_id, sme_transaction_id);
3026 goto end;
3027 }
3028#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3029 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3030 session_entry, 0, 0);
3031#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3032
3033 if (((LIM_IS_STA_ROLE(session_entry) ||
3034 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
3035 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3036 ((LIM_IS_IBSS_ROLE(session_entry) ||
3037 LIM_IS_AP_ROLE(session_entry) ||
3038 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
3039 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3040 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303041 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 if (NULL == mlm_set_key_req) {
3043 lim_log(mac_ctx, LOGP, FL(
3044 "mem alloc failed for mlmSetKeysReq"));
3045 goto end;
3046 }
3047 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3048 mlm_set_key_req->numKeys =
3049 set_context_req->keyMaterial.numKeys;
3050 if (mlm_set_key_req->numKeys >
3051 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3052 lim_log(mac_ctx, LOGP, FL(
3053 "no.of keys exceeded max num of default keys limit"));
3054 goto end;
3055 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303056 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003057 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303059 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 (uint8_t *) &set_context_req->keyMaterial.key,
3061 sizeof(tSirKeys) *
3062 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3063 numKeys : 1));
3064
3065 mlm_set_key_req->sessionId = session_id;
3066 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 lim_log(mac_ctx, LOG1, FL(
3068 "received SETCONTEXT_REQ message sessionId=%d"),
3069 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070
3071 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3072 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3073 LIM_IS_AP_ROLE(session_entry)) {
3074 if (set_context_req->keyMaterial.key[0].keyLength) {
3075 uint8_t key_id;
3076 key_id =
3077 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303078 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 &session_entry->WEPKeyMaterial[key_id],
3080 (uint8_t *) &set_context_req->keyMaterial,
3081 sizeof(tSirKeyMaterial));
3082 } else {
3083 uint32_t i;
3084 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3085 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303086 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 &mlm_set_key_req->key[i],
3088 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3089 sizeof(tSirKeys));
3090 }
3091 }
3092 }
3093 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3094 (uint32_t *) mlm_set_key_req);
3095 } else {
3096 lim_log(mac_ctx, LOGE, FL(
3097 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3098 GET_LIM_SYSTEM_ROLE(session_entry),
3099 session_entry->limSmeState);
3100 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3101
3102 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003103 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3105 session_entry, sme_session_id,
3106 sme_transaction_id);
3107 }
3108end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303109 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 return;
3111}
3112
3113/**
3114 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3115 *
3116 * @mac_ctx: Pointer to Global MAC structure
3117 * @msg_buf: pointer to the SME message buffer
3118 *
3119 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3120 * from HDD or upper layer application.
3121 *
3122 * Return: None
3123 */
3124
3125void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3126 uint32_t *msg_buf)
3127{
3128 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3129 tpDphHashNode sta_ds = NULL;
3130 tpPESession session_entry = NULL;
3131 tSap_Event sap_event;
3132 tpWLAN_SAPEventCB sap_event_cb = NULL;
3133 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3134 uint8_t session_id = CSR_SESSION_ID_INVALID;
3135 uint8_t assoc_id = 0;
3136 uint8_t sta_cnt = 0;
3137
3138 if (msg_buf == NULL) {
3139 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3140 return;
3141 }
3142
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303143 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 sizeof(struct sSirSmeGetAssocSTAsReq));
3145 /*
3146 * Get Associated stations from PE.
3147 * Find PE session Entry
3148 */
3149 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003150 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 &session_id);
3152 if (session_entry == NULL) {
3153 lim_log(mac_ctx, LOGE,
3154 FL("session does not exist for given bssId"));
3155 goto lim_assoc_sta_end;
3156 }
3157
3158 if (!LIM_IS_AP_ROLE(session_entry)) {
3159 lim_log(mac_ctx, LOGE, FL(
3160 "Received unexpected message in state %X, in role %X"),
3161 session_entry->limSmeState,
3162 GET_LIM_SYSTEM_ROLE(session_entry));
3163 goto lim_assoc_sta_end;
3164 }
3165 /* Retrieve values obtained in the request message */
3166 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3167 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3168
3169 if (NULL == assoc_sta_tmp)
3170 goto lim_assoc_sta_end;
3171 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3172 assoc_id++) {
3173 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3174 &session_entry->dph.dphHashTable);
3175 if (NULL == sta_ds)
3176 continue;
3177 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303178 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303180 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3182 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3183
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303184 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 (uint8_t *)&sta_ds->supportedRates,
3186 sizeof(tSirSupportedRates));
3187 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3188 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3189 assoc_sta_tmp->Support40Mhz =
3190 sta_ds->htDsssCckRate40MHzSupport;
3191
3192 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3193 sta_cnt + 1);
3194 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3195 MAC_ADDR_ARRAY(sta_ds->staAddr));
3196 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3197 sta_ds->assocId);
3198 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3199 sta_ds->staIndex);
3200 assoc_sta_tmp++;
3201 sta_cnt++;
3202 }
3203 }
3204lim_assoc_sta_end:
3205 /*
3206 * Call hdd callback with sap event to send the list of
3207 * associated stations from PE
3208 */
3209 if (sap_event_cb != NULL) {
3210 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3211 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303212 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3214 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3215 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3216 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3217 }
3218}
3219
3220/**
3221 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3222 *
3223 * @mac_ctx: Pointer to Global MAC structure
3224 * @msg_buf: pointer to WPS PBC overlap query message
3225 *
3226 * This function parses get WPS PBC overlap information
3227 * message and call callback to pass WPS PBC overlap
3228 * information back to hdd.
3229 *
3230 * Return: None
3231 */
3232void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3233 uint32_t *msg_buf)
3234{
3235 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3236 tpPESession session_entry = NULL;
3237 tSap_Event sap_event;
3238 tpWLAN_SAPEventCB sap_event_cb = NULL;
3239 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3241
3242 if (msg_buf == NULL) {
3243 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3244 return;
3245 }
3246
3247 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303248 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303250 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3252 /*
3253 * Get Associated stations from PE
3254 * Find PE session Entry
3255 */
3256 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003257 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 if (session_entry == NULL) {
3259 lim_log(mac_ctx, LOGE,
3260 FL("session does not exist for given bssId"));
3261 goto lim_get_wpspbc_sessions_end;
3262 }
3263
3264 if (!LIM_IS_AP_ROLE(session_entry)) {
3265 lim_log(mac_ctx, LOGE,
3266 FL("Received unexpected message in role %X"),
3267 GET_LIM_SYSTEM_ROLE(session_entry));
3268 goto lim_get_wpspbc_sessions_end;
3269 }
3270 /*
3271 * Call hdd callback with sap event to send the
3272 * WPS PBC overlap information
3273 */
3274 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303275 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276
Anurag Chouhanc5548422016-02-24 18:33:27 +05303277 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003279 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 sap_get_wpspbc_event->UUID_E,
3281 &sap_get_wpspbc_event->wpsPBCOverlap,
3282 session_entry);
3283 } else {
3284 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003285 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 session_entry);
3287 /* don't have to inform the HDD/Host */
3288 return;
3289 }
3290
3291 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3292 sap_get_wpspbc_event->wpsPBCOverlap);
3293 lim_print_mac_addr(mac_ctx,
3294 sap_get_wpspbc_event->addr.bytes, LOG4);
3295
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303296 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297
3298lim_get_wpspbc_sessions_end:
3299 sap_event_cb =
3300 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3301 if (NULL != sap_event_cb)
3302 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3303}
3304
3305/**
3306 * __lim_counter_measures()
3307 *
3308 * FUNCTION:
3309 * This function is called to "implement" MIC counter measure
3310 * and is *temporary* only
3311 *
3312 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3313 * we don't do the proper STA disassoc sequence since the
3314 * BSS will be stoped anyway
3315 *
3316 ***ASSUMPTIONS:
3317 *
3318 ***NOTE:
3319 *
3320 * @param pMac Pointer to Global MAC structure
3321 * @return None
3322 */
3323
3324static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3325{
3326 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3327 if (LIM_IS_AP_ROLE(psessionEntry) ||
3328 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3329 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3330 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 */
3439 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3440 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3441 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3442 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3443 /* Send disassoc all stations associated thru TKIP */
3444 __lim_counter_measures(pMac, psessionEntry);
3445 else
3446 lim_send_disassoc_mgmt_frame(pMac,
3447 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3448 bcAddr, psessionEntry, false);
3449 }
3450
3451 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303452 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 psessionEntry->addIeParams.probeRespDataLen = 0;
3454 psessionEntry->addIeParams.probeRespData_buff = NULL;
3455
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303456 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 psessionEntry->addIeParams.assocRespDataLen = 0;
3458 psessionEntry->addIeParams.assocRespData_buff = NULL;
3459
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303460 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3462 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3463
3464 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3465 pMac->lim.gLimIbssCoalescingHappened = false;
3466
3467 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3468 pStaDs =
3469 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3470 if (NULL == pStaDs)
3471 continue;
3472 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3473 if (eSIR_SUCCESS == status) {
3474 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3475 pStaDs->assocId, psessionEntry);
3476 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3477 } else {
3478 lim_log(pMac, LOGE,
3479 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303480 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 }
3482 }
3483 /* send a delBss to HAL and wait for a response */
3484 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3485
3486 if (status != eSIR_SUCCESS) {
3487 PELOGE(lim_log
3488 (pMac, LOGE, FL("delBss failed for bss %d"),
3489 psessionEntry->bssIdx);
3490 )
3491 psessionEntry->limSmeState = prevState;
3492
3493 MTRACE(mac_trace
3494 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3495 psessionEntry->limSmeState));
3496
3497 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3498 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3499 smetransactionId);
3500 }
3501}
3502
3503/**
3504 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3505 * @pMac: Global MAC context
3506 * @pMsg: Message from SME
3507 *
3508 * Wrapper for the function __lim_handle_sme_stop_bss_request
3509 * This message will be defered until softmac come out of
3510 * scan mode. Message should be handled even if we have
3511 * detected radar in the current operating channel.
3512 *
3513 * Return: true - If we consumed the buffer
3514 * false - If have defered the message.
3515 */
3516
3517static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3518{
3519 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3520 /**
3521 * If message defered, buffer is not consumed yet.
3522 * So return false
3523 */
3524 return false;
3525 }
3526 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3527 return true;
3528} /*** end __lim_process_sme_stop_bss_req() ***/
3529
3530void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3531 uint32_t body, tpPESession psessionEntry)
3532{
3533
3534 (void)body;
3535 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3536 lim_ibss_delete(pMac, psessionEntry);
3537 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3538 lim_delete_pre_auth_list(pMac);
3539 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3540 psessionEntry->smeSessionId,
3541 psessionEntry->transactionId);
3542 return;
3543}
3544
3545/**
3546 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3547 *
3548 * @mac_ctx: pointer to mac context
3549 * @msg_type: message type
3550 * @msg_buf: pointer to the SME message buffer
3551 *
3552 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3553 * in BTAMP AP.
3554 *
3555 * Return: None
3556 */
3557
3558void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3559 uint32_t *msg_buf)
3560{
3561 tSirSmeAssocCnf assoc_cnf;
3562 tpDphHashNode sta_ds = NULL;
3563 tpPESession session_entry = NULL;
3564 uint8_t session_id;
3565 tpSirAssocReq assoc_req;
3566
3567 if (msg_buf == NULL) {
3568 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3569 goto end;
3570 }
3571
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303572 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3574 lim_log(mac_ctx, LOGE,
3575 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3576 goto end;
3577 }
3578
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003579 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 &session_id);
3581 if (session_entry == NULL) {
3582 lim_log(mac_ctx, LOGE,
3583 FL("session does not exist for given bssId"));
3584 goto end;
3585 }
3586
3587 if ((!LIM_IS_AP_ROLE(session_entry) &&
3588 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3589 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3590 (session_entry->limSmeState !=
3591 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3592 lim_log(mac_ctx, LOGE, FL(
3593 "Rcvd unexpected msg %X in state %X, in role %X"),
3594 msg_type, session_entry->limSmeState,
3595 GET_LIM_SYSTEM_ROLE(session_entry));
3596 goto end;
3597 }
3598 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3599 &session_entry->dph.dphHashTable);
3600 if (sta_ds == NULL) {
3601 lim_log(mac_ctx, LOGE, FL(
3602 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3603 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003604 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605
3606 /*
3607 * send a DISASSOC_IND message to WSM to make sure
3608 * the state in WSM and LIM is the same
3609 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003610 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 eSIR_SME_STA_NOT_ASSOCIATED,
3612 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3613 session_entry->smeSessionId,
3614 session_entry->transactionId,
3615 session_entry);
3616 goto end;
3617 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303618 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003619 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303620 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 lim_log(mac_ctx, LOG1, FL(
3622 "peerMacAddr mismatched for aid %d, peer "),
3623 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003624 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 goto end;
3626 }
3627
3628 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3629 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3630 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3631 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3632 (msg_type != eWNI_SME_ASSOC_CNF))) {
3633 lim_log(mac_ctx, LOG1, FL(
3634 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3635 "StaD mlmState : %d"),
3636 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003637 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 goto end;
3639 }
3640 /*
3641 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3642 * has been received
3643 */
3644 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3645 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3646 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3647
3648 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3649 /*
3650 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3651 * when it had received Assoc Request frame. Now, PE just needs
3652 * to send association rsp frame to the requesting BTAMP-STA.
3653 */
3654 sta_ds->mlmStaContext.mlmState =
3655 eLIM_MLM_LINK_ESTABLISHED_STATE;
3656 lim_log(mac_ctx, LOG1,
3657 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3658 sta_ds->assocId);
3659 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3660 sta_ds->assocId, sta_ds->staAddr,
3661 sta_ds->mlmStaContext.subType, sta_ds,
3662 session_entry);
3663 goto end;
3664 } else {
3665 /*
3666 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3667 * to be associated since the HAL sta entry is created for
3668 * denied STA we need to remove this HAL entry.
3669 * So to do that set updateContext to 1
3670 */
3671 if (!sta_ds->mlmStaContext.updateContext)
3672 sta_ds->mlmStaContext.updateContext = 1;
3673 lim_log(mac_ctx, LOG1,
3674 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3675 assoc_cnf.statusCode, sta_ds->assocId);
3676 lim_reject_association(mac_ctx, sta_ds->staAddr,
3677 sta_ds->mlmStaContext.subType,
3678 true, sta_ds->mlmStaContext.authType,
3679 sta_ds->assocId, true,
3680 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3681 session_entry);
3682 }
3683end:
3684 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3685 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3686 assoc_req = (tpSirAssocReq)
3687 session_entry->parsedAssocReq[sta_ds->assocId];
3688 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303689 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 assoc_req->assocReqFrame = NULL;
3691 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303692 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3694 }
3695}
3696
3697static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3698{
3699 tpDphHashNode pStaDs;
3700 tSirMacAddr peerMac;
3701 tpSirAddtsReq pSirAddts;
3702 uint32_t timeout;
3703 tpPESession psessionEntry;
3704 uint8_t sessionId; /* PE sessionId */
3705 uint8_t smesessionId;
3706 uint16_t smetransactionId;
3707
3708 if (pMsgBuf == NULL) {
3709 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3710 return;
3711 }
3712
3713 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3714 &smetransactionId);
3715
3716 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3717
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003718 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3719 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 if (psessionEntry == NULL) {
3721 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3722 return;
3723 }
3724#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3725 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3726 0);
3727#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3728
3729 /* if sta
3730 * - verify assoc state
3731 * - send addts request to ap
3732 * - wait for addts response from ap
3733 * if ap, just ignore with error log
3734 */
3735 PELOG1(lim_log(pMac, LOG1,
3736 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3737 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3738 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3739 )
3740
3741 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3742 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3743 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3744 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3745 psessionEntry, pSirAddts->req.tspec,
3746 smesessionId, smetransactionId);
3747 return;
3748 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749
3750 pStaDs =
3751 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3752 &psessionEntry->dph.dphHashTable);
3753
3754 if (pStaDs == NULL) {
3755 PELOGE(lim_log
3756 (pMac, LOGE, "Cannot find AP context for addts req");
3757 )
3758 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3759 psessionEntry, pSirAddts->req.tspec,
3760 smesessionId, smetransactionId);
3761 return;
3762 }
3763
3764 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3765 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3766 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3767 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3768 psessionEntry, pSirAddts->req.tspec,
3769 smesessionId, smetransactionId);
3770 return;
3771 }
3772
3773 pSirAddts->req.wsmTspecPresent = 0;
3774 pSirAddts->req.wmeTspecPresent = 0;
3775 pSirAddts->req.lleTspecPresent = 0;
3776
3777 if ((pStaDs->wsmEnabled) &&
3778 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3779 SIR_MAC_ACCESSPOLICY_EDCA))
3780 pSirAddts->req.wsmTspecPresent = 1;
3781 else if (pStaDs->wmeEnabled)
3782 pSirAddts->req.wmeTspecPresent = 1;
3783 else if (pStaDs->lleEnabled)
3784 pSirAddts->req.lleTspecPresent = 1;
3785 else {
3786 PELOGW(lim_log
3787 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3788 )
3789 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3790 psessionEntry, pSirAddts->req.tspec,
3791 smesessionId, smetransactionId);
3792 return;
3793 }
3794
3795 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3796 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3797 lim_log(pMac, LOGE,
3798 "AddTs received in invalid LIMsme state (%d)",
3799 psessionEntry->limSmeState);
3800 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3801 psessionEntry, pSirAddts->req.tspec,
3802 smesessionId, smetransactionId);
3803 return;
3804 }
3805
3806 if (pMac->lim.gLimAddtsSent) {
3807 lim_log(pMac, LOGE,
3808 "Addts (token %d, tsid %d, up %d) is still pending",
3809 pMac->lim.gLimAddtsReq.req.dialogToken,
3810 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3811 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3812 userPrio);
3813 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3814 psessionEntry, pSirAddts->req.tspec,
3815 smesessionId, smetransactionId);
3816 return;
3817 }
3818
3819 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3820
3821 /* save the addts request */
3822 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303823 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3825
3826 /* ship out the message now */
3827 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3828 psessionEntry);
3829 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3830 /* start a timer to wait for the response */
3831 if (pSirAddts->timeout)
3832 timeout = pSirAddts->timeout;
3833 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3834 eSIR_SUCCESS) {
3835 lim_log(pMac, LOGP,
3836 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3837 WNI_CFG_ADDTS_RSP_TIMEOUT);
3838 return;
3839 }
3840
3841 timeout = SYS_MS_TO_TICKS(timeout);
3842 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3843 != TX_SUCCESS) {
3844 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3845 return;
3846 }
3847 pMac->lim.gLimAddtsRspTimerCount++;
3848 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3849 pMac->lim.gLimAddtsRspTimerCount) !=
3850 TX_SUCCESS) {
3851 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3852 return;
3853 }
3854 MTRACE(mac_trace
3855 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3856 eLIM_ADDTS_RSP_TIMER));
3857
3858 /* add the sessionId to the timer object */
3859 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3860 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3861 TX_SUCCESS) {
3862 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3863 return;
3864 }
3865 return;
3866}
3867
3868static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3869{
3870 tSirMacAddr peerMacAddr;
3871 uint8_t ac;
3872 tSirMacTSInfo *pTsinfo;
3873 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3874 tpDphHashNode pStaDs = NULL;
3875 tpPESession psessionEntry;
3876 uint8_t sessionId;
3877 uint32_t status = eSIR_SUCCESS;
3878 uint8_t smesessionId;
3879 uint16_t smetransactionId;
3880
3881 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3882 &smetransactionId);
3883
3884 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003885 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 &sessionId);
3887 if (psessionEntry == NULL) {
3888 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3889 status = eSIR_FAILURE;
3890 goto end;
3891 }
3892#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3893 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3894 0);
3895#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3896
3897 if (eSIR_SUCCESS !=
3898 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3899 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3900 status = eSIR_FAILURE;
3901 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3902 smesessionId, smetransactionId);
3903 return;
3904 }
3905
3906 lim_log(pMac, LOG1,
3907 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3908 MAC_ADDRESS_STR),
3909 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3910
3911 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3912 pDeltsReq->req.wmeTspecPresent,
3913 &pDeltsReq->req.tsinfo,
3914 &pDeltsReq->req.tspec, psessionEntry);
3915
3916 pTsinfo =
3917 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3918 tsinfo : &pDeltsReq->req.tsinfo;
3919
3920 /* We've successfully send DELTS frame to AP. Update the
3921 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3922 * is no longer trigger enabled or delivery enabled
3923 */
3924 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3925 pTsinfo, CLEAR_UAPSD_MASK);
3926
3927 /* We're deleting the TSPEC, so this particular AC is no longer
3928 * admitted. PE needs to downgrade the EDCA
3929 * parameters(for the AC for which TS is being deleted) to the
3930 * next best AC for which ACM is not enabled, and send the
3931 * updated values to HAL.
3932 */
3933 ac = upToAc(pTsinfo->traffic.userPrio);
3934
3935 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3936 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3937 ~(1 << ac);
3938 } else if (pTsinfo->traffic.direction ==
3939 SIR_MAC_DIRECTION_DNLINK) {
3940 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3941 ~(1 << ac);
3942 } else if (pTsinfo->traffic.direction ==
3943 SIR_MAC_DIRECTION_BIDIR) {
3944 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3945 ~(1 << ac);
3946 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3947 ~(1 << ac);
3948 }
3949
3950 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3951 psessionEntry);
3952
3953 pStaDs =
3954 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3955 &psessionEntry->dph.dphHashTable);
3956 if (pStaDs != NULL) {
3957 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3958 pStaDs->bssId);
3959 status = eSIR_SUCCESS;
3960 } else {
3961 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3962 status = eSIR_FAILURE;
3963 }
3964#ifdef FEATURE_WLAN_ESE
3965#ifdef FEATURE_WLAN_ESE_UPLOAD
3966 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967#endif /* FEATURE_WLAN_ESE_UPLOAD */
3968#endif
3969
3970 /* send an sme response back */
3971end:
3972 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3973 smesessionId, smetransactionId);
3974}
3975
3976void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3977{
3978 /* fetch the sessionEntry based on the sessionId */
3979 tpPESession psessionEntry;
3980 psessionEntry = pe_find_session_by_session_id(pMac,
3981 pMac->lim.limTimers.gLimAddtsRspTimer.
3982 sessionId);
3983 if (psessionEntry == NULL) {
3984 lim_log(pMac, LOGP,
3985 FL("Session Does not exist for given sessionID"));
3986 return;
3987 }
3988
3989 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3990 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3991 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3992 GET_LIM_SYSTEM_ROLE(psessionEntry));
3993 pMac->lim.gLimAddtsSent = false;
3994 return;
3995 }
3996
3997 if (!pMac->lim.gLimAddtsSent) {
3998 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3999 return;
4000 }
4001
4002 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4003 lim_log(pMac, LOGE,
4004 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4005 pMac->lim.gLimAddtsRspTimerCount);
4006 return;
4007 }
4008 /* this a real response timeout */
4009 pMac->lim.gLimAddtsSent = false;
4010 pMac->lim.gLimAddtsRspTimerCount++;
4011
4012 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4013 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4014 psessionEntry->smeSessionId,
4015 psessionEntry->transactionId);
4016}
4017
4018/**
4019 * __lim_process_sme_get_statistics_request()
4020 *
4021 ***FUNCTION:
4022 *
4023 *
4024 ***NOTE:
4025 *
4026 * @param pMac Pointer to Global MAC structure
4027 * @param *pMsgBuf A pointer to the SME message buffer
4028 * @return None
4029 */
4030static void
4031__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4032{
4033 tpAniGetPEStatsReq pPEStatsReq;
4034 tSirMsgQ msgQ;
4035
4036 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4037
4038 msgQ.type = WMA_GET_STATISTICS_REQ;
4039
4040 msgQ.reserved = 0;
4041 msgQ.bodyptr = pMsgBuf;
4042 msgQ.bodyval = 0;
4043 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4044
4045 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304046 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 pMsgBuf = NULL;
4048 lim_log(pMac, LOGP, "Unable to forward request");
4049 return;
4050 }
4051
4052 return;
4053}
4054
4055#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4056/**
4057 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
4058 *
4059 ***NOTE:
4060 *
4061 * @param pMac Pointer to Global MAC structure
4062 * @param *pMsgBuf A pointer to the SME message buffer
4063 * @return None
4064 */
4065static void
4066__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4067{
4068 tSirMsgQ msgQ;
4069
4070 msgQ.type = WMA_TSM_STATS_REQ;
4071 msgQ.reserved = 0;
4072 msgQ.bodyptr = pMsgBuf;
4073 msgQ.bodyval = 0;
4074 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4075
4076 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304077 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 pMsgBuf = NULL;
4079 lim_log(pMac, LOGP, "Unable to forward request");
4080 return;
4081 }
4082}
4083#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4084
4085static void
4086__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4087{
4088 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4089 tpPESession psessionEntry;
4090 uint8_t sessionId; /* PE sessionID */
4091
4092 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4093
4094 if (pMsgBuf == NULL) {
4095 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4096 return;
4097 }
4098
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304099 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 if (NULL == pUpdateAPWPSIEsReq) {
4101 lim_log(pMac, LOGP,
4102 FL
4103 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4104 return;
4105 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304106 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 sizeof(struct sSirUpdateAPWPSIEsReq));
4108
4109 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004110 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 &sessionId);
4112 if (psessionEntry == NULL) {
4113 lim_log(pMac, LOGW,
4114 FL("Session does not exist for given BSSID"));
4115 goto end;
4116 }
4117
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304118 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 sizeof(tSirAPWPSIEs));
4120
4121 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4122 lim_send_beacon_ind(pMac, psessionEntry);
4123
4124end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304125 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 return;
4127}
4128
4129void
4130lim_send_vdev_restart(tpAniSirGlobal pMac,
4131 tpPESession psessionEntry, uint8_t sessionId)
4132{
4133 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4134 tSirMsgQ msgQ;
4135 tSirRetStatus retCode = eSIR_SUCCESS;
4136
4137 if (psessionEntry == NULL) {
4138 PELOGE(lim_log
4139 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4140 __LINE__);
4141 )
4142 return;
4143 }
4144
4145 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304146 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 if (NULL == pHalHiddenSsidVdevRestart) {
4148 PELOGE(lim_log
4149 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4150 __func__, __LINE__);
4151 )
4152 return;
4153 }
4154
4155 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4156 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4157
4158 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4159 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4160 msgQ.bodyval = 0;
4161
4162 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4163 if (eSIR_SUCCESS != retCode) {
4164 PELOGE(lim_log
4165 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4166 __LINE__);
4167 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304168 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 }
4170}
4171
4172static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4173{
4174 tpSirUpdateParams pUpdateParams;
4175 tpPESession psessionEntry;
4176
4177 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4178
4179 if (pMsgBuf == NULL) {
4180 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4181 return;
4182 }
4183
4184 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4185
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004186 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 pUpdateParams->sessionId);
4188 if (psessionEntry == NULL) {
4189 lim_log(pMac, LOGW,
4190 "Session does not exist for given sessionId %d",
4191 pUpdateParams->sessionId);
4192 return;
4193 }
4194
4195 /* Update the session entry */
4196 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4197
4198 /* Send vdev restart */
4199 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4200
4201 /* Update beacon */
4202 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4203 lim_send_beacon_ind(pMac, psessionEntry);
4204
4205 return;
4206} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4207
4208static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4209{
4210 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4211 tpPESession psessionEntry;
4212 uint8_t sessionId; /* PE sessionID */
4213
4214 if (pMsgBuf == NULL) {
4215 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4216 return;
4217 }
4218
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304219 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 if (NULL == pUpdateAPWPARSNIEsReq) {
4221 lim_log(pMac, LOGP,
4222 FL
4223 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4224 return;
4225 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304226 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4228
4229 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004230 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 &sessionId);
4232 if (psessionEntry == NULL) {
4233 lim_log(pMac, LOGW,
4234 FL("Session does not exist for given BSSID"));
4235 goto end;
4236 }
4237
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304238 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4240
4241 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4242 &psessionEntry->
4243 pLimStartBssReq->rsnIE,
4244 psessionEntry);
4245
4246 psessionEntry->pLimStartBssReq->privacy = 1;
4247 psessionEntry->privacy = 1;
4248
4249 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4250 lim_send_beacon_ind(pMac, psessionEntry);
4251
4252end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304253 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 return;
4255} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4256
4257/*
4258 Update the beacon Interval dynamically if beaconInterval is different in MCC
4259 */
4260static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4261{
4262 tpSirChangeBIParams pChangeBIParams;
4263 tpPESession psessionEntry;
4264 uint8_t sessionId = 0;
4265 tUpdateBeaconParams beaconParams;
4266
4267 PELOG1(lim_log(pMac, LOG1,
4268 FL("received Update Beacon Interval message"));
4269 );
4270
4271 if (pMsgBuf == NULL) {
4272 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4273 return;
4274 }
4275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304276 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4278
4279 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004280 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 &sessionId);
4282 if (psessionEntry == NULL) {
4283 lim_log(pMac, LOGE,
4284 FL("Session does not exist for given BSSID"));
4285 return;
4286 }
4287
4288 /*Update sessionEntry Beacon Interval */
4289 if (psessionEntry->beaconParams.beaconInterval !=
4290 pChangeBIParams->beaconInterval) {
4291 psessionEntry->beaconParams.beaconInterval =
4292 pChangeBIParams->beaconInterval;
4293 }
4294
4295 /*Update sch beaconInterval */
4296 if (pMac->sch.schObject.gSchBeaconInterval !=
4297 pChangeBIParams->beaconInterval) {
4298 pMac->sch.schObject.gSchBeaconInterval =
4299 pChangeBIParams->beaconInterval;
4300
4301 PELOG1(lim_log(pMac, LOG1,
4302 FL
4303 ("LIM send update BeaconInterval Indication : %d"),
4304 pChangeBIParams->beaconInterval);
4305 );
4306
4307 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4308 /* Update beacon */
4309 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4310
4311 beaconParams.bssIdx = psessionEntry->bssIdx;
4312 /* Set change in beacon Interval */
4313 beaconParams.beaconInterval =
4314 pChangeBIParams->beaconInterval;
4315 beaconParams.paramChangeBitmap =
4316 PARAM_BCN_INTERVAL_CHANGED;
4317 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4318 }
4319 }
4320
4321 return;
4322} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4323
4324#ifdef QCA_HT_2040_COEX
4325static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4326 uint32_t *pMsgBuf)
4327{
4328 tpSirSetHT2040Mode pSetHT2040Mode;
4329 tpPESession psessionEntry;
4330 uint8_t sessionId = 0;
4331 cds_msg_t msg;
4332 tUpdateVHTOpMode *pHtOpMode = NULL;
4333 uint16_t staId = 0;
4334 tpDphHashNode pStaDs = NULL;
4335
4336 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4337 if (pMsgBuf == NULL) {
4338 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4339 return;
4340 }
4341
4342 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4343
4344 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004345 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 &sessionId);
4347 if (psessionEntry == NULL) {
4348 lim_log(pMac, LOG1,
4349 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004350 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351 return;
4352 }
4353
4354 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4355 pSetHT2040Mode->cbMode);
4356 /*Update sessionEntry HT related fields */
4357 switch (pSetHT2040Mode->cbMode) {
4358 case PHY_SINGLE_CHANNEL_CENTERED:
4359 psessionEntry->htSecondaryChannelOffset =
4360 PHY_SINGLE_CHANNEL_CENTERED;
4361 psessionEntry->htRecommendedTxWidthSet = 0;
4362 if (pSetHT2040Mode->obssEnabled)
4363 psessionEntry->htSupportedChannelWidthSet
4364 = eHT_CHANNEL_WIDTH_40MHZ;
4365 else
4366 psessionEntry->htSupportedChannelWidthSet
4367 = eHT_CHANNEL_WIDTH_20MHZ;
4368 break;
4369 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4370 psessionEntry->htSecondaryChannelOffset =
4371 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4372 psessionEntry->htRecommendedTxWidthSet = 1;
4373 break;
4374 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4375 psessionEntry->htSecondaryChannelOffset =
4376 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4377 psessionEntry->htRecommendedTxWidthSet = 1;
4378 break;
4379 default:
4380 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4381 return;
4382 }
4383
4384 /* Update beacon */
4385 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4386 lim_send_beacon_ind(pMac, psessionEntry);
4387
4388 /* update OP Mode for each associated peer */
4389 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4390 pStaDs = dph_get_hash_entry(pMac, staId,
4391 &psessionEntry->dph.dphHashTable);
4392 if (NULL == pStaDs)
4393 continue;
4394
4395 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304396 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 if (NULL == pHtOpMode) {
4398 lim_log(pMac, LOGE,
4399 FL
4400 ("%s: Not able to allocate memory for setting OP mode"),
4401 __func__);
4402 return;
4403 }
4404 pHtOpMode->opMode =
4405 (psessionEntry->htSecondaryChannelOffset ==
4406 PHY_SINGLE_CHANNEL_CENTERED) ?
4407 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4408 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304409 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 sizeof(tSirMacAddr));
4411 pHtOpMode->smesessionId = sessionId;
4412
4413 msg.type = WMA_UPDATE_OP_MODE;
4414 msg.reserved = 0;
4415 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304416 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304417 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 lim_log(pMac, LOGE,
4419 FL
4420 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4421 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304422 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 return;
4424 }
4425 lim_log(pMac, LOG1,
4426 FL
4427 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4428 __func__, pHtOpMode->opMode, staId);
4429
4430 } else
4431 lim_log(pMac, LOG1,
4432 FL("%s: station %d does not support HT40\n"),
4433 __func__, staId);
4434 }
4435
4436 return;
4437}
4438#endif
4439
4440/* -------------------------------------------------------------------- */
4441/**
4442 * __lim_process_report_message
4443 *
4444 * FUNCTION: Processes the next received Radio Resource Management message
4445 *
4446 * LOGIC:
4447 *
4448 * ASSUMPTIONS:
4449 *
4450 * NOTE:
4451 *
4452 * @param None
4453 * @return None
4454 */
4455
4456void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4457{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 switch (pMsg->type) {
4459 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4460 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4461 break;
4462 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004464 break;
4465 default:
4466 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468}
4469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470/* -------------------------------------------------------------------- */
4471/**
4472 * lim_send_set_max_tx_power_req
4473 *
4474 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4475 *
4476 * LOGIC:
4477 *
4478 * ASSUMPTIONS:
4479 *
4480 * NOTE:
4481 *
4482 * @param txPower txPower to be set.
4483 * @param pSessionEntry session entry.
4484 * @return None
4485 */
4486tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004487lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 tpPESession pSessionEntry)
4489{
4490 tpMaxTxPowerParams pMaxTxParams = NULL;
4491 tSirRetStatus retCode = eSIR_SUCCESS;
4492 tSirMsgQ msgQ;
4493
4494 if (pSessionEntry == NULL) {
4495 PELOGE(lim_log
4496 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4497 __LINE__);
4498 )
4499 return eSIR_FAILURE;
4500 }
4501
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304502 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 if (NULL == pMaxTxParams) {
4504 lim_log(pMac, LOGP,
4505 FL("Unable to allocate memory for pMaxTxParams "));
4506 return eSIR_MEM_ALLOC_FAILED;
4507
4508 }
4509#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4510 lim_log(pMac, LOG1,
4511 FL("pMaxTxParams allocated...will be freed in other module"));
4512#endif
4513 if (pMaxTxParams == NULL) {
4514 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4515 return eSIR_FAILURE;
4516 }
4517 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304518 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304519 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304520 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004521 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304522 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523
4524 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4525 msgQ.bodyptr = pMaxTxParams;
4526 msgQ.bodyval = 0;
4527 PELOG1(lim_log
4528 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4529 )
4530 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4531 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4532 if (eSIR_SUCCESS != retCode) {
4533 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304534 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 }
4536 return retCode;
4537}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538
4539/**
4540 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4541 *
4542 * @mac_ctx: Pointer to Global MAC structure
4543 * @msg_buf: pointer to the SME message buffer
4544 *
4545 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4546 * from SME. It Register this information within PE.
4547 *
4548 * Return: None
4549 */
4550static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4551 uint32_t *msg_buf)
4552{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304553 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4555 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4556 struct mgmt_frm_reg_info *next = NULL;
4557 bool match = false;
4558
4559 lim_log(mac_ctx, LOG1, FL(
4560 "registerFrame %d, frameType %d, matchLen %d"),
4561 sme_req->registerFrame, sme_req->frameType,
4562 sme_req->matchLen);
4563 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304564 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304565 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4566 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304567 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568
4569 while (lim_mgmt_regn != NULL) {
4570 if (lim_mgmt_regn->frameType != sme_req->frameType)
4571 goto skip_match;
4572 if (sme_req->matchLen) {
4573 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304574 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 sme_req->matchData,
4576 lim_mgmt_regn->matchLen))) {
4577 /* found match! */
4578 match = true;
4579 break;
4580 }
4581 } else {
4582 /* found match! */
4583 match = true;
4584 break;
4585 }
4586skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304587 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304588 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304590 (qdf_list_node_t *)lim_mgmt_regn,
4591 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304592 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 lim_mgmt_regn = next;
4594 next = NULL;
4595 }
4596 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304597 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304598 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304600 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304601 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304602 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 }
4604
4605 if (sme_req->registerFrame) {
4606 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304607 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 sme_req->matchLen);
4609 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304610 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 sizeof(struct mgmt_frm_reg_info) +
4612 sme_req->matchLen, 0);
4613 lim_mgmt_regn->frameType = sme_req->frameType;
4614 lim_mgmt_regn->matchLen = sme_req->matchLen;
4615 lim_mgmt_regn->sessionId = sme_req->sessionId;
4616 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304617 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 sme_req->matchData,
4619 sme_req->matchLen);
4620 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304621 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304623 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 gLimMgmtFrameRegistratinQueue,
4625 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304626 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 &mac_ctx->lim.lim_frame_register_lock);
4628 }
4629 }
4630 return;
4631}
4632
4633static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4634{
4635 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4636 pMac->lim.gDeferMsgTypeForNOA);
4637 pMac->lim.gDeferMsgTypeForNOA = 0;
4638 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4639 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304640 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4642 }
4643}
4644
4645/**
4646 * lim_process_regd_defd_sme_req_after_noa_start()
4647 *
4648 * mac_ctx: Pointer to Global MAC structure
4649 *
4650 * This function is called to process deferred sme req message
4651 * after noa start.
4652 *
4653 * Return: None
4654 */
4655void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4656{
4657 bool buf_consumed = true;
4658
4659 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4660 mac_ctx->lim.gDeferMsgTypeForNOA);
4661
4662 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4663 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4664 lim_log(mac_ctx, LOGW,
4665 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4666 lim_log(mac_ctx, LOGW,
4667 FL("It may happen when NOA start ind and timeout happen at the same time"));
4668 return;
4669 }
4670 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4671 case eWNI_SME_SCAN_REQ:
4672 __lim_process_sme_scan_req(mac_ctx,
4673 mac_ctx->lim.gpDefdSmeMsgForNOA);
4674 break;
4675#ifdef FEATURE_OEM_DATA_SUPPORT
4676 case eWNI_SME_OEM_DATA_REQ:
4677 __lim_process_sme_oem_data_req(mac_ctx,
4678 mac_ctx->lim.gpDefdSmeMsgForNOA);
4679 break;
4680#endif
4681 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4682 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4683 mac_ctx->lim.gpDefdSmeMsgForNOA);
4684 /*
4685 * lim_process_remain_on_chnl_req doesnt want us to free
4686 * the buffer since it is freed in lim_remain_on_chn_rsp.
4687 * this change is to avoid "double free"
4688 */
4689 if (false == buf_consumed)
4690 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4691 break;
4692 case eWNI_SME_JOIN_REQ:
4693 __lim_process_sme_join_req(mac_ctx,
4694 mac_ctx->lim.gpDefdSmeMsgForNOA);
4695 break;
4696 default:
4697 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4698 mac_ctx->lim.gDeferMsgTypeForNOA);
4699 break;
4700 }
4701 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4702}
4703
4704static void
4705__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4706{
4707 tpSirResetAPCapsChange pResetCapsChange;
4708 tpPESession psessionEntry;
4709 uint8_t sessionId = 0;
4710 if (pMsgBuf == NULL) {
4711 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4712 return;
4713 }
4714
4715 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4716 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004717 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4718 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 if (psessionEntry == NULL) {
4720 lim_log(pMac, LOGE,
4721 FL("Session does not exist for given BSSID"));
4722 return;
4723 }
4724
4725 psessionEntry->limSentCapsChangeNtf = false;
4726 return;
4727}
4728
4729/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304730 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4731 * indication callback in PE.
4732 * @mac_ptr: Mac pointer
4733 * @msg_buf: Msg pointer containing the callback
4734 *
4735 * This function is used save the Management frame
4736 * indication callback in PE.
4737 *
4738 * Return: None
4739 */
4740static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4741 uint32_t *msg_buf)
4742{
4743 struct sir_sme_mgmt_frame_cb_req *sme_req =
4744 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4745
4746 if (NULL == msg_buf) {
4747 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4748 return;
4749 }
4750 if (sme_req->callback)
4751 mac_ctx->mgmt_frame_ind_cb =
4752 (sir_mgmt_frame_ind_callback)sme_req->callback;
4753 else
4754 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4755}
4756
4757/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 * lim_process_sme_req_messages()
4759 *
4760 ***FUNCTION:
4761 * This function is called by limProcessMessageQueue(). This
4762 * function processes SME request messages from HDD or upper layer
4763 * application.
4764 *
4765 ***LOGIC:
4766 *
4767 ***ASSUMPTIONS:
4768 *
4769 ***NOTE:
4770 *
4771 * @param pMac Pointer to Global MAC structure
4772 * @param msgType Indicates the SME message type
4773 * @param *pMsgBuf A pointer to the SME message buffer
4774 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4775 * false - if pMsgBuf is not to be freed.
4776 */
4777
4778bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4779{
4780 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4781 uint32_t *pMsgBuf = pMsg->bodyptr;
4782 tpSirSmeScanReq pScanReq;
4783 PELOG1(lim_log
4784 (pMac, LOG1,
4785 FL
4786 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4787 lim_msg_str(pMsg->type), pMsg->type,
4788 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4789 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4790 )
4791
4792 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4793 /* If no insert NOA required then execute the code below */
4794
4795 switch (pMsg->type) {
4796 case eWNI_SME_SYS_READY_IND:
4797 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4798 break;
4799
4800 case eWNI_SME_START_BSS_REQ:
4801 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4802 break;
4803
4804 case eWNI_SME_SCAN_REQ:
4805 __lim_process_sme_scan_req(pMac, pMsgBuf);
4806 break;
4807
4808#ifdef FEATURE_OEM_DATA_SUPPORT
4809 case eWNI_SME_OEM_DATA_REQ:
4810 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4811 break;
4812#endif
4813 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4814 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4815 break;
4816
4817 case eWNI_SME_UPDATE_NOA:
4818 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4819 break;
4820 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4821 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4822 break;
4823 case eWNI_SME_JOIN_REQ:
4824 __lim_process_sme_join_req(pMac, pMsgBuf);
4825 break;
4826
4827 case eWNI_SME_REASSOC_REQ:
4828 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4829 break;
4830
4831 case eWNI_SME_DISASSOC_REQ:
4832 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4833 break;
4834
4835 case eWNI_SME_DISASSOC_CNF:
4836 case eWNI_SME_DEAUTH_CNF:
4837 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4838 break;
4839
4840 case eWNI_SME_DEAUTH_REQ:
4841 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4842 break;
4843
4844 case eWNI_SME_SETCONTEXT_REQ:
4845 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4846 break;
4847
4848 case eWNI_SME_STOP_BSS_REQ:
4849 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4850 break;
4851
4852 case eWNI_SME_ASSOC_CNF:
4853 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4854 PELOG1(lim_log(pMac,
4855 LOG1, FL("Received ASSOC_CNF message"));)
4856 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4857 pMsgBuf);
4858 break;
4859
4860 case eWNI_SME_ADDTS_REQ:
4861 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4862 __lim_process_sme_addts_req(pMac, pMsgBuf);
4863 break;
4864
4865 case eWNI_SME_DELTS_REQ:
4866 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4867 __lim_process_sme_delts_req(pMac, pMsgBuf);
4868 break;
4869
4870 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4871 PELOG1(lim_log
4872 (pMac, LOG1,
4873 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4874 )
4875 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4876 break;
4877
4878 case eWNI_SME_GET_STATISTICS_REQ:
4879 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4880 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4881 bufConsumed = false;
4882 break;
4883#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4884 case eWNI_SME_GET_TSM_STATS_REQ:
4885 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4886 bufConsumed = false;
4887 break;
4888#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4889 case eWNI_SME_GET_ASSOC_STAS_REQ:
4890 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4891 break;
4892 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4893 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4894 break;
4895
4896 case eWNI_SME_HIDE_SSID_REQ:
4897 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4898 break;
4899 case eWNI_SME_UPDATE_APWPSIE_REQ:
4900 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4901 break;
4902 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4903 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4904 break;
4905
4906 case eWNI_SME_SET_APWPARSNIEs_REQ:
4907 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4908 break;
4909
4910 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4911 /* Update the beaconInterval */
4912 __lim_process_sme_change_bi(pMac, pMsgBuf);
4913 break;
4914
4915#ifdef QCA_HT_2040_COEX
4916 case eWNI_SME_SET_HT_2040_MODE:
4917 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4918 break;
4919#endif
4920
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4922 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4923 __lim_process_report_message(pMac, pMsg);
4924 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 case eWNI_SME_FT_PRE_AUTH_REQ:
4927 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4928 break;
4929 case eWNI_SME_FT_UPDATE_KEY:
4930 lim_process_ft_update_key(pMac, pMsgBuf);
4931 break;
4932
4933 case eWNI_SME_FT_AGGR_QOS_REQ:
4934 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4935 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936
4937 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4938 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4939 break;
4940#ifdef FEATURE_WLAN_TDLS
4941 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4942 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4943 break;
4944 case eWNI_SME_TDLS_ADD_STA_REQ:
4945 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4946 break;
4947 case eWNI_SME_TDLS_DEL_STA_REQ:
4948 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4949 break;
4950 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4951 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4952 break;
4953#endif
4954 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4955 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4956 break;
4957
4958 case eWNI_SME_CHANNEL_CHANGE_REQ:
4959 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4960 break;
4961
4962 case eWNI_SME_START_BEACON_REQ:
4963 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4964 break;
4965
4966 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4967 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4968 break;
4969
4970 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4971 lim_process_update_add_ies(pMac, pMsgBuf);
4972 break;
4973
4974 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4975 lim_process_modify_add_ies(pMac, pMsgBuf);
4976 break;
4977 case eWNI_SME_SET_HW_MODE_REQ:
4978 lim_process_set_hw_mode(pMac, pMsgBuf);
4979 break;
4980 case eWNI_SME_NSS_UPDATE_REQ:
4981 lim_process_nss_update_request(pMac, pMsgBuf);
4982 break;
4983 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4984 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4985 break;
4986 case eWNI_SME_SET_IE_REQ:
4987 lim_process_set_ie_req(pMac, pMsgBuf);
4988 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304989 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4990 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4991 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304992 case eWNI_SME_EXT_CHANGE_CHANNEL:
4993 lim_process_ext_change_channel(pMac, pMsgBuf);
4994 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004995 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4996 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4997 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304999 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000 pMsg->bodyptr = NULL;
5001 break;
5002 } /* switch (msgType) */
5003
5004 return bufConsumed;
5005} /*** end lim_process_sme_req_messages() ***/
5006
5007/**
5008 * lim_process_sme_start_beacon_req()
5009 *
5010 ***FUNCTION:
5011 * This function is called by limProcessMessageQueue(). This
5012 * function processes SME request messages from HDD or upper layer
5013 * application.
5014 *
5015 ***LOGIC:
5016 *
5017 ***ASSUMPTIONS:
5018 *
5019 ***NOTE:
5020 *
5021 * @param pMac Pointer to Global MAC structure
5022 * @param msgType Indicates the SME message type
5023 * @param *pMsgBuf A pointer to the SME message buffer
5024 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5025 * false - if pMsgBuf is not to be freed.
5026 */
5027static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5028{
5029 tpSirStartBeaconIndication pBeaconStartInd;
5030 tpPESession psessionEntry;
5031 uint8_t sessionId; /* PE sessionID */
5032
5033 if (pMsg == NULL) {
5034 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5035 return;
5036 }
5037
5038 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5039 psessionEntry = pe_find_session_by_bssid(pMac,
5040 pBeaconStartInd->bssid,
5041 &sessionId);
5042 if (psessionEntry == NULL) {
5043 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5044 lim_log(pMac, LOGE,
5045 FL("Session does not exist for given bssId"));
5046 return;
5047 }
5048
5049 if (pBeaconStartInd->beaconStartStatus == true) {
5050 /*
5051 * Currently this Indication comes from SAP
5052 * to start Beacon Tx on a DFS channel
5053 * since beaconing has to be done on DFS
5054 * channel only after CAC WAIT is completed.
5055 * On a DFS Channel LIM does not start beacon
5056 * Tx right after the WMA_ADD_BSS_RSP.
5057 */
5058 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305059 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 FL("Start Beacon with ssid %s Ch %d"),
5061 psessionEntry->ssId.ssId,
5062 psessionEntry->currentOperChannel);
5063 lim_send_beacon_ind(pMac, psessionEntry);
5064 } else {
5065 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5066 return;
5067 }
5068}
5069
5070/**
5071 * lim_process_sme_channel_change_request() - process sme ch change req
5072 *
5073 * @mac_ctx: Pointer to Global MAC structure
5074 * @msg_buf: pointer to the SME message buffer
5075 *
5076 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5077 *
5078 * Return: None
5079 */
5080static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5081 uint32_t *msg_buf)
5082{
5083 tpSirChanChangeRequest ch_change_req;
5084 tpPESession session_entry;
5085 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005086 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 uint32_t val = 0;
5088
5089 if (msg_buf == NULL) {
5090 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5091 return;
5092 }
5093 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5094
5095 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5096 ch_change_req->targetChannel);
5097
5098 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5099 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5100 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5101 return;
5102 }
5103
5104 session_entry = pe_find_session_by_bssid(mac_ctx,
5105 ch_change_req->bssid, &session_id);
5106 if (session_entry == NULL) {
5107 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5108 lim_log(mac_ctx, LOGE, FL(
5109 "Session does not exist for given bssId"));
5110 return;
5111 }
5112
5113 if (session_entry->currentOperChannel ==
5114 ch_change_req->targetChannel) {
5115 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5116 return;
5117 }
5118
5119 if (LIM_IS_AP_ROLE(session_entry))
5120 session_entry->channelChangeReasonCode =
5121 LIM_SWITCH_CHANNEL_SAP_DFS;
5122 else
5123 session_entry->channelChangeReasonCode =
5124 LIM_SWITCH_CHANNEL_OPERATION;
5125
5126 lim_log(mac_ctx, LOGW, FL(
5127 "switch old chnl %d to new chnl %d, ch_bw %d"),
5128 session_entry->currentOperChannel,
5129 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005130 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131
5132 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005133 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 session_entry->ch_center_freq_seg0 =
5135 ch_change_req->center_freq_seg_0;
5136 session_entry->ch_center_freq_seg1 =
5137 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005138 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005140 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141 session_entry->htRecommendedTxWidthSet =
5142 session_entry->htSupportedChannelWidthSet;
5143 session_entry->currentOperChannel =
5144 ch_change_req->targetChannel;
5145 session_entry->limRFBand =
5146 lim_get_rf_band(session_entry->currentOperChannel);
5147 /* Initialize 11h Enable Flag */
5148 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5149 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5150 eSIR_SUCCESS)
5151 lim_log(mac_ctx, LOGP,
5152 FL("Fail to get WNI_CFG_11H_ENABLED"));
5153 }
5154
5155 session_entry->lim11hEnable = val;
5156 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305157 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 &ch_change_req->operational_rateset,
5159 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305160 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161 &ch_change_req->extended_rateset,
5162 sizeof(session_entry->extRateSet));
5163 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5164 session_entry->ch_center_freq_seg0,
5165 session_entry->ch_center_freq_seg1,
5166 session_entry->ch_width,
5167 max_tx_pwr, session_entry->peSessionId);
5168}
5169
5170/******************************************************************************
5171* lim_start_bss_update_add_ie_buffer()
5172*
5173***FUNCTION:
5174* This function checks the src buffer and its length and then malloc for
5175* dst buffer update the same
5176*
5177***LOGIC:
5178*
5179***ASSUMPTIONS:
5180*
5181***NOTE:
5182*
5183* @param pMac Pointer to Global MAC structure
5184* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5185* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5186* @param *pSrcData_buff A pointer of uint8_t src buffer
5187* @param srcDataLen src buffer length
5188******************************************************************************/
5189
5190static void
5191lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5192 uint8_t **pDstData_buff,
5193 uint16_t *pDstDataLen,
5194 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5195{
5196
5197 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5198 *pDstDataLen = srcDataLen;
5199
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305200 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201
5202 if (NULL == *pDstData_buff) {
5203 lim_log(pMac, LOGE,
5204 FL("AllocateMemory failed for pDstData_buff"));
5205 return;
5206 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305207 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 } else {
5209 *pDstData_buff = NULL;
5210 *pDstDataLen = 0;
5211 }
5212}
5213
5214/******************************************************************************
5215* lim_update_add_ie_buffer()
5216*
5217***FUNCTION:
5218* This function checks the src buffer and length if src buffer length more
5219* than dst buffer length then free the dst buffer and malloc for the new src
5220* length, and update the dst buffer and length. But if dst buffer is bigger
5221* than src buffer length then it just update the dst buffer and length
5222*
5223***LOGIC:
5224*
5225***ASSUMPTIONS:
5226*
5227***NOTE:
5228*
5229* @param pMac Pointer to Global MAC structure
5230* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5231* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5232* @param *pSrcData_buff A pointer of uint8_t src buffer
5233* @param srcDataLen src buffer length
5234******************************************************************************/
5235
5236static void
5237lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5238 uint8_t **pDstData_buff,
5239 uint16_t *pDstDataLen,
5240 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5241{
5242
5243 if (NULL == pSrcData_buff) {
5244 lim_log(pMac, LOGE, FL("src buffer is null."));
5245 return;
5246 }
5247
5248 if (srcDataLen > *pDstDataLen) {
5249 *pDstDataLen = srcDataLen;
5250 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305251 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305253 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005254
5255 if (NULL == *pDstData_buff) {
5256 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5257 *pDstDataLen = 0;
5258 return;
5259 }
5260 }
5261
5262 /* copy the content of buffer into dst buffer
5263 */
5264 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305265 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266
5267}
5268
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005269/**
5270 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5271 * @pMac : Pointer to Global MAC structure
5272 * @pDstData_buff : A pointer to pointer of dst buffer
5273 * @pDstDataLen : A pointer to pointer of dst buffer length
5274 * @pModifyIE : A pointer to tSirModifyIE
5275 *
5276 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5277 *
5278 * Return:
5279 * True or false depending upon whether IE is updated or not
5280 */
5281static bool
5282lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5283 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5284{
5285 int32_t oui_length;
5286 uint8_t *ibss_ie = NULL;
5287
5288 ibss_ie = pModifyIE->pIEBuffer;
5289 oui_length = pModifyIE->oui_length;
5290
5291 if ((0 == oui_length) || (NULL == ibss_ie)) {
5292 PELOGE(lim_log(pMac, LOGE,
5293 FL("Invalid set IBSS vendor IE command length %d "),
5294 oui_length);)
5295 return false;
5296 }
5297
5298 lim_update_add_ie_buffer(pMac,
5299 pDstData_buff,
5300 pDstDataLen,
5301 pModifyIE->pIEBuffer,
5302 pModifyIE->ieBufferlength);
5303
5304 return true;
5305}
5306
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307/*
5308* lim_process_modify_add_ies() - process modify additional IE req.
5309*
5310* @mac_ctx: Pointer to Global MAC structure
5311* @msg_buf: pointer to the SME message buffer
5312*
5313* This function update the PE buffers for additional IEs.
5314*
5315* Return: None
5316*/
5317static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5318 uint32_t *msg_buf)
5319{
5320 tpSirModifyIEsInd modify_add_ies;
5321 tpPESession session_entry;
5322 uint8_t session_id;
5323 bool ret = false;
5324 tSirAddIeParams *add_ie_params;
5325
5326 if (msg_buf == NULL) {
5327 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5328 return;
5329 }
5330
5331 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5332 /* Incoming message has smeSession, use BSSID to find PE session */
5333 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005334 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335
5336 if (NULL == session_entry) {
5337 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5338 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005339 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 goto end;
5341 }
5342 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5343 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5344 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5345 lim_log(mac_ctx, LOGE,
5346 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5347 modify_add_ies->modifyIE.pIEBuffer,
5348 modify_add_ies->modifyIE.ieBufferlength,
5349 modify_add_ies->modifyIE.ieID,
5350 modify_add_ies->modifyIE.ieIDLen,
5351 modify_add_ies->updateType);
5352 goto end;
5353 }
5354 add_ie_params = &session_entry->addIeParams;
5355 switch (modify_add_ies->updateType) {
5356 case eUPDATE_IE_PROBE_RESP:
5357 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005358 if (LIM_IS_IBSS_ROLE(session_entry)) {
5359 lim_update_ibss_prop_add_ies(mac_ctx,
5360 &add_ie_params->probeRespData_buff,
5361 &add_ie_params->probeRespDataLen,
5362 &modify_add_ies->modifyIE);
5363 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364 break;
5365 case eUPDATE_IE_ASSOC_RESP:
5366 /* assoc resp IE */
5367 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305368 QDF_TRACE(QDF_MODULE_ID_PE,
5369 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 "assoc resp add ie not present %d"),
5371 add_ie_params->assocRespDataLen);
5372 }
5373 /* search through the buffer and modify the IE */
5374 break;
5375 case eUPDATE_IE_PROBE_BCN:
5376 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005377 if (LIM_IS_IBSS_ROLE(session_entry)) {
5378 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5379 &add_ie_params->probeRespBCNData_buff,
5380 &add_ie_params->probeRespBCNDataLen,
5381 &modify_add_ies->modifyIE);
5382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 if (ret == true && modify_add_ies->modifyIE.notify) {
5384 lim_handle_param_update(mac_ctx,
5385 modify_add_ies->updateType);
5386 }
5387 break;
5388 default:
5389 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5390 modify_add_ies->updateType);
5391 break;
5392 }
5393end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305394 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 modify_add_ies->modifyIE.pIEBuffer = NULL;
5396}
5397
5398/*
5399* lim_process_update_add_ies() - process additional IE update req
5400*
5401* @mac_ctx: Pointer to Global MAC structure
5402* @msg_buf: pointer to the SME message buffer
5403*
5404* This function update the PE buffers for additional IEs.
5405*
5406* Return: None
5407*/
5408static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5409 uint32_t *msg_buf)
5410{
5411 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5412 uint8_t session_id;
5413 tpPESession session_entry;
5414 tSirAddIeParams *addn_ie;
5415 uint16_t new_length = 0;
5416 uint8_t *new_ptr = NULL;
5417 tSirUpdateIE *update_ie;
5418
5419 if (msg_buf == NULL) {
5420 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5421 return;
5422 }
5423 update_ie = &update_add_ies->updateIE;
5424 /* incoming message has smeSession, use BSSID to find PE session */
5425 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005426 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427
5428 if (NULL == session_entry) {
5429 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5430 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005431 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 goto end;
5433 }
5434 addn_ie = &session_entry->addIeParams;
5435 /* if len is 0, upper layer requested freeing of buffer */
5436 if (0 == update_ie->ieBufferlength) {
5437 switch (update_add_ies->updateType) {
5438 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305439 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 addn_ie->probeRespData_buff = NULL;
5441 addn_ie->probeRespDataLen = 0;
5442 break;
5443 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305444 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 addn_ie->assocRespData_buff = NULL;
5446 addn_ie->assocRespDataLen = 0;
5447 break;
5448 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305449 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 addn_ie->probeRespBCNData_buff = NULL;
5451 addn_ie->probeRespBCNDataLen = 0;
5452
5453 if (update_ie->notify)
5454 lim_handle_param_update(mac_ctx,
5455 update_add_ies->updateType);
5456 break;
5457 default:
5458 break;
5459 }
5460 return;
5461 }
5462 switch (update_add_ies->updateType) {
5463 case eUPDATE_IE_PROBE_RESP:
5464 if (update_ie->append) {
5465 /*
5466 * In case of append, allocate new memory
5467 * with combined length
5468 */
5469 new_length = update_ie->ieBufferlength +
5470 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305471 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 if (NULL == new_ptr) {
5473 lim_log(mac_ctx, LOGE, FL(
5474 "Memory allocation failed."));
5475 goto end;
5476 }
5477 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305478 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305480 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 update_ie->pAdditionIEBuffer,
5482 update_ie->ieBufferlength);
5483 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305484 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 /* adjust length accordingly */
5486 addn_ie->probeRespDataLen = new_length;
5487 /* save refernece of local buffer in PE session */
5488 addn_ie->probeRespData_buff = new_ptr;
5489 goto end;
5490 }
5491 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5492 &addn_ie->probeRespDataLen,
5493 update_ie->pAdditionIEBuffer,
5494 update_ie->ieBufferlength);
5495 break;
5496 case eUPDATE_IE_ASSOC_RESP:
5497 /* assoc resp IE */
5498 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5499 &addn_ie->assocRespDataLen,
5500 update_ie->pAdditionIEBuffer,
5501 update_ie->ieBufferlength);
5502 break;
5503 case eUPDATE_IE_PROBE_BCN:
5504 /* probe resp Bcn IE */
5505 lim_update_add_ie_buffer(mac_ctx,
5506 &addn_ie->probeRespBCNData_buff,
5507 &addn_ie->probeRespBCNDataLen,
5508 update_ie->pAdditionIEBuffer,
5509 update_ie->ieBufferlength);
5510 if (update_ie->notify)
5511 lim_handle_param_update(mac_ctx,
5512 update_add_ies->updateType);
5513 break;
5514 default:
5515 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5516 update_add_ies->updateType);
5517 break;
5518 }
5519end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305520 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 update_ie->pAdditionIEBuffer = NULL;
5522}
5523
5524/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305525 * send_extended_chan_switch_action_frame()- function to send ECSA
5526 * action frame for each sta connected to SAP/GO and AP in case of
5527 * STA .
5528 * @mac_ctx: pointer to global mac structure
5529 * @new_channel: new channel to switch to.
5530 * @ch_bandwidth: BW of channel to calculate op_class
5531 * @session_entry: pe session
5532 *
5533 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5534 *
5535 * Return: void
5536 */
5537
5538static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5539 uint16_t new_channel, uint8_t ch_bandwidth,
5540 tpPESession session_entry)
5541{
5542 uint16_t op_class;
5543 uint8_t switch_mode = 0, i;
5544 tpDphHashNode psta;
5545
5546
5547 op_class = cds_regdm_get_opclass_from_channel(
5548 mac_ctx->scan.countryCodeCurrent,
5549 new_channel,
5550 ch_bandwidth);
5551
5552 if (LIM_IS_AP_ROLE(session_entry) &&
5553 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5554 switch_mode = 1;
5555
5556 if (LIM_IS_AP_ROLE(session_entry)) {
5557 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5558 psta =
5559 session_entry->dph.dphHashTable.pDphNodeArray + i;
5560 if (psta && psta->added)
5561 lim_send_extended_chan_switch_action_frame(
5562 mac_ctx,
5563 psta->staAddr,
5564 switch_mode, op_class, new_channel,
5565 LIM_MAX_CSA_IE_UPDATES, session_entry);
5566 }
5567 } else if (LIM_IS_STA_ROLE(session_entry)) {
5568 lim_send_extended_chan_switch_action_frame(mac_ctx,
5569 session_entry->bssId,
5570 switch_mode, op_class, new_channel,
5571 LIM_MAX_CSA_IE_UPDATES, session_entry);
5572 }
5573
5574}
5575
5576/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5578 *
5579 * @mac_ctx: Pointer to Global MAC structure
5580 * @msg_buf: pointer to the SME message buffer
5581 *
5582 * This function processes SME request messages from HDD or upper layer
5583 * application.
5584 *
5585 * Return: None
5586 */
5587static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5588 uint32_t *msg_buf)
5589{
5590 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5591 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 uint8_t session_id;
5593 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305594 offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595
5596 if (msg_buf == NULL) {
5597 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5598 return;
5599 }
5600
5601 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5602 session_entry = pe_find_session_by_bssid(mac_ctx,
5603 dfs_csa_ie_req->bssid, &session_id);
5604 if (session_entry == NULL) {
5605 lim_log(mac_ctx, LOGE, FL(
5606 "Session not found for given BSSID" MAC_ADDRESS_STR),
5607 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5608 return;
5609 }
5610
5611 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5612 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5613 GET_LIM_SYSTEM_ROLE(session_entry));
5614 return;
5615 }
5616
5617 /* target channel */
5618 session_entry->gLimChannelSwitch.primaryChannel =
5619 dfs_csa_ie_req->targetChannel;
5620
5621 /* Channel switch announcement needs to be included in beacon */
5622 session_entry->dfsIncludeChanSwIe = true;
5623 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5624 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005625 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305626 session_entry->gLimChannelSwitch.sec_ch_offset =
5627 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5629 session_entry->gLimChannelSwitch.switchMode = 1;
5630
5631 /*
5632 * Validate if SAP is operating HT or VHT mode and set the Channel
5633 * Switch Wrapper element with the Wide Band Switch subelement.
5634 */
5635 if (true != session_entry->vhtCapability)
5636 goto skip_vht;
5637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 /* Now encode the Wider Ch BW element depending on the ch width */
5639 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005640 switch (dfs_csa_ie_req->ch_params.ch_width) {
5641 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 /*
5643 * Wide channel BW sublement in channel wrapper element is not
5644 * required in case of 20 Mhz operation. Currently It is set
5645 * only set in case of 40/80 Mhz Operation.
5646 */
5647 session_entry->dfsIncludeChanWrapperIe = false;
5648 wider_bw_ch_switch->newChanWidth =
5649 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5650 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005651 case CH_WIDTH_40MHZ:
5652 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 wider_bw_ch_switch->newChanWidth =
5654 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5655 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005656 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 session_entry->dfsIncludeChanWrapperIe = true;
5658 wider_bw_ch_switch->newChanWidth =
5659 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5660 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005661 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005662 session_entry->dfsIncludeChanWrapperIe = true;
5663 wider_bw_ch_switch->newChanWidth =
5664 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5665 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005666 case CH_WIDTH_80P80MHZ:
5667 session_entry->dfsIncludeChanWrapperIe = true;
5668 wider_bw_ch_switch->newChanWidth =
5669 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005670 /*
5671 * This is not applicable for 20/40/80 Mhz.
5672 * Only used when we support 80+80 Mhz operation.
5673 * In case of 80+80 Mhz, this parameter indicates
5674 * center channel frequency index of 80 Mhz channel of
5675 * frequency segment 1.
5676 */
5677 wider_bw_ch_switch->newCenterChanFreq1 =
5678 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005679 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 default:
5681 session_entry->dfsIncludeChanWrapperIe = false;
5682 /*
5683 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5684 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5685 */
5686 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5687 break;
5688 }
5689 /* Fetch the center channel based on the channel width */
5690 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005691 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692skip_vht:
5693 /* Send CSA IE request from here */
5694 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5695 eSIR_SUCCESS) {
5696 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5697 return;
5698 }
5699
5700 /*
5701 * First beacon update request is sent here, the remaining updates are
5702 * done when the FW responds back after sending the first beacon after
5703 * the template update
5704 */
5705 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305706
5707 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5708 ch_offset = BW80;
5709 else
5710 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5711
5712 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5713 session_entry->gLimChannelSwitch.switchCount,
5714 session_entry->gLimChannelSwitch.primaryChannel,
5715 session_entry->gLimChannelSwitch.ch_width,
5716 session_entry->dfsIncludeChanWrapperIe,
5717 ch_offset);
5718
Abhishek Singh518323d2015-10-19 17:42:01 +05305719 /* Send ECSA Action frame after updating the beacon */
5720 send_extended_chan_switch_action_frame(mac_ctx,
5721 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305722 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723 session_entry->gLimChannelSwitch.switchCount--;
5724}
5725
5726/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305727 * lim_process_ext_change_channel()- function to send ECSA
5728 * action frame for STA/CLI .
5729 * @mac_ctx: pointer to global mac structure
5730 * @msg: params from sme for new channel.
5731 *
5732 * This function is called to send ECSA frame for STA/CLI.
5733 *
5734 * Return: void
5735 */
5736
5737static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5738 uint32_t *msg)
5739{
5740 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5741 (struct sir_sme_ext_cng_chan_req *) msg;
5742 tpPESession session_entry = NULL;
5743
5744 if (NULL == msg) {
5745 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5746 return;
5747 }
5748 session_entry =
5749 pe_find_session_by_sme_session_id(mac_ctx,
5750 ext_chng_channel->session_id);
5751 if (NULL == session_entry) {
5752 lim_log(mac_ctx, LOGE,
5753 FL("Session not found for given session %d"),
5754 ext_chng_channel->session_id);
5755 return;
5756 }
5757 if (LIM_IS_AP_ROLE(session_entry)) {
5758 lim_log(mac_ctx, LOGE,
5759 FL("not an STA/CLI session"));
5760 return;
5761 }
5762 send_extended_chan_switch_action_frame(mac_ctx,
5763 ext_chng_channel->new_channel,
5764 0, session_entry);
5765}
5766
5767/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 * lim_process_nss_update_request() - process sme nss update req
5769 *
5770 * @mac_ctx: Pointer to Global MAC structure
5771 * @msg_buf: pointer to the SME message buffer
5772 *
5773 * This function processes SME request messages from HDD or upper layer
5774 * application.
5775 *
5776 * Return: None
5777 */
5778static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5779 uint32_t *msg_buf)
5780{
5781 struct sir_nss_update_request *nss_update_req_ptr;
5782 tpPESession session_entry = NULL;
5783
5784 if (msg_buf == NULL) {
5785 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5786 return;
5787 }
5788
5789 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305790 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 nss_update_req_ptr->vdev_id);
5792 if (session_entry == NULL) {
5793 lim_log(mac_ctx, LOGE, FL(
5794 "Session not found for given session_id %d"),
5795 nss_update_req_ptr->vdev_id);
5796 return;
5797 }
5798
5799 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5800 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5801 GET_LIM_SYSTEM_ROLE(session_entry));
5802 return;
5803 }
5804
5805 /* populate nss field in the beacon */
5806 session_entry->gLimOperatingMode.present = 1;
5807 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5808 /* Send nss update request from here */
5809 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5810 eSIR_SUCCESS) {
5811 lim_log(mac_ctx, LOGE,
5812 FL("Unable to set op mode IE in beacon"));
5813 return;
5814 }
5815
5816 lim_send_beacon_ind(mac_ctx, session_entry);
5817}
5818
5819/**
5820 * lim_process_set_ie_req() - process sme set IE request
5821 *
5822 * @mac_ctx: Pointer to Global MAC structure
5823 * @msg_buf: pointer to the SME message buffer
5824 *
5825 * This function processes SME request messages from HDD or upper layer
5826 * application.
5827 *
5828 * Return: None
5829 */
5830static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5831{
5832 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305833 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834
5835 if (msg_buf == NULL) {
5836 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5837 return;
5838 }
5839
5840 msg = (struct send_extcap_ie *)msg_buf;
5841 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305842 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005843 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5844
5845}