blob: 8de45fe8734fb851f025ced8329e6328e41d9f7e [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 Ramachandran5482d6a2016-03-29 17:09:22 -07001732 /*
1733 * By default supported NSS 1x1 is set to true
1734 * and later on updated while determining session
1735 * supported rates which is the intersection of
1736 * self and peer rates
1737 */
1738 session->supported_nss_1x1 = true;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001739 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001740 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001741 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001742 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001743 session->send_smps_action,
1744 session->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745
1746 /*Store Persona */
1747 session->pePersona = sme_join_req->staPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301748 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 FL("PE PERSONA=%d cbMode %u"),
1750 session->pePersona, sme_join_req->cbMode);
1751 if (mac_ctx->roam.configParam.enable2x2)
1752 session->nss = 2;
1753 else
1754 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 session->vhtCapability =
1756 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301757 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 "***__lim_process_sme_join_req: vhtCapability=%d****",
1759 session->vhtCapability);
1760 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301761 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 session->txBFIniFeatureEnabled =
1763 sme_join_req->txBFIniFeatureEnabled;
1764 } else {
1765 session->txBFIniFeatureEnabled = 0;
1766 }
1767 session->txMuBformee = sme_join_req->txMuBformee;
1768 session->enableVhtpAid =
1769 sme_join_req->enableVhtpAid;
1770 session->enableVhtGid =
1771 sme_join_req->enableVhtGid;
1772
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301773 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 FL("***txBFIniFeatureEnabled=%d***"),
1775 session->txBFIniFeatureEnabled);
1776 if (wlan_cfg_get_int(mac_ctx,
1777 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1778 eSIR_SUCCESS)
1779 lim_log(mac_ctx, LOGE, FL(
1780 "cfg get vht su bformer failed"));
1781
1782 session->enable_su_tx_bformer = val;
1783 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1784 }
1785 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1786 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1787 session->txBFIniFeatureEnabled) !=
1788 eSIR_SUCCESS) {
1789 /*
1790 * Set failed for
1791 * CFG_VHT_SU_BEAMFORMEE_CAP
1792 */
1793 lim_log(mac_ctx, LOGP,
1794 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1795 ret_code = eSIR_LOGP_EXCEPTION;
1796 goto end;
1797 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301798 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 "%s: txBFCsnValue=%d", __func__,
1800 sme_join_req->txBFCsnValue);
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001801 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001804 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 handle_ht_capabilityand_ht_info(mac_ctx, session);
1806 /* Copy The channel Id to the session Table */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001807 session->currentOperChannel = bss_desc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 /* cbMode is already merged value of peer and self -
1809 * done by csr in csr_get_cb_mode_from_ies */
1810 session->htSupportedChannelWidthSet =
1811 (sme_join_req->cbMode) ? 1 : 0;
1812 session->htRecommendedTxWidthSet =
1813 session->htSupportedChannelWidthSet;
1814 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1815
1816 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1817 session->ch_center_freq_seg0 =
1818 session->currentOperChannel - 2;
1819 session->ch_width = CH_WIDTH_40MHZ;
1820 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1821 sme_join_req->cbMode) {
1822 session->ch_center_freq_seg0 =
1823 session->currentOperChannel + 2;
1824 session->ch_width = CH_WIDTH_40MHZ;
1825 } else {
1826 session->ch_center_freq_seg0 = 0;
1827 session->ch_width = CH_WIDTH_20MHZ;
1828 }
1829
1830 /* Record if management frames need to be protected */
1831#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001832 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001834 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836#endif
1837
1838#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001839 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840#endif
1841
1842 /* Copy the SSID from smejoinreq to session entry */
1843 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301844 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 session->ssId.length);
1846
1847 /*
1848 * Determin 11r or ESE connection based on input from SME
1849 * which inturn is dependent on the profile the user wants
1850 * to connect to, So input is coming from supplicant
1851 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853#ifdef FEATURE_WLAN_ESE
1854 session->isESEconnection = sme_join_req->isESEconnection;
1855#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 session->isFastTransitionEnabled =
1857 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 session->isFastRoamIniFeatureEnabled =
1860 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 session->txLdpcIniFeatureEnabled =
1862 sme_join_req->txLdpcIniFeatureEnabled;
1863
1864 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1865 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 } else {
1867 /*
1868 * Throw an error and return and make
1869 * sure to delete the session.
1870 */
1871 lim_log(mac_ctx, LOGE,
1872 FL("recvd JOIN_REQ with invalid bss type %d"),
1873 session->bssType);
1874 ret_code = eSIR_SME_INVALID_PARAMETERS;
1875 goto end;
1876 }
1877
1878 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301879 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 &sme_join_req->addIEScan, sizeof(tSirAddie));
1881
1882 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301883 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1885
1886 val = sizeof(tLimMlmJoinReq) +
1887 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301888 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 if (NULL == mlm_join_req) {
1890 lim_log(mac_ctx, LOGP,
1891 FL("AllocateMemory failed for mlmJoinReq"));
1892 return;
1893 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301894 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895
1896 /* PE SessionId is stored as a part of JoinReq */
1897 mlm_join_req->sessionId = session->peSessionId;
1898
1899 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1900 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1901 eSIR_SUCCESS) {
1902 lim_log(mac_ctx, LOGP,
1903 FL("couldn't retrieve JoinFailureTimer value"
1904 " setting to default value"));
1905 mlm_join_req->joinFailureTimeout =
1906 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1907 }
1908
1909 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301910 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 (void *)&sme_join_req->operationalRateSet,
1912 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301913 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 (void *)&sme_join_req->extendedRateSet,
1915 sizeof(tSirMacRateSet));
1916 /*
1917 * this may not be needed anymore now, as rateSet is now
1918 * included in the session entry and MLM has session context.
1919 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301920 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 (void *)&session->rateSet,
1922 sizeof(tSirMacRateSet));
1923
1924 session->encryptType = sme_join_req->UCEncryptionType;
1925
1926 mlm_join_req->bssDescription.length =
1927 session->pLimJoinReq->bssDescription.length;
1928
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301929 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 (uint8_t *)
1931 &session->pLimJoinReq->bssDescription.bssId,
1932 session->pLimJoinReq->bssDescription.length + 2);
1933
1934 session->limCurrentBssCaps =
1935 session->pLimJoinReq->bssDescription.capabilityInfo;
1936
1937 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1938 session->currentOperChannel);
1939 local_power_constraint = reg_max;
1940
1941 lim_extract_ap_capability(mac_ctx,
1942 (uint8_t *)
1943 session->pLimJoinReq->bssDescription.ieFields,
1944 lim_get_ielen_from_bss_description(
1945 &session->pLimJoinReq->bssDescription),
1946 &session->limCurrentBssQosCaps,
1947 &session->limCurrentBssPropCap,
1948 &session->gLimCurrentBssUapsd,
1949 &local_power_constraint, session);
1950
1951#ifdef FEATURE_WLAN_ESE
1952 session->maxTxPower = lim_get_max_tx_power(reg_max,
1953 local_power_constraint,
1954 mac_ctx->roam.configParam.nTxPowerCap);
1955#else
1956 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301957 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301959 lim_log(mac_ctx, LOG1,
1960 FL("Reg max = %d, local power con = %d, max tx = %d"),
1961 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962
1963 if (session->gLimCurrentBssUapsd) {
1964 session->gUapsdPerAcBitmask =
1965 session->pLimJoinReq->uapsdPerAcBitmask;
1966 lim_log(mac_ctx, LOG1,
1967 FL("UAPSD flag for all AC - 0x%2x"),
1968 session->gUapsdPerAcBitmask);
1969
1970 /* resetting the dynamic uapsd mask */
1971 session->gUapsdPerAcDeliveryEnableMask = 0;
1972 session->gUapsdPerAcTriggerEnableMask = 0;
1973 }
1974
1975 session->limRFBand =
1976 lim_get_rf_band(session->currentOperChannel);
1977
1978 /* Initialize 11h Enable Flag */
1979 if (SIR_BAND_5_GHZ == session->limRFBand) {
1980 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1981 &val) != eSIR_SUCCESS) {
1982 lim_log(mac_ctx, LOGP,
1983 FL("Fail to get WNI_CFG_11H_ENABLED "));
1984 session->lim11hEnable =
1985 WNI_CFG_11H_ENABLED_STADEF;
1986 } else {
1987 session->lim11hEnable = val;
1988 }
1989 } else {
1990 session->lim11hEnable = 0;
1991 }
1992
1993 /*
1994 * To care of the scenario when STA transitions from
1995 * IBSS to Infrastructure mode.
1996 */
1997 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1998
1999 session->limPrevSmeState = session->limSmeState;
2000 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2001 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2002 session->peSessionId,
2003 session->limSmeState));
2004
2005 lim_log(mac_ctx, LOG1,
2006 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
2007 mlm_join_req->sessionId, session->ssId.length,
2008 session->ssId.ssId, session->currentOperChannel,
2009 MAC_ADDR_ARRAY(session->bssId));
2010
2011 /* Indicate whether spectrum management is enabled */
2012 session->spectrumMgtEnabled =
2013 sme_join_req->spectrumMgtIndicator;
2014
2015 /* Enable the spectrum management if this is a DFS channel */
2016 if (session->country_info_present &&
2017 lim_isconnected_on_dfs_channel(
2018 session->currentOperChannel))
2019 session->spectrumMgtEnabled = true;
2020
2021 session->isOSENConnection = sme_join_req->isOSENConnection;
2022
2023 lim_log(mac_ctx, LOG1,
2024 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
2025 mlm_join_req->sessionId);
2026 /* Issue LIM_MLM_JOIN_REQ to MLM */
2027 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2028 (uint32_t *) mlm_join_req);
2029 return;
2030
2031 } else {
2032 /* Received eWNI_SME_JOIN_REQ un expected state */
2033 lim_log(mac_ctx, LOGE,
2034 FL("received unexpected SME_JOIN_REQ in state %X"),
2035 mac_ctx->lim.gLimSmeState);
2036 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2037 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2038 session = NULL;
2039 goto end;
2040 }
2041
2042end:
2043 sme_session_id = sme_join_req->sessionId;
2044 sme_transaction_id = sme_join_req->transactionId;
2045
2046 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302047 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 sme_join_req = NULL;
2049 if (NULL != session)
2050 session->pLimJoinReq = NULL;
2051 }
2052 if (ret_code != eSIR_SME_SUCCESS) {
2053 if (NULL != session) {
2054 pe_delete_session(mac_ctx, session);
2055 session = NULL;
2056 }
2057 }
2058 lim_log(mac_ctx, LOG1,
2059 FL("Send failure status on sessionid: %d with ret_code = %d"),
2060 sme_session_id, ret_code);
2061 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2062 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2063 sme_transaction_id);
2064}
2065
Amar Singhala297bfa2015-10-15 15:07:29 -07002066uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 uint8_t iniTxPower)
2068{
2069 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302070 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2071 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2073 maxTxPower = txPower;
2074 else if (txPower < MIN_TX_PWR_CAP)
2075 maxTxPower = MIN_TX_PWR_CAP;
2076 else
2077 maxTxPower = MAX_TX_PWR_CAP;
2078
2079 return maxTxPower;
2080}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081
2082/**
2083 * __lim_process_sme_reassoc_req() - process reassoc req
2084 *
2085 * @mac_ctx: Pointer to Global MAC structure
2086 * @msg_buf: pointer to the SME message buffer
2087 *
2088 * This function is called to process SME_REASSOC_REQ message
2089 * from HDD or upper layer application.
2090 *
2091 * Return: None
2092 */
2093
2094static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2095 uint32_t *msg_buf)
2096{
2097 uint16_t caps;
2098 uint32_t val;
2099 tpSirSmeJoinReq reassoc_req = NULL;
2100 tLimMlmReassocReq *mlm_reassoc_req;
2101 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2102 tpPESession session_entry = NULL;
2103 uint8_t session_id;
2104 uint8_t sme_session_id;
2105 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002106 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 uint32_t tele_bcn_en = 0;
2108 uint16_t size;
2109
2110 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2111
2112 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302113 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 if (NULL == reassoc_req) {
2115 lim_log(mac_ctx, LOGP,
2116 FL("call to AllocateMemory failed for reassoc_req"));
2117
2118 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2119 goto end;
2120 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302121 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2122 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123
2124 if (!lim_is_sme_join_req_valid(mac_ctx,
2125 (tpSirSmeJoinReq)reassoc_req)) {
2126 /*
2127 * Received invalid eWNI_SME_REASSOC_REQ
2128 */
2129 lim_log(mac_ctx, LOGW,
2130 FL("received SME_REASSOC_REQ with invalid data"));
2131
2132 ret_code = eSIR_SME_INVALID_PARAMETERS;
2133 goto end;
2134 }
2135
2136 session_entry = pe_find_session_by_bssid(mac_ctx,
2137 reassoc_req->bssDescription.bssId,
2138 &session_id);
2139 if (session_entry == NULL) {
2140 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2141 LOGE);
2142 lim_log(mac_ctx, LOGE,
2143 FL("Session does not exist for given bssId"));
2144 ret_code = eSIR_SME_INVALID_PARAMETERS;
2145 goto end;
2146 }
2147#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2148 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2149 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2150#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2151 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2152
2153 /* Store the reassoc handle in the session Table */
2154 session_entry->pLimReAssocReq = reassoc_req;
2155
2156 session_entry->dot11mode = reassoc_req->dot11mode;
2157 session_entry->vhtCapability =
2158 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002159
2160 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2161 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002162 session_entry->send_smps_action =
2163 reassoc_req->send_smps_action;
2164 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002165 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002166 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002167 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002168 session_entry->send_smps_action,
2169 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 /*
2171 * Reassociate request is expected
2172 * in link established state only.
2173 */
2174
2175 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2177 /*
2178 * May be from 11r FT pre-auth. So lets check it
2179 * before we bail out
2180 */
2181 lim_log(mac_ctx, LOG1, FL(
2182 "Session in reassoc state is %d"),
2183 session_entry->peSessionId);
2184
2185 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302186 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 session_entry->limReAssocbssId,
2188 6)) {
2189 lim_print_mac_addr(mac_ctx,
2190 reassoc_req->bssDescription.
2191 bssId, LOGE);
2192 lim_log(mac_ctx, LOGP,
2193 FL("Unknown bssId in reassoc state"));
2194 ret_code = eSIR_SME_INVALID_PARAMETERS;
2195 goto end;
2196 }
2197
2198 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2199 session_entry);
2200 return;
2201 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 /*
2203 * Should not have received eWNI_SME_REASSOC_REQ
2204 */
2205 lim_log(mac_ctx, LOGE,
2206 FL("received unexpected SME_REASSOC_REQ in state %X"),
2207 session_entry->limSmeState);
2208 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2209
2210 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2211 goto end;
2212 }
2213
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302214 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 session_entry->pLimReAssocReq->bssDescription.bssId,
2216 sizeof(tSirMacAddr));
2217
2218 session_entry->limReassocChannelId =
2219 session_entry->pLimReAssocReq->bssDescription.channelId;
2220
2221 session_entry->reAssocHtSupportedChannelWidthSet =
2222 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2223 session_entry->reAssocHtRecommendedTxWidthSet =
2224 session_entry->reAssocHtSupportedChannelWidthSet;
2225 session_entry->reAssocHtSecondaryChannelOffset =
2226 session_entry->pLimReAssocReq->cbMode;
2227
2228 session_entry->limReassocBssCaps =
2229 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2230 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2231 session_entry->currentOperChannel);
2232 local_pwr_constraint = reg_max;
2233
2234 lim_extract_ap_capability(mac_ctx,
2235 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2236 lim_get_ielen_from_bss_description(
2237 &session_entry->pLimReAssocReq->bssDescription),
2238 &session_entry->limReassocBssQosCaps,
2239 &session_entry->limReassocBssPropCap,
2240 &session_entry->gLimCurrentBssUapsd,
2241 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302242 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302244 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2245 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 /* Copy the SSID from session entry to local variable */
2247 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302248 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 reassoc_req->ssId.ssId,
2250 session_entry->limReassocSSID.length);
2251 if (session_entry->gLimCurrentBssUapsd) {
2252 session_entry->gUapsdPerAcBitmask =
2253 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2254 lim_log(mac_ctx, LOG1,
2255 FL("UAPSD flag for all AC - 0x%2x"),
2256 session_entry->gUapsdPerAcBitmask);
2257 }
2258
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302259 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 if (NULL == mlm_reassoc_req) {
2261 lim_log(mac_ctx, LOGP,
2262 FL("call to AllocateMemory failed for mlmReassocReq"));
2263
2264 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2265 goto end;
2266 }
2267
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302268 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2270
2271 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2272 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2273 eSIR_SUCCESS) {
2274 /*
2275 * Could not get ReassocFailureTimeout value
2276 * from CFG. Log error.
2277 */
2278 lim_log(mac_ctx, LOGP,
2279 FL("could not retrieve ReassocFailureTimeout value"));
2280 }
2281
2282 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2283 eSIR_SUCCESS) {
2284 /*
2285 * Could not get Capabilities value
2286 * from CFG. Log error.
2287 */
2288 lim_log(mac_ctx, LOGP, FL(
2289 "could not retrieve Capabilities value"));
2290 }
2291 mlm_reassoc_req->capabilityInfo = caps;
2292
2293 /* Update PE session_id */
2294 mlm_reassoc_req->sessionId = session_id;
2295
2296 /*
2297 * If telescopic beaconing is enabled, set listen interval to
2298 * WNI_CFG_TELE_BCN_MAX_LI
2299 */
2300 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2301 &tele_bcn_en) != eSIR_SUCCESS)
2302 lim_log(mac_ctx, LOGP,
2303 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2304
2305 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2306
2307 if (tele_bcn_en) {
2308 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &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 } else {
2317 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2318 eSIR_SUCCESS)
2319 /*
2320 * Could not get ListenInterval value
2321 * from CFG. Log error.
2322 */
2323 lim_log(mac_ctx, LOGP,
2324 FL("could not retrieve ListenInterval"));
2325 }
2326
2327 mlm_reassoc_req->listenInterval = (uint16_t) val;
2328
2329 /* Indicate whether spectrum management is enabled */
2330 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2331
2332 /* Enable the spectrum management if this is a DFS channel */
2333 if (session_entry->country_info_present &&
2334 lim_isconnected_on_dfs_channel(
2335 session_entry->currentOperChannel))
2336 session_entry->spectrumMgtEnabled = true;
2337
2338 session_entry->limPrevSmeState = session_entry->limSmeState;
2339 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2340
2341 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2342 session_entry->peSessionId,
2343 session_entry->limSmeState));
2344
2345 lim_post_mlm_message(mac_ctx,
2346 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2347 return;
2348end:
2349 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302350 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 if (session_entry)
2352 session_entry->pLimReAssocReq = NULL;
2353 }
2354
2355 if (session_entry) {
2356 /*
2357 * error occurred after we determined the session so extract
2358 * session and transaction info from there
2359 */
2360 sme_session_id = session_entry->smeSessionId;
2361 transaction_id = session_entry->transactionId;
2362 } else
2363 /*
2364 * error occurred before or during the time we determined
2365 * the session so extract the session and transaction info
2366 * from the message
2367 */
2368 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2369 &sme_session_id, &transaction_id);
2370
2371 /*
2372 * Send Reassoc failure response to host
2373 * (note session_entry may be NULL, but that's OK)
2374 */
2375 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2376 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2377 session_entry, sme_session_id,
2378 transaction_id);
2379}
2380
2381bool send_disassoc_frame = 1;
2382/**
2383 * __lim_process_sme_disassoc_req()
2384 *
2385 ***FUNCTION:
2386 * This function is called to process SME_DISASSOC_REQ message
2387 * from HDD or upper layer application.
2388 *
2389 ***LOGIC:
2390 *
2391 ***ASSUMPTIONS:
2392 *
2393 ***NOTE:
2394 *
2395 * @param pMac Pointer to Global MAC structure
2396 * @param *pMsgBuf A pointer to the SME message buffer
2397 * @return None
2398 */
2399
2400static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2401{
2402 uint16_t disassocTrigger, reasonCode;
2403 tLimMlmDisassocReq *pMlmDisassocReq;
2404 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2405 tSirSmeDisassocReq smeDisassocReq;
2406 tpPESession psessionEntry = NULL;
2407 uint8_t sessionId;
2408 uint8_t smesessionId;
2409 uint16_t smetransactionId;
2410
2411 if (pMsgBuf == NULL) {
2412 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2413 return;
2414 }
2415
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302416 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 smesessionId = smeDisassocReq.sessionId;
2418 smetransactionId = smeDisassocReq.transactionId;
2419 if (!lim_is_sme_disassoc_req_valid(pMac,
2420 &smeDisassocReq,
2421 psessionEntry)) {
2422 PELOGE(lim_log(pMac, LOGE,
2423 FL("received invalid SME_DISASSOC_REQ message"));)
2424 if (pMac->lim.gLimRspReqd) {
2425 pMac->lim.gLimRspReqd = false;
2426
2427 retCode = eSIR_SME_INVALID_PARAMETERS;
2428 disassocTrigger = eLIM_HOST_DISASSOC;
2429 goto sendDisassoc;
2430 }
2431
2432 return;
2433 }
2434
2435 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002436 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 &sessionId);
2438 if (psessionEntry == NULL) {
2439 lim_log(pMac, LOGE,
2440 FL("session does not exist for given bssId "
2441 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002442 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 retCode = eSIR_SME_INVALID_PARAMETERS;
2444 disassocTrigger = eLIM_HOST_DISASSOC;
2445 goto sendDisassoc;
2446 }
2447 lim_log(pMac, LOG1,
2448 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2449 MAC_ADDRESS_STR), smesessionId,
2450 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2451 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002452 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453
2454#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2455 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2456 0, smeDisassocReq.reasonCode);
2457#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2458
2459 /* Update SME session Id and SME transaction ID */
2460
2461 psessionEntry->smeSessionId = smesessionId;
2462 psessionEntry->transactionId = smetransactionId;
2463
2464 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2465 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 switch (psessionEntry->limSmeState) {
2467 case eLIM_SME_ASSOCIATED_STATE:
2468 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002469 lim_log(pMac, LOG1,
2470 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2471 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 psessionEntry->limPrevSmeState =
2473 psessionEntry->limSmeState;
2474 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2475#ifdef FEATURE_WLAN_TDLS
2476 /* Delete all TDLS peers connected before leaving BSS */
2477 lim_delete_tdls_peers(pMac, psessionEntry);
2478#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002479 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2480 psessionEntry->peSessionId,
2481 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 break;
2483
2484 case eLIM_SME_WT_DEAUTH_STATE:
2485 /* PE shall still process the DISASSOC_REQ and proceed with
2486 * link tear down even if it had already sent a DEAUTH_IND to
2487 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2488 * its been set when PE entered WT_DEAUTH_STATE.
2489 */
2490 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2491 MTRACE(mac_trace
2492 (pMac, TRACE_CODE_SME_STATE,
2493 psessionEntry->peSessionId,
2494 psessionEntry->limSmeState));
2495 lim_log(pMac, LOG1,
2496 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2497 break;
2498
2499 case eLIM_SME_WT_DISASSOC_STATE:
2500 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2501 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2502 * PE can continue processing DISASSOC_REQ and send the response instead
2503 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2504 * for disassoc frame.
2505 *
2506 * It will send a disassoc, which is ok. However, we can use the global flag
2507 * sendDisassoc to not send disassoc frame.
2508 */
2509 lim_log(pMac, LOG1,
2510 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2511 break;
2512
2513 case eLIM_SME_JOIN_FAILURE_STATE: {
2514 /* Already in Disconnected State, return success */
2515 lim_log(pMac, LOG1,
2516 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2517 if (pMac->lim.gLimRspReqd) {
2518 retCode = eSIR_SME_SUCCESS;
2519 disassocTrigger = eLIM_HOST_DISASSOC;
2520 goto sendDisassoc;
2521 }
2522 }
2523 break;
2524 default:
2525 /**
2526 * STA is not currently associated.
2527 * Log error and send response to host
2528 */
2529 lim_log(pMac, LOGE,
2530 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2531 psessionEntry->limSmeState);
2532 lim_print_sme_state(pMac, LOGE,
2533 psessionEntry->limSmeState);
2534
2535 if (pMac->lim.gLimRspReqd) {
2536 if (psessionEntry->limSmeState !=
2537 eLIM_SME_WT_ASSOC_STATE)
2538 pMac->lim.gLimRspReqd = false;
2539
2540 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2541 disassocTrigger = eLIM_HOST_DISASSOC;
2542 goto sendDisassoc;
2543 }
2544
2545 return;
2546 }
2547
2548 break;
2549
2550 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 /* Fall through */
2552 break;
2553
2554 case eLIM_STA_IN_IBSS_ROLE:
2555 default:
2556 /* eLIM_UNKNOWN_ROLE */
2557 lim_log(pMac, LOGE,
2558 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2559 GET_LIM_SYSTEM_ROLE(psessionEntry));
2560
2561 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2562 disassocTrigger = eLIM_HOST_DISASSOC;
2563 goto sendDisassoc;
2564 } /* end switch (pMac->lim.gLimSystemRole) */
2565
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302566 disassocTrigger = eLIM_HOST_DISASSOC;
2567 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568
2569 if (smeDisassocReq.doNotSendOverTheAir) {
2570 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2571 send_disassoc_frame = 0;
2572 }
2573 /* Trigger Disassociation frame to peer MAC entity */
2574 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2575 " : %d, reasonCode : %d"),
2576 disassocTrigger, reasonCode);
2577
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302578 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 if (NULL == pMlmDisassocReq) {
2580 /* Log error */
2581 lim_log(pMac, LOGP,
2582 FL("call to AllocateMemory failed for mlmDisassocReq"));
2583
2584 return;
2585 }
2586
Anurag Chouhanc5548422016-02-24 18:33:27 +05302587 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002588 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589
2590 pMlmDisassocReq->reasonCode = reasonCode;
2591 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2592
2593 /* Update PE session ID */
2594 pMlmDisassocReq->sessionId = sessionId;
2595
2596 lim_post_mlm_message(pMac,
2597 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2598 return;
2599
2600sendDisassoc:
2601 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002602 lim_send_sme_disassoc_ntf(pMac,
2603 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 retCode,
2605 disassocTrigger,
2606 1, smesessionId, smetransactionId,
2607 psessionEntry);
2608 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002609 lim_send_sme_disassoc_ntf(pMac,
2610 smeDisassocReq.peer_macaddr.bytes,
2611 retCode, disassocTrigger, 1,
2612 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613
2614} /*** end __lim_process_sme_disassoc_req() ***/
2615
2616/** -----------------------------------------------------------------
2617 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2618
2619 This function is called to process SME_DISASSOC_CNF message
2620 from HDD or upper layer application.
2621
2622 \param pMac - global mac structure
2623 \param pStaDs - station dph hash node
2624 \return none
2625 \sa
2626 ----------------------------------------------------------------- */
2627static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2628{
2629 tSirSmeDisassocCnf smeDisassocCnf;
2630 uint16_t aid;
2631 tpDphHashNode pStaDs;
2632 tpPESession psessionEntry;
2633 uint8_t sessionId;
2634
2635 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2636
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302637 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638 sizeof(struct sSirSmeDisassocCnf));
2639
2640 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002641 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 &sessionId);
2643 if (psessionEntry == NULL) {
2644 lim_log(pMac, LOGE,
2645 FL("session does not exist for given bssId"));
2646 return;
2647 }
2648
2649 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2650 lim_log(pMac, LOGE,
2651 FL("received invalid SME_DISASSOC_CNF message"));
2652 return;
2653 }
2654#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2655 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2656 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2657 psessionEntry,
2658 (uint16_t) smeDisassocCnf.statusCode, 0);
2659 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2660 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2661 psessionEntry,
2662 (uint16_t) smeDisassocCnf.statusCode, 0);
2663#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2664
2665 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2666 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2668 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2669 && (psessionEntry->limSmeState !=
2670 eLIM_SME_WT_DEAUTH_STATE)) {
2671 lim_log(pMac, LOGE,
2672 FL
2673 ("received unexp SME_DISASSOC_CNF in state %X"),
2674 psessionEntry->limSmeState);
2675 lim_print_sme_state(pMac, LOGE,
2676 psessionEntry->limSmeState);
2677 return;
2678 }
2679 break;
2680
2681 case eLIM_AP_ROLE:
2682 /* Fall through */
2683 break;
2684
2685 case eLIM_STA_IN_IBSS_ROLE:
2686 default: /* eLIM_UNKNOWN_ROLE */
2687 lim_log(pMac, LOGE,
2688 FL("received unexpected SME_DISASSOC_CNF role %d"),
2689 GET_LIM_SYSTEM_ROLE(psessionEntry));
2690
2691 return;
2692 }
2693
2694 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2695 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2696 LIM_IS_AP_ROLE(psessionEntry)) {
2697 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002698 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 &psessionEntry->dph.dphHashTable);
2700 if (pStaDs == NULL) {
2701 lim_log(pMac, LOGE,
2702 FL("DISASSOC_CNF for a STA with no context, addr= "
2703 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002704 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 return;
2706 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302707
2708 if ((pStaDs->mlmStaContext.mlmState ==
2709 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2710 (pStaDs->mlmStaContext.mlmState ==
2711 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2712 lim_log(pMac, LOGE,
2713 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002714 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302715 pStaDs->mlmStaContext.mlmState);
2716 return;
2717 }
2718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 /* Delete FT session if there exists one */
2720 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2722
2723 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002724 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 }
2726
2727 return;
2728}
2729
2730/**
2731 * __lim_process_sme_deauth_req() - process sme deauth req
2732 * @mac_ctx: Pointer to Global MAC structure
2733 * @msg_buf: pointer to the SME message buffer
2734 *
2735 * This function is called to process SME_DEAUTH_REQ message
2736 * from HDD or upper layer application.
2737 *
2738 * Return: None
2739 */
2740
2741static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2742 uint32_t *msg_buf)
2743{
2744 uint16_t deauth_trigger, reason_code;
2745 tLimMlmDeauthReq *mlm_deauth_req;
2746 tSirSmeDeauthReq sme_deauth_req;
2747 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2748 tpPESession session_entry;
2749 uint8_t session_id; /* PE sessionId */
2750 uint8_t sme_session_id;
2751 uint16_t sme_transaction_id;
2752
2753 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2754
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302755 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 sme_session_id = sme_deauth_req.sessionId;
2757 sme_transaction_id = sme_deauth_req.transactionId;
2758
2759 /*
2760 * We need to get a session first but we don't even know
2761 * if the message is correct.
2762 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002763 session_entry = pe_find_session_by_bssid(mac_ctx,
2764 sme_deauth_req.bssid.bytes,
2765 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 if (session_entry == NULL) {
2767 lim_log(mac_ctx, LOGE,
2768 FL("session does not exist for given bssId"));
2769 ret_code = eSIR_SME_INVALID_PARAMETERS;
2770 deauth_trigger = eLIM_HOST_DEAUTH;
2771 goto send_deauth;
2772 }
2773
2774 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2775 session_entry)) {
2776 lim_log(mac_ctx, LOGE,
2777 FL("received invalid SME_DEAUTH_REQ message"));
2778 mac_ctx->lim.gLimRspReqd = false;
2779
2780 ret_code = eSIR_SME_INVALID_PARAMETERS;
2781 deauth_trigger = eLIM_HOST_DEAUTH;
2782 goto send_deauth;
2783 }
2784 lim_log(mac_ctx, LOG1,
2785 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2786 MAC_ADDRESS_STR), sme_session_id,
2787 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2788 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002789 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2791 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2792 session_entry, 0, sme_deauth_req.reasonCode);
2793#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2794
2795 /* Update SME session ID and Transaction ID */
2796 session_entry->smeSessionId = sme_session_id;
2797 session_entry->transactionId = sme_transaction_id;
2798
2799 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2800 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 switch (session_entry->limSmeState) {
2802 case eLIM_SME_ASSOCIATED_STATE:
2803 case eLIM_SME_LINK_EST_STATE:
2804 case eLIM_SME_WT_ASSOC_STATE:
2805 case eLIM_SME_JOIN_FAILURE_STATE:
2806 case eLIM_SME_IDLE_STATE:
2807 session_entry->limPrevSmeState =
2808 session_entry->limSmeState;
2809 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2810 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2811 session_entry->peSessionId,
2812 session_entry->limSmeState));
2813 /* Send Deauthentication request to MLM below */
2814 break;
2815 case eLIM_SME_WT_DEAUTH_STATE:
2816 case eLIM_SME_WT_DISASSOC_STATE:
2817 /*
2818 * PE Recieved a Deauth/Disassoc frame. Normally it get
2819 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2820 * Which means host is also trying to disconnect.
2821 * PE can continue processing DEAUTH_REQ and send
2822 * the response instead of failing the request.
2823 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2824 * was sent for deauth/disassoc frame.
2825 */
2826 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2827 lim_log(mac_ctx, LOG1, FL(
2828 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2829 break;
2830 default:
2831 /*
2832 * STA is not in a state to deauthenticate with
2833 * peer. Log error and send response to host.
2834 */
2835 lim_log(mac_ctx, LOGE, FL(
2836 "received unexp SME_DEAUTH_REQ in state %X"),
2837 session_entry->limSmeState);
2838 lim_print_sme_state(mac_ctx, LOGE,
2839 session_entry->limSmeState);
2840
2841 if (mac_ctx->lim.gLimRspReqd) {
2842 mac_ctx->lim.gLimRspReqd = false;
2843
2844 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2845 deauth_trigger = eLIM_HOST_DEAUTH;
2846
2847 /*
2848 * here we received deauth request from AP so sme state
2849 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2850 * delSta then mlm state should be
2851 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2852 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2853 * so the below condition captures the state where
2854 * delSta not done and firmware still in
2855 * connected state.
2856 */
2857 if (session_entry->limSmeState ==
2858 eLIM_SME_WT_DEAUTH_STATE &&
2859 session_entry->limMlmState !=
2860 eLIM_MLM_IDLE_STATE &&
2861 session_entry->limMlmState !=
2862 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2863 ret_code = eSIR_SME_DEAUTH_STATUS;
2864 goto send_deauth;
2865 }
2866 return;
2867 }
2868 break;
2869
2870 case eLIM_STA_IN_IBSS_ROLE:
2871 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2872 if (mac_ctx->lim.gLimRspReqd) {
2873 mac_ctx->lim.gLimRspReqd = false;
2874 ret_code = eSIR_SME_INVALID_PARAMETERS;
2875 deauth_trigger = eLIM_HOST_DEAUTH;
2876 goto send_deauth;
2877 }
2878 return;
2879 case eLIM_AP_ROLE:
2880 break;
2881 default:
2882 lim_log(mac_ctx, LOGE,
2883 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2884 GET_LIM_SYSTEM_ROLE(session_entry));
2885 if (mac_ctx->lim.gLimRspReqd) {
2886 mac_ctx->lim.gLimRspReqd = false;
2887 ret_code = eSIR_SME_INVALID_PARAMETERS;
2888 deauth_trigger = eLIM_HOST_DEAUTH;
2889 goto send_deauth;
2890 }
2891 return;
2892 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2893
2894 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2895 /* Deauthentication is triggered by Link Monitoring */
2896 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2897 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2898 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2899 } else {
2900 deauth_trigger = eLIM_HOST_DEAUTH;
2901 reason_code = sme_deauth_req.reasonCode;
2902 }
2903
2904 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302905 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 if (NULL == mlm_deauth_req) {
2907 lim_log(mac_ctx, LOGP,
2908 FL("call to AllocateMemory failed for mlmDeauthReq"));
2909 if (mac_ctx->lim.gLimRspReqd) {
2910 mac_ctx->lim.gLimRspReqd = false;
2911 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2912 deauth_trigger = eLIM_HOST_DEAUTH;
2913 goto send_deauth;
2914 }
2915 return;
2916 }
2917
Anurag Chouhanc5548422016-02-24 18:33:27 +05302918 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002919 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920
2921 mlm_deauth_req->reasonCode = reason_code;
2922 mlm_deauth_req->deauthTrigger = deauth_trigger;
2923
2924 /* Update PE session Id */
2925 mlm_deauth_req->sessionId = session_id;
2926
2927 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2928 (uint32_t *)mlm_deauth_req);
2929 return;
2930
2931send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002932 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2933 ret_code, deauth_trigger, 1,
2934 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935}
2936
2937/**
2938 * __lim_process_sme_set_context_req()
2939 *
2940 * @mac_ctx: Pointer to Global MAC structure
2941 * @msg_buf: pointer to the SME message buffer
2942 *
2943 * This function is called to process SME_SETCONTEXT_REQ message
2944 * from HDD or upper layer application.
2945 *
2946 * Return: None
2947 */
2948
2949static void
2950__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2951{
2952 tpSirSmeSetContextReq set_context_req;
2953 tLimMlmSetKeysReq *mlm_set_key_req;
2954 tpPESession session_entry;
2955 uint8_t session_id; /* PE sessionID */
2956 uint8_t sme_session_id;
2957 uint16_t sme_transaction_id;
2958
2959 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2960
2961 if (msg_buf == NULL) {
2962 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2963 return;
2964 }
2965
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302966 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 if (NULL == set_context_req) {
2968 lim_log(mac_ctx, LOGP, FL(
2969 "call to AllocateMemory failed for set_context_req"));
2970 return;
2971 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302972 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 sizeof(struct sSirSmeSetContextReq));
2974 sme_session_id = set_context_req->sessionId;
2975 sme_transaction_id = set_context_req->transactionId;
2976
2977 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2978 lim_log(mac_ctx, LOGW,
2979 FL("received invalid SME_SETCONTEXT_REQ message"));
2980 goto end;
2981 }
2982
2983 if (set_context_req->keyMaterial.numKeys >
2984 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2985 lim_log(mac_ctx, LOGE, FL(
2986 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2987 set_context_req->keyMaterial.numKeys);
2988 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002989 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 eSIR_SME_INVALID_PARAMETERS, NULL,
2991 sme_session_id, sme_transaction_id);
2992 goto end;
2993 }
2994
2995 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002996 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 if (session_entry == NULL) {
2998 lim_log(mac_ctx, LOGW,
2999 FL("Session does not exist for given BSSID"));
3000 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003001 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 eSIR_SME_INVALID_PARAMETERS, NULL,
3003 sme_session_id, sme_transaction_id);
3004 goto end;
3005 }
3006#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3007 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3008 session_entry, 0, 0);
3009#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3010
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003011 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3013 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003014 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3016 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303017 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 if (NULL == mlm_set_key_req) {
3019 lim_log(mac_ctx, LOGP, FL(
3020 "mem alloc failed for mlmSetKeysReq"));
3021 goto end;
3022 }
3023 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3024 mlm_set_key_req->numKeys =
3025 set_context_req->keyMaterial.numKeys;
3026 if (mlm_set_key_req->numKeys >
3027 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3028 lim_log(mac_ctx, LOGP, FL(
3029 "no.of keys exceeded max num of default keys limit"));
3030 goto end;
3031 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303032 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003033 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303035 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 (uint8_t *) &set_context_req->keyMaterial.key,
3037 sizeof(tSirKeys) *
3038 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3039 numKeys : 1));
3040
3041 mlm_set_key_req->sessionId = session_id;
3042 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 lim_log(mac_ctx, LOG1, FL(
3044 "received SETCONTEXT_REQ message sessionId=%d"),
3045 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046
3047 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3048 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3049 LIM_IS_AP_ROLE(session_entry)) {
3050 if (set_context_req->keyMaterial.key[0].keyLength) {
3051 uint8_t key_id;
3052 key_id =
3053 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 &session_entry->WEPKeyMaterial[key_id],
3056 (uint8_t *) &set_context_req->keyMaterial,
3057 sizeof(tSirKeyMaterial));
3058 } else {
3059 uint32_t i;
3060 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3061 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303062 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 &mlm_set_key_req->key[i],
3064 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3065 sizeof(tSirKeys));
3066 }
3067 }
3068 }
3069 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3070 (uint32_t *) mlm_set_key_req);
3071 } else {
3072 lim_log(mac_ctx, LOGE, FL(
3073 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3074 GET_LIM_SYSTEM_ROLE(session_entry),
3075 session_entry->limSmeState);
3076 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3077
3078 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003079 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3081 session_entry, sme_session_id,
3082 sme_transaction_id);
3083 }
3084end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303085 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 return;
3087}
3088
3089/**
3090 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3091 *
3092 * @mac_ctx: Pointer to Global MAC structure
3093 * @msg_buf: pointer to the SME message buffer
3094 *
3095 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3096 * from HDD or upper layer application.
3097 *
3098 * Return: None
3099 */
3100
3101void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3102 uint32_t *msg_buf)
3103{
3104 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3105 tpDphHashNode sta_ds = NULL;
3106 tpPESession session_entry = NULL;
3107 tSap_Event sap_event;
3108 tpWLAN_SAPEventCB sap_event_cb = NULL;
3109 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3110 uint8_t session_id = CSR_SESSION_ID_INVALID;
3111 uint8_t assoc_id = 0;
3112 uint8_t sta_cnt = 0;
3113
3114 if (msg_buf == NULL) {
3115 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3116 return;
3117 }
3118
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303119 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 sizeof(struct sSirSmeGetAssocSTAsReq));
3121 /*
3122 * Get Associated stations from PE.
3123 * Find PE session Entry
3124 */
3125 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003126 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 &session_id);
3128 if (session_entry == NULL) {
3129 lim_log(mac_ctx, LOGE,
3130 FL("session does not exist for given bssId"));
3131 goto lim_assoc_sta_end;
3132 }
3133
3134 if (!LIM_IS_AP_ROLE(session_entry)) {
3135 lim_log(mac_ctx, LOGE, FL(
3136 "Received unexpected message in state %X, in role %X"),
3137 session_entry->limSmeState,
3138 GET_LIM_SYSTEM_ROLE(session_entry));
3139 goto lim_assoc_sta_end;
3140 }
3141 /* Retrieve values obtained in the request message */
3142 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3143 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3144
3145 if (NULL == assoc_sta_tmp)
3146 goto lim_assoc_sta_end;
3147 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3148 assoc_id++) {
3149 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3150 &session_entry->dph.dphHashTable);
3151 if (NULL == sta_ds)
3152 continue;
3153 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303154 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303156 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3158 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3159
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303160 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 (uint8_t *)&sta_ds->supportedRates,
3162 sizeof(tSirSupportedRates));
3163 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3164 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3165 assoc_sta_tmp->Support40Mhz =
3166 sta_ds->htDsssCckRate40MHzSupport;
3167
3168 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3169 sta_cnt + 1);
3170 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3171 MAC_ADDR_ARRAY(sta_ds->staAddr));
3172 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3173 sta_ds->assocId);
3174 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3175 sta_ds->staIndex);
3176 assoc_sta_tmp++;
3177 sta_cnt++;
3178 }
3179 }
3180lim_assoc_sta_end:
3181 /*
3182 * Call hdd callback with sap event to send the list of
3183 * associated stations from PE
3184 */
3185 if (sap_event_cb != NULL) {
3186 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3187 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303188 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3190 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3191 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3192 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3193 }
3194}
3195
3196/**
3197 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3198 *
3199 * @mac_ctx: Pointer to Global MAC structure
3200 * @msg_buf: pointer to WPS PBC overlap query message
3201 *
3202 * This function parses get WPS PBC overlap information
3203 * message and call callback to pass WPS PBC overlap
3204 * information back to hdd.
3205 *
3206 * Return: None
3207 */
3208void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3209 uint32_t *msg_buf)
3210{
3211 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3212 tpPESession session_entry = NULL;
3213 tSap_Event sap_event;
3214 tpWLAN_SAPEventCB sap_event_cb = NULL;
3215 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3217
3218 if (msg_buf == NULL) {
3219 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3220 return;
3221 }
3222
3223 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303224 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303226 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3228 /*
3229 * Get Associated stations from PE
3230 * Find PE session Entry
3231 */
3232 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003233 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 if (session_entry == NULL) {
3235 lim_log(mac_ctx, LOGE,
3236 FL("session does not exist for given bssId"));
3237 goto lim_get_wpspbc_sessions_end;
3238 }
3239
3240 if (!LIM_IS_AP_ROLE(session_entry)) {
3241 lim_log(mac_ctx, LOGE,
3242 FL("Received unexpected message in role %X"),
3243 GET_LIM_SYSTEM_ROLE(session_entry));
3244 goto lim_get_wpspbc_sessions_end;
3245 }
3246 /*
3247 * Call hdd callback with sap event to send the
3248 * WPS PBC overlap information
3249 */
3250 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303251 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252
Anurag Chouhanc5548422016-02-24 18:33:27 +05303253 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003255 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 sap_get_wpspbc_event->UUID_E,
3257 &sap_get_wpspbc_event->wpsPBCOverlap,
3258 session_entry);
3259 } else {
3260 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003261 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 session_entry);
3263 /* don't have to inform the HDD/Host */
3264 return;
3265 }
3266
3267 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3268 sap_get_wpspbc_event->wpsPBCOverlap);
3269 lim_print_mac_addr(mac_ctx,
3270 sap_get_wpspbc_event->addr.bytes, LOG4);
3271
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303272 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273
3274lim_get_wpspbc_sessions_end:
3275 sap_event_cb =
3276 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3277 if (NULL != sap_event_cb)
3278 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3279}
3280
3281/**
3282 * __lim_counter_measures()
3283 *
3284 * FUNCTION:
3285 * This function is called to "implement" MIC counter measure
3286 * and is *temporary* only
3287 *
3288 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3289 * we don't do the proper STA disassoc sequence since the
3290 * BSS will be stoped anyway
3291 *
3292 ***ASSUMPTIONS:
3293 *
3294 ***NOTE:
3295 *
3296 * @param pMac Pointer to Global MAC structure
3297 * @return None
3298 */
3299
3300static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3301{
3302 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003303 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3305 mac, psessionEntry, false);
3306};
3307
3308void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3309{
3310 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3311 tpPESession psessionEntry;
3312 uint8_t sessionId; /* PE sessionId */
3313
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303314 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 sizeof(struct sSirSmeTkipCntrMeasReq));
3316
3317 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003318 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 if (NULL == psessionEntry) {
3320 lim_log(pMac, LOGE,
3321 FL("session does not exist for given BSSID "));
3322 return;
3323 }
3324
3325 if (tkipCntrMeasReq.bEnable)
3326 __lim_counter_measures(pMac, psessionEntry);
3327
3328 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3329}
3330
3331static void
3332__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3333{
3334 tSirSmeStopBssReq stopBssReq;
3335 tSirRetStatus status;
3336 tLimSmeStates prevState;
3337 tpPESession psessionEntry;
3338 uint8_t smesessionId;
3339 uint8_t sessionId;
3340 uint16_t smetransactionId;
3341 uint8_t i = 0;
3342 tpDphHashNode pStaDs = NULL;
3343
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303344 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 smesessionId = stopBssReq.sessionId;
3346 smetransactionId = stopBssReq.transactionId;
3347
3348 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3349 PELOGW(lim_log(pMac, LOGW,
3350 FL("received invalid SME_STOP_BSS_REQ message"));)
3351 /* Send Stop BSS response to host */
3352 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3353 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3354 smetransactionId);
3355 return;
3356 }
3357
3358 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003359 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 &sessionId);
3361 if (psessionEntry == NULL) {
3362 lim_log(pMac, LOGW,
3363 FL("session does not exist for given BSSID "));
3364 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3365 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3366 smetransactionId);
3367 return;
3368 }
3369#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3370 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3371 0, 0);
3372#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3373
3374 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3375 LIM_IS_STA_ROLE(psessionEntry)) {
3376 /**
3377 * Should not have received STOP_BSS_REQ in states
3378 * other than 'normal' state or on STA in Infrastructure
3379 * mode. Log error and return response to host.
3380 */
3381 lim_log(pMac, LOGE,
3382 FL
3383 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3384 psessionEntry->limSmeState,
3385 GET_LIM_SYSTEM_ROLE(psessionEntry));
3386 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3387 /* / Send Stop BSS response to host */
3388 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3389 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3390 smetransactionId);
3391 return;
3392 }
3393
3394 if (LIM_IS_AP_ROLE(psessionEntry))
3395 lim_wpspbc_close(pMac, psessionEntry);
3396
3397 lim_log(pMac, LOGW,
3398 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3399 stopBssReq.reasonCode);
3400
3401 prevState = psessionEntry->limSmeState;
3402
3403 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3404 MTRACE(mac_trace
3405 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3406 psessionEntry->limSmeState));
3407
3408 /* Update SME session Id and Transaction Id */
3409 psessionEntry->smeSessionId = smesessionId;
3410 psessionEntry->transactionId = smetransactionId;
3411
3412 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003413 if (!LIM_IS_IBSS_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3415 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3416 /* Send disassoc all stations associated thru TKIP */
3417 __lim_counter_measures(pMac, psessionEntry);
3418 else
3419 lim_send_disassoc_mgmt_frame(pMac,
3420 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3421 bcAddr, psessionEntry, false);
3422 }
3423
3424 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303425 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 psessionEntry->addIeParams.probeRespDataLen = 0;
3427 psessionEntry->addIeParams.probeRespData_buff = NULL;
3428
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303429 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 psessionEntry->addIeParams.assocRespDataLen = 0;
3431 psessionEntry->addIeParams.assocRespData_buff = NULL;
3432
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303433 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3435 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3436
3437 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3438 pMac->lim.gLimIbssCoalescingHappened = false;
3439
3440 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3441 pStaDs =
3442 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3443 if (NULL == pStaDs)
3444 continue;
3445 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3446 if (eSIR_SUCCESS == status) {
3447 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3448 pStaDs->assocId, psessionEntry);
3449 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3450 } else {
3451 lim_log(pMac, LOGE,
3452 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303453 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 }
3455 }
3456 /* send a delBss to HAL and wait for a response */
3457 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3458
3459 if (status != eSIR_SUCCESS) {
3460 PELOGE(lim_log
3461 (pMac, LOGE, FL("delBss failed for bss %d"),
3462 psessionEntry->bssIdx);
3463 )
3464 psessionEntry->limSmeState = prevState;
3465
3466 MTRACE(mac_trace
3467 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3468 psessionEntry->limSmeState));
3469
3470 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3471 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3472 smetransactionId);
3473 }
3474}
3475
3476/**
3477 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3478 * @pMac: Global MAC context
3479 * @pMsg: Message from SME
3480 *
3481 * Wrapper for the function __lim_handle_sme_stop_bss_request
3482 * This message will be defered until softmac come out of
3483 * scan mode. Message should be handled even if we have
3484 * detected radar in the current operating channel.
3485 *
3486 * Return: true - If we consumed the buffer
3487 * false - If have defered the message.
3488 */
3489
3490static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3491{
3492 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3493 /**
3494 * If message defered, buffer is not consumed yet.
3495 * So return false
3496 */
3497 return false;
3498 }
3499 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3500 return true;
3501} /*** end __lim_process_sme_stop_bss_req() ***/
3502
3503void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3504 uint32_t body, tpPESession psessionEntry)
3505{
3506
3507 (void)body;
3508 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3509 lim_ibss_delete(pMac, psessionEntry);
3510 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3511 lim_delete_pre_auth_list(pMac);
3512 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3513 psessionEntry->smeSessionId,
3514 psessionEntry->transactionId);
3515 return;
3516}
3517
3518/**
3519 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3520 *
3521 * @mac_ctx: pointer to mac context
3522 * @msg_type: message type
3523 * @msg_buf: pointer to the SME message buffer
3524 *
3525 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3526 * in BTAMP AP.
3527 *
3528 * Return: None
3529 */
3530
3531void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3532 uint32_t *msg_buf)
3533{
3534 tSirSmeAssocCnf assoc_cnf;
3535 tpDphHashNode sta_ds = NULL;
3536 tpPESession session_entry = NULL;
3537 uint8_t session_id;
3538 tpSirAssocReq assoc_req;
3539
3540 if (msg_buf == NULL) {
3541 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3542 goto end;
3543 }
3544
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303545 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3547 lim_log(mac_ctx, LOGE,
3548 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3549 goto end;
3550 }
3551
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003552 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 &session_id);
3554 if (session_entry == NULL) {
3555 lim_log(mac_ctx, LOGE,
3556 FL("session does not exist for given bssId"));
3557 goto end;
3558 }
3559
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003560 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3562 (session_entry->limSmeState !=
3563 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3564 lim_log(mac_ctx, LOGE, FL(
3565 "Rcvd unexpected msg %X in state %X, in role %X"),
3566 msg_type, session_entry->limSmeState,
3567 GET_LIM_SYSTEM_ROLE(session_entry));
3568 goto end;
3569 }
3570 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3571 &session_entry->dph.dphHashTable);
3572 if (sta_ds == NULL) {
3573 lim_log(mac_ctx, LOGE, FL(
3574 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3575 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003576 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577
3578 /*
3579 * send a DISASSOC_IND message to WSM to make sure
3580 * the state in WSM and LIM is the same
3581 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003582 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 eSIR_SME_STA_NOT_ASSOCIATED,
3584 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3585 session_entry->smeSessionId,
3586 session_entry->transactionId,
3587 session_entry);
3588 goto end;
3589 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303590 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003591 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303592 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 lim_log(mac_ctx, LOG1, FL(
3594 "peerMacAddr mismatched for aid %d, peer "),
3595 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003596 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 goto end;
3598 }
3599
3600 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3601 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3602 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3603 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3604 (msg_type != eWNI_SME_ASSOC_CNF))) {
3605 lim_log(mac_ctx, LOG1, FL(
3606 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3607 "StaD mlmState : %d"),
3608 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003609 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 goto end;
3611 }
3612 /*
3613 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3614 * has been received
3615 */
3616 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3617 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3618 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3619
3620 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3621 /*
3622 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3623 * when it had received Assoc Request frame. Now, PE just needs
3624 * to send association rsp frame to the requesting BTAMP-STA.
3625 */
3626 sta_ds->mlmStaContext.mlmState =
3627 eLIM_MLM_LINK_ESTABLISHED_STATE;
3628 lim_log(mac_ctx, LOG1,
3629 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3630 sta_ds->assocId);
3631 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3632 sta_ds->assocId, sta_ds->staAddr,
3633 sta_ds->mlmStaContext.subType, sta_ds,
3634 session_entry);
3635 goto end;
3636 } else {
3637 /*
3638 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3639 * to be associated since the HAL sta entry is created for
3640 * denied STA we need to remove this HAL entry.
3641 * So to do that set updateContext to 1
3642 */
3643 if (!sta_ds->mlmStaContext.updateContext)
3644 sta_ds->mlmStaContext.updateContext = 1;
3645 lim_log(mac_ctx, LOG1,
3646 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3647 assoc_cnf.statusCode, sta_ds->assocId);
3648 lim_reject_association(mac_ctx, sta_ds->staAddr,
3649 sta_ds->mlmStaContext.subType,
3650 true, sta_ds->mlmStaContext.authType,
3651 sta_ds->assocId, true,
3652 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3653 session_entry);
3654 }
3655end:
3656 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3657 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3658 assoc_req = (tpSirAssocReq)
3659 session_entry->parsedAssocReq[sta_ds->assocId];
3660 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303661 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 assoc_req->assocReqFrame = NULL;
3663 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303664 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3666 }
3667}
3668
3669static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3670{
3671 tpDphHashNode pStaDs;
3672 tSirMacAddr peerMac;
3673 tpSirAddtsReq pSirAddts;
3674 uint32_t timeout;
3675 tpPESession psessionEntry;
3676 uint8_t sessionId; /* PE sessionId */
3677 uint8_t smesessionId;
3678 uint16_t smetransactionId;
3679
3680 if (pMsgBuf == NULL) {
3681 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3682 return;
3683 }
3684
3685 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3686 &smetransactionId);
3687
3688 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3689
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003690 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3691 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692 if (psessionEntry == NULL) {
3693 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3694 return;
3695 }
3696#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3697 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3698 0);
3699#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3700
3701 /* if sta
3702 * - verify assoc state
3703 * - send addts request to ap
3704 * - wait for addts response from ap
3705 * if ap, just ignore with error log
3706 */
3707 PELOG1(lim_log(pMac, LOG1,
3708 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3709 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3710 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3711 )
3712
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003713 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3715 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3716 psessionEntry, pSirAddts->req.tspec,
3717 smesessionId, smetransactionId);
3718 return;
3719 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720
3721 pStaDs =
3722 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3723 &psessionEntry->dph.dphHashTable);
3724
3725 if (pStaDs == NULL) {
3726 PELOGE(lim_log
3727 (pMac, LOGE, "Cannot find AP context for addts req");
3728 )
3729 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3730 psessionEntry, pSirAddts->req.tspec,
3731 smesessionId, smetransactionId);
3732 return;
3733 }
3734
3735 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3736 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3737 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3738 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3739 psessionEntry, pSirAddts->req.tspec,
3740 smesessionId, smetransactionId);
3741 return;
3742 }
3743
3744 pSirAddts->req.wsmTspecPresent = 0;
3745 pSirAddts->req.wmeTspecPresent = 0;
3746 pSirAddts->req.lleTspecPresent = 0;
3747
3748 if ((pStaDs->wsmEnabled) &&
3749 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3750 SIR_MAC_ACCESSPOLICY_EDCA))
3751 pSirAddts->req.wsmTspecPresent = 1;
3752 else if (pStaDs->wmeEnabled)
3753 pSirAddts->req.wmeTspecPresent = 1;
3754 else if (pStaDs->lleEnabled)
3755 pSirAddts->req.lleTspecPresent = 1;
3756 else {
3757 PELOGW(lim_log
3758 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3759 )
3760 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3761 psessionEntry, pSirAddts->req.tspec,
3762 smesessionId, smetransactionId);
3763 return;
3764 }
3765
3766 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3767 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3768 lim_log(pMac, LOGE,
3769 "AddTs received in invalid LIMsme state (%d)",
3770 psessionEntry->limSmeState);
3771 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3772 psessionEntry, pSirAddts->req.tspec,
3773 smesessionId, smetransactionId);
3774 return;
3775 }
3776
3777 if (pMac->lim.gLimAddtsSent) {
3778 lim_log(pMac, LOGE,
3779 "Addts (token %d, tsid %d, up %d) is still pending",
3780 pMac->lim.gLimAddtsReq.req.dialogToken,
3781 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3782 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3783 userPrio);
3784 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3785 psessionEntry, pSirAddts->req.tspec,
3786 smesessionId, smetransactionId);
3787 return;
3788 }
3789
3790 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3791
3792 /* save the addts request */
3793 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303794 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3796
3797 /* ship out the message now */
3798 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3799 psessionEntry);
3800 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3801 /* start a timer to wait for the response */
3802 if (pSirAddts->timeout)
3803 timeout = pSirAddts->timeout;
3804 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3805 eSIR_SUCCESS) {
3806 lim_log(pMac, LOGP,
3807 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3808 WNI_CFG_ADDTS_RSP_TIMEOUT);
3809 return;
3810 }
3811
3812 timeout = SYS_MS_TO_TICKS(timeout);
3813 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3814 != TX_SUCCESS) {
3815 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3816 return;
3817 }
3818 pMac->lim.gLimAddtsRspTimerCount++;
3819 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3820 pMac->lim.gLimAddtsRspTimerCount) !=
3821 TX_SUCCESS) {
3822 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3823 return;
3824 }
3825 MTRACE(mac_trace
3826 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3827 eLIM_ADDTS_RSP_TIMER));
3828
3829 /* add the sessionId to the timer object */
3830 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3831 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3832 TX_SUCCESS) {
3833 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3834 return;
3835 }
3836 return;
3837}
3838
3839static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3840{
3841 tSirMacAddr peerMacAddr;
3842 uint8_t ac;
3843 tSirMacTSInfo *pTsinfo;
3844 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3845 tpDphHashNode pStaDs = NULL;
3846 tpPESession psessionEntry;
3847 uint8_t sessionId;
3848 uint32_t status = eSIR_SUCCESS;
3849 uint8_t smesessionId;
3850 uint16_t smetransactionId;
3851
3852 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3853 &smetransactionId);
3854
3855 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003856 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 &sessionId);
3858 if (psessionEntry == NULL) {
3859 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3860 status = eSIR_FAILURE;
3861 goto end;
3862 }
3863#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3864 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3865 0);
3866#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3867
3868 if (eSIR_SUCCESS !=
3869 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3870 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3871 status = eSIR_FAILURE;
3872 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3873 smesessionId, smetransactionId);
3874 return;
3875 }
3876
3877 lim_log(pMac, LOG1,
3878 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3879 MAC_ADDRESS_STR),
3880 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3881
3882 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3883 pDeltsReq->req.wmeTspecPresent,
3884 &pDeltsReq->req.tsinfo,
3885 &pDeltsReq->req.tspec, psessionEntry);
3886
3887 pTsinfo =
3888 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3889 tsinfo : &pDeltsReq->req.tsinfo;
3890
3891 /* We've successfully send DELTS frame to AP. Update the
3892 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3893 * is no longer trigger enabled or delivery enabled
3894 */
3895 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3896 pTsinfo, CLEAR_UAPSD_MASK);
3897
3898 /* We're deleting the TSPEC, so this particular AC is no longer
3899 * admitted. PE needs to downgrade the EDCA
3900 * parameters(for the AC for which TS is being deleted) to the
3901 * next best AC for which ACM is not enabled, and send the
3902 * updated values to HAL.
3903 */
3904 ac = upToAc(pTsinfo->traffic.userPrio);
3905
3906 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3907 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3908 ~(1 << ac);
3909 } else if (pTsinfo->traffic.direction ==
3910 SIR_MAC_DIRECTION_DNLINK) {
3911 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3912 ~(1 << ac);
3913 } else if (pTsinfo->traffic.direction ==
3914 SIR_MAC_DIRECTION_BIDIR) {
3915 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3916 ~(1 << ac);
3917 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3918 ~(1 << ac);
3919 }
3920
3921 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3922 psessionEntry);
3923
3924 pStaDs =
3925 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3926 &psessionEntry->dph.dphHashTable);
3927 if (pStaDs != NULL) {
3928 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3929 pStaDs->bssId);
3930 status = eSIR_SUCCESS;
3931 } else {
3932 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3933 status = eSIR_FAILURE;
3934 }
3935#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937#endif
3938
3939 /* send an sme response back */
3940end:
3941 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3942 smesessionId, smetransactionId);
3943}
3944
3945void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3946{
3947 /* fetch the sessionEntry based on the sessionId */
3948 tpPESession psessionEntry;
3949 psessionEntry = pe_find_session_by_session_id(pMac,
3950 pMac->lim.limTimers.gLimAddtsRspTimer.
3951 sessionId);
3952 if (psessionEntry == NULL) {
3953 lim_log(pMac, LOGP,
3954 FL("Session Does not exist for given sessionID"));
3955 return;
3956 }
3957
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003958 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3960 GET_LIM_SYSTEM_ROLE(psessionEntry));
3961 pMac->lim.gLimAddtsSent = false;
3962 return;
3963 }
3964
3965 if (!pMac->lim.gLimAddtsSent) {
3966 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3967 return;
3968 }
3969
3970 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3971 lim_log(pMac, LOGE,
3972 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3973 pMac->lim.gLimAddtsRspTimerCount);
3974 return;
3975 }
3976 /* this a real response timeout */
3977 pMac->lim.gLimAddtsSent = false;
3978 pMac->lim.gLimAddtsRspTimerCount++;
3979
3980 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3981 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3982 psessionEntry->smeSessionId,
3983 psessionEntry->transactionId);
3984}
3985
3986/**
3987 * __lim_process_sme_get_statistics_request()
3988 *
3989 ***FUNCTION:
3990 *
3991 *
3992 ***NOTE:
3993 *
3994 * @param pMac Pointer to Global MAC structure
3995 * @param *pMsgBuf A pointer to the SME message buffer
3996 * @return None
3997 */
3998static void
3999__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4000{
4001 tpAniGetPEStatsReq pPEStatsReq;
4002 tSirMsgQ msgQ;
4003
4004 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4005
4006 msgQ.type = WMA_GET_STATISTICS_REQ;
4007
4008 msgQ.reserved = 0;
4009 msgQ.bodyptr = pMsgBuf;
4010 msgQ.bodyval = 0;
4011 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4012
4013 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304014 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 pMsgBuf = NULL;
4016 lim_log(pMac, LOGP, "Unable to forward request");
4017 return;
4018 }
4019
4020 return;
4021}
4022
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004023#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004025 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004027 * @pMac: Pointer to Global MAC structure
4028 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004030 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 */
4032static void
4033__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4034{
4035 tSirMsgQ msgQ;
4036
4037 msgQ.type = WMA_TSM_STATS_REQ;
4038 msgQ.reserved = 0;
4039 msgQ.bodyptr = pMsgBuf;
4040 msgQ.bodyval = 0;
4041 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4042
4043 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304044 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 pMsgBuf = NULL;
4046 lim_log(pMac, LOGP, "Unable to forward request");
4047 return;
4048 }
4049}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004050#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051
4052static void
4053__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4054{
4055 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4056 tpPESession psessionEntry;
4057 uint8_t sessionId; /* PE sessionID */
4058
4059 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4060
4061 if (pMsgBuf == NULL) {
4062 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4063 return;
4064 }
4065
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304066 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 if (NULL == pUpdateAPWPSIEsReq) {
4068 lim_log(pMac, LOGP,
4069 FL
4070 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4071 return;
4072 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304073 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 sizeof(struct sSirUpdateAPWPSIEsReq));
4075
4076 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004077 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 &sessionId);
4079 if (psessionEntry == NULL) {
4080 lim_log(pMac, LOGW,
4081 FL("Session does not exist for given BSSID"));
4082 goto end;
4083 }
4084
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304085 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 sizeof(tSirAPWPSIEs));
4087
4088 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4089 lim_send_beacon_ind(pMac, psessionEntry);
4090
4091end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 return;
4094}
4095
4096void
4097lim_send_vdev_restart(tpAniSirGlobal pMac,
4098 tpPESession psessionEntry, uint8_t sessionId)
4099{
4100 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4101 tSirMsgQ msgQ;
4102 tSirRetStatus retCode = eSIR_SUCCESS;
4103
4104 if (psessionEntry == NULL) {
4105 PELOGE(lim_log
4106 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4107 __LINE__);
4108 )
4109 return;
4110 }
4111
4112 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304113 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 if (NULL == pHalHiddenSsidVdevRestart) {
4115 PELOGE(lim_log
4116 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4117 __func__, __LINE__);
4118 )
4119 return;
4120 }
4121
4122 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4123 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4124
4125 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4126 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4127 msgQ.bodyval = 0;
4128
4129 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4130 if (eSIR_SUCCESS != retCode) {
4131 PELOGE(lim_log
4132 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4133 __LINE__);
4134 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304135 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 }
4137}
4138
4139static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4140{
4141 tpSirUpdateParams pUpdateParams;
4142 tpPESession psessionEntry;
4143
4144 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4145
4146 if (pMsgBuf == NULL) {
4147 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4148 return;
4149 }
4150
4151 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4152
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004153 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 pUpdateParams->sessionId);
4155 if (psessionEntry == NULL) {
4156 lim_log(pMac, LOGW,
4157 "Session does not exist for given sessionId %d",
4158 pUpdateParams->sessionId);
4159 return;
4160 }
4161
4162 /* Update the session entry */
4163 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4164
4165 /* Send vdev restart */
4166 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4167
4168 /* Update beacon */
4169 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4170 lim_send_beacon_ind(pMac, psessionEntry);
4171
4172 return;
4173} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4174
4175static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4176{
4177 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4178 tpPESession psessionEntry;
4179 uint8_t sessionId; /* PE sessionID */
4180
4181 if (pMsgBuf == NULL) {
4182 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4183 return;
4184 }
4185
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304186 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 if (NULL == pUpdateAPWPARSNIEsReq) {
4188 lim_log(pMac, LOGP,
4189 FL
4190 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4191 return;
4192 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4195
4196 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004197 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 &sessionId);
4199 if (psessionEntry == NULL) {
4200 lim_log(pMac, LOGW,
4201 FL("Session does not exist for given BSSID"));
4202 goto end;
4203 }
4204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304205 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4207
4208 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4209 &psessionEntry->
4210 pLimStartBssReq->rsnIE,
4211 psessionEntry);
4212
4213 psessionEntry->pLimStartBssReq->privacy = 1;
4214 psessionEntry->privacy = 1;
4215
4216 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4217 lim_send_beacon_ind(pMac, psessionEntry);
4218
4219end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304220 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 return;
4222} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4223
4224/*
4225 Update the beacon Interval dynamically if beaconInterval is different in MCC
4226 */
4227static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4228{
4229 tpSirChangeBIParams pChangeBIParams;
4230 tpPESession psessionEntry;
4231 uint8_t sessionId = 0;
4232 tUpdateBeaconParams beaconParams;
4233
4234 PELOG1(lim_log(pMac, LOG1,
4235 FL("received Update Beacon Interval message"));
4236 );
4237
4238 if (pMsgBuf == NULL) {
4239 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4240 return;
4241 }
4242
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304243 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4245
4246 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004247 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 &sessionId);
4249 if (psessionEntry == NULL) {
4250 lim_log(pMac, LOGE,
4251 FL("Session does not exist for given BSSID"));
4252 return;
4253 }
4254
4255 /*Update sessionEntry Beacon Interval */
4256 if (psessionEntry->beaconParams.beaconInterval !=
4257 pChangeBIParams->beaconInterval) {
4258 psessionEntry->beaconParams.beaconInterval =
4259 pChangeBIParams->beaconInterval;
4260 }
4261
4262 /*Update sch beaconInterval */
4263 if (pMac->sch.schObject.gSchBeaconInterval !=
4264 pChangeBIParams->beaconInterval) {
4265 pMac->sch.schObject.gSchBeaconInterval =
4266 pChangeBIParams->beaconInterval;
4267
4268 PELOG1(lim_log(pMac, LOG1,
4269 FL
4270 ("LIM send update BeaconInterval Indication : %d"),
4271 pChangeBIParams->beaconInterval);
4272 );
4273
4274 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4275 /* Update beacon */
4276 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4277
4278 beaconParams.bssIdx = psessionEntry->bssIdx;
4279 /* Set change in beacon Interval */
4280 beaconParams.beaconInterval =
4281 pChangeBIParams->beaconInterval;
4282 beaconParams.paramChangeBitmap =
4283 PARAM_BCN_INTERVAL_CHANGED;
4284 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4285 }
4286 }
4287
4288 return;
4289} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4290
4291#ifdef QCA_HT_2040_COEX
4292static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4293 uint32_t *pMsgBuf)
4294{
4295 tpSirSetHT2040Mode pSetHT2040Mode;
4296 tpPESession psessionEntry;
4297 uint8_t sessionId = 0;
4298 cds_msg_t msg;
4299 tUpdateVHTOpMode *pHtOpMode = NULL;
4300 uint16_t staId = 0;
4301 tpDphHashNode pStaDs = NULL;
4302
4303 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4304 if (pMsgBuf == NULL) {
4305 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4306 return;
4307 }
4308
4309 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4310
4311 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004312 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 &sessionId);
4314 if (psessionEntry == NULL) {
4315 lim_log(pMac, LOG1,
4316 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004317 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 return;
4319 }
4320
4321 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4322 pSetHT2040Mode->cbMode);
4323 /*Update sessionEntry HT related fields */
4324 switch (pSetHT2040Mode->cbMode) {
4325 case PHY_SINGLE_CHANNEL_CENTERED:
4326 psessionEntry->htSecondaryChannelOffset =
4327 PHY_SINGLE_CHANNEL_CENTERED;
4328 psessionEntry->htRecommendedTxWidthSet = 0;
4329 if (pSetHT2040Mode->obssEnabled)
4330 psessionEntry->htSupportedChannelWidthSet
4331 = eHT_CHANNEL_WIDTH_40MHZ;
4332 else
4333 psessionEntry->htSupportedChannelWidthSet
4334 = eHT_CHANNEL_WIDTH_20MHZ;
4335 break;
4336 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4337 psessionEntry->htSecondaryChannelOffset =
4338 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4339 psessionEntry->htRecommendedTxWidthSet = 1;
4340 break;
4341 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4342 psessionEntry->htSecondaryChannelOffset =
4343 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4344 psessionEntry->htRecommendedTxWidthSet = 1;
4345 break;
4346 default:
4347 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4348 return;
4349 }
4350
4351 /* Update beacon */
4352 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4353 lim_send_beacon_ind(pMac, psessionEntry);
4354
4355 /* update OP Mode for each associated peer */
4356 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4357 pStaDs = dph_get_hash_entry(pMac, staId,
4358 &psessionEntry->dph.dphHashTable);
4359 if (NULL == pStaDs)
4360 continue;
4361
4362 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304363 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 if (NULL == pHtOpMode) {
4365 lim_log(pMac, LOGE,
4366 FL
4367 ("%s: Not able to allocate memory for setting OP mode"),
4368 __func__);
4369 return;
4370 }
4371 pHtOpMode->opMode =
4372 (psessionEntry->htSecondaryChannelOffset ==
4373 PHY_SINGLE_CHANNEL_CENTERED) ?
4374 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4375 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304376 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 sizeof(tSirMacAddr));
4378 pHtOpMode->smesessionId = sessionId;
4379
4380 msg.type = WMA_UPDATE_OP_MODE;
4381 msg.reserved = 0;
4382 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304383 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304384 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 lim_log(pMac, LOGE,
4386 FL
4387 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4388 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304389 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390 return;
4391 }
4392 lim_log(pMac, LOG1,
4393 FL
4394 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4395 __func__, pHtOpMode->opMode, staId);
4396
4397 } else
4398 lim_log(pMac, LOG1,
4399 FL("%s: station %d does not support HT40\n"),
4400 __func__, staId);
4401 }
4402
4403 return;
4404}
4405#endif
4406
4407/* -------------------------------------------------------------------- */
4408/**
4409 * __lim_process_report_message
4410 *
4411 * FUNCTION: Processes the next received Radio Resource Management message
4412 *
4413 * LOGIC:
4414 *
4415 * ASSUMPTIONS:
4416 *
4417 * NOTE:
4418 *
4419 * @param None
4420 * @return None
4421 */
4422
4423void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4424{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 switch (pMsg->type) {
4426 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4427 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4428 break;
4429 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004431 break;
4432 default:
4433 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435}
4436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437/* -------------------------------------------------------------------- */
4438/**
4439 * lim_send_set_max_tx_power_req
4440 *
4441 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4442 *
4443 * LOGIC:
4444 *
4445 * ASSUMPTIONS:
4446 *
4447 * NOTE:
4448 *
4449 * @param txPower txPower to be set.
4450 * @param pSessionEntry session entry.
4451 * @return None
4452 */
4453tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004454lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 tpPESession pSessionEntry)
4456{
4457 tpMaxTxPowerParams pMaxTxParams = NULL;
4458 tSirRetStatus retCode = eSIR_SUCCESS;
4459 tSirMsgQ msgQ;
4460
4461 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304462 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 return eSIR_FAILURE;
4464 }
4465
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304466 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 if (NULL == pMaxTxParams) {
4468 lim_log(pMac, LOGP,
4469 FL("Unable to allocate memory for pMaxTxParams "));
4470 return eSIR_MEM_ALLOC_FAILED;
4471
4472 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304474 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304475 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304476 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004477 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304478 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479
4480 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4481 msgQ.bodyptr = pMaxTxParams;
4482 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304483 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4485 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4486 if (eSIR_SUCCESS != retCode) {
4487 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304488 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 }
4490 return retCode;
4491}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492
4493/**
4494 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4495 *
4496 * @mac_ctx: Pointer to Global MAC structure
4497 * @msg_buf: pointer to the SME message buffer
4498 *
4499 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4500 * from SME. It Register this information within PE.
4501 *
4502 * Return: None
4503 */
4504static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4505 uint32_t *msg_buf)
4506{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304507 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4509 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4510 struct mgmt_frm_reg_info *next = NULL;
4511 bool match = false;
4512
4513 lim_log(mac_ctx, LOG1, FL(
4514 "registerFrame %d, frameType %d, matchLen %d"),
4515 sme_req->registerFrame, sme_req->frameType,
4516 sme_req->matchLen);
4517 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304518 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304519 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4520 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304521 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522
4523 while (lim_mgmt_regn != NULL) {
4524 if (lim_mgmt_regn->frameType != sme_req->frameType)
4525 goto skip_match;
4526 if (sme_req->matchLen) {
4527 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304528 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 sme_req->matchData,
4530 lim_mgmt_regn->matchLen))) {
4531 /* found match! */
4532 match = true;
4533 break;
4534 }
4535 } else {
4536 /* found match! */
4537 match = true;
4538 break;
4539 }
4540skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304541 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304542 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304544 (qdf_list_node_t *)lim_mgmt_regn,
4545 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304546 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 lim_mgmt_regn = next;
4548 next = NULL;
4549 }
4550 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304551 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304552 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304554 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304555 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304556 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 }
4558
4559 if (sme_req->registerFrame) {
4560 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304561 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 sme_req->matchLen);
4563 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304564 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 sizeof(struct mgmt_frm_reg_info) +
4566 sme_req->matchLen, 0);
4567 lim_mgmt_regn->frameType = sme_req->frameType;
4568 lim_mgmt_regn->matchLen = sme_req->matchLen;
4569 lim_mgmt_regn->sessionId = sme_req->sessionId;
4570 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304571 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 sme_req->matchData,
4573 sme_req->matchLen);
4574 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304575 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304577 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 gLimMgmtFrameRegistratinQueue,
4579 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304580 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 &mac_ctx->lim.lim_frame_register_lock);
4582 }
4583 }
4584 return;
4585}
4586
4587static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4588{
4589 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4590 pMac->lim.gDeferMsgTypeForNOA);
4591 pMac->lim.gDeferMsgTypeForNOA = 0;
4592 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4593 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304594 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4596 }
4597}
4598
4599/**
4600 * lim_process_regd_defd_sme_req_after_noa_start()
4601 *
4602 * mac_ctx: Pointer to Global MAC structure
4603 *
4604 * This function is called to process deferred sme req message
4605 * after noa start.
4606 *
4607 * Return: None
4608 */
4609void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4610{
4611 bool buf_consumed = true;
4612
4613 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4614 mac_ctx->lim.gDeferMsgTypeForNOA);
4615
4616 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4617 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4618 lim_log(mac_ctx, LOGW,
4619 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4620 lim_log(mac_ctx, LOGW,
4621 FL("It may happen when NOA start ind and timeout happen at the same time"));
4622 return;
4623 }
4624 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4625 case eWNI_SME_SCAN_REQ:
4626 __lim_process_sme_scan_req(mac_ctx,
4627 mac_ctx->lim.gpDefdSmeMsgForNOA);
4628 break;
4629#ifdef FEATURE_OEM_DATA_SUPPORT
4630 case eWNI_SME_OEM_DATA_REQ:
4631 __lim_process_sme_oem_data_req(mac_ctx,
4632 mac_ctx->lim.gpDefdSmeMsgForNOA);
4633 break;
4634#endif
4635 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4636 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4637 mac_ctx->lim.gpDefdSmeMsgForNOA);
4638 /*
4639 * lim_process_remain_on_chnl_req doesnt want us to free
4640 * the buffer since it is freed in lim_remain_on_chn_rsp.
4641 * this change is to avoid "double free"
4642 */
4643 if (false == buf_consumed)
4644 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4645 break;
4646 case eWNI_SME_JOIN_REQ:
4647 __lim_process_sme_join_req(mac_ctx,
4648 mac_ctx->lim.gpDefdSmeMsgForNOA);
4649 break;
4650 default:
4651 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4652 mac_ctx->lim.gDeferMsgTypeForNOA);
4653 break;
4654 }
4655 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4656}
4657
4658static void
4659__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4660{
4661 tpSirResetAPCapsChange pResetCapsChange;
4662 tpPESession psessionEntry;
4663 uint8_t sessionId = 0;
4664 if (pMsgBuf == NULL) {
4665 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4666 return;
4667 }
4668
4669 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4670 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004671 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4672 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 if (psessionEntry == NULL) {
4674 lim_log(pMac, LOGE,
4675 FL("Session does not exist for given BSSID"));
4676 return;
4677 }
4678
4679 psessionEntry->limSentCapsChangeNtf = false;
4680 return;
4681}
4682
4683/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304684 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4685 * indication callback in PE.
4686 * @mac_ptr: Mac pointer
4687 * @msg_buf: Msg pointer containing the callback
4688 *
4689 * This function is used save the Management frame
4690 * indication callback in PE.
4691 *
4692 * Return: None
4693 */
4694static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4695 uint32_t *msg_buf)
4696{
4697 struct sir_sme_mgmt_frame_cb_req *sme_req =
4698 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4699
4700 if (NULL == msg_buf) {
4701 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4702 return;
4703 }
4704 if (sme_req->callback)
4705 mac_ctx->mgmt_frame_ind_cb =
4706 (sir_mgmt_frame_ind_callback)sme_req->callback;
4707 else
4708 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4709}
4710
4711/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 * lim_process_sme_req_messages()
4713 *
4714 ***FUNCTION:
4715 * This function is called by limProcessMessageQueue(). This
4716 * function processes SME request messages from HDD or upper layer
4717 * application.
4718 *
4719 ***LOGIC:
4720 *
4721 ***ASSUMPTIONS:
4722 *
4723 ***NOTE:
4724 *
4725 * @param pMac Pointer to Global MAC structure
4726 * @param msgType Indicates the SME message type
4727 * @param *pMsgBuf A pointer to the SME message buffer
4728 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4729 * false - if pMsgBuf is not to be freed.
4730 */
4731
4732bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4733{
4734 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4735 uint32_t *pMsgBuf = pMsg->bodyptr;
4736 tpSirSmeScanReq pScanReq;
4737 PELOG1(lim_log
4738 (pMac, LOG1,
4739 FL
4740 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4741 lim_msg_str(pMsg->type), pMsg->type,
4742 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4743 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4744 )
4745
4746 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4747 /* If no insert NOA required then execute the code below */
4748
4749 switch (pMsg->type) {
4750 case eWNI_SME_SYS_READY_IND:
4751 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4752 break;
4753
4754 case eWNI_SME_START_BSS_REQ:
4755 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4756 break;
4757
4758 case eWNI_SME_SCAN_REQ:
4759 __lim_process_sme_scan_req(pMac, pMsgBuf);
4760 break;
4761
4762#ifdef FEATURE_OEM_DATA_SUPPORT
4763 case eWNI_SME_OEM_DATA_REQ:
4764 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4765 break;
4766#endif
4767 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4768 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4769 break;
4770
4771 case eWNI_SME_UPDATE_NOA:
4772 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4773 break;
4774 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4775 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4776 break;
4777 case eWNI_SME_JOIN_REQ:
4778 __lim_process_sme_join_req(pMac, pMsgBuf);
4779 break;
4780
4781 case eWNI_SME_REASSOC_REQ:
4782 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4783 break;
4784
4785 case eWNI_SME_DISASSOC_REQ:
4786 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4787 break;
4788
4789 case eWNI_SME_DISASSOC_CNF:
4790 case eWNI_SME_DEAUTH_CNF:
4791 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4792 break;
4793
4794 case eWNI_SME_DEAUTH_REQ:
4795 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4796 break;
4797
4798 case eWNI_SME_SETCONTEXT_REQ:
4799 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4800 break;
4801
4802 case eWNI_SME_STOP_BSS_REQ:
4803 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4804 break;
4805
4806 case eWNI_SME_ASSOC_CNF:
4807 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4808 PELOG1(lim_log(pMac,
4809 LOG1, FL("Received ASSOC_CNF message"));)
4810 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4811 pMsgBuf);
4812 break;
4813
4814 case eWNI_SME_ADDTS_REQ:
4815 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4816 __lim_process_sme_addts_req(pMac, pMsgBuf);
4817 break;
4818
4819 case eWNI_SME_DELTS_REQ:
4820 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4821 __lim_process_sme_delts_req(pMac, pMsgBuf);
4822 break;
4823
4824 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4825 PELOG1(lim_log
4826 (pMac, LOG1,
4827 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4828 )
4829 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4830 break;
4831
4832 case eWNI_SME_GET_STATISTICS_REQ:
4833 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4834 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4835 bufConsumed = false;
4836 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004837#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838 case eWNI_SME_GET_TSM_STATS_REQ:
4839 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4840 bufConsumed = false;
4841 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004842#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 case eWNI_SME_GET_ASSOC_STAS_REQ:
4844 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4845 break;
4846 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4847 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4848 break;
4849
4850 case eWNI_SME_HIDE_SSID_REQ:
4851 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4852 break;
4853 case eWNI_SME_UPDATE_APWPSIE_REQ:
4854 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4855 break;
4856 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4857 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4858 break;
4859
4860 case eWNI_SME_SET_APWPARSNIEs_REQ:
4861 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4862 break;
4863
4864 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4865 /* Update the beaconInterval */
4866 __lim_process_sme_change_bi(pMac, pMsgBuf);
4867 break;
4868
4869#ifdef QCA_HT_2040_COEX
4870 case eWNI_SME_SET_HT_2040_MODE:
4871 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4872 break;
4873#endif
4874
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4876 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4877 __lim_process_report_message(pMac, pMsg);
4878 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 case eWNI_SME_FT_PRE_AUTH_REQ:
4881 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4882 break;
4883 case eWNI_SME_FT_UPDATE_KEY:
4884 lim_process_ft_update_key(pMac, pMsgBuf);
4885 break;
4886
4887 case eWNI_SME_FT_AGGR_QOS_REQ:
4888 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4889 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890
4891 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4892 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4893 break;
4894#ifdef FEATURE_WLAN_TDLS
4895 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4896 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4897 break;
4898 case eWNI_SME_TDLS_ADD_STA_REQ:
4899 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4900 break;
4901 case eWNI_SME_TDLS_DEL_STA_REQ:
4902 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4903 break;
4904 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4905 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4906 break;
4907#endif
4908 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4909 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4910 break;
4911
4912 case eWNI_SME_CHANNEL_CHANGE_REQ:
4913 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4914 break;
4915
4916 case eWNI_SME_START_BEACON_REQ:
4917 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4918 break;
4919
4920 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4921 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4922 break;
4923
4924 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4925 lim_process_update_add_ies(pMac, pMsgBuf);
4926 break;
4927
4928 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4929 lim_process_modify_add_ies(pMac, pMsgBuf);
4930 break;
4931 case eWNI_SME_SET_HW_MODE_REQ:
4932 lim_process_set_hw_mode(pMac, pMsgBuf);
4933 break;
4934 case eWNI_SME_NSS_UPDATE_REQ:
4935 lim_process_nss_update_request(pMac, pMsgBuf);
4936 break;
4937 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4938 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4939 break;
4940 case eWNI_SME_SET_IE_REQ:
4941 lim_process_set_ie_req(pMac, pMsgBuf);
4942 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304943 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4944 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4945 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304946 case eWNI_SME_EXT_CHANGE_CHANNEL:
4947 lim_process_ext_change_channel(pMac, pMsgBuf);
4948 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004949 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4950 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4951 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304953 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954 pMsg->bodyptr = NULL;
4955 break;
4956 } /* switch (msgType) */
4957
4958 return bufConsumed;
4959} /*** end lim_process_sme_req_messages() ***/
4960
4961/**
4962 * lim_process_sme_start_beacon_req()
4963 *
4964 ***FUNCTION:
4965 * This function is called by limProcessMessageQueue(). This
4966 * function processes SME request messages from HDD or upper layer
4967 * application.
4968 *
4969 ***LOGIC:
4970 *
4971 ***ASSUMPTIONS:
4972 *
4973 ***NOTE:
4974 *
4975 * @param pMac Pointer to Global MAC structure
4976 * @param msgType Indicates the SME message type
4977 * @param *pMsgBuf A pointer to the SME message buffer
4978 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4979 * false - if pMsgBuf is not to be freed.
4980 */
4981static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4982{
4983 tpSirStartBeaconIndication pBeaconStartInd;
4984 tpPESession psessionEntry;
4985 uint8_t sessionId; /* PE sessionID */
4986
4987 if (pMsg == NULL) {
4988 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4989 return;
4990 }
4991
4992 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4993 psessionEntry = pe_find_session_by_bssid(pMac,
4994 pBeaconStartInd->bssid,
4995 &sessionId);
4996 if (psessionEntry == NULL) {
4997 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
4998 lim_log(pMac, LOGE,
4999 FL("Session does not exist for given bssId"));
5000 return;
5001 }
5002
5003 if (pBeaconStartInd->beaconStartStatus == true) {
5004 /*
5005 * Currently this Indication comes from SAP
5006 * to start Beacon Tx on a DFS channel
5007 * since beaconing has to be done on DFS
5008 * channel only after CAC WAIT is completed.
5009 * On a DFS Channel LIM does not start beacon
5010 * Tx right after the WMA_ADD_BSS_RSP.
5011 */
5012 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305013 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 FL("Start Beacon with ssid %s Ch %d"),
5015 psessionEntry->ssId.ssId,
5016 psessionEntry->currentOperChannel);
5017 lim_send_beacon_ind(pMac, psessionEntry);
5018 } else {
5019 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5020 return;
5021 }
5022}
5023
5024/**
5025 * lim_process_sme_channel_change_request() - process sme ch change req
5026 *
5027 * @mac_ctx: Pointer to Global MAC structure
5028 * @msg_buf: pointer to the SME message buffer
5029 *
5030 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5031 *
5032 * Return: None
5033 */
5034static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5035 uint32_t *msg_buf)
5036{
5037 tpSirChanChangeRequest ch_change_req;
5038 tpPESession session_entry;
5039 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005040 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041 uint32_t val = 0;
5042
5043 if (msg_buf == NULL) {
5044 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5045 return;
5046 }
5047 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5048
5049 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5050 ch_change_req->targetChannel);
5051
5052 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5053 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5054 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5055 return;
5056 }
5057
5058 session_entry = pe_find_session_by_bssid(mac_ctx,
5059 ch_change_req->bssid, &session_id);
5060 if (session_entry == NULL) {
5061 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5062 lim_log(mac_ctx, LOGE, FL(
5063 "Session does not exist for given bssId"));
5064 return;
5065 }
5066
5067 if (session_entry->currentOperChannel ==
5068 ch_change_req->targetChannel) {
5069 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5070 return;
5071 }
5072
5073 if (LIM_IS_AP_ROLE(session_entry))
5074 session_entry->channelChangeReasonCode =
5075 LIM_SWITCH_CHANNEL_SAP_DFS;
5076 else
5077 session_entry->channelChangeReasonCode =
5078 LIM_SWITCH_CHANNEL_OPERATION;
5079
5080 lim_log(mac_ctx, LOGW, FL(
5081 "switch old chnl %d to new chnl %d, ch_bw %d"),
5082 session_entry->currentOperChannel,
5083 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005084 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085
5086 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005087 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088 session_entry->ch_center_freq_seg0 =
5089 ch_change_req->center_freq_seg_0;
5090 session_entry->ch_center_freq_seg1 =
5091 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005092 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005094 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 session_entry->htRecommendedTxWidthSet =
5096 session_entry->htSupportedChannelWidthSet;
5097 session_entry->currentOperChannel =
5098 ch_change_req->targetChannel;
5099 session_entry->limRFBand =
5100 lim_get_rf_band(session_entry->currentOperChannel);
5101 /* Initialize 11h Enable Flag */
5102 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5103 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5104 eSIR_SUCCESS)
5105 lim_log(mac_ctx, LOGP,
5106 FL("Fail to get WNI_CFG_11H_ENABLED"));
5107 }
5108
5109 session_entry->lim11hEnable = val;
5110 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305111 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 &ch_change_req->operational_rateset,
5113 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305114 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 &ch_change_req->extended_rateset,
5116 sizeof(session_entry->extRateSet));
5117 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5118 session_entry->ch_center_freq_seg0,
5119 session_entry->ch_center_freq_seg1,
5120 session_entry->ch_width,
5121 max_tx_pwr, session_entry->peSessionId);
5122}
5123
5124/******************************************************************************
5125* lim_start_bss_update_add_ie_buffer()
5126*
5127***FUNCTION:
5128* This function checks the src buffer and its length and then malloc for
5129* dst buffer update the same
5130*
5131***LOGIC:
5132*
5133***ASSUMPTIONS:
5134*
5135***NOTE:
5136*
5137* @param pMac Pointer to Global MAC structure
5138* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5139* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5140* @param *pSrcData_buff A pointer of uint8_t src buffer
5141* @param srcDataLen src buffer length
5142******************************************************************************/
5143
5144static void
5145lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5146 uint8_t **pDstData_buff,
5147 uint16_t *pDstDataLen,
5148 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5149{
5150
5151 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5152 *pDstDataLen = srcDataLen;
5153
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305154 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155
5156 if (NULL == *pDstData_buff) {
5157 lim_log(pMac, LOGE,
5158 FL("AllocateMemory failed for pDstData_buff"));
5159 return;
5160 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305161 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 } else {
5163 *pDstData_buff = NULL;
5164 *pDstDataLen = 0;
5165 }
5166}
5167
5168/******************************************************************************
5169* lim_update_add_ie_buffer()
5170*
5171***FUNCTION:
5172* This function checks the src buffer and length if src buffer length more
5173* than dst buffer length then free the dst buffer and malloc for the new src
5174* length, and update the dst buffer and length. But if dst buffer is bigger
5175* than src buffer length then it just update the dst buffer and length
5176*
5177***LOGIC:
5178*
5179***ASSUMPTIONS:
5180*
5181***NOTE:
5182*
5183* @param pMac Pointer to Global MAC structure
5184* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5185* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5186* @param *pSrcData_buff A pointer of uint8_t src buffer
5187* @param srcDataLen src buffer length
5188******************************************************************************/
5189
5190static void
5191lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5192 uint8_t **pDstData_buff,
5193 uint16_t *pDstDataLen,
5194 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5195{
5196
5197 if (NULL == pSrcData_buff) {
5198 lim_log(pMac, LOGE, FL("src buffer is null."));
5199 return;
5200 }
5201
5202 if (srcDataLen > *pDstDataLen) {
5203 *pDstDataLen = srcDataLen;
5204 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305205 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305207 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208
5209 if (NULL == *pDstData_buff) {
5210 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5211 *pDstDataLen = 0;
5212 return;
5213 }
5214 }
5215
5216 /* copy the content of buffer into dst buffer
5217 */
5218 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305219 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220
5221}
5222
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005223/**
5224 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5225 * @pMac : Pointer to Global MAC structure
5226 * @pDstData_buff : A pointer to pointer of dst buffer
5227 * @pDstDataLen : A pointer to pointer of dst buffer length
5228 * @pModifyIE : A pointer to tSirModifyIE
5229 *
5230 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5231 *
5232 * Return:
5233 * True or false depending upon whether IE is updated or not
5234 */
5235static bool
5236lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5237 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5238{
5239 int32_t oui_length;
5240 uint8_t *ibss_ie = NULL;
5241
5242 ibss_ie = pModifyIE->pIEBuffer;
5243 oui_length = pModifyIE->oui_length;
5244
5245 if ((0 == oui_length) || (NULL == ibss_ie)) {
5246 PELOGE(lim_log(pMac, LOGE,
5247 FL("Invalid set IBSS vendor IE command length %d "),
5248 oui_length);)
5249 return false;
5250 }
5251
5252 lim_update_add_ie_buffer(pMac,
5253 pDstData_buff,
5254 pDstDataLen,
5255 pModifyIE->pIEBuffer,
5256 pModifyIE->ieBufferlength);
5257
5258 return true;
5259}
5260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261/*
5262* lim_process_modify_add_ies() - process modify additional IE req.
5263*
5264* @mac_ctx: Pointer to Global MAC structure
5265* @msg_buf: pointer to the SME message buffer
5266*
5267* This function update the PE buffers for additional IEs.
5268*
5269* Return: None
5270*/
5271static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5272 uint32_t *msg_buf)
5273{
5274 tpSirModifyIEsInd modify_add_ies;
5275 tpPESession session_entry;
5276 uint8_t session_id;
5277 bool ret = false;
5278 tSirAddIeParams *add_ie_params;
5279
5280 if (msg_buf == NULL) {
5281 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5282 return;
5283 }
5284
5285 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5286 /* Incoming message has smeSession, use BSSID to find PE session */
5287 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005288 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289
5290 if (NULL == session_entry) {
5291 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5292 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005293 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 goto end;
5295 }
5296 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5297 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5298 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5299 lim_log(mac_ctx, LOGE,
5300 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5301 modify_add_ies->modifyIE.pIEBuffer,
5302 modify_add_ies->modifyIE.ieBufferlength,
5303 modify_add_ies->modifyIE.ieID,
5304 modify_add_ies->modifyIE.ieIDLen,
5305 modify_add_ies->updateType);
5306 goto end;
5307 }
5308 add_ie_params = &session_entry->addIeParams;
5309 switch (modify_add_ies->updateType) {
5310 case eUPDATE_IE_PROBE_RESP:
5311 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005312 if (LIM_IS_IBSS_ROLE(session_entry)) {
5313 lim_update_ibss_prop_add_ies(mac_ctx,
5314 &add_ie_params->probeRespData_buff,
5315 &add_ie_params->probeRespDataLen,
5316 &modify_add_ies->modifyIE);
5317 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 break;
5319 case eUPDATE_IE_ASSOC_RESP:
5320 /* assoc resp IE */
5321 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305322 QDF_TRACE(QDF_MODULE_ID_PE,
5323 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 "assoc resp add ie not present %d"),
5325 add_ie_params->assocRespDataLen);
5326 }
5327 /* search through the buffer and modify the IE */
5328 break;
5329 case eUPDATE_IE_PROBE_BCN:
5330 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005331 if (LIM_IS_IBSS_ROLE(session_entry)) {
5332 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5333 &add_ie_params->probeRespBCNData_buff,
5334 &add_ie_params->probeRespBCNDataLen,
5335 &modify_add_ies->modifyIE);
5336 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 if (ret == true && modify_add_ies->modifyIE.notify) {
5338 lim_handle_param_update(mac_ctx,
5339 modify_add_ies->updateType);
5340 }
5341 break;
5342 default:
5343 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5344 modify_add_ies->updateType);
5345 break;
5346 }
5347end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305348 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 modify_add_ies->modifyIE.pIEBuffer = NULL;
5350}
5351
5352/*
5353* lim_process_update_add_ies() - process additional IE update req
5354*
5355* @mac_ctx: Pointer to Global MAC structure
5356* @msg_buf: pointer to the SME message buffer
5357*
5358* This function update the PE buffers for additional IEs.
5359*
5360* Return: None
5361*/
5362static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5363 uint32_t *msg_buf)
5364{
5365 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5366 uint8_t session_id;
5367 tpPESession session_entry;
5368 tSirAddIeParams *addn_ie;
5369 uint16_t new_length = 0;
5370 uint8_t *new_ptr = NULL;
5371 tSirUpdateIE *update_ie;
5372
5373 if (msg_buf == NULL) {
5374 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5375 return;
5376 }
5377 update_ie = &update_add_ies->updateIE;
5378 /* incoming message has smeSession, use BSSID to find PE session */
5379 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005380 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381
5382 if (NULL == session_entry) {
5383 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5384 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005385 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 goto end;
5387 }
5388 addn_ie = &session_entry->addIeParams;
5389 /* if len is 0, upper layer requested freeing of buffer */
5390 if (0 == update_ie->ieBufferlength) {
5391 switch (update_add_ies->updateType) {
5392 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305393 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 addn_ie->probeRespData_buff = NULL;
5395 addn_ie->probeRespDataLen = 0;
5396 break;
5397 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305398 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 addn_ie->assocRespData_buff = NULL;
5400 addn_ie->assocRespDataLen = 0;
5401 break;
5402 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305403 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 addn_ie->probeRespBCNData_buff = NULL;
5405 addn_ie->probeRespBCNDataLen = 0;
5406
5407 if (update_ie->notify)
5408 lim_handle_param_update(mac_ctx,
5409 update_add_ies->updateType);
5410 break;
5411 default:
5412 break;
5413 }
5414 return;
5415 }
5416 switch (update_add_ies->updateType) {
5417 case eUPDATE_IE_PROBE_RESP:
5418 if (update_ie->append) {
5419 /*
5420 * In case of append, allocate new memory
5421 * with combined length
5422 */
5423 new_length = update_ie->ieBufferlength +
5424 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305425 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 if (NULL == new_ptr) {
5427 lim_log(mac_ctx, LOGE, FL(
5428 "Memory allocation failed."));
5429 goto end;
5430 }
5431 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305432 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305434 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435 update_ie->pAdditionIEBuffer,
5436 update_ie->ieBufferlength);
5437 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305438 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005439 /* adjust length accordingly */
5440 addn_ie->probeRespDataLen = new_length;
5441 /* save refernece of local buffer in PE session */
5442 addn_ie->probeRespData_buff = new_ptr;
5443 goto end;
5444 }
5445 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5446 &addn_ie->probeRespDataLen,
5447 update_ie->pAdditionIEBuffer,
5448 update_ie->ieBufferlength);
5449 break;
5450 case eUPDATE_IE_ASSOC_RESP:
5451 /* assoc resp IE */
5452 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5453 &addn_ie->assocRespDataLen,
5454 update_ie->pAdditionIEBuffer,
5455 update_ie->ieBufferlength);
5456 break;
5457 case eUPDATE_IE_PROBE_BCN:
5458 /* probe resp Bcn IE */
5459 lim_update_add_ie_buffer(mac_ctx,
5460 &addn_ie->probeRespBCNData_buff,
5461 &addn_ie->probeRespBCNDataLen,
5462 update_ie->pAdditionIEBuffer,
5463 update_ie->ieBufferlength);
5464 if (update_ie->notify)
5465 lim_handle_param_update(mac_ctx,
5466 update_add_ies->updateType);
5467 break;
5468 default:
5469 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5470 update_add_ies->updateType);
5471 break;
5472 }
5473end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305474 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475 update_ie->pAdditionIEBuffer = NULL;
5476}
5477
5478/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305479 * send_extended_chan_switch_action_frame()- function to send ECSA
5480 * action frame for each sta connected to SAP/GO and AP in case of
5481 * STA .
5482 * @mac_ctx: pointer to global mac structure
5483 * @new_channel: new channel to switch to.
5484 * @ch_bandwidth: BW of channel to calculate op_class
5485 * @session_entry: pe session
5486 *
5487 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5488 *
5489 * Return: void
5490 */
5491
5492static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5493 uint16_t new_channel, uint8_t ch_bandwidth,
5494 tpPESession session_entry)
5495{
5496 uint16_t op_class;
5497 uint8_t switch_mode = 0, i;
5498 tpDphHashNode psta;
5499
5500
Amar Singhal22995112016-01-22 10:42:33 -08005501 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305502 mac_ctx->scan.countryCodeCurrent,
5503 new_channel,
5504 ch_bandwidth);
5505
5506 if (LIM_IS_AP_ROLE(session_entry) &&
5507 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5508 switch_mode = 1;
5509
5510 if (LIM_IS_AP_ROLE(session_entry)) {
5511 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5512 psta =
5513 session_entry->dph.dphHashTable.pDphNodeArray + i;
5514 if (psta && psta->added)
5515 lim_send_extended_chan_switch_action_frame(
5516 mac_ctx,
5517 psta->staAddr,
5518 switch_mode, op_class, new_channel,
5519 LIM_MAX_CSA_IE_UPDATES, session_entry);
5520 }
5521 } else if (LIM_IS_STA_ROLE(session_entry)) {
5522 lim_send_extended_chan_switch_action_frame(mac_ctx,
5523 session_entry->bssId,
5524 switch_mode, op_class, new_channel,
5525 LIM_MAX_CSA_IE_UPDATES, session_entry);
5526 }
5527
5528}
5529
5530/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5532 *
5533 * @mac_ctx: Pointer to Global MAC structure
5534 * @msg_buf: pointer to the SME message buffer
5535 *
5536 * This function processes SME request messages from HDD or upper layer
5537 * application.
5538 *
5539 * Return: None
5540 */
5541static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5542 uint32_t *msg_buf)
5543{
5544 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5545 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 uint8_t session_id;
5547 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005548 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549
5550 if (msg_buf == NULL) {
5551 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5552 return;
5553 }
5554
5555 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5556 session_entry = pe_find_session_by_bssid(mac_ctx,
5557 dfs_csa_ie_req->bssid, &session_id);
5558 if (session_entry == NULL) {
5559 lim_log(mac_ctx, LOGE, FL(
5560 "Session not found for given BSSID" MAC_ADDRESS_STR),
5561 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5562 return;
5563 }
5564
5565 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5566 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5567 GET_LIM_SYSTEM_ROLE(session_entry));
5568 return;
5569 }
5570
5571 /* target channel */
5572 session_entry->gLimChannelSwitch.primaryChannel =
5573 dfs_csa_ie_req->targetChannel;
5574
5575 /* Channel switch announcement needs to be included in beacon */
5576 session_entry->dfsIncludeChanSwIe = true;
5577 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5578 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005579 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305580 session_entry->gLimChannelSwitch.sec_ch_offset =
5581 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5583 session_entry->gLimChannelSwitch.switchMode = 1;
5584
5585 /*
5586 * Validate if SAP is operating HT or VHT mode and set the Channel
5587 * Switch Wrapper element with the Wide Band Switch subelement.
5588 */
5589 if (true != session_entry->vhtCapability)
5590 goto skip_vht;
5591
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 /* Now encode the Wider Ch BW element depending on the ch width */
5593 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005594 switch (dfs_csa_ie_req->ch_params.ch_width) {
5595 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 /*
5597 * Wide channel BW sublement in channel wrapper element is not
5598 * required in case of 20 Mhz operation. Currently It is set
5599 * only set in case of 40/80 Mhz Operation.
5600 */
5601 session_entry->dfsIncludeChanWrapperIe = false;
5602 wider_bw_ch_switch->newChanWidth =
5603 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5604 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005605 case CH_WIDTH_40MHZ:
5606 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 wider_bw_ch_switch->newChanWidth =
5608 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5609 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005610 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 session_entry->dfsIncludeChanWrapperIe = true;
5612 wider_bw_ch_switch->newChanWidth =
5613 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5614 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005615 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 session_entry->dfsIncludeChanWrapperIe = true;
5617 wider_bw_ch_switch->newChanWidth =
5618 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5619 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005620 case CH_WIDTH_80P80MHZ:
5621 session_entry->dfsIncludeChanWrapperIe = true;
5622 wider_bw_ch_switch->newChanWidth =
5623 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005624 /*
5625 * This is not applicable for 20/40/80 Mhz.
5626 * Only used when we support 80+80 Mhz operation.
5627 * In case of 80+80 Mhz, this parameter indicates
5628 * center channel frequency index of 80 Mhz channel of
5629 * frequency segment 1.
5630 */
5631 wider_bw_ch_switch->newCenterChanFreq1 =
5632 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005633 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 default:
5635 session_entry->dfsIncludeChanWrapperIe = false;
5636 /*
5637 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5638 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5639 */
5640 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5641 break;
5642 }
5643 /* Fetch the center channel based on the channel width */
5644 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005645 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646skip_vht:
5647 /* Send CSA IE request from here */
5648 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5649 eSIR_SUCCESS) {
5650 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5651 return;
5652 }
5653
5654 /*
5655 * First beacon update request is sent here, the remaining updates are
5656 * done when the FW responds back after sending the first beacon after
5657 * the template update
5658 */
5659 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305660
5661 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5662 ch_offset = BW80;
5663 else
5664 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5665
5666 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5667 session_entry->gLimChannelSwitch.switchCount,
5668 session_entry->gLimChannelSwitch.primaryChannel,
5669 session_entry->gLimChannelSwitch.ch_width,
5670 session_entry->dfsIncludeChanWrapperIe,
5671 ch_offset);
5672
Abhishek Singh518323d2015-10-19 17:42:01 +05305673 /* Send ECSA Action frame after updating the beacon */
5674 send_extended_chan_switch_action_frame(mac_ctx,
5675 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305676 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 session_entry->gLimChannelSwitch.switchCount--;
5678}
5679
5680/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305681 * lim_process_ext_change_channel()- function to send ECSA
5682 * action frame for STA/CLI .
5683 * @mac_ctx: pointer to global mac structure
5684 * @msg: params from sme for new channel.
5685 *
5686 * This function is called to send ECSA frame for STA/CLI.
5687 *
5688 * Return: void
5689 */
5690
5691static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5692 uint32_t *msg)
5693{
5694 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5695 (struct sir_sme_ext_cng_chan_req *) msg;
5696 tpPESession session_entry = NULL;
5697
5698 if (NULL == msg) {
5699 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5700 return;
5701 }
5702 session_entry =
5703 pe_find_session_by_sme_session_id(mac_ctx,
5704 ext_chng_channel->session_id);
5705 if (NULL == session_entry) {
5706 lim_log(mac_ctx, LOGE,
5707 FL("Session not found for given session %d"),
5708 ext_chng_channel->session_id);
5709 return;
5710 }
5711 if (LIM_IS_AP_ROLE(session_entry)) {
5712 lim_log(mac_ctx, LOGE,
5713 FL("not an STA/CLI session"));
5714 return;
5715 }
5716 send_extended_chan_switch_action_frame(mac_ctx,
5717 ext_chng_channel->new_channel,
5718 0, session_entry);
5719}
5720
5721/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722 * lim_process_nss_update_request() - process sme nss update req
5723 *
5724 * @mac_ctx: Pointer to Global MAC structure
5725 * @msg_buf: pointer to the SME message buffer
5726 *
5727 * This function processes SME request messages from HDD or upper layer
5728 * application.
5729 *
5730 * Return: None
5731 */
5732static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5733 uint32_t *msg_buf)
5734{
5735 struct sir_nss_update_request *nss_update_req_ptr;
5736 tpPESession session_entry = NULL;
5737
5738 if (msg_buf == NULL) {
5739 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5740 return;
5741 }
5742
5743 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305744 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745 nss_update_req_ptr->vdev_id);
5746 if (session_entry == NULL) {
5747 lim_log(mac_ctx, LOGE, FL(
5748 "Session not found for given session_id %d"),
5749 nss_update_req_ptr->vdev_id);
5750 return;
5751 }
5752
5753 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5754 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5755 GET_LIM_SYSTEM_ROLE(session_entry));
5756 return;
5757 }
5758
5759 /* populate nss field in the beacon */
5760 session_entry->gLimOperatingMode.present = 1;
5761 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5762 /* Send nss update request from here */
5763 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5764 eSIR_SUCCESS) {
5765 lim_log(mac_ctx, LOGE,
5766 FL("Unable to set op mode IE in beacon"));
5767 return;
5768 }
5769
5770 lim_send_beacon_ind(mac_ctx, session_entry);
5771}
5772
5773/**
5774 * lim_process_set_ie_req() - process sme set IE request
5775 *
5776 * @mac_ctx: Pointer to Global MAC structure
5777 * @msg_buf: pointer to the SME message buffer
5778 *
5779 * This function processes SME request messages from HDD or upper layer
5780 * application.
5781 *
5782 * Return: None
5783 */
5784static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5785{
5786 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305787 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788
5789 if (msg_buf == NULL) {
5790 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5791 return;
5792 }
5793
5794 msg = (struct send_extcap_ie *)msg_buf;
5795 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305796 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5798
5799}