blob: 026a50a89c0e9cdaddd620c3ad76134811c18fe5 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_process_sme_req_messages.cc contains the code
30 * for processing SME request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38
39#include "cds_api.h"
40#include "wni_api.h"
41#include "wni_cfg.h"
42#include "cfg_api.h"
43#include "sir_api.h"
44#include "sch_api.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_security_utils.h"
50#include "lim_ser_des_utils.h"
51#include "lim_sme_req_utils.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "lim_admit_control.h"
54#include "dph_hash_table.h"
55#include "lim_send_messages.h"
56#include "lim_api.h"
57#include "wmm_apsd.h"
58#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080059#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61#include "sap_api.h"
62
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070065#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/*
68 * This overhead is time for sending NOA start to host in case of GO/sending
69 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
70 * with init scan req/rsp plus in case of concurrency, taking care of sending
71 * null data and receiving ACK to/from AP/Also SetChannel with calibration
72 * is taking around 7ms .
73 */
74#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
75#define JOIN_NOA_DURATION 2000 /* in msecs */
76#define OEM_DATA_NOA_DURATION 60 /* in msecs */
77#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
78
79#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
80
81/* SME REQ processing function templates */
82static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
83static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
84static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
85static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
91static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
92static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
93 uint32_t *pMsg);
94static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98
99static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
100 uint8_t **pDstData_buff,
101 uint16_t *pDstDataLen,
102 uint8_t *pSrcData_buff,
103 uint16_t srcDataLen);
104
105static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
106 uint8_t **pDstData_buff,
107 uint16_t *pDstDataLen,
108 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800109static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
114
115static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
116
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800117extern void pe_register_wma_handle(tpAniSirGlobal pMac,
118 tSirSmeReadyReq *ready_req);
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 ==
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700370 eSIR_INFRASTRUCTURE_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 (mac_ctx->lim.gpSession[i].limSmeState ==
372 eLIM_SME_LINK_EST_STATE)) ||
373 (((mac_ctx->lim.gpSession[i].bssType ==
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700374 eSIR_IBSS_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 (mac_ctx->lim.gpSession[i].limSmeState ==
376 eLIM_SME_NORMAL_STATE)) ||
377 ((((mac_ctx->lim.gpSession[i].bssType ==
378 eSIR_INFRA_AP_MODE) &&
379 (mac_ctx->lim.gpSession[i].pePersona ==
Anurag Chouhan6d760662016-02-20 16:05:43 +0530380 QDF_P2P_GO_MODE)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 (mac_ctx->lim.gpSession[i].limSystemRole ==
382 eLIM_AP_ROLE)) &&
383 (mac_ctx->lim.gpSession[i].limSmeState ==
384 eLIM_SME_NORMAL_STATE)))) {
385 valid_state = false;
386 break;
387 }
388 }
389 }
390
391 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
392
393 if ((valid_state) &&
394 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
395 return true;
396 else
397 return false;
398}
399
400/**
401 * __lim_is_sme_assoc_cnf_valid()
402 *
403 ***FUNCTION:
404 * This function is called by __lim_process_sme_assoc_cnf_new() upon
405 * receiving SME_ASSOC_CNF.
406 *
407 ***LOGIC:
408 * Message validity checks are performed in this function
409 *
410 ***ASSUMPTIONS:
411 *
412 ***NOTE:
413 *
414 * @param pMeasReq Pointer to Received ASSOC_CNF message
415 * @return true When received SME_ASSOC_CNF is formatted
416 * correctly
417 * false otherwise
418 */
419
420static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
421{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530422 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 return false;
424 else
425 return true;
426} /*** end __lim_is_sme_assoc_cnf_valid() ***/
427
428/**
429 * __lim_get_sme_join_req_size_for_alloc()
430 *
431 ***FUNCTION:
432 * This function is called in various places to get IE length
433 * from tSirBssDescription structure
434 * number being scanned.
435 *
436 ***PARAMS:
437 *
438 ***LOGIC:
439 *
440 ***ASSUMPTIONS:
441 * NA
442 *
443 ***NOTE:
444 * NA
445 *
446 * @param pBssDescr
447 * @return Total IE length
448 */
449
450static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
451{
452 uint16_t len = 0;
453
454 if (!pBuf)
455 return len;
456
457 pBuf += sizeof(uint16_t);
458 len = lim_get_u16(pBuf);
459 return len + sizeof(uint16_t);
460}
461
462/**
463 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
464 * @pMac: Global MAC context
465 * @pMsg: Pointer to message posted from SME to LIM.
466 *
467 * Has role only if 11h is enabled. Not used on STA side.
468 * Defers the message if SME is in learn state and brings
469 * the LIM back to normal mode.
470 *
471 * Return: true - If defered false - Otherwise
472 */
473
474static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
475{
476 if (lim_is_system_in_scan_state(pMac)) {
477 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
478 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
479 pMsg->type);
480 return false;
481 }
482 lim_log(pMac, LOG1,
483 FL("Defer the message, in learn mode type = %d"),
484 pMsg->type);
485 return true;
486 }
487 return false;
488}
489
490/**
491 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
492 * @mac_ctx: Pointer to Global MAC structure
493 * @message: Pointer to message posted from SME to LIM.
494 *
495 * Has role only if 11h is enabled. Not used on STA side.
496 * Defers the message if radar is detected.
497 *
498 * Return: true, if defered otherwise return false.
499 */
500static bool
501__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
502{
503 /*
504 * fRadarDetCurOperChan will be set only if we
505 * detect radar in current operating channel and
506 * System Role == AP ROLE
507 *
508 * TODO: Need to take care radar detection.
509 *
510 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
511 */
512 if (0) {
513 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
514 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
515 message->type);
516 return false;
517 }
518 lim_log(mac_ctx, LOG1,
519 FL("Defer the message, in learn mode type = %d"),
520 message->type);
521 return true;
522 }
523 return false;
524}
525
526/**
527 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
528 * @pMac: Global MAC context
529 * @pMsgBuf: Message from WMA
530 *
531 * handles the notification from HDD. PE just forwards this message to HAL.
532 *
533 * Return: true-Posting to HAL failed, so PE will consume the buffer.
534 * false-Posting to HAL successful, so HAL will consume the buffer.
535 */
536
537static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
538{
539 tSirMsgQ msg;
540 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
541
542 msg.type = WMA_SYS_READY_IND;
543 msg.reserved = 0;
544 msg.bodyptr = pMsgBuf;
545 msg.bodyval = 0;
546
547 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800548 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
549 pe_register_wma_handle(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
551 }
552 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
553 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
554
555 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
556 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
557 return true;
558 }
559 return false;
560}
561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562/**
563 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
564 *@mac_ctx: Pointer to Global MAC structure
565 *@session: A pointer to session entry
566 *@sme_start_bss_req: Start BSS Request from upper layers.
567 *
568 * This function is used to configure the start bss parameters
569 * in to the session.
570 *
571 * Return: None.
572 */
573static void
574lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
575 tpSirSmeStartBssReq sme_start_bss_req)
576{
577 session->limSystemRole = eLIM_AP_ROLE;
578 session->privacy = sme_start_bss_req->privacy;
579 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
580 session->authType = sme_start_bss_req->authType;
581 /* Store the DTIM period */
582 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
583 /* Enable/disable UAPSD */
584 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530585 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 session->proxyProbeRspEn = 0;
587 } else {
588 /*
589 * To detect PBC overlap in SAP WPS mode,
590 * Host handles Probe Requests.
591 */
592 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
593 session->proxyProbeRspEn = 1;
594 else
595 session->proxyProbeRspEn = 0;
596 }
597 session->ssidHidden = sme_start_bss_req->ssidHidden;
598 session->wps_state = sme_start_bss_req->wps_state;
599 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
600 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
601 &session->shortSlotTimeSupported);
602 session->isCoalesingInIBSSAllowed =
603 sme_start_bss_req->isCoalesingInIBSSAllowed;
604
605}
606
607/**
608 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
609 *@mac_ctx: Pointer to Global MAC structure
610 *@msg_buf: A pointer to the SME message buffer
611 *
612 * This function is called to process SME_START_BSS_REQ message
613 * from HDD or upper layer application.
614 *
615 * Return: None
616 */
617static void
618__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
619{
620 uint16_t size;
621 uint32_t val = 0;
622 tSirRetStatus ret_status;
623 tSirMacChanNum channel_number;
624 tLimMlmStartReq *mlm_start_req = NULL;
625 tpSirSmeStartBssReq sme_start_bss_req = NULL;
626 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
627 /* Flag Used in case of IBSS to Auto generate BSSID. */
628 uint32_t auto_gen_bssid = false;
629 uint8_t session_id;
630 tpPESession session = NULL;
631 uint8_t sme_session_id = 0;
632 uint16_t sme_transaction_id = 0;
633 uint32_t chanwidth;
634 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
635
636/* FEATURE_WLAN_DIAG_SUPPORT */
637#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
638 /*
639 * Since the session is not created yet, sending NULL.
640 * The response should have the correct state.
641 */
642 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
643 NULL, 0, 0);
644#endif /* FEATURE_WLAN_DIAG_SUPPORT */
645
646 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
647
648 /*
649 * Global Sme state and mlm states are not defined yet,
650 * for BT-AMP Suppoprt . TO BE DONE
651 */
652 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
653 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
654 size = sizeof(tSirSmeStartBssReq);
655
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530656 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 if (NULL == sme_start_bss_req) {
658 lim_log(mac_ctx, LOGE,
659 FL("Allocate Memory fail for LimStartBssReq"));
660 /* Send failure response to host */
661 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
662 goto end;
663 }
664
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530665 qdf_mem_set((void *)sme_start_bss_req, size, 0);
666 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 sizeof(tSirSmeStartBssReq));
668 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
669 sme_start_bss_req)) {
670 lim_log(mac_ctx, LOGW,
671 FL("Received invalid eWNI_SME_START_BSS_REQ"));
672 ret_code = eSIR_SME_INVALID_PARAMETERS;
673 goto free;
674 }
675
676 /*
677 * This is the place where PE is going to create a session.
678 * If session is not existed, then create a new session
679 */
680 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800681 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 if (session != NULL) {
683 lim_log(mac_ctx, LOGW,
684 FL("Session Already exists for given BSSID"));
685 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
686 session = NULL;
687 goto free;
688 } else {
689 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800690 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 &session_id, mac_ctx->lim.maxStation,
692 sme_start_bss_req->bssType);
693 if (session == NULL) {
694 lim_log(mac_ctx, LOGW,
695 FL("Session Can not be created "));
696 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
697 goto free;
698 }
699 }
700
701 /* Probe resp add ie */
702 lim_start_bss_update_add_ie_buffer(mac_ctx,
703 &session->addIeParams.probeRespData_buff,
704 &session->addIeParams.probeRespDataLen,
705 sme_start_bss_req->addIeParams.probeRespData_buff,
706 sme_start_bss_req->addIeParams.probeRespDataLen);
707
708 /* Probe Beacon add ie */
709 lim_start_bss_update_add_ie_buffer(mac_ctx,
710 &session->addIeParams.probeRespBCNData_buff,
711 &session->addIeParams.probeRespBCNDataLen,
712 sme_start_bss_req->addIeParams.probeRespBCNData_buff,
713 sme_start_bss_req->addIeParams.probeRespBCNDataLen);
714
715 /* Assoc resp IE */
716 lim_start_bss_update_add_ie_buffer(mac_ctx,
717 &session->addIeParams.assocRespData_buff,
718 &session->addIeParams.assocRespDataLen,
719 sme_start_bss_req->addIeParams.assocRespData_buff,
720 sme_start_bss_req->addIeParams.assocRespDataLen);
721
722 /* Store the session related params in newly created session */
723 session->pLimStartBssReq = sme_start_bss_req;
724
725 /* Store PE session_id in session Table */
726 session->peSessionId = session_id;
727
728 /* Store SME session Id in sessionTable */
729 session->smeSessionId = sme_start_bss_req->sessionId;
730
731 session->transactionId = sme_start_bss_req->transactionId;
732
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530733 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 &(sme_start_bss_req->htConfig),
735 sizeof(session->htConfig));
736
737 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800738 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739
740 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530741 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 (uint8_t *) &sme_start_bss_req->ssId,
743 (sme_start_bss_req->ssId.length + 1));
744
745 session->bssType = sme_start_bss_req->bssType;
746
747 session->nwType = sme_start_bss_req->nwType;
748
749 session->beaconParams.beaconInterval =
750 sme_start_bss_req->beaconInterval;
751
752 /* Store the channel number in session Table */
753 session->currentOperChannel =
754 sme_start_bss_req->channelId;
755
756 /* Store Persona */
757 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530758 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 FL("PE PERSONA=%d"), session->pePersona);
760
761 /* Update the phymode */
762 session->gLimPhyMode = sme_start_bss_req->nwType;
763
764 session->maxTxPower =
765 cfg_get_regulatory_max_transmit_power(mac_ctx,
766 session->currentOperChannel);
767 /* Store the dot 11 mode in to the session Table */
768 session->dot11mode = sme_start_bss_req->dot11mode;
769#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
770 session->cc_switch_mode =
771 sme_start_bss_req->cc_switch_mode;
772#endif
773 session->htCapability =
774 IS_DOT11_MODE_HT(session->dot11mode);
775 session->vhtCapability =
776 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530777 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778 FL("*****session->vhtCapability = %d"),
779 session->vhtCapability);
780 session->txLdpcIniFeatureEnabled =
781 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 if (mac_ctx->roam.configParam.enable2x2)
783 session->nss = 2;
784 else
785 session->nss = 1;
786#ifdef WLAN_FEATURE_11W
787 session->limRmfEnabled =
788 sme_start_bss_req->pmfCapable ? 1 : 0;
789 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
790 session->limRmfEnabled);
791#endif
792
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530793 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 (void *)&sme_start_bss_req->operationalRateSet,
795 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 (void *)&sme_start_bss_req->extendedRateSet,
798 sizeof(tSirMacRateSet));
799
800 switch (sme_start_bss_req->bssType) {
801 case eSIR_INFRA_AP_MODE:
802 lim_configure_ap_start_bss_session(mac_ctx, session,
803 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530804 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800805 session->txBFIniFeatureEnabled =
806 sme_start_bss_req->txbf_ini_enabled;
807 session->txbf_csn_value =
808 sme_start_bss_req->txbf_csn_val;
809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 break;
811 case eSIR_IBSS_MODE:
812 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
813 lim_get_short_slot_from_phy_mode(mac_ctx, session,
814 session->gLimPhyMode,
815 &session->shortSlotTimeSupported);
816
817 /*
818 * initialize to "OPEN".
819 * will be updated upon key installation
820 */
821 session->encryptType = eSIR_ED_NONE;
822
823 break;
824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 /*
826 * There is one more mode called auto mode.
827 * which is used no where
828 */
829
830 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
831
832 default:
833 /* not used anywhere...used in scan function */
834 break;
835 }
836
837 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700838 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 * parsed (Re)Assoc request structure
840 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700841 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530843 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700844 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 if (NULL == session->parsedAssocReq) {
846 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700847 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
849 goto free;
850 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530851 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700852 (session->dph.dphHashTable.size *
853 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 }
855
856 if (!sme_start_bss_req->channelId) {
857 lim_log(mac_ctx, LOGE,
858 FL("Received invalid eWNI_SME_START_BSS_REQ"));
859 ret_code = eSIR_SME_INVALID_PARAMETERS;
860 goto free;
861 }
862 channel_number = sme_start_bss_req->channelId;
863#ifdef QCA_HT_2040_COEX
864 if (sme_start_bss_req->obssEnabled)
865 session->htSupportedChannelWidthSet =
866 session->htCapability;
867 else
868#endif
869 session->htSupportedChannelWidthSet =
870 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
871 session->htSecondaryChannelOffset =
872 sme_start_bss_req->sec_ch_offset;
873 session->htRecommendedTxWidthSet =
874 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530875 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 FL("cbMode %u"), sme_start_bss_req->cbMode);
877 if (session->vhtCapability || session->htCapability) {
878 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800879 lim_log(mac_ctx, LOG1,
880 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
881 sme_start_bss_req->vht_channel_width,
882 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 session->ch_width = chanwidth;
884 if (session->htSupportedChannelWidthSet) {
885 session->ch_center_freq_seg0 =
886 sme_start_bss_req->center_freq_seg0;
887 session->ch_center_freq_seg1 =
888 sme_start_bss_req->center_freq_seg1;
889 } else {
890 session->ch_center_freq_seg0 = 0;
891 session->ch_center_freq_seg1 = 0;
892 }
893 }
894
895 if (session->vhtCapability &&
896 (CH_WIDTH_160MHZ > session->ch_width)) {
897 if (wlan_cfg_get_int(mac_ctx,
898 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
899 eSIR_SUCCESS)
900 lim_log(mac_ctx, LOGE, FL(
901 "cfg get vht su bformer failed"));
902
903 session->enable_su_tx_bformer = val;
904 } else {
905 session->nss = 1;
906 }
907 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
908
909 /* Delete pre-auth list if any */
910 lim_delete_pre_auth_list(mac_ctx);
911
912 /*
913 * keep the RSN/WPA IE information in PE Session Entry
914 * later will be using this to check when received (Re)Assoc req
915 */
916 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
917 &sme_start_bss_req->rsnIE, session);
918
919 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
920 session->gLimProtectionControl =
921 sme_start_bss_req->protEnabled;
922 /*
923 * each byte will have the following info
924 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
925 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
926 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530927 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 (void *)&sme_start_bss_req->ht_capab,
929 sizeof(uint16_t));
930 /* Initialize WPS PBC session link list */
931 session->pAPWPSPBCSession = NULL;
932 }
933 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530934 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 if (NULL == mlm_start_req) {
936 lim_log(mac_ctx, LOGP,
937 FL("Allocate Memory failed for mlmStartReq"));
938 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
939 goto free;
940 }
941
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530942 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943
944 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530945 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 (uint8_t *) &sme_start_bss_req->ssId,
947 sme_start_bss_req->ssId.length + 1);
948 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
949 mlm_start_req->obssProtEnabled =
950 sme_start_bss_req->obssProtEnabled;
951
952 mlm_start_req->bssType = session->bssType;
953
954 /* Fill PE session Id from the session Table */
955 mlm_start_req->sessionId = session->peSessionId;
956
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700957 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 /*
959 * Copy the BSSId from sessionTable to
960 * mlmStartReq struct
961 */
962 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
963 } else {
964 /* ibss mode */
965 mac_ctx->lim.gLimIbssCoalescingHappened = false;
966
967 ret_status = wlan_cfg_get_int(mac_ctx,
968 WNI_CFG_IBSS_AUTO_BSSID,
969 &auto_gen_bssid);
970 if (ret_status != eSIR_SUCCESS) {
971 lim_log(mac_ctx, LOGP,
972 FL("Get Auto Gen BSSID fail,Status=%d"),
973 ret_status);
974 ret_code = eSIR_LOGP_EXCEPTION;
975 goto free;
976 }
977
978 if (!auto_gen_bssid) {
979 /*
980 * We're not auto generating BSSID.
981 * Instead, get it from session entry
982 */
983 sir_copy_mac_addr(mlm_start_req->bssId,
984 session->bssId);
985 /*
986 * Start IBSS group BSSID
987 * Auto Generating BSSID.
988 */
989 auto_gen_bssid = ((mlm_start_req->bssId[0] &
990 0x01) ? true : false);
991 }
992
993 if (auto_gen_bssid) {
994 /*
995 * if BSSID is not any uc id.
996 * then use locally generated BSSID.
997 * Autogenerate the BSSID
998 */
999 lim_get_random_bssid(mac_ctx,
1000 mlm_start_req->bssId);
1001 mlm_start_req->bssId[0] = 0x02;
1002
1003 /*
1004 * Copy randomly generated BSSID
1005 * to the session Table
1006 */
1007 sir_copy_mac_addr(session->bssId,
1008 mlm_start_req->bssId);
1009 }
1010 }
1011 /* store the channel num in mlmstart req structure */
1012 mlm_start_req->channelNumber = session->currentOperChannel;
1013 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1014 mlm_start_req->beaconPeriod =
1015 session->beaconParams.beaconInterval;
1016
1017 if (LIM_IS_AP_ROLE(session)) {
1018 mlm_start_req->dtimPeriod = session->dtimPeriod;
1019 mlm_start_req->wps_state = session->wps_state;
1020
1021 } else {
1022 if (wlan_cfg_get_int(mac_ctx,
1023 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1024 lim_log(mac_ctx, LOGP,
1025 FL("could not retrieve DTIM Period"));
1026 mlm_start_req->dtimPeriod = (uint8_t) val;
1027 }
1028
1029 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1030 eSIR_SUCCESS)
1031 lim_log(mac_ctx, LOGP,
1032 FL("could not retrieve Beacon interval"));
1033 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1034
1035 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1036 eSIR_SUCCESS)
1037 lim_log(mac_ctx, LOGP,
1038 FL("could not retrieve CFPMaxDuration"));
1039 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1040
1041 /*
1042 * this may not be needed anymore now,
1043 * as rateSet is now included in the
1044 * session entry and MLM has session context.
1045 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301046 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 (void *)&session->rateSet,
1048 sizeof(tSirMacRateSet));
1049
1050 /* Now populate the 11n related parameters */
1051 mlm_start_req->nwType = session->nwType;
1052 mlm_start_req->htCapable = session->htCapability;
1053
1054 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1055 /* Unused */
1056 mlm_start_req->dualCTSProtection =
1057 mac_ctx->lim.gHTDualCTSProtection;
1058 mlm_start_req->txChannelWidthSet =
1059 session->htRecommendedTxWidthSet;
1060
1061 session->limRFBand = lim_get_rf_band(channel_number);
1062
1063 /* Initialize 11h Enable Flag */
1064 session->lim11hEnable = 0;
1065 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1066 (SIR_BAND_5_GHZ == session->limRFBand)) {
1067 if (wlan_cfg_get_int(mac_ctx,
1068 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1069 lim_log(mac_ctx, LOGP,
1070 FL("Fail to get WNI_CFG_11H_ENABLED "));
1071 else
1072 session->lim11hEnable = val;
1073
1074 if (session->lim11hEnable &&
1075 (eSIR_INFRA_AP_MODE ==
1076 mlm_start_req->bssType)) {
1077 cfg_get_wmi_dfs_master_param =
1078 wlan_cfg_get_int(mac_ctx,
1079 WNI_CFG_DFS_MASTER_ENABLED,
1080 &val);
1081 session->lim11hEnable = val;
1082 }
1083 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1084 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1085 lim_log(mac_ctx, LOGE,
1086 FL("Get Fail, CFG DFS ENABLE"));
1087 }
1088
1089 if (!session->lim11hEnable) {
1090 if (cfg_set_int(mac_ctx,
1091 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1092 eSIR_SUCCESS)
1093 /*
1094 * Failed to set the CFG param
1095 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1096 */
1097 lim_log(mac_ctx, LOGE,
1098 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1099 }
1100
1101 session->limPrevSmeState = session->limSmeState;
1102 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1103 MTRACE(mac_trace
1104 (mac_ctx, TRACE_CODE_SME_STATE,
1105 session->peSessionId,
1106 session->limSmeState));
1107
1108 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1109 (uint32_t *) mlm_start_req);
1110 return;
1111 } else {
1112
1113 lim_log(mac_ctx, LOGE,
1114 FL("Received unexpected START_BSS_REQ, in state %X"),
1115 mac_ctx->lim.gLimSmeState);
1116 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1117 goto end;
1118 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1119
1120free:
1121 if ((session != NULL) &&
1122 (session->pLimStartBssReq == sme_start_bss_req)) {
1123 session->pLimStartBssReq = NULL;
1124 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301125 qdf_mem_free(sme_start_bss_req);
1126 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127
1128end:
1129 if (sme_start_bss_req != NULL) {
1130 sme_session_id = sme_start_bss_req->sessionId;
1131 sme_transaction_id = sme_start_bss_req->transactionId;
1132 }
1133 if (NULL != session) {
1134 pe_delete_session(mac_ctx, session);
1135 session = NULL;
1136 }
1137 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1138 session, sme_session_id, sme_transaction_id);
1139}
1140
1141/**
1142 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1143 *
1144 * @pMac: Global MAC context
1145 * @pMsg: Message pointer
1146 *
1147 * Wrapper for the function __lim_handle_sme_start_bss_request
1148 * This message will be defered until softmac come out of
1149 * scan mode or if we have detected radar on the current
1150 * operating channel.
1151 *
1152 * return true - If we consumed the buffer
1153 * false - If have defered the message.
1154 */
1155static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1156{
1157 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1158 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1159 /**
1160 * If message defered, buffer is not consumed yet.
1161 * So return false
1162 */
1163 return false;
1164 }
1165
1166 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1167 return true;
1168}
1169
1170/**
1171 * lim_get_random_bssid()
1172 *
1173 * FUNCTION:This function is called to process generate the random number for bssid
1174 * This function is called to process SME_SCAN_REQ message
1175 * from HDD or upper layer application.
1176 *
1177 * LOGIC:
1178 *
1179 * ASSUMPTIONS:
1180 *
1181 * NOTE:
1182 * 1. geneartes the unique random number for bssid in ibss
1183 *
1184 * @param pMac Pointer to Global MAC structure
1185 * @param *data Pointer to bssid buffer
1186 * @return None
1187 */
1188void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1189{
1190 uint32_t random[2];
1191 random[0] = tx_time_get();
1192 random[0] |= (random[0] << 15);
1193 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301194 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195}
1196
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301197static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 tpSirSmeScanReq pScanReq)
1199{
1200 tSirScanOffloadReq *pScanOffloadReq;
1201 uint8_t *p;
1202 uint8_t *ht_cap_ie;
1203 tSirMsgQ msg;
1204 uint16_t i, len;
1205 uint16_t ht_cap_len = 0, addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206 uint8_t *vht_cap_ie;
1207 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 tSirRetStatus status, rc = eSIR_SUCCESS;
1209 tDot11fIEExtCap extracted_extcap = {0};
1210 bool extcap_present = true;
1211
1212 if (pScanReq->uIEFieldLen) {
1213 status = lim_strip_extcap_update_struct(pMac,
1214 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1215 &pScanReq->uIEFieldLen, &extracted_extcap);
1216
1217 if (eSIR_SUCCESS != status) {
1218 extcap_present = false;
1219 lim_log(pMac, LOG1,
1220 FL("Unable to Strip ExtCap IE from Scan Req"));
1221 }
1222
1223 if (extcap_present) {
1224 lim_log(pMac, LOG1,
1225 FL("Extcap was part of SCAN IE - Updating FW"));
1226 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1227 &extracted_extcap, true);
1228 }
1229 } else {
1230 lim_log(pMac, LOG1,
1231 FL("No IEs in the scan request from supplicant"));
1232 }
1233
1234 /**
1235 * The tSirScanOffloadReq will reserve the space for first channel,
1236 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1237 */
1238 len = sizeof(tSirScanOffloadReq) +
1239 (pScanReq->channelList.numChannels - 1) + pScanReq->uIEFieldLen;
1240
1241 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1242 lim_log(pMac, LOG1,
1243 FL("Adding HT Caps IE since dot11mode=%d"),
1244 pScanReq->dot11mode);
1245 /* 2 bytes for EID and Length */
1246 ht_cap_len = 2 + sizeof(tHtCaps);
1247 len += ht_cap_len;
1248 addn_ie_len += ht_cap_len;
1249 }
1250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1252 lim_log(pMac, LOG1,
1253 FL("Adding VHT Caps IE since dot11mode=%d"),
1254 pScanReq->dot11mode);
1255 /* 2 bytes for EID and Length */
1256 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1257 sizeof(tSirVhtMcsInfo);
1258 len += vht_cap_len;
1259 addn_ie_len += vht_cap_len;
1260 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301262 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 if (NULL == pScanOffloadReq) {
1264 lim_log(pMac, LOGE,
1265 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301266 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 }
1268
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301269 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270
1271 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1272 msg.bodyptr = pScanOffloadReq;
1273 msg.bodyval = 0;
1274
Anurag Chouhanc5548422016-02-24 18:33:27 +05301275 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276
1277 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1278 lim_log(pMac, LOGE,
1279 FL("Invalid value (%d) for numSsid"),
1280 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301281 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301282 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 }
1284
1285 pScanOffloadReq->numSsid = pScanReq->numSsid;
1286 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1287 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301288 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 (uint8_t *) pScanReq->ssId[i].ssId,
1290 pScanOffloadReq->ssId[i].length);
1291 }
1292
1293 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301294 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 pScanOffloadReq->bssType = pScanReq->bssType;
1296 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1297 pScanOffloadReq->scanType = pScanReq->scanType;
1298 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1299 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1300 pScanOffloadReq->restTime = pScanReq->restTime;
1301
1302 /* for normal scan, the value for p2pScanType should be 0
1303 always */
1304 if (pScanReq->p2pSearch)
1305 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1306
1307 pScanOffloadReq->sessionId = pScanReq->sessionId;
1308 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001309 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310
1311 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1312 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1313 pScanOffloadReq->sessionId);
1314
1315 pScanOffloadReq->channelList.numChannels =
1316 pScanReq->channelList.numChannels;
1317 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1318 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1319 p[i] = pScanReq->channelList.channelNumber[i];
1320
1321 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1322 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1323 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301324 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 pScanOffloadReq->uIEFieldOffset,
1326 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1327 pScanReq->uIEFieldLen);
1328
1329 /* Copy HT Capability info if dot11mode is HT */
1330 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1331 /* Populate EID and Length field here */
1332 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1333 pScanOffloadReq->uIEFieldOffset +
1334 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301335 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1337 *(ht_cap_ie + 1) = ht_cap_len - 2;
1338 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1339 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1340 }
1341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 /* Copy VHT Capability info if dot11mode is VHT Capable */
1343 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1344 /* Populate EID and Length field here */
1345 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1346 pScanOffloadReq->uIEFieldOffset +
1347 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301348 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1350 *(vht_cap_ie + 1) = vht_cap_len - 2;
1351 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1352 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1353 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354
1355 rc = wma_post_ctrl_msg(pMac, &msg);
1356 if (rc != eSIR_SUCCESS) {
1357 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301358 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301359 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 }
1361
1362 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1363
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301364 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365}
1366
1367/**
1368 * __lim_process_sme_scan_req() - Process the SME Scan Request
1369 * @mac_ctx: Global MAC Context
1370 * @msg_buf: Buffer which contains the request and pertinent parameters
1371 *
1372 * This function is called to process SME_SCAN_REQ message
1373 * from HDD or upper layer application.
1374 *
1375 * Return: None
1376 */
1377
1378static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1379 uint32_t *msg_buf)
1380{
1381 tpSirSmeScanReq scan_req;
1382 uint8_t valid_req = 0;
1383
1384#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1385 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1386 eSIR_SUCCESS, eSIR_SUCCESS);
1387#endif
1388
1389 scan_req = (tpSirSmeScanReq) msg_buf;
1390 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301391 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 -08001392 scan_req->scan_id, scan_req->channelList.numChannels,
1393 scan_req->minChannelTime, scan_req->maxChannelTime,
1394 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1395 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301396 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1398 /*
1399 * Since scan req always requires a response, we will overwrite response
1400 * required here. This is added esp to take care of the condition where
1401 * in p2p go case, we hold the scan req and insert single NOA. We send
1402 * the held scan request to FW later on getting start NOA ind from FW so
1403 * we lose state of the gLimRspReqd flag for the scan req if any other
1404 * request comes by then. e.g. While unit testing, we found when insert
1405 * single NOA is done, we see a get stats request which turns the flag
1406 * gLimRspReqd to false; now when we actually start the saved scan req
1407 * for init scan after getting NOA started, the gLimRspReqd being a
1408 * global flag is showing false instead of true value for this saved
1409 * scan req. Since all scan reqs coming to lim require a response,
1410 * there is no harm in setting the global flag gLimRspReqd to true here.
1411 */
1412 mac_ctx->lim.gLimRspReqd = true;
1413
1414 /*
1415 * copy the Self MAC address from SmeReq to the globalplace,
1416 * used for sending probe req
1417 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001418 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1419 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1421
1422 if (!valid_req || mac_ctx->lim.scan_disabled) {
1423 lim_log(mac_ctx, LOGE,
1424 FL("Scan disabled %d, Valid Scan Req %d"),
1425 mac_ctx->lim.scan_disabled, valid_req);
1426
1427 if (mac_ctx->lim.gLimRspReqd) {
1428 mac_ctx->lim.gLimRspReqd = false;
1429
1430 lim_send_sme_scan_rsp(mac_ctx,
1431 eSIR_SME_INVALID_PARAMETERS,
1432 scan_req->sessionId,
1433 scan_req->transactionId,
1434 scan_req->scan_id);
1435 }
1436 return;
1437 }
1438
1439 /*
1440 * If scan request is received in idle, joinFailed
1441 * states or in link established state (in STA role)
1442 * or in normal state (in STA-in-IBSS/AP role) with
1443 * 'return fresh scan results' request from HDD or
1444 * it is periodic background scanning request,
1445 * trigger fresh scan request to MLM
1446 */
1447 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1448
1449 mac_ctx->lim.gLim24Band11dScanDone = 0;
1450 mac_ctx->lim.gLim50Band11dScanDone = 0;
1451 mac_ctx->lim.gLimReturnAfterFirstMatch =
1452 scan_req->returnAfterFirstMatch;
1453 mac_ctx->lim.gLimReturnUniqueResults =
1454 ((scan_req->returnUniqueResults) > 0 ? true : false);
1455
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 lim_send_hal_start_scan_offload_req(mac_ctx,
1458 scan_req)) {
1459 lim_log(mac_ctx, LOGE, FL(
1460 "Couldn't send Offload scan request"));
1461 lim_send_sme_scan_rsp(mac_ctx,
1462 eSIR_SME_INVALID_PARAMETERS,
1463 scan_req->sessionId,
1464 scan_req->transactionId,
1465 scan_req->scan_id);
1466 return;
1467 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301468 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 /* In all other cases return 'cached' scan results */
1470 if (mac_ctx->lim.gLimRspReqd) {
1471 mac_ctx->lim.gLimRspReqd = false;
1472 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1473 scan_req->sessionId,
1474 scan_req->transactionId, scan_req->scan_id);
1475 }
1476 }
1477}
1478
1479#ifdef FEATURE_OEM_DATA_SUPPORT
1480
1481static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1482{
1483 tpSirOemDataReq pOemDataReq;
1484 tLimMlmOemDataReq *pMlmOemDataReq;
1485
1486 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1487
1488 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301489 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490 if (NULL == pMlmOemDataReq) {
1491 lim_log(pMac, LOGP,
1492 FL("AllocateMemory failed for mlmOemDataReq"));
1493 return;
1494 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301495 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001496 if (!pMlmOemDataReq->data) {
1497 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301498 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001499 return;
1500 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501
Anurag Chouhanc5548422016-02-24 18:33:27 +05301502 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001503 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001504 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301505 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001506 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001507 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301508 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1510 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1511 (uint32_t *) pMlmOemDataReq);
1512
1513 return;
1514
1515} /*** end __lim_process_sme_oem_data_req() ***/
1516
1517#endif /* FEATURE_OEM_DATA_SUPPORT */
1518
1519/**
1520 * __lim_process_clear_dfs_channel_list()
1521 *
1522 ***FUNCTION:
1523 ***Clear DFS channel list when country is changed/aquired.
1524 .*This message is sent from SME.
1525 *
1526 ***LOGIC:
1527 *
1528 ***ASSUMPTIONS:
1529 *
1530 ***NOTE:
1531 *
1532 * @param pMac Pointer to Global MAC structure
1533 * @param *pMsgBuf A pointer to the SME message buffer
1534 * @return None
1535 */
1536static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1537{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301538 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539}
1540
1541/**
1542 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1543 * @mac_ctx: Pointer to Global MAC structure
1544 * @msg_buf: A pointer to the SME message buffer
1545 *
1546 * This function is called to process SME_JOIN_REQ message
1547 * from HDD or upper layer application.
1548 *
1549 * Return: None
1550 */
1551static void
1552__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1553{
1554 tpSirSmeJoinReq sme_join_req = NULL;
1555 tLimMlmJoinReq *mlm_join_req;
1556 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1557 uint32_t val = 0;
1558 uint16_t n_size;
1559 uint8_t session_id;
1560 tpPESession session = NULL;
1561 uint8_t sme_session_id;
1562 uint16_t sme_transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001563 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 uint16_t ie_len;
1565 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001566 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567
1568/* FEATURE_WLAN_DIAG_SUPPORT */
1569#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1570 /*
1571 * Not sending any session, since it is not created yet.
1572 * The response whould have correct state.
1573 */
1574 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1575#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1576
1577 lim_log(mac_ctx, LOG1, FL("Received SME_JOIN_REQ"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578
1579 /*
1580 * Expect Join request in idle state.
1581 * Reassociate request is expected in link established state.
1582 */
1583
1584 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1585 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1586 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1587 msg_buf);
1588
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301589 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 if (NULL == sme_join_req) {
1591 lim_log(mac_ctx, LOGP,
1592 FL("AllocateMemory failed for sme_join_req"));
1593 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1594 return;
1595 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301596 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1597 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 n_size);
1599
1600 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1601 /* Received invalid eWNI_SME_JOIN_REQ */
1602 /* Log the event */
1603 lim_log(mac_ctx, LOGW,
1604 FL("SessionId:%d JOIN REQ with invalid data"),
1605 sme_join_req->sessionId);
1606 ret_code = eSIR_SME_INVALID_PARAMETERS;
1607 goto end;
1608 }
1609
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001610 /*
1611 * Update the capability here itself as this is used in
1612 * lim_extract_ap_capability() below. If not updated issues
1613 * like not honoring power constraint on 1st association after
1614 * driver loading might occur.
1615 */
1616 lim_update_rrm_capability(mac_ctx, sme_join_req);
1617
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001618 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001620 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 &session_id);
1622
1623 if (session != NULL) {
1624 lim_log(mac_ctx, LOGE,
1625 FL("Session(%d) Already exists for BSSID: "
1626 MAC_ADDRESS_STR " in limSmeState = %X"),
1627 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001628 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 session->limSmeState);
1630
1631 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1632 session->smeSessionId == sme_join_req->sessionId) {
1633 /*
1634 * Received eWNI_SME_JOIN_REQ for same
1635 * BSS as currently associated.
1636 * Log the event and send success
1637 */
1638 lim_log(mac_ctx, LOGW,
1639 FL("SessionId: %d"), session_id);
1640 lim_log(mac_ctx, LOGW,
1641 FL("JOIN_REQ for current joined BSS"));
1642 /* Send Join success response to host */
1643 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1644 session = NULL;
1645 goto end;
1646 } else {
1647 lim_log(mac_ctx, LOGE,
1648 FL("JOIN_REQ not for current joined BSS"));
1649 ret_code = eSIR_SME_REFUSED;
1650 session = NULL;
1651 goto end;
1652 }
1653 } else {
1654 /*
1655 * Session Entry does not exist for given BSSId
1656 * Try to Create a new session
1657 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001658 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 &session_id, mac_ctx->lim.maxStation,
1660 eSIR_INFRASTRUCTURE_MODE);
1661 if (session == NULL) {
1662 lim_log(mac_ctx, LOGE,
1663 FL("Session Can not be created "));
1664 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1665 goto end;
1666 } else
1667 lim_log(mac_ctx, LOG1,
1668 FL("SessionId:%d New session created"),
1669 session_id);
1670 }
1671 session->isAmsduSupportInAMPDU =
1672 sme_join_req->isAmsduSupportInAMPDU;
1673
1674 /*
1675 * Store Session related parameters
1676 * Store PE session Id in session Table
1677 */
1678 session->peSessionId = session_id;
1679
1680 /* store the smejoin req handle in session table */
1681 session->pLimJoinReq = sme_join_req;
1682
1683 /* Store SME session Id in sessionTable */
1684 session->smeSessionId = sme_join_req->sessionId;
1685
1686 /* Store SME transaction Id in session Table */
1687 session->transactionId = sme_join_req->transactionId;
1688
1689 /* Store beaconInterval */
1690 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001691 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301693 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 sizeof(session->htConfig));
1695
1696 /* Copying of bssId is already done, while creating session */
1697 sir_copy_mac_addr(session->selfMacAddr,
1698 sme_join_req->selfMacAddr);
1699 session->bssType = sme_join_req->bsstype;
1700
1701 session->statypeForBss = STA_ENTRY_PEER;
1702 session->limWmeEnabled = sme_join_req->isWMEenabled;
1703 session->limQosEnabled = sme_join_req->isQosEnabled;
1704
1705 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001706 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1708
1709 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1710 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001711 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712
1713 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001714 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 session->isCiscoVendorAP = true;
1716 } else {
1717 session->isCiscoVendorAP = false;
1718 }
1719
1720 /* Copy the dot 11 mode in to the session table */
1721
1722 session->dot11mode = sme_join_req->dot11mode;
1723#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1724 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1725#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001726 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1728 session->enableHtSmps = sme_join_req->enableHtSmps;
1729 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001730 session->send_smps_action =
1731 sme_join_req->send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001732 lim_log(mac_ctx, LOG1,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001733 FL("enable Smps: %d mode: %d send action: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001734 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001735 session->htSmpsvalue,
1736 session->send_smps_action);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737
1738 /*Store Persona */
1739 session->pePersona = sme_join_req->staPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301740 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 FL("PE PERSONA=%d cbMode %u"),
1742 session->pePersona, sme_join_req->cbMode);
1743 if (mac_ctx->roam.configParam.enable2x2)
1744 session->nss = 2;
1745 else
1746 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747 session->vhtCapability =
1748 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301749 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 "***__lim_process_sme_join_req: vhtCapability=%d****",
1751 session->vhtCapability);
1752 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301753 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 session->txBFIniFeatureEnabled =
1755 sme_join_req->txBFIniFeatureEnabled;
1756 } else {
1757 session->txBFIniFeatureEnabled = 0;
1758 }
1759 session->txMuBformee = sme_join_req->txMuBformee;
1760 session->enableVhtpAid =
1761 sme_join_req->enableVhtpAid;
1762 session->enableVhtGid =
1763 sme_join_req->enableVhtGid;
1764
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301765 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 FL("***txBFIniFeatureEnabled=%d***"),
1767 session->txBFIniFeatureEnabled);
1768 if (wlan_cfg_get_int(mac_ctx,
1769 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1770 eSIR_SUCCESS)
1771 lim_log(mac_ctx, LOGE, FL(
1772 "cfg get vht su bformer failed"));
1773
1774 session->enable_su_tx_bformer = val;
1775 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1776 }
1777 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1778 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1779 session->txBFIniFeatureEnabled) !=
1780 eSIR_SUCCESS) {
1781 /*
1782 * Set failed for
1783 * CFG_VHT_SU_BEAMFORMEE_CAP
1784 */
1785 lim_log(mac_ctx, LOGP,
1786 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1787 ret_code = eSIR_LOGP_EXCEPTION;
1788 goto end;
1789 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301790 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 "%s: txBFCsnValue=%d", __func__,
1792 sme_join_req->txBFCsnValue);
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001793 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001796 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 handle_ht_capabilityand_ht_info(mac_ctx, session);
1798 /* Copy The channel Id to the session Table */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001799 session->currentOperChannel = bss_desc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 /* cbMode is already merged value of peer and self -
1801 * done by csr in csr_get_cb_mode_from_ies */
1802 session->htSupportedChannelWidthSet =
1803 (sme_join_req->cbMode) ? 1 : 0;
1804 session->htRecommendedTxWidthSet =
1805 session->htSupportedChannelWidthSet;
1806 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1807
1808 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1809 session->ch_center_freq_seg0 =
1810 session->currentOperChannel - 2;
1811 session->ch_width = CH_WIDTH_40MHZ;
1812 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1813 sme_join_req->cbMode) {
1814 session->ch_center_freq_seg0 =
1815 session->currentOperChannel + 2;
1816 session->ch_width = CH_WIDTH_40MHZ;
1817 } else {
1818 session->ch_center_freq_seg0 = 0;
1819 session->ch_width = CH_WIDTH_20MHZ;
1820 }
1821
1822 /* Record if management frames need to be protected */
1823#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001824 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001826 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828#endif
1829
1830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001831 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832#endif
1833
1834 /* Copy the SSID from smejoinreq to session entry */
1835 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301836 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 session->ssId.length);
1838
1839 /*
1840 * Determin 11r or ESE connection based on input from SME
1841 * which inturn is dependent on the profile the user wants
1842 * to connect to, So input is coming from supplicant
1843 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845#ifdef FEATURE_WLAN_ESE
1846 session->isESEconnection = sme_join_req->isESEconnection;
1847#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 session->isFastTransitionEnabled =
1849 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 session->isFastRoamIniFeatureEnabled =
1852 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 session->txLdpcIniFeatureEnabled =
1854 sme_join_req->txLdpcIniFeatureEnabled;
1855
1856 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1857 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 } else {
1859 /*
1860 * Throw an error and return and make
1861 * sure to delete the session.
1862 */
1863 lim_log(mac_ctx, LOGE,
1864 FL("recvd JOIN_REQ with invalid bss type %d"),
1865 session->bssType);
1866 ret_code = eSIR_SME_INVALID_PARAMETERS;
1867 goto end;
1868 }
1869
1870 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301871 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 &sme_join_req->addIEScan, sizeof(tSirAddie));
1873
1874 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301875 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1877
1878 val = sizeof(tLimMlmJoinReq) +
1879 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301880 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 if (NULL == mlm_join_req) {
1882 lim_log(mac_ctx, LOGP,
1883 FL("AllocateMemory failed for mlmJoinReq"));
1884 return;
1885 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301886 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887
1888 /* PE SessionId is stored as a part of JoinReq */
1889 mlm_join_req->sessionId = session->peSessionId;
1890
1891 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1892 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1893 eSIR_SUCCESS) {
1894 lim_log(mac_ctx, LOGP,
1895 FL("couldn't retrieve JoinFailureTimer value"
1896 " setting to default value"));
1897 mlm_join_req->joinFailureTimeout =
1898 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1899 }
1900
1901 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301902 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 (void *)&sme_join_req->operationalRateSet,
1904 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301905 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 (void *)&sme_join_req->extendedRateSet,
1907 sizeof(tSirMacRateSet));
1908 /*
1909 * this may not be needed anymore now, as rateSet is now
1910 * included in the session entry and MLM has session context.
1911 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301912 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 (void *)&session->rateSet,
1914 sizeof(tSirMacRateSet));
1915
1916 session->encryptType = sme_join_req->UCEncryptionType;
1917
1918 mlm_join_req->bssDescription.length =
1919 session->pLimJoinReq->bssDescription.length;
1920
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301921 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 (uint8_t *)
1923 &session->pLimJoinReq->bssDescription.bssId,
1924 session->pLimJoinReq->bssDescription.length + 2);
1925
1926 session->limCurrentBssCaps =
1927 session->pLimJoinReq->bssDescription.capabilityInfo;
1928
1929 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1930 session->currentOperChannel);
1931 local_power_constraint = reg_max;
1932
1933 lim_extract_ap_capability(mac_ctx,
1934 (uint8_t *)
1935 session->pLimJoinReq->bssDescription.ieFields,
1936 lim_get_ielen_from_bss_description(
1937 &session->pLimJoinReq->bssDescription),
1938 &session->limCurrentBssQosCaps,
1939 &session->limCurrentBssPropCap,
1940 &session->gLimCurrentBssUapsd,
1941 &local_power_constraint, session);
1942
1943#ifdef FEATURE_WLAN_ESE
1944 session->maxTxPower = lim_get_max_tx_power(reg_max,
1945 local_power_constraint,
1946 mac_ctx->roam.configParam.nTxPowerCap);
1947#else
1948 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301949 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301951 lim_log(mac_ctx, LOG1,
1952 FL("Reg max = %d, local power con = %d, max tx = %d"),
1953 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954
1955 if (session->gLimCurrentBssUapsd) {
1956 session->gUapsdPerAcBitmask =
1957 session->pLimJoinReq->uapsdPerAcBitmask;
1958 lim_log(mac_ctx, LOG1,
1959 FL("UAPSD flag for all AC - 0x%2x"),
1960 session->gUapsdPerAcBitmask);
1961
1962 /* resetting the dynamic uapsd mask */
1963 session->gUapsdPerAcDeliveryEnableMask = 0;
1964 session->gUapsdPerAcTriggerEnableMask = 0;
1965 }
1966
1967 session->limRFBand =
1968 lim_get_rf_band(session->currentOperChannel);
1969
1970 /* Initialize 11h Enable Flag */
1971 if (SIR_BAND_5_GHZ == session->limRFBand) {
1972 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1973 &val) != eSIR_SUCCESS) {
1974 lim_log(mac_ctx, LOGP,
1975 FL("Fail to get WNI_CFG_11H_ENABLED "));
1976 session->lim11hEnable =
1977 WNI_CFG_11H_ENABLED_STADEF;
1978 } else {
1979 session->lim11hEnable = val;
1980 }
1981 } else {
1982 session->lim11hEnable = 0;
1983 }
1984
1985 /*
1986 * To care of the scenario when STA transitions from
1987 * IBSS to Infrastructure mode.
1988 */
1989 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1990
1991 session->limPrevSmeState = session->limSmeState;
1992 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1993 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1994 session->peSessionId,
1995 session->limSmeState));
1996
1997 lim_log(mac_ctx, LOG1,
1998 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
1999 mlm_join_req->sessionId, session->ssId.length,
2000 session->ssId.ssId, session->currentOperChannel,
2001 MAC_ADDR_ARRAY(session->bssId));
2002
2003 /* Indicate whether spectrum management is enabled */
2004 session->spectrumMgtEnabled =
2005 sme_join_req->spectrumMgtIndicator;
2006
2007 /* Enable the spectrum management if this is a DFS channel */
2008 if (session->country_info_present &&
2009 lim_isconnected_on_dfs_channel(
2010 session->currentOperChannel))
2011 session->spectrumMgtEnabled = true;
2012
2013 session->isOSENConnection = sme_join_req->isOSENConnection;
2014
2015 lim_log(mac_ctx, LOG1,
2016 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
2017 mlm_join_req->sessionId);
2018 /* Issue LIM_MLM_JOIN_REQ to MLM */
2019 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2020 (uint32_t *) mlm_join_req);
2021 return;
2022
2023 } else {
2024 /* Received eWNI_SME_JOIN_REQ un expected state */
2025 lim_log(mac_ctx, LOGE,
2026 FL("received unexpected SME_JOIN_REQ in state %X"),
2027 mac_ctx->lim.gLimSmeState);
2028 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2029 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2030 session = NULL;
2031 goto end;
2032 }
2033
2034end:
2035 sme_session_id = sme_join_req->sessionId;
2036 sme_transaction_id = sme_join_req->transactionId;
2037
2038 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302039 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 sme_join_req = NULL;
2041 if (NULL != session)
2042 session->pLimJoinReq = NULL;
2043 }
2044 if (ret_code != eSIR_SME_SUCCESS) {
2045 if (NULL != session) {
2046 pe_delete_session(mac_ctx, session);
2047 session = NULL;
2048 }
2049 }
2050 lim_log(mac_ctx, LOG1,
2051 FL("Send failure status on sessionid: %d with ret_code = %d"),
2052 sme_session_id, ret_code);
2053 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2054 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2055 sme_transaction_id);
2056}
2057
Amar Singhala297bfa2015-10-15 15:07:29 -07002058uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059 uint8_t iniTxPower)
2060{
2061 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302062 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2063 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2065 maxTxPower = txPower;
2066 else if (txPower < MIN_TX_PWR_CAP)
2067 maxTxPower = MIN_TX_PWR_CAP;
2068 else
2069 maxTxPower = MAX_TX_PWR_CAP;
2070
2071 return maxTxPower;
2072}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073
2074/**
2075 * __lim_process_sme_reassoc_req() - process reassoc req
2076 *
2077 * @mac_ctx: Pointer to Global MAC structure
2078 * @msg_buf: pointer to the SME message buffer
2079 *
2080 * This function is called to process SME_REASSOC_REQ message
2081 * from HDD or upper layer application.
2082 *
2083 * Return: None
2084 */
2085
2086static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2087 uint32_t *msg_buf)
2088{
2089 uint16_t caps;
2090 uint32_t val;
2091 tpSirSmeJoinReq reassoc_req = NULL;
2092 tLimMlmReassocReq *mlm_reassoc_req;
2093 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2094 tpPESession session_entry = NULL;
2095 uint8_t session_id;
2096 uint8_t sme_session_id;
2097 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002098 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 uint32_t tele_bcn_en = 0;
2100 uint16_t size;
2101
2102 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2103
2104 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302105 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 if (NULL == reassoc_req) {
2107 lim_log(mac_ctx, LOGP,
2108 FL("call to AllocateMemory failed for reassoc_req"));
2109
2110 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2111 goto end;
2112 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302113 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2114 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115
2116 if (!lim_is_sme_join_req_valid(mac_ctx,
2117 (tpSirSmeJoinReq)reassoc_req)) {
2118 /*
2119 * Received invalid eWNI_SME_REASSOC_REQ
2120 */
2121 lim_log(mac_ctx, LOGW,
2122 FL("received SME_REASSOC_REQ with invalid data"));
2123
2124 ret_code = eSIR_SME_INVALID_PARAMETERS;
2125 goto end;
2126 }
2127
2128 session_entry = pe_find_session_by_bssid(mac_ctx,
2129 reassoc_req->bssDescription.bssId,
2130 &session_id);
2131 if (session_entry == NULL) {
2132 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2133 LOGE);
2134 lim_log(mac_ctx, LOGE,
2135 FL("Session does not exist for given bssId"));
2136 ret_code = eSIR_SME_INVALID_PARAMETERS;
2137 goto end;
2138 }
2139#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2140 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2141 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2142#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2143 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2144
2145 /* Store the reassoc handle in the session Table */
2146 session_entry->pLimReAssocReq = reassoc_req;
2147
2148 session_entry->dot11mode = reassoc_req->dot11mode;
2149 session_entry->vhtCapability =
2150 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002151
2152 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2153 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002154 session_entry->send_smps_action =
2155 reassoc_req->send_smps_action;
2156 lim_log(mac_ctx, LOG1,
2157 FL("enableHtSmps: %d htSmps: %d send action: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002158 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002159 session_entry->htSmpsvalue,
2160 session_entry->send_smps_action);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 /*
2162 * Reassociate request is expected
2163 * in link established state only.
2164 */
2165
2166 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2168 /*
2169 * May be from 11r FT pre-auth. So lets check it
2170 * before we bail out
2171 */
2172 lim_log(mac_ctx, LOG1, FL(
2173 "Session in reassoc state is %d"),
2174 session_entry->peSessionId);
2175
2176 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302177 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178 session_entry->limReAssocbssId,
2179 6)) {
2180 lim_print_mac_addr(mac_ctx,
2181 reassoc_req->bssDescription.
2182 bssId, LOGE);
2183 lim_log(mac_ctx, LOGP,
2184 FL("Unknown bssId in reassoc state"));
2185 ret_code = eSIR_SME_INVALID_PARAMETERS;
2186 goto end;
2187 }
2188
2189 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2190 session_entry);
2191 return;
2192 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 /*
2194 * Should not have received eWNI_SME_REASSOC_REQ
2195 */
2196 lim_log(mac_ctx, LOGE,
2197 FL("received unexpected SME_REASSOC_REQ in state %X"),
2198 session_entry->limSmeState);
2199 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2200
2201 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2202 goto end;
2203 }
2204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302205 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 session_entry->pLimReAssocReq->bssDescription.bssId,
2207 sizeof(tSirMacAddr));
2208
2209 session_entry->limReassocChannelId =
2210 session_entry->pLimReAssocReq->bssDescription.channelId;
2211
2212 session_entry->reAssocHtSupportedChannelWidthSet =
2213 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2214 session_entry->reAssocHtRecommendedTxWidthSet =
2215 session_entry->reAssocHtSupportedChannelWidthSet;
2216 session_entry->reAssocHtSecondaryChannelOffset =
2217 session_entry->pLimReAssocReq->cbMode;
2218
2219 session_entry->limReassocBssCaps =
2220 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2221 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2222 session_entry->currentOperChannel);
2223 local_pwr_constraint = reg_max;
2224
2225 lim_extract_ap_capability(mac_ctx,
2226 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2227 lim_get_ielen_from_bss_description(
2228 &session_entry->pLimReAssocReq->bssDescription),
2229 &session_entry->limReassocBssQosCaps,
2230 &session_entry->limReassocBssPropCap,
2231 &session_entry->gLimCurrentBssUapsd,
2232 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302233 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302235 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2236 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 /* Copy the SSID from session entry to local variable */
2238 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302239 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 reassoc_req->ssId.ssId,
2241 session_entry->limReassocSSID.length);
2242 if (session_entry->gLimCurrentBssUapsd) {
2243 session_entry->gUapsdPerAcBitmask =
2244 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2245 lim_log(mac_ctx, LOG1,
2246 FL("UAPSD flag for all AC - 0x%2x"),
2247 session_entry->gUapsdPerAcBitmask);
2248 }
2249
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302250 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 if (NULL == mlm_reassoc_req) {
2252 lim_log(mac_ctx, LOGP,
2253 FL("call to AllocateMemory failed for mlmReassocReq"));
2254
2255 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2256 goto end;
2257 }
2258
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302259 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2261
2262 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2263 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2264 eSIR_SUCCESS) {
2265 /*
2266 * Could not get ReassocFailureTimeout value
2267 * from CFG. Log error.
2268 */
2269 lim_log(mac_ctx, LOGP,
2270 FL("could not retrieve ReassocFailureTimeout value"));
2271 }
2272
2273 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2274 eSIR_SUCCESS) {
2275 /*
2276 * Could not get Capabilities value
2277 * from CFG. Log error.
2278 */
2279 lim_log(mac_ctx, LOGP, FL(
2280 "could not retrieve Capabilities value"));
2281 }
2282 mlm_reassoc_req->capabilityInfo = caps;
2283
2284 /* Update PE session_id */
2285 mlm_reassoc_req->sessionId = session_id;
2286
2287 /*
2288 * If telescopic beaconing is enabled, set listen interval to
2289 * WNI_CFG_TELE_BCN_MAX_LI
2290 */
2291 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2292 &tele_bcn_en) != eSIR_SUCCESS)
2293 lim_log(mac_ctx, LOGP,
2294 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2295
2296 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2297
2298 if (tele_bcn_en) {
2299 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2300 eSIR_SUCCESS)
2301 /*
2302 * Could not get ListenInterval value
2303 * from CFG. Log error.
2304 */
2305 lim_log(mac_ctx, LOGP,
2306 FL("could not retrieve ListenInterval"));
2307 } else {
2308 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2309 eSIR_SUCCESS)
2310 /*
2311 * Could not get ListenInterval value
2312 * from CFG. Log error.
2313 */
2314 lim_log(mac_ctx, LOGP,
2315 FL("could not retrieve ListenInterval"));
2316 }
2317
2318 mlm_reassoc_req->listenInterval = (uint16_t) val;
2319
2320 /* Indicate whether spectrum management is enabled */
2321 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2322
2323 /* Enable the spectrum management if this is a DFS channel */
2324 if (session_entry->country_info_present &&
2325 lim_isconnected_on_dfs_channel(
2326 session_entry->currentOperChannel))
2327 session_entry->spectrumMgtEnabled = true;
2328
2329 session_entry->limPrevSmeState = session_entry->limSmeState;
2330 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2331
2332 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2333 session_entry->peSessionId,
2334 session_entry->limSmeState));
2335
2336 lim_post_mlm_message(mac_ctx,
2337 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2338 return;
2339end:
2340 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302341 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 if (session_entry)
2343 session_entry->pLimReAssocReq = NULL;
2344 }
2345
2346 if (session_entry) {
2347 /*
2348 * error occurred after we determined the session so extract
2349 * session and transaction info from there
2350 */
2351 sme_session_id = session_entry->smeSessionId;
2352 transaction_id = session_entry->transactionId;
2353 } else
2354 /*
2355 * error occurred before or during the time we determined
2356 * the session so extract the session and transaction info
2357 * from the message
2358 */
2359 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2360 &sme_session_id, &transaction_id);
2361
2362 /*
2363 * Send Reassoc failure response to host
2364 * (note session_entry may be NULL, but that's OK)
2365 */
2366 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2367 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2368 session_entry, sme_session_id,
2369 transaction_id);
2370}
2371
2372bool send_disassoc_frame = 1;
2373/**
2374 * __lim_process_sme_disassoc_req()
2375 *
2376 ***FUNCTION:
2377 * This function is called to process SME_DISASSOC_REQ message
2378 * from HDD or upper layer application.
2379 *
2380 ***LOGIC:
2381 *
2382 ***ASSUMPTIONS:
2383 *
2384 ***NOTE:
2385 *
2386 * @param pMac Pointer to Global MAC structure
2387 * @param *pMsgBuf A pointer to the SME message buffer
2388 * @return None
2389 */
2390
2391static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2392{
2393 uint16_t disassocTrigger, reasonCode;
2394 tLimMlmDisassocReq *pMlmDisassocReq;
2395 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2396 tSirSmeDisassocReq smeDisassocReq;
2397 tpPESession psessionEntry = NULL;
2398 uint8_t sessionId;
2399 uint8_t smesessionId;
2400 uint16_t smetransactionId;
2401
2402 if (pMsgBuf == NULL) {
2403 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2404 return;
2405 }
2406
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302407 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 smesessionId = smeDisassocReq.sessionId;
2409 smetransactionId = smeDisassocReq.transactionId;
2410 if (!lim_is_sme_disassoc_req_valid(pMac,
2411 &smeDisassocReq,
2412 psessionEntry)) {
2413 PELOGE(lim_log(pMac, LOGE,
2414 FL("received invalid SME_DISASSOC_REQ message"));)
2415 if (pMac->lim.gLimRspReqd) {
2416 pMac->lim.gLimRspReqd = false;
2417
2418 retCode = eSIR_SME_INVALID_PARAMETERS;
2419 disassocTrigger = eLIM_HOST_DISASSOC;
2420 goto sendDisassoc;
2421 }
2422
2423 return;
2424 }
2425
2426 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002427 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 &sessionId);
2429 if (psessionEntry == NULL) {
2430 lim_log(pMac, LOGE,
2431 FL("session does not exist for given bssId "
2432 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002433 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 retCode = eSIR_SME_INVALID_PARAMETERS;
2435 disassocTrigger = eLIM_HOST_DISASSOC;
2436 goto sendDisassoc;
2437 }
2438 lim_log(pMac, LOG1,
2439 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2440 MAC_ADDRESS_STR), smesessionId,
2441 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2442 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002443 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444
2445#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2446 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2447 0, smeDisassocReq.reasonCode);
2448#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2449
2450 /* Update SME session Id and SME transaction ID */
2451
2452 psessionEntry->smeSessionId = smesessionId;
2453 psessionEntry->transactionId = smetransactionId;
2454
2455 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2456 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 switch (psessionEntry->limSmeState) {
2458 case eLIM_SME_ASSOCIATED_STATE:
2459 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002460 lim_log(pMac, LOG1,
2461 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2462 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 psessionEntry->limPrevSmeState =
2464 psessionEntry->limSmeState;
2465 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2466#ifdef FEATURE_WLAN_TDLS
2467 /* Delete all TDLS peers connected before leaving BSS */
2468 lim_delete_tdls_peers(pMac, psessionEntry);
2469#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002470 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2471 psessionEntry->peSessionId,
2472 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 break;
2474
2475 case eLIM_SME_WT_DEAUTH_STATE:
2476 /* PE shall still process the DISASSOC_REQ and proceed with
2477 * link tear down even if it had already sent a DEAUTH_IND to
2478 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2479 * its been set when PE entered WT_DEAUTH_STATE.
2480 */
2481 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2482 MTRACE(mac_trace
2483 (pMac, TRACE_CODE_SME_STATE,
2484 psessionEntry->peSessionId,
2485 psessionEntry->limSmeState));
2486 lim_log(pMac, LOG1,
2487 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2488 break;
2489
2490 case eLIM_SME_WT_DISASSOC_STATE:
2491 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2492 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2493 * PE can continue processing DISASSOC_REQ and send the response instead
2494 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2495 * for disassoc frame.
2496 *
2497 * It will send a disassoc, which is ok. However, we can use the global flag
2498 * sendDisassoc to not send disassoc frame.
2499 */
2500 lim_log(pMac, LOG1,
2501 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2502 break;
2503
2504 case eLIM_SME_JOIN_FAILURE_STATE: {
2505 /* Already in Disconnected State, return success */
2506 lim_log(pMac, LOG1,
2507 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2508 if (pMac->lim.gLimRspReqd) {
2509 retCode = eSIR_SME_SUCCESS;
2510 disassocTrigger = eLIM_HOST_DISASSOC;
2511 goto sendDisassoc;
2512 }
2513 }
2514 break;
2515 default:
2516 /**
2517 * STA is not currently associated.
2518 * Log error and send response to host
2519 */
2520 lim_log(pMac, LOGE,
2521 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2522 psessionEntry->limSmeState);
2523 lim_print_sme_state(pMac, LOGE,
2524 psessionEntry->limSmeState);
2525
2526 if (pMac->lim.gLimRspReqd) {
2527 if (psessionEntry->limSmeState !=
2528 eLIM_SME_WT_ASSOC_STATE)
2529 pMac->lim.gLimRspReqd = false;
2530
2531 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2532 disassocTrigger = eLIM_HOST_DISASSOC;
2533 goto sendDisassoc;
2534 }
2535
2536 return;
2537 }
2538
2539 break;
2540
2541 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 /* Fall through */
2543 break;
2544
2545 case eLIM_STA_IN_IBSS_ROLE:
2546 default:
2547 /* eLIM_UNKNOWN_ROLE */
2548 lim_log(pMac, LOGE,
2549 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2550 GET_LIM_SYSTEM_ROLE(psessionEntry));
2551
2552 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2553 disassocTrigger = eLIM_HOST_DISASSOC;
2554 goto sendDisassoc;
2555 } /* end switch (pMac->lim.gLimSystemRole) */
2556
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302557 disassocTrigger = eLIM_HOST_DISASSOC;
2558 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559
2560 if (smeDisassocReq.doNotSendOverTheAir) {
2561 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2562 send_disassoc_frame = 0;
2563 }
2564 /* Trigger Disassociation frame to peer MAC entity */
2565 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2566 " : %d, reasonCode : %d"),
2567 disassocTrigger, reasonCode);
2568
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302569 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 if (NULL == pMlmDisassocReq) {
2571 /* Log error */
2572 lim_log(pMac, LOGP,
2573 FL("call to AllocateMemory failed for mlmDisassocReq"));
2574
2575 return;
2576 }
2577
Anurag Chouhanc5548422016-02-24 18:33:27 +05302578 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002579 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580
2581 pMlmDisassocReq->reasonCode = reasonCode;
2582 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2583
2584 /* Update PE session ID */
2585 pMlmDisassocReq->sessionId = sessionId;
2586
2587 lim_post_mlm_message(pMac,
2588 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2589 return;
2590
2591sendDisassoc:
2592 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002593 lim_send_sme_disassoc_ntf(pMac,
2594 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 retCode,
2596 disassocTrigger,
2597 1, smesessionId, smetransactionId,
2598 psessionEntry);
2599 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002600 lim_send_sme_disassoc_ntf(pMac,
2601 smeDisassocReq.peer_macaddr.bytes,
2602 retCode, disassocTrigger, 1,
2603 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
2605} /*** end __lim_process_sme_disassoc_req() ***/
2606
2607/** -----------------------------------------------------------------
2608 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2609
2610 This function is called to process SME_DISASSOC_CNF message
2611 from HDD or upper layer application.
2612
2613 \param pMac - global mac structure
2614 \param pStaDs - station dph hash node
2615 \return none
2616 \sa
2617 ----------------------------------------------------------------- */
2618static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2619{
2620 tSirSmeDisassocCnf smeDisassocCnf;
2621 uint16_t aid;
2622 tpDphHashNode pStaDs;
2623 tpPESession psessionEntry;
2624 uint8_t sessionId;
2625
2626 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2627
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302628 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 sizeof(struct sSirSmeDisassocCnf));
2630
2631 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002632 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 &sessionId);
2634 if (psessionEntry == NULL) {
2635 lim_log(pMac, LOGE,
2636 FL("session does not exist for given bssId"));
2637 return;
2638 }
2639
2640 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2641 lim_log(pMac, LOGE,
2642 FL("received invalid SME_DISASSOC_CNF message"));
2643 return;
2644 }
2645#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2646 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2647 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2648 psessionEntry,
2649 (uint16_t) smeDisassocCnf.statusCode, 0);
2650 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2651 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2652 psessionEntry,
2653 (uint16_t) smeDisassocCnf.statusCode, 0);
2654#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2655
2656 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2657 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2659 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2660 && (psessionEntry->limSmeState !=
2661 eLIM_SME_WT_DEAUTH_STATE)) {
2662 lim_log(pMac, LOGE,
2663 FL
2664 ("received unexp SME_DISASSOC_CNF in state %X"),
2665 psessionEntry->limSmeState);
2666 lim_print_sme_state(pMac, LOGE,
2667 psessionEntry->limSmeState);
2668 return;
2669 }
2670 break;
2671
2672 case eLIM_AP_ROLE:
2673 /* Fall through */
2674 break;
2675
2676 case eLIM_STA_IN_IBSS_ROLE:
2677 default: /* eLIM_UNKNOWN_ROLE */
2678 lim_log(pMac, LOGE,
2679 FL("received unexpected SME_DISASSOC_CNF role %d"),
2680 GET_LIM_SYSTEM_ROLE(psessionEntry));
2681
2682 return;
2683 }
2684
2685 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2686 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2687 LIM_IS_AP_ROLE(psessionEntry)) {
2688 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002689 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 &psessionEntry->dph.dphHashTable);
2691 if (pStaDs == NULL) {
2692 lim_log(pMac, LOGE,
2693 FL("DISASSOC_CNF for a STA with no context, addr= "
2694 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002695 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 return;
2697 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302698
2699 if ((pStaDs->mlmStaContext.mlmState ==
2700 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2701 (pStaDs->mlmStaContext.mlmState ==
2702 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2703 lim_log(pMac, LOGE,
2704 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002705 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302706 pStaDs->mlmStaContext.mlmState);
2707 return;
2708 }
2709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 /* Delete FT session if there exists one */
2711 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2713
2714 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002715 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 }
2717
2718 return;
2719}
2720
2721/**
2722 * __lim_process_sme_deauth_req() - process sme deauth req
2723 * @mac_ctx: Pointer to Global MAC structure
2724 * @msg_buf: pointer to the SME message buffer
2725 *
2726 * This function is called to process SME_DEAUTH_REQ message
2727 * from HDD or upper layer application.
2728 *
2729 * Return: None
2730 */
2731
2732static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2733 uint32_t *msg_buf)
2734{
2735 uint16_t deauth_trigger, reason_code;
2736 tLimMlmDeauthReq *mlm_deauth_req;
2737 tSirSmeDeauthReq sme_deauth_req;
2738 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2739 tpPESession session_entry;
2740 uint8_t session_id; /* PE sessionId */
2741 uint8_t sme_session_id;
2742 uint16_t sme_transaction_id;
2743
2744 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2745
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302746 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 sme_session_id = sme_deauth_req.sessionId;
2748 sme_transaction_id = sme_deauth_req.transactionId;
2749
2750 /*
2751 * We need to get a session first but we don't even know
2752 * if the message is correct.
2753 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002754 session_entry = pe_find_session_by_bssid(mac_ctx,
2755 sme_deauth_req.bssid.bytes,
2756 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 if (session_entry == NULL) {
2758 lim_log(mac_ctx, LOGE,
2759 FL("session does not exist for given bssId"));
2760 ret_code = eSIR_SME_INVALID_PARAMETERS;
2761 deauth_trigger = eLIM_HOST_DEAUTH;
2762 goto send_deauth;
2763 }
2764
2765 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2766 session_entry)) {
2767 lim_log(mac_ctx, LOGE,
2768 FL("received invalid SME_DEAUTH_REQ message"));
2769 mac_ctx->lim.gLimRspReqd = false;
2770
2771 ret_code = eSIR_SME_INVALID_PARAMETERS;
2772 deauth_trigger = eLIM_HOST_DEAUTH;
2773 goto send_deauth;
2774 }
2775 lim_log(mac_ctx, LOG1,
2776 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2777 MAC_ADDRESS_STR), sme_session_id,
2778 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2779 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002780 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2782 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2783 session_entry, 0, sme_deauth_req.reasonCode);
2784#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2785
2786 /* Update SME session ID and Transaction ID */
2787 session_entry->smeSessionId = sme_session_id;
2788 session_entry->transactionId = sme_transaction_id;
2789
2790 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2791 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 switch (session_entry->limSmeState) {
2793 case eLIM_SME_ASSOCIATED_STATE:
2794 case eLIM_SME_LINK_EST_STATE:
2795 case eLIM_SME_WT_ASSOC_STATE:
2796 case eLIM_SME_JOIN_FAILURE_STATE:
2797 case eLIM_SME_IDLE_STATE:
2798 session_entry->limPrevSmeState =
2799 session_entry->limSmeState;
2800 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2801 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2802 session_entry->peSessionId,
2803 session_entry->limSmeState));
2804 /* Send Deauthentication request to MLM below */
2805 break;
2806 case eLIM_SME_WT_DEAUTH_STATE:
2807 case eLIM_SME_WT_DISASSOC_STATE:
2808 /*
2809 * PE Recieved a Deauth/Disassoc frame. Normally it get
2810 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2811 * Which means host is also trying to disconnect.
2812 * PE can continue processing DEAUTH_REQ and send
2813 * the response instead of failing the request.
2814 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2815 * was sent for deauth/disassoc frame.
2816 */
2817 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2818 lim_log(mac_ctx, LOG1, FL(
2819 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2820 break;
2821 default:
2822 /*
2823 * STA is not in a state to deauthenticate with
2824 * peer. Log error and send response to host.
2825 */
2826 lim_log(mac_ctx, LOGE, FL(
2827 "received unexp SME_DEAUTH_REQ in state %X"),
2828 session_entry->limSmeState);
2829 lim_print_sme_state(mac_ctx, LOGE,
2830 session_entry->limSmeState);
2831
2832 if (mac_ctx->lim.gLimRspReqd) {
2833 mac_ctx->lim.gLimRspReqd = false;
2834
2835 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2836 deauth_trigger = eLIM_HOST_DEAUTH;
2837
2838 /*
2839 * here we received deauth request from AP so sme state
2840 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2841 * delSta then mlm state should be
2842 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2843 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2844 * so the below condition captures the state where
2845 * delSta not done and firmware still in
2846 * connected state.
2847 */
2848 if (session_entry->limSmeState ==
2849 eLIM_SME_WT_DEAUTH_STATE &&
2850 session_entry->limMlmState !=
2851 eLIM_MLM_IDLE_STATE &&
2852 session_entry->limMlmState !=
2853 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2854 ret_code = eSIR_SME_DEAUTH_STATUS;
2855 goto send_deauth;
2856 }
2857 return;
2858 }
2859 break;
2860
2861 case eLIM_STA_IN_IBSS_ROLE:
2862 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2863 if (mac_ctx->lim.gLimRspReqd) {
2864 mac_ctx->lim.gLimRspReqd = false;
2865 ret_code = eSIR_SME_INVALID_PARAMETERS;
2866 deauth_trigger = eLIM_HOST_DEAUTH;
2867 goto send_deauth;
2868 }
2869 return;
2870 case eLIM_AP_ROLE:
2871 break;
2872 default:
2873 lim_log(mac_ctx, LOGE,
2874 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2875 GET_LIM_SYSTEM_ROLE(session_entry));
2876 if (mac_ctx->lim.gLimRspReqd) {
2877 mac_ctx->lim.gLimRspReqd = false;
2878 ret_code = eSIR_SME_INVALID_PARAMETERS;
2879 deauth_trigger = eLIM_HOST_DEAUTH;
2880 goto send_deauth;
2881 }
2882 return;
2883 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2884
2885 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2886 /* Deauthentication is triggered by Link Monitoring */
2887 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2888 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2889 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2890 } else {
2891 deauth_trigger = eLIM_HOST_DEAUTH;
2892 reason_code = sme_deauth_req.reasonCode;
2893 }
2894
2895 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302896 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 if (NULL == mlm_deauth_req) {
2898 lim_log(mac_ctx, LOGP,
2899 FL("call to AllocateMemory failed for mlmDeauthReq"));
2900 if (mac_ctx->lim.gLimRspReqd) {
2901 mac_ctx->lim.gLimRspReqd = false;
2902 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2903 deauth_trigger = eLIM_HOST_DEAUTH;
2904 goto send_deauth;
2905 }
2906 return;
2907 }
2908
Anurag Chouhanc5548422016-02-24 18:33:27 +05302909 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002910 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911
2912 mlm_deauth_req->reasonCode = reason_code;
2913 mlm_deauth_req->deauthTrigger = deauth_trigger;
2914
2915 /* Update PE session Id */
2916 mlm_deauth_req->sessionId = session_id;
2917
2918 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2919 (uint32_t *)mlm_deauth_req);
2920 return;
2921
2922send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002923 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2924 ret_code, deauth_trigger, 1,
2925 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926}
2927
2928/**
2929 * __lim_process_sme_set_context_req()
2930 *
2931 * @mac_ctx: Pointer to Global MAC structure
2932 * @msg_buf: pointer to the SME message buffer
2933 *
2934 * This function is called to process SME_SETCONTEXT_REQ message
2935 * from HDD or upper layer application.
2936 *
2937 * Return: None
2938 */
2939
2940static void
2941__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2942{
2943 tpSirSmeSetContextReq set_context_req;
2944 tLimMlmSetKeysReq *mlm_set_key_req;
2945 tpPESession session_entry;
2946 uint8_t session_id; /* PE sessionID */
2947 uint8_t sme_session_id;
2948 uint16_t sme_transaction_id;
2949
2950 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2951
2952 if (msg_buf == NULL) {
2953 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2954 return;
2955 }
2956
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302957 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 if (NULL == set_context_req) {
2959 lim_log(mac_ctx, LOGP, FL(
2960 "call to AllocateMemory failed for set_context_req"));
2961 return;
2962 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302963 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 sizeof(struct sSirSmeSetContextReq));
2965 sme_session_id = set_context_req->sessionId;
2966 sme_transaction_id = set_context_req->transactionId;
2967
2968 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2969 lim_log(mac_ctx, LOGW,
2970 FL("received invalid SME_SETCONTEXT_REQ message"));
2971 goto end;
2972 }
2973
2974 if (set_context_req->keyMaterial.numKeys >
2975 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2976 lim_log(mac_ctx, LOGE, FL(
2977 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2978 set_context_req->keyMaterial.numKeys);
2979 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002980 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 eSIR_SME_INVALID_PARAMETERS, NULL,
2982 sme_session_id, sme_transaction_id);
2983 goto end;
2984 }
2985
2986 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002987 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 if (session_entry == NULL) {
2989 lim_log(mac_ctx, LOGW,
2990 FL("Session does not exist for given BSSID"));
2991 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002992 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 eSIR_SME_INVALID_PARAMETERS, NULL,
2994 sme_session_id, sme_transaction_id);
2995 goto end;
2996 }
2997#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2998 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2999 session_entry, 0, 0);
3000#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3001
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003002 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3004 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003005 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3007 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303008 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009 if (NULL == mlm_set_key_req) {
3010 lim_log(mac_ctx, LOGP, FL(
3011 "mem alloc failed for mlmSetKeysReq"));
3012 goto end;
3013 }
3014 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3015 mlm_set_key_req->numKeys =
3016 set_context_req->keyMaterial.numKeys;
3017 if (mlm_set_key_req->numKeys >
3018 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3019 lim_log(mac_ctx, LOGP, FL(
3020 "no.of keys exceeded max num of default keys limit"));
3021 goto end;
3022 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303023 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003024 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303026 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 (uint8_t *) &set_context_req->keyMaterial.key,
3028 sizeof(tSirKeys) *
3029 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3030 numKeys : 1));
3031
3032 mlm_set_key_req->sessionId = session_id;
3033 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 lim_log(mac_ctx, LOG1, FL(
3035 "received SETCONTEXT_REQ message sessionId=%d"),
3036 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037
3038 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3039 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3040 LIM_IS_AP_ROLE(session_entry)) {
3041 if (set_context_req->keyMaterial.key[0].keyLength) {
3042 uint8_t key_id;
3043 key_id =
3044 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303045 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 &session_entry->WEPKeyMaterial[key_id],
3047 (uint8_t *) &set_context_req->keyMaterial,
3048 sizeof(tSirKeyMaterial));
3049 } else {
3050 uint32_t i;
3051 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3052 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303053 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 &mlm_set_key_req->key[i],
3055 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3056 sizeof(tSirKeys));
3057 }
3058 }
3059 }
3060 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3061 (uint32_t *) mlm_set_key_req);
3062 } else {
3063 lim_log(mac_ctx, LOGE, FL(
3064 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3065 GET_LIM_SYSTEM_ROLE(session_entry),
3066 session_entry->limSmeState);
3067 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3068
3069 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003070 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3072 session_entry, sme_session_id,
3073 sme_transaction_id);
3074 }
3075end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303076 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 return;
3078}
3079
3080/**
3081 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3082 *
3083 * @mac_ctx: Pointer to Global MAC structure
3084 * @msg_buf: pointer to the SME message buffer
3085 *
3086 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3087 * from HDD or upper layer application.
3088 *
3089 * Return: None
3090 */
3091
3092void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3093 uint32_t *msg_buf)
3094{
3095 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3096 tpDphHashNode sta_ds = NULL;
3097 tpPESession session_entry = NULL;
3098 tSap_Event sap_event;
3099 tpWLAN_SAPEventCB sap_event_cb = NULL;
3100 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3101 uint8_t session_id = CSR_SESSION_ID_INVALID;
3102 uint8_t assoc_id = 0;
3103 uint8_t sta_cnt = 0;
3104
3105 if (msg_buf == NULL) {
3106 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3107 return;
3108 }
3109
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303110 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 sizeof(struct sSirSmeGetAssocSTAsReq));
3112 /*
3113 * Get Associated stations from PE.
3114 * Find PE session Entry
3115 */
3116 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003117 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 &session_id);
3119 if (session_entry == NULL) {
3120 lim_log(mac_ctx, LOGE,
3121 FL("session does not exist for given bssId"));
3122 goto lim_assoc_sta_end;
3123 }
3124
3125 if (!LIM_IS_AP_ROLE(session_entry)) {
3126 lim_log(mac_ctx, LOGE, FL(
3127 "Received unexpected message in state %X, in role %X"),
3128 session_entry->limSmeState,
3129 GET_LIM_SYSTEM_ROLE(session_entry));
3130 goto lim_assoc_sta_end;
3131 }
3132 /* Retrieve values obtained in the request message */
3133 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3134 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3135
3136 if (NULL == assoc_sta_tmp)
3137 goto lim_assoc_sta_end;
3138 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3139 assoc_id++) {
3140 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3141 &session_entry->dph.dphHashTable);
3142 if (NULL == sta_ds)
3143 continue;
3144 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303145 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303147 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3149 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3150
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303151 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 (uint8_t *)&sta_ds->supportedRates,
3153 sizeof(tSirSupportedRates));
3154 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3155 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3156 assoc_sta_tmp->Support40Mhz =
3157 sta_ds->htDsssCckRate40MHzSupport;
3158
3159 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3160 sta_cnt + 1);
3161 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3162 MAC_ADDR_ARRAY(sta_ds->staAddr));
3163 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3164 sta_ds->assocId);
3165 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3166 sta_ds->staIndex);
3167 assoc_sta_tmp++;
3168 sta_cnt++;
3169 }
3170 }
3171lim_assoc_sta_end:
3172 /*
3173 * Call hdd callback with sap event to send the list of
3174 * associated stations from PE
3175 */
3176 if (sap_event_cb != NULL) {
3177 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3178 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303179 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3181 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3182 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3183 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3184 }
3185}
3186
3187/**
3188 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3189 *
3190 * @mac_ctx: Pointer to Global MAC structure
3191 * @msg_buf: pointer to WPS PBC overlap query message
3192 *
3193 * This function parses get WPS PBC overlap information
3194 * message and call callback to pass WPS PBC overlap
3195 * information back to hdd.
3196 *
3197 * Return: None
3198 */
3199void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3200 uint32_t *msg_buf)
3201{
3202 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3203 tpPESession session_entry = NULL;
3204 tSap_Event sap_event;
3205 tpWLAN_SAPEventCB sap_event_cb = NULL;
3206 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3208
3209 if (msg_buf == NULL) {
3210 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3211 return;
3212 }
3213
3214 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303215 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303217 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3219 /*
3220 * Get Associated stations from PE
3221 * Find PE session Entry
3222 */
3223 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003224 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 if (session_entry == NULL) {
3226 lim_log(mac_ctx, LOGE,
3227 FL("session does not exist for given bssId"));
3228 goto lim_get_wpspbc_sessions_end;
3229 }
3230
3231 if (!LIM_IS_AP_ROLE(session_entry)) {
3232 lim_log(mac_ctx, LOGE,
3233 FL("Received unexpected message in role %X"),
3234 GET_LIM_SYSTEM_ROLE(session_entry));
3235 goto lim_get_wpspbc_sessions_end;
3236 }
3237 /*
3238 * Call hdd callback with sap event to send the
3239 * WPS PBC overlap information
3240 */
3241 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303242 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
Anurag Chouhanc5548422016-02-24 18:33:27 +05303244 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003246 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 sap_get_wpspbc_event->UUID_E,
3248 &sap_get_wpspbc_event->wpsPBCOverlap,
3249 session_entry);
3250 } else {
3251 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003252 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 session_entry);
3254 /* don't have to inform the HDD/Host */
3255 return;
3256 }
3257
3258 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3259 sap_get_wpspbc_event->wpsPBCOverlap);
3260 lim_print_mac_addr(mac_ctx,
3261 sap_get_wpspbc_event->addr.bytes, LOG4);
3262
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303263 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264
3265lim_get_wpspbc_sessions_end:
3266 sap_event_cb =
3267 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3268 if (NULL != sap_event_cb)
3269 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3270}
3271
3272/**
3273 * __lim_counter_measures()
3274 *
3275 * FUNCTION:
3276 * This function is called to "implement" MIC counter measure
3277 * and is *temporary* only
3278 *
3279 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3280 * we don't do the proper STA disassoc sequence since the
3281 * BSS will be stoped anyway
3282 *
3283 ***ASSUMPTIONS:
3284 *
3285 ***NOTE:
3286 *
3287 * @param pMac Pointer to Global MAC structure
3288 * @return None
3289 */
3290
3291static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3292{
3293 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003294 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3296 mac, psessionEntry, false);
3297};
3298
3299void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3300{
3301 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3302 tpPESession psessionEntry;
3303 uint8_t sessionId; /* PE sessionId */
3304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303305 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 sizeof(struct sSirSmeTkipCntrMeasReq));
3307
3308 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003309 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 if (NULL == psessionEntry) {
3311 lim_log(pMac, LOGE,
3312 FL("session does not exist for given BSSID "));
3313 return;
3314 }
3315
3316 if (tkipCntrMeasReq.bEnable)
3317 __lim_counter_measures(pMac, psessionEntry);
3318
3319 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3320}
3321
3322static void
3323__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3324{
3325 tSirSmeStopBssReq stopBssReq;
3326 tSirRetStatus status;
3327 tLimSmeStates prevState;
3328 tpPESession psessionEntry;
3329 uint8_t smesessionId;
3330 uint8_t sessionId;
3331 uint16_t smetransactionId;
3332 uint8_t i = 0;
3333 tpDphHashNode pStaDs = NULL;
3334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303335 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 smesessionId = stopBssReq.sessionId;
3337 smetransactionId = stopBssReq.transactionId;
3338
3339 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3340 PELOGW(lim_log(pMac, LOGW,
3341 FL("received invalid SME_STOP_BSS_REQ message"));)
3342 /* Send Stop BSS response to host */
3343 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3344 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3345 smetransactionId);
3346 return;
3347 }
3348
3349 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003350 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 &sessionId);
3352 if (psessionEntry == NULL) {
3353 lim_log(pMac, LOGW,
3354 FL("session does not exist for given BSSID "));
3355 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3356 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3357 smetransactionId);
3358 return;
3359 }
3360#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3361 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3362 0, 0);
3363#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3364
3365 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3366 LIM_IS_STA_ROLE(psessionEntry)) {
3367 /**
3368 * Should not have received STOP_BSS_REQ in states
3369 * other than 'normal' state or on STA in Infrastructure
3370 * mode. Log error and return response to host.
3371 */
3372 lim_log(pMac, LOGE,
3373 FL
3374 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3375 psessionEntry->limSmeState,
3376 GET_LIM_SYSTEM_ROLE(psessionEntry));
3377 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3378 /* / Send Stop BSS response to host */
3379 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3380 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3381 smetransactionId);
3382 return;
3383 }
3384
3385 if (LIM_IS_AP_ROLE(psessionEntry))
3386 lim_wpspbc_close(pMac, psessionEntry);
3387
3388 lim_log(pMac, LOGW,
3389 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3390 stopBssReq.reasonCode);
3391
3392 prevState = psessionEntry->limSmeState;
3393
3394 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3395 MTRACE(mac_trace
3396 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3397 psessionEntry->limSmeState));
3398
3399 /* Update SME session Id and Transaction Id */
3400 psessionEntry->smeSessionId = smesessionId;
3401 psessionEntry->transactionId = smetransactionId;
3402
3403 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003404 if (!LIM_IS_IBSS_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3406 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3407 /* Send disassoc all stations associated thru TKIP */
3408 __lim_counter_measures(pMac, psessionEntry);
3409 else
3410 lim_send_disassoc_mgmt_frame(pMac,
3411 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3412 bcAddr, psessionEntry, false);
3413 }
3414
3415 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303416 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 psessionEntry->addIeParams.probeRespDataLen = 0;
3418 psessionEntry->addIeParams.probeRespData_buff = NULL;
3419
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303420 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 psessionEntry->addIeParams.assocRespDataLen = 0;
3422 psessionEntry->addIeParams.assocRespData_buff = NULL;
3423
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303424 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3426 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3427
3428 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3429 pMac->lim.gLimIbssCoalescingHappened = false;
3430
3431 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3432 pStaDs =
3433 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3434 if (NULL == pStaDs)
3435 continue;
3436 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3437 if (eSIR_SUCCESS == status) {
3438 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3439 pStaDs->assocId, psessionEntry);
3440 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3441 } else {
3442 lim_log(pMac, LOGE,
3443 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303444 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 }
3446 }
3447 /* send a delBss to HAL and wait for a response */
3448 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3449
3450 if (status != eSIR_SUCCESS) {
3451 PELOGE(lim_log
3452 (pMac, LOGE, FL("delBss failed for bss %d"),
3453 psessionEntry->bssIdx);
3454 )
3455 psessionEntry->limSmeState = prevState;
3456
3457 MTRACE(mac_trace
3458 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3459 psessionEntry->limSmeState));
3460
3461 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3462 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3463 smetransactionId);
3464 }
3465}
3466
3467/**
3468 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3469 * @pMac: Global MAC context
3470 * @pMsg: Message from SME
3471 *
3472 * Wrapper for the function __lim_handle_sme_stop_bss_request
3473 * This message will be defered until softmac come out of
3474 * scan mode. Message should be handled even if we have
3475 * detected radar in the current operating channel.
3476 *
3477 * Return: true - If we consumed the buffer
3478 * false - If have defered the message.
3479 */
3480
3481static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3482{
3483 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3484 /**
3485 * If message defered, buffer is not consumed yet.
3486 * So return false
3487 */
3488 return false;
3489 }
3490 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3491 return true;
3492} /*** end __lim_process_sme_stop_bss_req() ***/
3493
3494void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3495 uint32_t body, tpPESession psessionEntry)
3496{
3497
3498 (void)body;
3499 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3500 lim_ibss_delete(pMac, psessionEntry);
3501 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3502 lim_delete_pre_auth_list(pMac);
3503 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3504 psessionEntry->smeSessionId,
3505 psessionEntry->transactionId);
3506 return;
3507}
3508
3509/**
3510 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3511 *
3512 * @mac_ctx: pointer to mac context
3513 * @msg_type: message type
3514 * @msg_buf: pointer to the SME message buffer
3515 *
3516 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3517 * in BTAMP AP.
3518 *
3519 * Return: None
3520 */
3521
3522void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3523 uint32_t *msg_buf)
3524{
3525 tSirSmeAssocCnf assoc_cnf;
3526 tpDphHashNode sta_ds = NULL;
3527 tpPESession session_entry = NULL;
3528 uint8_t session_id;
3529 tpSirAssocReq assoc_req;
3530
3531 if (msg_buf == NULL) {
3532 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3533 goto end;
3534 }
3535
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303536 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3538 lim_log(mac_ctx, LOGE,
3539 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3540 goto end;
3541 }
3542
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003543 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 &session_id);
3545 if (session_entry == NULL) {
3546 lim_log(mac_ctx, LOGE,
3547 FL("session does not exist for given bssId"));
3548 goto end;
3549 }
3550
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003551 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3553 (session_entry->limSmeState !=
3554 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3555 lim_log(mac_ctx, LOGE, FL(
3556 "Rcvd unexpected msg %X in state %X, in role %X"),
3557 msg_type, session_entry->limSmeState,
3558 GET_LIM_SYSTEM_ROLE(session_entry));
3559 goto end;
3560 }
3561 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3562 &session_entry->dph.dphHashTable);
3563 if (sta_ds == NULL) {
3564 lim_log(mac_ctx, LOGE, FL(
3565 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3566 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003567 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568
3569 /*
3570 * send a DISASSOC_IND message to WSM to make sure
3571 * the state in WSM and LIM is the same
3572 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003573 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 eSIR_SME_STA_NOT_ASSOCIATED,
3575 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3576 session_entry->smeSessionId,
3577 session_entry->transactionId,
3578 session_entry);
3579 goto end;
3580 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303581 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003582 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303583 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 lim_log(mac_ctx, LOG1, FL(
3585 "peerMacAddr mismatched for aid %d, peer "),
3586 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003587 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 goto end;
3589 }
3590
3591 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3592 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3593 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3594 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3595 (msg_type != eWNI_SME_ASSOC_CNF))) {
3596 lim_log(mac_ctx, LOG1, FL(
3597 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3598 "StaD mlmState : %d"),
3599 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003600 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 goto end;
3602 }
3603 /*
3604 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3605 * has been received
3606 */
3607 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3608 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3609 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3610
3611 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3612 /*
3613 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3614 * when it had received Assoc Request frame. Now, PE just needs
3615 * to send association rsp frame to the requesting BTAMP-STA.
3616 */
3617 sta_ds->mlmStaContext.mlmState =
3618 eLIM_MLM_LINK_ESTABLISHED_STATE;
3619 lim_log(mac_ctx, LOG1,
3620 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3621 sta_ds->assocId);
3622 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3623 sta_ds->assocId, sta_ds->staAddr,
3624 sta_ds->mlmStaContext.subType, sta_ds,
3625 session_entry);
3626 goto end;
3627 } else {
3628 /*
3629 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3630 * to be associated since the HAL sta entry is created for
3631 * denied STA we need to remove this HAL entry.
3632 * So to do that set updateContext to 1
3633 */
3634 if (!sta_ds->mlmStaContext.updateContext)
3635 sta_ds->mlmStaContext.updateContext = 1;
3636 lim_log(mac_ctx, LOG1,
3637 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3638 assoc_cnf.statusCode, sta_ds->assocId);
3639 lim_reject_association(mac_ctx, sta_ds->staAddr,
3640 sta_ds->mlmStaContext.subType,
3641 true, sta_ds->mlmStaContext.authType,
3642 sta_ds->assocId, true,
3643 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3644 session_entry);
3645 }
3646end:
3647 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3648 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3649 assoc_req = (tpSirAssocReq)
3650 session_entry->parsedAssocReq[sta_ds->assocId];
3651 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303652 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 assoc_req->assocReqFrame = NULL;
3654 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303655 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3657 }
3658}
3659
3660static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3661{
3662 tpDphHashNode pStaDs;
3663 tSirMacAddr peerMac;
3664 tpSirAddtsReq pSirAddts;
3665 uint32_t timeout;
3666 tpPESession psessionEntry;
3667 uint8_t sessionId; /* PE sessionId */
3668 uint8_t smesessionId;
3669 uint16_t smetransactionId;
3670
3671 if (pMsgBuf == NULL) {
3672 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3673 return;
3674 }
3675
3676 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3677 &smetransactionId);
3678
3679 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3680
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003681 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3682 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 if (psessionEntry == NULL) {
3684 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3685 return;
3686 }
3687#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3688 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3689 0);
3690#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3691
3692 /* if sta
3693 * - verify assoc state
3694 * - send addts request to ap
3695 * - wait for addts response from ap
3696 * if ap, just ignore with error log
3697 */
3698 PELOG1(lim_log(pMac, LOG1,
3699 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3700 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3701 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3702 )
3703
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003704 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3706 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3707 psessionEntry, pSirAddts->req.tspec,
3708 smesessionId, smetransactionId);
3709 return;
3710 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711
3712 pStaDs =
3713 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3714 &psessionEntry->dph.dphHashTable);
3715
3716 if (pStaDs == NULL) {
3717 PELOGE(lim_log
3718 (pMac, LOGE, "Cannot find AP context for addts req");
3719 )
3720 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3721 psessionEntry, pSirAddts->req.tspec,
3722 smesessionId, smetransactionId);
3723 return;
3724 }
3725
3726 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3727 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3728 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3729 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3730 psessionEntry, pSirAddts->req.tspec,
3731 smesessionId, smetransactionId);
3732 return;
3733 }
3734
3735 pSirAddts->req.wsmTspecPresent = 0;
3736 pSirAddts->req.wmeTspecPresent = 0;
3737 pSirAddts->req.lleTspecPresent = 0;
3738
3739 if ((pStaDs->wsmEnabled) &&
3740 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3741 SIR_MAC_ACCESSPOLICY_EDCA))
3742 pSirAddts->req.wsmTspecPresent = 1;
3743 else if (pStaDs->wmeEnabled)
3744 pSirAddts->req.wmeTspecPresent = 1;
3745 else if (pStaDs->lleEnabled)
3746 pSirAddts->req.lleTspecPresent = 1;
3747 else {
3748 PELOGW(lim_log
3749 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3750 )
3751 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3752 psessionEntry, pSirAddts->req.tspec,
3753 smesessionId, smetransactionId);
3754 return;
3755 }
3756
3757 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3758 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3759 lim_log(pMac, LOGE,
3760 "AddTs received in invalid LIMsme state (%d)",
3761 psessionEntry->limSmeState);
3762 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3763 psessionEntry, pSirAddts->req.tspec,
3764 smesessionId, smetransactionId);
3765 return;
3766 }
3767
3768 if (pMac->lim.gLimAddtsSent) {
3769 lim_log(pMac, LOGE,
3770 "Addts (token %d, tsid %d, up %d) is still pending",
3771 pMac->lim.gLimAddtsReq.req.dialogToken,
3772 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3773 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3774 userPrio);
3775 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3776 psessionEntry, pSirAddts->req.tspec,
3777 smesessionId, smetransactionId);
3778 return;
3779 }
3780
3781 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3782
3783 /* save the addts request */
3784 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303785 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3787
3788 /* ship out the message now */
3789 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3790 psessionEntry);
3791 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3792 /* start a timer to wait for the response */
3793 if (pSirAddts->timeout)
3794 timeout = pSirAddts->timeout;
3795 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3796 eSIR_SUCCESS) {
3797 lim_log(pMac, LOGP,
3798 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3799 WNI_CFG_ADDTS_RSP_TIMEOUT);
3800 return;
3801 }
3802
3803 timeout = SYS_MS_TO_TICKS(timeout);
3804 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3805 != TX_SUCCESS) {
3806 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3807 return;
3808 }
3809 pMac->lim.gLimAddtsRspTimerCount++;
3810 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3811 pMac->lim.gLimAddtsRspTimerCount) !=
3812 TX_SUCCESS) {
3813 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3814 return;
3815 }
3816 MTRACE(mac_trace
3817 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3818 eLIM_ADDTS_RSP_TIMER));
3819
3820 /* add the sessionId to the timer object */
3821 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3822 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3823 TX_SUCCESS) {
3824 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3825 return;
3826 }
3827 return;
3828}
3829
3830static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3831{
3832 tSirMacAddr peerMacAddr;
3833 uint8_t ac;
3834 tSirMacTSInfo *pTsinfo;
3835 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3836 tpDphHashNode pStaDs = NULL;
3837 tpPESession psessionEntry;
3838 uint8_t sessionId;
3839 uint32_t status = eSIR_SUCCESS;
3840 uint8_t smesessionId;
3841 uint16_t smetransactionId;
3842
3843 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3844 &smetransactionId);
3845
3846 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003847 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 &sessionId);
3849 if (psessionEntry == NULL) {
3850 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3851 status = eSIR_FAILURE;
3852 goto end;
3853 }
3854#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3855 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3856 0);
3857#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3858
3859 if (eSIR_SUCCESS !=
3860 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3861 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3862 status = eSIR_FAILURE;
3863 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3864 smesessionId, smetransactionId);
3865 return;
3866 }
3867
3868 lim_log(pMac, LOG1,
3869 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3870 MAC_ADDRESS_STR),
3871 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3872
3873 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3874 pDeltsReq->req.wmeTspecPresent,
3875 &pDeltsReq->req.tsinfo,
3876 &pDeltsReq->req.tspec, psessionEntry);
3877
3878 pTsinfo =
3879 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3880 tsinfo : &pDeltsReq->req.tsinfo;
3881
3882 /* We've successfully send DELTS frame to AP. Update the
3883 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3884 * is no longer trigger enabled or delivery enabled
3885 */
3886 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3887 pTsinfo, CLEAR_UAPSD_MASK);
3888
3889 /* We're deleting the TSPEC, so this particular AC is no longer
3890 * admitted. PE needs to downgrade the EDCA
3891 * parameters(for the AC for which TS is being deleted) to the
3892 * next best AC for which ACM is not enabled, and send the
3893 * updated values to HAL.
3894 */
3895 ac = upToAc(pTsinfo->traffic.userPrio);
3896
3897 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3898 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3899 ~(1 << ac);
3900 } else if (pTsinfo->traffic.direction ==
3901 SIR_MAC_DIRECTION_DNLINK) {
3902 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3903 ~(1 << ac);
3904 } else if (pTsinfo->traffic.direction ==
3905 SIR_MAC_DIRECTION_BIDIR) {
3906 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3907 ~(1 << ac);
3908 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3909 ~(1 << ac);
3910 }
3911
3912 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3913 psessionEntry);
3914
3915 pStaDs =
3916 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3917 &psessionEntry->dph.dphHashTable);
3918 if (pStaDs != NULL) {
3919 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3920 pStaDs->bssId);
3921 status = eSIR_SUCCESS;
3922 } else {
3923 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3924 status = eSIR_FAILURE;
3925 }
3926#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928#endif
3929
3930 /* send an sme response back */
3931end:
3932 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3933 smesessionId, smetransactionId);
3934}
3935
3936void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3937{
3938 /* fetch the sessionEntry based on the sessionId */
3939 tpPESession psessionEntry;
3940 psessionEntry = pe_find_session_by_session_id(pMac,
3941 pMac->lim.limTimers.gLimAddtsRspTimer.
3942 sessionId);
3943 if (psessionEntry == NULL) {
3944 lim_log(pMac, LOGP,
3945 FL("Session Does not exist for given sessionID"));
3946 return;
3947 }
3948
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003949 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3951 GET_LIM_SYSTEM_ROLE(psessionEntry));
3952 pMac->lim.gLimAddtsSent = false;
3953 return;
3954 }
3955
3956 if (!pMac->lim.gLimAddtsSent) {
3957 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3958 return;
3959 }
3960
3961 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3962 lim_log(pMac, LOGE,
3963 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3964 pMac->lim.gLimAddtsRspTimerCount);
3965 return;
3966 }
3967 /* this a real response timeout */
3968 pMac->lim.gLimAddtsSent = false;
3969 pMac->lim.gLimAddtsRspTimerCount++;
3970
3971 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3972 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3973 psessionEntry->smeSessionId,
3974 psessionEntry->transactionId);
3975}
3976
3977/**
3978 * __lim_process_sme_get_statistics_request()
3979 *
3980 ***FUNCTION:
3981 *
3982 *
3983 ***NOTE:
3984 *
3985 * @param pMac Pointer to Global MAC structure
3986 * @param *pMsgBuf A pointer to the SME message buffer
3987 * @return None
3988 */
3989static void
3990__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3991{
3992 tpAniGetPEStatsReq pPEStatsReq;
3993 tSirMsgQ msgQ;
3994
3995 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3996
3997 msgQ.type = WMA_GET_STATISTICS_REQ;
3998
3999 msgQ.reserved = 0;
4000 msgQ.bodyptr = pMsgBuf;
4001 msgQ.bodyval = 0;
4002 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4003
4004 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304005 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 pMsgBuf = NULL;
4007 lim_log(pMac, LOGP, "Unable to forward request");
4008 return;
4009 }
4010
4011 return;
4012}
4013
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004014#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004016 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004018 * @pMac: Pointer to Global MAC structure
4019 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004021 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 */
4023static void
4024__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4025{
4026 tSirMsgQ msgQ;
4027
4028 msgQ.type = WMA_TSM_STATS_REQ;
4029 msgQ.reserved = 0;
4030 msgQ.bodyptr = pMsgBuf;
4031 msgQ.bodyval = 0;
4032 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4033
4034 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304035 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 pMsgBuf = NULL;
4037 lim_log(pMac, LOGP, "Unable to forward request");
4038 return;
4039 }
4040}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004041#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042
4043static void
4044__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4045{
4046 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4047 tpPESession psessionEntry;
4048 uint8_t sessionId; /* PE sessionID */
4049
4050 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4051
4052 if (pMsgBuf == NULL) {
4053 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4054 return;
4055 }
4056
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304057 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 if (NULL == pUpdateAPWPSIEsReq) {
4059 lim_log(pMac, LOGP,
4060 FL
4061 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4062 return;
4063 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304064 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 sizeof(struct sSirUpdateAPWPSIEsReq));
4066
4067 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004068 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 &sessionId);
4070 if (psessionEntry == NULL) {
4071 lim_log(pMac, LOGW,
4072 FL("Session does not exist for given BSSID"));
4073 goto end;
4074 }
4075
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304076 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 sizeof(tSirAPWPSIEs));
4078
4079 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4080 lim_send_beacon_ind(pMac, psessionEntry);
4081
4082end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304083 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 return;
4085}
4086
4087void
4088lim_send_vdev_restart(tpAniSirGlobal pMac,
4089 tpPESession psessionEntry, uint8_t sessionId)
4090{
4091 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4092 tSirMsgQ msgQ;
4093 tSirRetStatus retCode = eSIR_SUCCESS;
4094
4095 if (psessionEntry == NULL) {
4096 PELOGE(lim_log
4097 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4098 __LINE__);
4099 )
4100 return;
4101 }
4102
4103 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304104 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 if (NULL == pHalHiddenSsidVdevRestart) {
4106 PELOGE(lim_log
4107 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4108 __func__, __LINE__);
4109 )
4110 return;
4111 }
4112
4113 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4114 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4115
4116 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4117 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4118 msgQ.bodyval = 0;
4119
4120 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4121 if (eSIR_SUCCESS != retCode) {
4122 PELOGE(lim_log
4123 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4124 __LINE__);
4125 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304126 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 }
4128}
4129
4130static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4131{
4132 tpSirUpdateParams pUpdateParams;
4133 tpPESession psessionEntry;
4134
4135 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4136
4137 if (pMsgBuf == NULL) {
4138 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4139 return;
4140 }
4141
4142 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4143
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004144 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 pUpdateParams->sessionId);
4146 if (psessionEntry == NULL) {
4147 lim_log(pMac, LOGW,
4148 "Session does not exist for given sessionId %d",
4149 pUpdateParams->sessionId);
4150 return;
4151 }
4152
4153 /* Update the session entry */
4154 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4155
4156 /* Send vdev restart */
4157 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4158
4159 /* Update beacon */
4160 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4161 lim_send_beacon_ind(pMac, psessionEntry);
4162
4163 return;
4164} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4165
4166static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4167{
4168 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4169 tpPESession psessionEntry;
4170 uint8_t sessionId; /* PE sessionID */
4171
4172 if (pMsgBuf == NULL) {
4173 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4174 return;
4175 }
4176
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304177 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 if (NULL == pUpdateAPWPARSNIEsReq) {
4179 lim_log(pMac, LOGP,
4180 FL
4181 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4182 return;
4183 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304184 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4186
4187 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004188 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 &sessionId);
4190 if (psessionEntry == NULL) {
4191 lim_log(pMac, LOGW,
4192 FL("Session does not exist for given BSSID"));
4193 goto end;
4194 }
4195
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304196 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4198
4199 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4200 &psessionEntry->
4201 pLimStartBssReq->rsnIE,
4202 psessionEntry);
4203
4204 psessionEntry->pLimStartBssReq->privacy = 1;
4205 psessionEntry->privacy = 1;
4206
4207 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4208 lim_send_beacon_ind(pMac, psessionEntry);
4209
4210end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304211 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 return;
4213} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4214
4215/*
4216 Update the beacon Interval dynamically if beaconInterval is different in MCC
4217 */
4218static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4219{
4220 tpSirChangeBIParams pChangeBIParams;
4221 tpPESession psessionEntry;
4222 uint8_t sessionId = 0;
4223 tUpdateBeaconParams beaconParams;
4224
4225 PELOG1(lim_log(pMac, LOG1,
4226 FL("received Update Beacon Interval message"));
4227 );
4228
4229 if (pMsgBuf == NULL) {
4230 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4231 return;
4232 }
4233
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304234 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4236
4237 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004238 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 &sessionId);
4240 if (psessionEntry == NULL) {
4241 lim_log(pMac, LOGE,
4242 FL("Session does not exist for given BSSID"));
4243 return;
4244 }
4245
4246 /*Update sessionEntry Beacon Interval */
4247 if (psessionEntry->beaconParams.beaconInterval !=
4248 pChangeBIParams->beaconInterval) {
4249 psessionEntry->beaconParams.beaconInterval =
4250 pChangeBIParams->beaconInterval;
4251 }
4252
4253 /*Update sch beaconInterval */
4254 if (pMac->sch.schObject.gSchBeaconInterval !=
4255 pChangeBIParams->beaconInterval) {
4256 pMac->sch.schObject.gSchBeaconInterval =
4257 pChangeBIParams->beaconInterval;
4258
4259 PELOG1(lim_log(pMac, LOG1,
4260 FL
4261 ("LIM send update BeaconInterval Indication : %d"),
4262 pChangeBIParams->beaconInterval);
4263 );
4264
4265 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4266 /* Update beacon */
4267 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4268
4269 beaconParams.bssIdx = psessionEntry->bssIdx;
4270 /* Set change in beacon Interval */
4271 beaconParams.beaconInterval =
4272 pChangeBIParams->beaconInterval;
4273 beaconParams.paramChangeBitmap =
4274 PARAM_BCN_INTERVAL_CHANGED;
4275 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4276 }
4277 }
4278
4279 return;
4280} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4281
4282#ifdef QCA_HT_2040_COEX
4283static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4284 uint32_t *pMsgBuf)
4285{
4286 tpSirSetHT2040Mode pSetHT2040Mode;
4287 tpPESession psessionEntry;
4288 uint8_t sessionId = 0;
4289 cds_msg_t msg;
4290 tUpdateVHTOpMode *pHtOpMode = NULL;
4291 uint16_t staId = 0;
4292 tpDphHashNode pStaDs = NULL;
4293
4294 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4295 if (pMsgBuf == NULL) {
4296 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4297 return;
4298 }
4299
4300 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4301
4302 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004303 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 &sessionId);
4305 if (psessionEntry == NULL) {
4306 lim_log(pMac, LOG1,
4307 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004308 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 return;
4310 }
4311
4312 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4313 pSetHT2040Mode->cbMode);
4314 /*Update sessionEntry HT related fields */
4315 switch (pSetHT2040Mode->cbMode) {
4316 case PHY_SINGLE_CHANNEL_CENTERED:
4317 psessionEntry->htSecondaryChannelOffset =
4318 PHY_SINGLE_CHANNEL_CENTERED;
4319 psessionEntry->htRecommendedTxWidthSet = 0;
4320 if (pSetHT2040Mode->obssEnabled)
4321 psessionEntry->htSupportedChannelWidthSet
4322 = eHT_CHANNEL_WIDTH_40MHZ;
4323 else
4324 psessionEntry->htSupportedChannelWidthSet
4325 = eHT_CHANNEL_WIDTH_20MHZ;
4326 break;
4327 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4328 psessionEntry->htSecondaryChannelOffset =
4329 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4330 psessionEntry->htRecommendedTxWidthSet = 1;
4331 break;
4332 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4333 psessionEntry->htSecondaryChannelOffset =
4334 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4335 psessionEntry->htRecommendedTxWidthSet = 1;
4336 break;
4337 default:
4338 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4339 return;
4340 }
4341
4342 /* Update beacon */
4343 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4344 lim_send_beacon_ind(pMac, psessionEntry);
4345
4346 /* update OP Mode for each associated peer */
4347 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4348 pStaDs = dph_get_hash_entry(pMac, staId,
4349 &psessionEntry->dph.dphHashTable);
4350 if (NULL == pStaDs)
4351 continue;
4352
4353 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304354 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355 if (NULL == pHtOpMode) {
4356 lim_log(pMac, LOGE,
4357 FL
4358 ("%s: Not able to allocate memory for setting OP mode"),
4359 __func__);
4360 return;
4361 }
4362 pHtOpMode->opMode =
4363 (psessionEntry->htSecondaryChannelOffset ==
4364 PHY_SINGLE_CHANNEL_CENTERED) ?
4365 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4366 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304367 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 sizeof(tSirMacAddr));
4369 pHtOpMode->smesessionId = sessionId;
4370
4371 msg.type = WMA_UPDATE_OP_MODE;
4372 msg.reserved = 0;
4373 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304374 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304375 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 lim_log(pMac, LOGE,
4377 FL
4378 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4379 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304380 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 return;
4382 }
4383 lim_log(pMac, LOG1,
4384 FL
4385 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4386 __func__, pHtOpMode->opMode, staId);
4387
4388 } else
4389 lim_log(pMac, LOG1,
4390 FL("%s: station %d does not support HT40\n"),
4391 __func__, staId);
4392 }
4393
4394 return;
4395}
4396#endif
4397
4398/* -------------------------------------------------------------------- */
4399/**
4400 * __lim_process_report_message
4401 *
4402 * FUNCTION: Processes the next received Radio Resource Management message
4403 *
4404 * LOGIC:
4405 *
4406 * ASSUMPTIONS:
4407 *
4408 * NOTE:
4409 *
4410 * @param None
4411 * @return None
4412 */
4413
4414void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4415{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 switch (pMsg->type) {
4417 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4418 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4419 break;
4420 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004422 break;
4423 default:
4424 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426}
4427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428/* -------------------------------------------------------------------- */
4429/**
4430 * lim_send_set_max_tx_power_req
4431 *
4432 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4433 *
4434 * LOGIC:
4435 *
4436 * ASSUMPTIONS:
4437 *
4438 * NOTE:
4439 *
4440 * @param txPower txPower to be set.
4441 * @param pSessionEntry session entry.
4442 * @return None
4443 */
4444tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004445lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 tpPESession pSessionEntry)
4447{
4448 tpMaxTxPowerParams pMaxTxParams = NULL;
4449 tSirRetStatus retCode = eSIR_SUCCESS;
4450 tSirMsgQ msgQ;
4451
4452 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304453 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454 return eSIR_FAILURE;
4455 }
4456
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 if (NULL == pMaxTxParams) {
4459 lim_log(pMac, LOGP,
4460 FL("Unable to allocate memory for pMaxTxParams "));
4461 return eSIR_MEM_ALLOC_FAILED;
4462
4463 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304465 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304466 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304467 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004468 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304469 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470
4471 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4472 msgQ.bodyptr = pMaxTxParams;
4473 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304474 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4476 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4477 if (eSIR_SUCCESS != retCode) {
4478 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304479 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 }
4481 return retCode;
4482}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483
4484/**
4485 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4486 *
4487 * @mac_ctx: Pointer to Global MAC structure
4488 * @msg_buf: pointer to the SME message buffer
4489 *
4490 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4491 * from SME. It Register this information within PE.
4492 *
4493 * Return: None
4494 */
4495static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4496 uint32_t *msg_buf)
4497{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304498 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4500 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4501 struct mgmt_frm_reg_info *next = NULL;
4502 bool match = false;
4503
4504 lim_log(mac_ctx, LOG1, FL(
4505 "registerFrame %d, frameType %d, matchLen %d"),
4506 sme_req->registerFrame, sme_req->frameType,
4507 sme_req->matchLen);
4508 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304509 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304510 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4511 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304512 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513
4514 while (lim_mgmt_regn != NULL) {
4515 if (lim_mgmt_regn->frameType != sme_req->frameType)
4516 goto skip_match;
4517 if (sme_req->matchLen) {
4518 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304519 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 sme_req->matchData,
4521 lim_mgmt_regn->matchLen))) {
4522 /* found match! */
4523 match = true;
4524 break;
4525 }
4526 } else {
4527 /* found match! */
4528 match = true;
4529 break;
4530 }
4531skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304532 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304533 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304535 (qdf_list_node_t *)lim_mgmt_regn,
4536 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304537 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 lim_mgmt_regn = next;
4539 next = NULL;
4540 }
4541 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304542 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304543 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304545 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304546 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304547 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 }
4549
4550 if (sme_req->registerFrame) {
4551 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304552 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 sme_req->matchLen);
4554 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304555 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 sizeof(struct mgmt_frm_reg_info) +
4557 sme_req->matchLen, 0);
4558 lim_mgmt_regn->frameType = sme_req->frameType;
4559 lim_mgmt_regn->matchLen = sme_req->matchLen;
4560 lim_mgmt_regn->sessionId = sme_req->sessionId;
4561 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304562 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 sme_req->matchData,
4564 sme_req->matchLen);
4565 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304566 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304568 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 gLimMgmtFrameRegistratinQueue,
4570 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304571 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 &mac_ctx->lim.lim_frame_register_lock);
4573 }
4574 }
4575 return;
4576}
4577
4578static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4579{
4580 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4581 pMac->lim.gDeferMsgTypeForNOA);
4582 pMac->lim.gDeferMsgTypeForNOA = 0;
4583 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4584 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304585 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4587 }
4588}
4589
4590/**
4591 * lim_process_regd_defd_sme_req_after_noa_start()
4592 *
4593 * mac_ctx: Pointer to Global MAC structure
4594 *
4595 * This function is called to process deferred sme req message
4596 * after noa start.
4597 *
4598 * Return: None
4599 */
4600void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4601{
4602 bool buf_consumed = true;
4603
4604 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4605 mac_ctx->lim.gDeferMsgTypeForNOA);
4606
4607 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4608 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4609 lim_log(mac_ctx, LOGW,
4610 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4611 lim_log(mac_ctx, LOGW,
4612 FL("It may happen when NOA start ind and timeout happen at the same time"));
4613 return;
4614 }
4615 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4616 case eWNI_SME_SCAN_REQ:
4617 __lim_process_sme_scan_req(mac_ctx,
4618 mac_ctx->lim.gpDefdSmeMsgForNOA);
4619 break;
4620#ifdef FEATURE_OEM_DATA_SUPPORT
4621 case eWNI_SME_OEM_DATA_REQ:
4622 __lim_process_sme_oem_data_req(mac_ctx,
4623 mac_ctx->lim.gpDefdSmeMsgForNOA);
4624 break;
4625#endif
4626 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4627 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4628 mac_ctx->lim.gpDefdSmeMsgForNOA);
4629 /*
4630 * lim_process_remain_on_chnl_req doesnt want us to free
4631 * the buffer since it is freed in lim_remain_on_chn_rsp.
4632 * this change is to avoid "double free"
4633 */
4634 if (false == buf_consumed)
4635 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4636 break;
4637 case eWNI_SME_JOIN_REQ:
4638 __lim_process_sme_join_req(mac_ctx,
4639 mac_ctx->lim.gpDefdSmeMsgForNOA);
4640 break;
4641 default:
4642 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4643 mac_ctx->lim.gDeferMsgTypeForNOA);
4644 break;
4645 }
4646 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4647}
4648
4649static void
4650__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4651{
4652 tpSirResetAPCapsChange pResetCapsChange;
4653 tpPESession psessionEntry;
4654 uint8_t sessionId = 0;
4655 if (pMsgBuf == NULL) {
4656 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4657 return;
4658 }
4659
4660 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4661 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004662 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4663 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 if (psessionEntry == NULL) {
4665 lim_log(pMac, LOGE,
4666 FL("Session does not exist for given BSSID"));
4667 return;
4668 }
4669
4670 psessionEntry->limSentCapsChangeNtf = false;
4671 return;
4672}
4673
4674/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304675 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4676 * indication callback in PE.
4677 * @mac_ptr: Mac pointer
4678 * @msg_buf: Msg pointer containing the callback
4679 *
4680 * This function is used save the Management frame
4681 * indication callback in PE.
4682 *
4683 * Return: None
4684 */
4685static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4686 uint32_t *msg_buf)
4687{
4688 struct sir_sme_mgmt_frame_cb_req *sme_req =
4689 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4690
4691 if (NULL == msg_buf) {
4692 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4693 return;
4694 }
4695 if (sme_req->callback)
4696 mac_ctx->mgmt_frame_ind_cb =
4697 (sir_mgmt_frame_ind_callback)sme_req->callback;
4698 else
4699 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4700}
4701
4702/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 * lim_process_sme_req_messages()
4704 *
4705 ***FUNCTION:
4706 * This function is called by limProcessMessageQueue(). This
4707 * function processes SME request messages from HDD or upper layer
4708 * application.
4709 *
4710 ***LOGIC:
4711 *
4712 ***ASSUMPTIONS:
4713 *
4714 ***NOTE:
4715 *
4716 * @param pMac Pointer to Global MAC structure
4717 * @param msgType Indicates the SME message type
4718 * @param *pMsgBuf A pointer to the SME message buffer
4719 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4720 * false - if pMsgBuf is not to be freed.
4721 */
4722
4723bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4724{
4725 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4726 uint32_t *pMsgBuf = pMsg->bodyptr;
4727 tpSirSmeScanReq pScanReq;
4728 PELOG1(lim_log
4729 (pMac, LOG1,
4730 FL
4731 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4732 lim_msg_str(pMsg->type), pMsg->type,
4733 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4734 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4735 )
4736
4737 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4738 /* If no insert NOA required then execute the code below */
4739
4740 switch (pMsg->type) {
4741 case eWNI_SME_SYS_READY_IND:
4742 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4743 break;
4744
4745 case eWNI_SME_START_BSS_REQ:
4746 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4747 break;
4748
4749 case eWNI_SME_SCAN_REQ:
4750 __lim_process_sme_scan_req(pMac, pMsgBuf);
4751 break;
4752
4753#ifdef FEATURE_OEM_DATA_SUPPORT
4754 case eWNI_SME_OEM_DATA_REQ:
4755 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4756 break;
4757#endif
4758 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4759 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4760 break;
4761
4762 case eWNI_SME_UPDATE_NOA:
4763 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4764 break;
4765 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4766 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4767 break;
4768 case eWNI_SME_JOIN_REQ:
4769 __lim_process_sme_join_req(pMac, pMsgBuf);
4770 break;
4771
4772 case eWNI_SME_REASSOC_REQ:
4773 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4774 break;
4775
4776 case eWNI_SME_DISASSOC_REQ:
4777 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4778 break;
4779
4780 case eWNI_SME_DISASSOC_CNF:
4781 case eWNI_SME_DEAUTH_CNF:
4782 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4783 break;
4784
4785 case eWNI_SME_DEAUTH_REQ:
4786 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4787 break;
4788
4789 case eWNI_SME_SETCONTEXT_REQ:
4790 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4791 break;
4792
4793 case eWNI_SME_STOP_BSS_REQ:
4794 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4795 break;
4796
4797 case eWNI_SME_ASSOC_CNF:
4798 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4799 PELOG1(lim_log(pMac,
4800 LOG1, FL("Received ASSOC_CNF message"));)
4801 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4802 pMsgBuf);
4803 break;
4804
4805 case eWNI_SME_ADDTS_REQ:
4806 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4807 __lim_process_sme_addts_req(pMac, pMsgBuf);
4808 break;
4809
4810 case eWNI_SME_DELTS_REQ:
4811 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4812 __lim_process_sme_delts_req(pMac, pMsgBuf);
4813 break;
4814
4815 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4816 PELOG1(lim_log
4817 (pMac, LOG1,
4818 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4819 )
4820 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4821 break;
4822
4823 case eWNI_SME_GET_STATISTICS_REQ:
4824 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4825 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4826 bufConsumed = false;
4827 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004828#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 case eWNI_SME_GET_TSM_STATS_REQ:
4830 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4831 bufConsumed = false;
4832 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004833#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834 case eWNI_SME_GET_ASSOC_STAS_REQ:
4835 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4836 break;
4837 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4838 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4839 break;
4840
4841 case eWNI_SME_HIDE_SSID_REQ:
4842 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4843 break;
4844 case eWNI_SME_UPDATE_APWPSIE_REQ:
4845 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4846 break;
4847 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4848 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4849 break;
4850
4851 case eWNI_SME_SET_APWPARSNIEs_REQ:
4852 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4853 break;
4854
4855 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4856 /* Update the beaconInterval */
4857 __lim_process_sme_change_bi(pMac, pMsgBuf);
4858 break;
4859
4860#ifdef QCA_HT_2040_COEX
4861 case eWNI_SME_SET_HT_2040_MODE:
4862 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4863 break;
4864#endif
4865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4867 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4868 __lim_process_report_message(pMac, pMsg);
4869 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 case eWNI_SME_FT_PRE_AUTH_REQ:
4872 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4873 break;
4874 case eWNI_SME_FT_UPDATE_KEY:
4875 lim_process_ft_update_key(pMac, pMsgBuf);
4876 break;
4877
4878 case eWNI_SME_FT_AGGR_QOS_REQ:
4879 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4880 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881
4882 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4883 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4884 break;
4885#ifdef FEATURE_WLAN_TDLS
4886 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4887 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4888 break;
4889 case eWNI_SME_TDLS_ADD_STA_REQ:
4890 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4891 break;
4892 case eWNI_SME_TDLS_DEL_STA_REQ:
4893 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4894 break;
4895 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4896 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4897 break;
4898#endif
4899 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4900 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4901 break;
4902
4903 case eWNI_SME_CHANNEL_CHANGE_REQ:
4904 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4905 break;
4906
4907 case eWNI_SME_START_BEACON_REQ:
4908 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4909 break;
4910
4911 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4912 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4913 break;
4914
4915 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4916 lim_process_update_add_ies(pMac, pMsgBuf);
4917 break;
4918
4919 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4920 lim_process_modify_add_ies(pMac, pMsgBuf);
4921 break;
4922 case eWNI_SME_SET_HW_MODE_REQ:
4923 lim_process_set_hw_mode(pMac, pMsgBuf);
4924 break;
4925 case eWNI_SME_NSS_UPDATE_REQ:
4926 lim_process_nss_update_request(pMac, pMsgBuf);
4927 break;
4928 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4929 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4930 break;
4931 case eWNI_SME_SET_IE_REQ:
4932 lim_process_set_ie_req(pMac, pMsgBuf);
4933 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304934 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4935 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4936 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304937 case eWNI_SME_EXT_CHANGE_CHANNEL:
4938 lim_process_ext_change_channel(pMac, pMsgBuf);
4939 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004940 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4941 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4942 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304944 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 pMsg->bodyptr = NULL;
4946 break;
4947 } /* switch (msgType) */
4948
4949 return bufConsumed;
4950} /*** end lim_process_sme_req_messages() ***/
4951
4952/**
4953 * lim_process_sme_start_beacon_req()
4954 *
4955 ***FUNCTION:
4956 * This function is called by limProcessMessageQueue(). This
4957 * function processes SME request messages from HDD or upper layer
4958 * application.
4959 *
4960 ***LOGIC:
4961 *
4962 ***ASSUMPTIONS:
4963 *
4964 ***NOTE:
4965 *
4966 * @param pMac Pointer to Global MAC structure
4967 * @param msgType Indicates the SME message type
4968 * @param *pMsgBuf A pointer to the SME message buffer
4969 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4970 * false - if pMsgBuf is not to be freed.
4971 */
4972static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4973{
4974 tpSirStartBeaconIndication pBeaconStartInd;
4975 tpPESession psessionEntry;
4976 uint8_t sessionId; /* PE sessionID */
4977
4978 if (pMsg == NULL) {
4979 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4980 return;
4981 }
4982
4983 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4984 psessionEntry = pe_find_session_by_bssid(pMac,
4985 pBeaconStartInd->bssid,
4986 &sessionId);
4987 if (psessionEntry == NULL) {
4988 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
4989 lim_log(pMac, LOGE,
4990 FL("Session does not exist for given bssId"));
4991 return;
4992 }
4993
4994 if (pBeaconStartInd->beaconStartStatus == true) {
4995 /*
4996 * Currently this Indication comes from SAP
4997 * to start Beacon Tx on a DFS channel
4998 * since beaconing has to be done on DFS
4999 * channel only after CAC WAIT is completed.
5000 * On a DFS Channel LIM does not start beacon
5001 * Tx right after the WMA_ADD_BSS_RSP.
5002 */
5003 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305004 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 FL("Start Beacon with ssid %s Ch %d"),
5006 psessionEntry->ssId.ssId,
5007 psessionEntry->currentOperChannel);
5008 lim_send_beacon_ind(pMac, psessionEntry);
5009 } else {
5010 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5011 return;
5012 }
5013}
5014
5015/**
5016 * lim_process_sme_channel_change_request() - process sme ch change req
5017 *
5018 * @mac_ctx: Pointer to Global MAC structure
5019 * @msg_buf: pointer to the SME message buffer
5020 *
5021 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5022 *
5023 * Return: None
5024 */
5025static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5026 uint32_t *msg_buf)
5027{
5028 tpSirChanChangeRequest ch_change_req;
5029 tpPESession session_entry;
5030 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005031 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 uint32_t val = 0;
5033
5034 if (msg_buf == NULL) {
5035 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5036 return;
5037 }
5038 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5039
5040 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5041 ch_change_req->targetChannel);
5042
5043 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5044 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5045 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5046 return;
5047 }
5048
5049 session_entry = pe_find_session_by_bssid(mac_ctx,
5050 ch_change_req->bssid, &session_id);
5051 if (session_entry == NULL) {
5052 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5053 lim_log(mac_ctx, LOGE, FL(
5054 "Session does not exist for given bssId"));
5055 return;
5056 }
5057
5058 if (session_entry->currentOperChannel ==
5059 ch_change_req->targetChannel) {
5060 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5061 return;
5062 }
5063
5064 if (LIM_IS_AP_ROLE(session_entry))
5065 session_entry->channelChangeReasonCode =
5066 LIM_SWITCH_CHANNEL_SAP_DFS;
5067 else
5068 session_entry->channelChangeReasonCode =
5069 LIM_SWITCH_CHANNEL_OPERATION;
5070
5071 lim_log(mac_ctx, LOGW, FL(
5072 "switch old chnl %d to new chnl %d, ch_bw %d"),
5073 session_entry->currentOperChannel,
5074 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005075 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076
5077 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005078 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 session_entry->ch_center_freq_seg0 =
5080 ch_change_req->center_freq_seg_0;
5081 session_entry->ch_center_freq_seg1 =
5082 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005083 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005085 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 session_entry->htRecommendedTxWidthSet =
5087 session_entry->htSupportedChannelWidthSet;
5088 session_entry->currentOperChannel =
5089 ch_change_req->targetChannel;
5090 session_entry->limRFBand =
5091 lim_get_rf_band(session_entry->currentOperChannel);
5092 /* Initialize 11h Enable Flag */
5093 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5094 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5095 eSIR_SUCCESS)
5096 lim_log(mac_ctx, LOGP,
5097 FL("Fail to get WNI_CFG_11H_ENABLED"));
5098 }
5099
5100 session_entry->lim11hEnable = val;
5101 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305102 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103 &ch_change_req->operational_rateset,
5104 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305105 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 &ch_change_req->extended_rateset,
5107 sizeof(session_entry->extRateSet));
5108 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5109 session_entry->ch_center_freq_seg0,
5110 session_entry->ch_center_freq_seg1,
5111 session_entry->ch_width,
5112 max_tx_pwr, session_entry->peSessionId);
5113}
5114
5115/******************************************************************************
5116* lim_start_bss_update_add_ie_buffer()
5117*
5118***FUNCTION:
5119* This function checks the src buffer and its length and then malloc for
5120* dst buffer update the same
5121*
5122***LOGIC:
5123*
5124***ASSUMPTIONS:
5125*
5126***NOTE:
5127*
5128* @param pMac Pointer to Global MAC structure
5129* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5130* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5131* @param *pSrcData_buff A pointer of uint8_t src buffer
5132* @param srcDataLen src buffer length
5133******************************************************************************/
5134
5135static void
5136lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5137 uint8_t **pDstData_buff,
5138 uint16_t *pDstDataLen,
5139 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5140{
5141
5142 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5143 *pDstDataLen = srcDataLen;
5144
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305145 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146
5147 if (NULL == *pDstData_buff) {
5148 lim_log(pMac, LOGE,
5149 FL("AllocateMemory failed for pDstData_buff"));
5150 return;
5151 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305152 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 } else {
5154 *pDstData_buff = NULL;
5155 *pDstDataLen = 0;
5156 }
5157}
5158
5159/******************************************************************************
5160* lim_update_add_ie_buffer()
5161*
5162***FUNCTION:
5163* This function checks the src buffer and length if src buffer length more
5164* than dst buffer length then free the dst buffer and malloc for the new src
5165* length, and update the dst buffer and length. But if dst buffer is bigger
5166* than src buffer length then it just update the dst buffer and length
5167*
5168***LOGIC:
5169*
5170***ASSUMPTIONS:
5171*
5172***NOTE:
5173*
5174* @param pMac Pointer to Global MAC structure
5175* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5176* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5177* @param *pSrcData_buff A pointer of uint8_t src buffer
5178* @param srcDataLen src buffer length
5179******************************************************************************/
5180
5181static void
5182lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5183 uint8_t **pDstData_buff,
5184 uint16_t *pDstDataLen,
5185 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5186{
5187
5188 if (NULL == pSrcData_buff) {
5189 lim_log(pMac, LOGE, FL("src buffer is null."));
5190 return;
5191 }
5192
5193 if (srcDataLen > *pDstDataLen) {
5194 *pDstDataLen = srcDataLen;
5195 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305196 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305198 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199
5200 if (NULL == *pDstData_buff) {
5201 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5202 *pDstDataLen = 0;
5203 return;
5204 }
5205 }
5206
5207 /* copy the content of buffer into dst buffer
5208 */
5209 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305210 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005211
5212}
5213
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005214/**
5215 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5216 * @pMac : Pointer to Global MAC structure
5217 * @pDstData_buff : A pointer to pointer of dst buffer
5218 * @pDstDataLen : A pointer to pointer of dst buffer length
5219 * @pModifyIE : A pointer to tSirModifyIE
5220 *
5221 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5222 *
5223 * Return:
5224 * True or false depending upon whether IE is updated or not
5225 */
5226static bool
5227lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5228 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5229{
5230 int32_t oui_length;
5231 uint8_t *ibss_ie = NULL;
5232
5233 ibss_ie = pModifyIE->pIEBuffer;
5234 oui_length = pModifyIE->oui_length;
5235
5236 if ((0 == oui_length) || (NULL == ibss_ie)) {
5237 PELOGE(lim_log(pMac, LOGE,
5238 FL("Invalid set IBSS vendor IE command length %d "),
5239 oui_length);)
5240 return false;
5241 }
5242
5243 lim_update_add_ie_buffer(pMac,
5244 pDstData_buff,
5245 pDstDataLen,
5246 pModifyIE->pIEBuffer,
5247 pModifyIE->ieBufferlength);
5248
5249 return true;
5250}
5251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252/*
5253* lim_process_modify_add_ies() - process modify additional IE req.
5254*
5255* @mac_ctx: Pointer to Global MAC structure
5256* @msg_buf: pointer to the SME message buffer
5257*
5258* This function update the PE buffers for additional IEs.
5259*
5260* Return: None
5261*/
5262static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5263 uint32_t *msg_buf)
5264{
5265 tpSirModifyIEsInd modify_add_ies;
5266 tpPESession session_entry;
5267 uint8_t session_id;
5268 bool ret = false;
5269 tSirAddIeParams *add_ie_params;
5270
5271 if (msg_buf == NULL) {
5272 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5273 return;
5274 }
5275
5276 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5277 /* Incoming message has smeSession, use BSSID to find PE session */
5278 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005279 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280
5281 if (NULL == session_entry) {
5282 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5283 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005284 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285 goto end;
5286 }
5287 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5288 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5289 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5290 lim_log(mac_ctx, LOGE,
5291 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5292 modify_add_ies->modifyIE.pIEBuffer,
5293 modify_add_ies->modifyIE.ieBufferlength,
5294 modify_add_ies->modifyIE.ieID,
5295 modify_add_ies->modifyIE.ieIDLen,
5296 modify_add_ies->updateType);
5297 goto end;
5298 }
5299 add_ie_params = &session_entry->addIeParams;
5300 switch (modify_add_ies->updateType) {
5301 case eUPDATE_IE_PROBE_RESP:
5302 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005303 if (LIM_IS_IBSS_ROLE(session_entry)) {
5304 lim_update_ibss_prop_add_ies(mac_ctx,
5305 &add_ie_params->probeRespData_buff,
5306 &add_ie_params->probeRespDataLen,
5307 &modify_add_ies->modifyIE);
5308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 break;
5310 case eUPDATE_IE_ASSOC_RESP:
5311 /* assoc resp IE */
5312 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305313 QDF_TRACE(QDF_MODULE_ID_PE,
5314 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 "assoc resp add ie not present %d"),
5316 add_ie_params->assocRespDataLen);
5317 }
5318 /* search through the buffer and modify the IE */
5319 break;
5320 case eUPDATE_IE_PROBE_BCN:
5321 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005322 if (LIM_IS_IBSS_ROLE(session_entry)) {
5323 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5324 &add_ie_params->probeRespBCNData_buff,
5325 &add_ie_params->probeRespBCNDataLen,
5326 &modify_add_ies->modifyIE);
5327 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 if (ret == true && modify_add_ies->modifyIE.notify) {
5329 lim_handle_param_update(mac_ctx,
5330 modify_add_ies->updateType);
5331 }
5332 break;
5333 default:
5334 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5335 modify_add_ies->updateType);
5336 break;
5337 }
5338end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305339 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 modify_add_ies->modifyIE.pIEBuffer = NULL;
5341}
5342
5343/*
5344* lim_process_update_add_ies() - process additional IE update req
5345*
5346* @mac_ctx: Pointer to Global MAC structure
5347* @msg_buf: pointer to the SME message buffer
5348*
5349* This function update the PE buffers for additional IEs.
5350*
5351* Return: None
5352*/
5353static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5354 uint32_t *msg_buf)
5355{
5356 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5357 uint8_t session_id;
5358 tpPESession session_entry;
5359 tSirAddIeParams *addn_ie;
5360 uint16_t new_length = 0;
5361 uint8_t *new_ptr = NULL;
5362 tSirUpdateIE *update_ie;
5363
5364 if (msg_buf == NULL) {
5365 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5366 return;
5367 }
5368 update_ie = &update_add_ies->updateIE;
5369 /* incoming message has smeSession, use BSSID to find PE session */
5370 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005371 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372
5373 if (NULL == session_entry) {
5374 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5375 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005376 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 goto end;
5378 }
5379 addn_ie = &session_entry->addIeParams;
5380 /* if len is 0, upper layer requested freeing of buffer */
5381 if (0 == update_ie->ieBufferlength) {
5382 switch (update_add_ies->updateType) {
5383 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305384 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005385 addn_ie->probeRespData_buff = NULL;
5386 addn_ie->probeRespDataLen = 0;
5387 break;
5388 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305389 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 addn_ie->assocRespData_buff = NULL;
5391 addn_ie->assocRespDataLen = 0;
5392 break;
5393 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305394 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 addn_ie->probeRespBCNData_buff = NULL;
5396 addn_ie->probeRespBCNDataLen = 0;
5397
5398 if (update_ie->notify)
5399 lim_handle_param_update(mac_ctx,
5400 update_add_ies->updateType);
5401 break;
5402 default:
5403 break;
5404 }
5405 return;
5406 }
5407 switch (update_add_ies->updateType) {
5408 case eUPDATE_IE_PROBE_RESP:
5409 if (update_ie->append) {
5410 /*
5411 * In case of append, allocate new memory
5412 * with combined length
5413 */
5414 new_length = update_ie->ieBufferlength +
5415 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305416 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 if (NULL == new_ptr) {
5418 lim_log(mac_ctx, LOGE, FL(
5419 "Memory allocation failed."));
5420 goto end;
5421 }
5422 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305423 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305425 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 update_ie->pAdditionIEBuffer,
5427 update_ie->ieBufferlength);
5428 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305429 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 /* adjust length accordingly */
5431 addn_ie->probeRespDataLen = new_length;
5432 /* save refernece of local buffer in PE session */
5433 addn_ie->probeRespData_buff = new_ptr;
5434 goto end;
5435 }
5436 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5437 &addn_ie->probeRespDataLen,
5438 update_ie->pAdditionIEBuffer,
5439 update_ie->ieBufferlength);
5440 break;
5441 case eUPDATE_IE_ASSOC_RESP:
5442 /* assoc resp IE */
5443 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5444 &addn_ie->assocRespDataLen,
5445 update_ie->pAdditionIEBuffer,
5446 update_ie->ieBufferlength);
5447 break;
5448 case eUPDATE_IE_PROBE_BCN:
5449 /* probe resp Bcn IE */
5450 lim_update_add_ie_buffer(mac_ctx,
5451 &addn_ie->probeRespBCNData_buff,
5452 &addn_ie->probeRespBCNDataLen,
5453 update_ie->pAdditionIEBuffer,
5454 update_ie->ieBufferlength);
5455 if (update_ie->notify)
5456 lim_handle_param_update(mac_ctx,
5457 update_add_ies->updateType);
5458 break;
5459 default:
5460 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5461 update_add_ies->updateType);
5462 break;
5463 }
5464end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305465 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 update_ie->pAdditionIEBuffer = NULL;
5467}
5468
5469/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305470 * send_extended_chan_switch_action_frame()- function to send ECSA
5471 * action frame for each sta connected to SAP/GO and AP in case of
5472 * STA .
5473 * @mac_ctx: pointer to global mac structure
5474 * @new_channel: new channel to switch to.
5475 * @ch_bandwidth: BW of channel to calculate op_class
5476 * @session_entry: pe session
5477 *
5478 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5479 *
5480 * Return: void
5481 */
5482
5483static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5484 uint16_t new_channel, uint8_t ch_bandwidth,
5485 tpPESession session_entry)
5486{
5487 uint16_t op_class;
5488 uint8_t switch_mode = 0, i;
5489 tpDphHashNode psta;
5490
5491
Amar Singhal22995112016-01-22 10:42:33 -08005492 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305493 mac_ctx->scan.countryCodeCurrent,
5494 new_channel,
5495 ch_bandwidth);
5496
5497 if (LIM_IS_AP_ROLE(session_entry) &&
5498 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5499 switch_mode = 1;
5500
5501 if (LIM_IS_AP_ROLE(session_entry)) {
5502 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5503 psta =
5504 session_entry->dph.dphHashTable.pDphNodeArray + i;
5505 if (psta && psta->added)
5506 lim_send_extended_chan_switch_action_frame(
5507 mac_ctx,
5508 psta->staAddr,
5509 switch_mode, op_class, new_channel,
5510 LIM_MAX_CSA_IE_UPDATES, session_entry);
5511 }
5512 } else if (LIM_IS_STA_ROLE(session_entry)) {
5513 lim_send_extended_chan_switch_action_frame(mac_ctx,
5514 session_entry->bssId,
5515 switch_mode, op_class, new_channel,
5516 LIM_MAX_CSA_IE_UPDATES, session_entry);
5517 }
5518
5519}
5520
5521/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5523 *
5524 * @mac_ctx: Pointer to Global MAC structure
5525 * @msg_buf: pointer to the SME message buffer
5526 *
5527 * This function processes SME request messages from HDD or upper layer
5528 * application.
5529 *
5530 * Return: None
5531 */
5532static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5533 uint32_t *msg_buf)
5534{
5535 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5536 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537 uint8_t session_id;
5538 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005539 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540
5541 if (msg_buf == NULL) {
5542 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5543 return;
5544 }
5545
5546 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5547 session_entry = pe_find_session_by_bssid(mac_ctx,
5548 dfs_csa_ie_req->bssid, &session_id);
5549 if (session_entry == NULL) {
5550 lim_log(mac_ctx, LOGE, FL(
5551 "Session not found for given BSSID" MAC_ADDRESS_STR),
5552 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5553 return;
5554 }
5555
5556 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5557 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5558 GET_LIM_SYSTEM_ROLE(session_entry));
5559 return;
5560 }
5561
5562 /* target channel */
5563 session_entry->gLimChannelSwitch.primaryChannel =
5564 dfs_csa_ie_req->targetChannel;
5565
5566 /* Channel switch announcement needs to be included in beacon */
5567 session_entry->dfsIncludeChanSwIe = true;
5568 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5569 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005570 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305571 session_entry->gLimChannelSwitch.sec_ch_offset =
5572 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5574 session_entry->gLimChannelSwitch.switchMode = 1;
5575
5576 /*
5577 * Validate if SAP is operating HT or VHT mode and set the Channel
5578 * Switch Wrapper element with the Wide Band Switch subelement.
5579 */
5580 if (true != session_entry->vhtCapability)
5581 goto skip_vht;
5582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 /* Now encode the Wider Ch BW element depending on the ch width */
5584 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005585 switch (dfs_csa_ie_req->ch_params.ch_width) {
5586 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 /*
5588 * Wide channel BW sublement in channel wrapper element is not
5589 * required in case of 20 Mhz operation. Currently It is set
5590 * only set in case of 40/80 Mhz Operation.
5591 */
5592 session_entry->dfsIncludeChanWrapperIe = false;
5593 wider_bw_ch_switch->newChanWidth =
5594 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5595 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005596 case CH_WIDTH_40MHZ:
5597 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598 wider_bw_ch_switch->newChanWidth =
5599 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5600 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005601 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 session_entry->dfsIncludeChanWrapperIe = true;
5603 wider_bw_ch_switch->newChanWidth =
5604 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5605 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005606 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 session_entry->dfsIncludeChanWrapperIe = true;
5608 wider_bw_ch_switch->newChanWidth =
5609 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5610 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005611 case CH_WIDTH_80P80MHZ:
5612 session_entry->dfsIncludeChanWrapperIe = true;
5613 wider_bw_ch_switch->newChanWidth =
5614 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005615 /*
5616 * This is not applicable for 20/40/80 Mhz.
5617 * Only used when we support 80+80 Mhz operation.
5618 * In case of 80+80 Mhz, this parameter indicates
5619 * center channel frequency index of 80 Mhz channel of
5620 * frequency segment 1.
5621 */
5622 wider_bw_ch_switch->newCenterChanFreq1 =
5623 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005624 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 default:
5626 session_entry->dfsIncludeChanWrapperIe = false;
5627 /*
5628 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5629 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5630 */
5631 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5632 break;
5633 }
5634 /* Fetch the center channel based on the channel width */
5635 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005636 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637skip_vht:
5638 /* Send CSA IE request from here */
5639 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5640 eSIR_SUCCESS) {
5641 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5642 return;
5643 }
5644
5645 /*
5646 * First beacon update request is sent here, the remaining updates are
5647 * done when the FW responds back after sending the first beacon after
5648 * the template update
5649 */
5650 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305651
5652 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5653 ch_offset = BW80;
5654 else
5655 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5656
5657 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5658 session_entry->gLimChannelSwitch.switchCount,
5659 session_entry->gLimChannelSwitch.primaryChannel,
5660 session_entry->gLimChannelSwitch.ch_width,
5661 session_entry->dfsIncludeChanWrapperIe,
5662 ch_offset);
5663
Abhishek Singh518323d2015-10-19 17:42:01 +05305664 /* Send ECSA Action frame after updating the beacon */
5665 send_extended_chan_switch_action_frame(mac_ctx,
5666 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305667 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 session_entry->gLimChannelSwitch.switchCount--;
5669}
5670
5671/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305672 * lim_process_ext_change_channel()- function to send ECSA
5673 * action frame for STA/CLI .
5674 * @mac_ctx: pointer to global mac structure
5675 * @msg: params from sme for new channel.
5676 *
5677 * This function is called to send ECSA frame for STA/CLI.
5678 *
5679 * Return: void
5680 */
5681
5682static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5683 uint32_t *msg)
5684{
5685 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5686 (struct sir_sme_ext_cng_chan_req *) msg;
5687 tpPESession session_entry = NULL;
5688
5689 if (NULL == msg) {
5690 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5691 return;
5692 }
5693 session_entry =
5694 pe_find_session_by_sme_session_id(mac_ctx,
5695 ext_chng_channel->session_id);
5696 if (NULL == session_entry) {
5697 lim_log(mac_ctx, LOGE,
5698 FL("Session not found for given session %d"),
5699 ext_chng_channel->session_id);
5700 return;
5701 }
5702 if (LIM_IS_AP_ROLE(session_entry)) {
5703 lim_log(mac_ctx, LOGE,
5704 FL("not an STA/CLI session"));
5705 return;
5706 }
5707 send_extended_chan_switch_action_frame(mac_ctx,
5708 ext_chng_channel->new_channel,
5709 0, session_entry);
5710}
5711
5712/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 * lim_process_nss_update_request() - process sme nss update req
5714 *
5715 * @mac_ctx: Pointer to Global MAC structure
5716 * @msg_buf: pointer to the SME message buffer
5717 *
5718 * This function processes SME request messages from HDD or upper layer
5719 * application.
5720 *
5721 * Return: None
5722 */
5723static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5724 uint32_t *msg_buf)
5725{
5726 struct sir_nss_update_request *nss_update_req_ptr;
5727 tpPESession session_entry = NULL;
5728
5729 if (msg_buf == NULL) {
5730 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5731 return;
5732 }
5733
5734 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305735 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 nss_update_req_ptr->vdev_id);
5737 if (session_entry == NULL) {
5738 lim_log(mac_ctx, LOGE, FL(
5739 "Session not found for given session_id %d"),
5740 nss_update_req_ptr->vdev_id);
5741 return;
5742 }
5743
5744 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5745 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5746 GET_LIM_SYSTEM_ROLE(session_entry));
5747 return;
5748 }
5749
5750 /* populate nss field in the beacon */
5751 session_entry->gLimOperatingMode.present = 1;
5752 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5753 /* Send nss update request from here */
5754 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5755 eSIR_SUCCESS) {
5756 lim_log(mac_ctx, LOGE,
5757 FL("Unable to set op mode IE in beacon"));
5758 return;
5759 }
5760
5761 lim_send_beacon_ind(mac_ctx, session_entry);
5762}
5763
5764/**
5765 * lim_process_set_ie_req() - process sme set IE request
5766 *
5767 * @mac_ctx: Pointer to Global MAC structure
5768 * @msg_buf: pointer to the SME message buffer
5769 *
5770 * This function processes SME request messages from HDD or upper layer
5771 * application.
5772 *
5773 * Return: None
5774 */
5775static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5776{
5777 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305778 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779
5780 if (msg_buf == NULL) {
5781 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5782 return;
5783 }
5784
5785 msg = (struct send_extcap_ie *)msg_buf;
5786 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305787 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5789
5790}