blob: ddcbaf7afeb6479f605b479231c98ab1bfe19a31 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_process_sme_req_messages.cc contains the code
30 * for processing SME request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38
39#include "cds_api.h"
40#include "wni_api.h"
41#include "wni_cfg.h"
42#include "cfg_api.h"
43#include "sir_api.h"
44#include "sch_api.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_security_utils.h"
50#include "lim_ser_des_utils.h"
51#include "lim_sme_req_utils.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "lim_admit_control.h"
54#include "dph_hash_table.h"
55#include "lim_send_messages.h"
56#include "lim_api.h"
57#include "wmm_apsd.h"
58#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080059#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61#include "sap_api.h"
62
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064#include <lim_ft.h>
Abhishek Singh518323d2015-10-19 17:42:01 +053065#include "cds_regdomain_common.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/*
68 * This overhead is time for sending NOA start to host in case of GO/sending
69 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
70 * with init scan req/rsp plus in case of concurrency, taking care of sending
71 * null data and receiving ACK to/from AP/Also SetChannel with calibration
72 * is taking around 7ms .
73 */
74#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
75#define JOIN_NOA_DURATION 2000 /* in msecs */
76#define OEM_DATA_NOA_DURATION 60 /* in msecs */
77#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
78
79#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
80
81/* SME REQ processing function templates */
82static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
83static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
84static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
85static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
91static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
92static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
93 uint32_t *pMsg);
94static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98
99static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
100 uint8_t **pDstData_buff,
101 uint16_t *pDstDataLen,
102 uint8_t *pSrcData_buff,
103 uint16_t srcDataLen);
104
105static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
106 uint8_t **pDstData_buff,
107 uint16_t *pDstDataLen,
108 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800109static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
114
115static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
116
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800117extern void pe_register_wma_handle(tpAniSirGlobal pMac,
118 tSirSmeReadyReq *ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119
Abhishek Singh518323d2015-10-19 17:42:01 +0530120static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
121 uint32_t *msg);
122
123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124/**
125 * lim_process_set_hw_mode() - Send set HW mode command to WMA
126 * @mac: Globacl MAC pointer
127 * @msg: Message containing the hw mode index
128 *
129 * Send the set HW mode command to WMA
130 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530131 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530133static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530135 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136 cds_msg_t cds_message;
137 struct sir_hw_mode *req_msg;
138 uint32_t len;
139 struct s_sir_set_hw_mode *buf;
140 tSirMsgQ resp_msg;
141 struct sir_set_hw_mode_resp *param;
142
143 buf = (struct s_sir_set_hw_mode *) msg;
144 if (!buf) {
145 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
146 /* To free the active command list */
147 goto fail;
148 }
149
150 len = sizeof(*req_msg);
151
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530152 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530154 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 /* Free the active command list
156 * Probably the malloc is going to fail there as well?!
157 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530158 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 }
160
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530161 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162
163 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530164 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 /* Other parameters are not needed for WMA */
166
167 cds_message.bodyptr = req_msg;
168 cds_message.type = SIR_HAL_SOC_SET_HW_MODE;
169
170 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
171 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530172 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 lim_log(mac, LOGE,
174 FL("vos_mq_post_message failed!(err=%d)"),
175 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530176 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 goto fail;
178 }
179 return status;
180fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530181 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 if (!param) {
183 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530184 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 }
186 param->status = SET_HW_MODE_STATUS_ECANCELED;
187 param->cfgd_hw_mode_index = 0;
188 param->num_vdev_mac_entries = 0;
189 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
190 resp_msg.bodyptr = param;
191 resp_msg.bodyval = 0;
192 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530193 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194}
195
196/**
197 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
198 * @mac: Global MAC pointer
199 * @msg: Message containing the dual mac config parameter
200 *
201 * Send the set dual mac config command to WMA
202 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530203 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 uint32_t *msg)
207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530208 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 cds_msg_t cds_message;
210 struct sir_dual_mac_config *req_msg;
211 uint32_t len;
212 struct sir_set_dual_mac_cfg *buf;
213 tSirMsgQ resp_msg;
214 struct sir_dual_mac_config_resp *param;
215
216 buf = (struct sir_set_dual_mac_cfg *) msg;
217 if (!buf) {
218 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
219 /* To free the active command list */
220 goto fail;
221 }
222
223 len = sizeof(*req_msg);
224
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530225 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 if (!req_msg) {
227 lim_log(mac, LOGE, FL("vos_mem_malloc failed"));
228 /* Free the active command list
229 * Probably the malloc is going to fail there as well?!
230 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530231 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 }
233
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530234 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
236 req_msg->scan_config = buf->set_dual_mac.scan_config;
237 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
238 /* Other parameters are not needed for WMA */
239
240 cds_message.bodyptr = req_msg;
241 cds_message.type = SIR_HAL_SOC_DUAL_MAC_CFG_REQ;
242
243 lim_log(mac, LOG1,
244 FL("Post SIR_HAL_SOC_DUAL_MAC_CFG_REQ to WMA: %x %x"),
245 req_msg->scan_config, req_msg->fw_mode_config);
246 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 lim_log(mac, LOGE,
249 FL("vos_mq_post_message failed!(err=%d)"),
250 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530251 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 goto fail;
253 }
254 return status;
255fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530256 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 if (!param) {
258 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530259 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 }
261 param->status = SET_HW_MODE_STATUS_ECANCELED;
262 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
263 resp_msg.bodyptr = param;
264 resp_msg.bodyval = 0;
265 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530266 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267}
268
269/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800270 * lim_process_set_antenna_mode_req() - Set antenna mode command
271 * to WMA
272 * @mac: Global MAC pointer
273 * @msg: Message containing the antenna mode parameter
274 *
275 * Send the set antenna mode command to WMA
276 *
277 * Return: QDF_STATUS_SUCCESS if message posting is successful
278 */
279static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
280 uint32_t *msg)
281{
282 QDF_STATUS status = QDF_STATUS_SUCCESS;
283 cds_msg_t cds_message;
284 struct sir_antenna_mode_param *req_msg;
285 struct sir_set_antenna_mode *buf;
286 tSirMsgQ resp_msg;
287 struct sir_antenna_mode_resp *param;
288
289 buf = (struct sir_set_antenna_mode *) msg;
290 if (!buf) {
291 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
292 /* To free the active command list */
293 goto fail;
294 }
295
296 req_msg = qdf_mem_malloc(sizeof(*req_msg));
297 if (!req_msg) {
298 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
299 return QDF_STATUS_E_NOMEM;
300 }
301
302 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
303 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
304
305 cds_message.bodyptr = req_msg;
306 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
307
308 lim_log(mac, LOG1,
309 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
310 req_msg->num_rx_chains,
311 req_msg->num_tx_chains);
312 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
313 if (!QDF_IS_STATUS_SUCCESS(status)) {
314 lim_log(mac, LOGE,
315 FL("vos_mq_post_message failed!(err=%d)"),
316 status);
317 qdf_mem_free(req_msg);
318 goto fail;
319 }
320 return status;
321fail:
322 param = qdf_mem_malloc(sizeof(*param));
323 if (!param) {
324 lim_log(mac, LOGE, FL("antenna mode resp failed"));
325 return QDF_STATUS_E_NOMEM;
326 }
327 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
328 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
329 resp_msg.bodyptr = param;
330 resp_msg.bodyval = 0;
331 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
332 return QDF_STATUS_SUCCESS;
333}
334
335/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
337 * @mac_ctx: Pointer to Global MAC structure
338 * @return_fresh_results: Trigger fresh scan.
339 *
340 * PE will do fresh scan, if all of the active sessions are in
341 * good state (Link Est or BSS Started). If one of the sessions
342 * is not in one of the above states, then PE does not do fresh
343 * scan. If no session exists (scanning very first time),
344 * then PE will always do fresh scan if SME asks it to do that.
345 *
346 * Return: true for fresh scan results, false if in invalid state.
347 */
348static uint8_t
349__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
350{
351 uint8_t valid_state = true;
352 int i;
353
354 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
355 mac_ctx->lim.gLimSmeState, return_fresh_results);
356
357 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
358 lim_log(mac_ctx, LOG1, FL("return FALSE"));
359 return false;
360 }
361
362 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
363 lim_log(mac_ctx, LOG1,
364 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
365 i, mac_ctx->lim.gpSession[i].bssType,
366 mac_ctx->lim.gpSession[i].limSystemRole,
367 mac_ctx->lim.gpSession[i].limSmeState);
368 if (mac_ctx->lim.gpSession[i].valid == true) {
369 if (!((((mac_ctx->lim.gpSession[i].bssType ==
370 eSIR_INFRASTRUCTURE_MODE) ||
371 (mac_ctx->lim.gpSession[i].limSystemRole ==
372 eLIM_BT_AMP_STA_ROLE)) &&
373 (mac_ctx->lim.gpSession[i].limSmeState ==
374 eLIM_SME_LINK_EST_STATE)) ||
375 (((mac_ctx->lim.gpSession[i].bssType ==
376 eSIR_IBSS_MODE) ||
377 (mac_ctx->lim.gpSession[i].limSystemRole ==
378 eLIM_BT_AMP_AP_ROLE) ||
379 (mac_ctx->lim.gpSession[i].limSystemRole ==
380 eLIM_BT_AMP_STA_ROLE)) &&
381 (mac_ctx->lim.gpSession[i].limSmeState ==
382 eLIM_SME_NORMAL_STATE)) ||
383 ((((mac_ctx->lim.gpSession[i].bssType ==
384 eSIR_INFRA_AP_MODE) &&
385 (mac_ctx->lim.gpSession[i].pePersona ==
Anurag Chouhan6d760662016-02-20 16:05:43 +0530386 QDF_P2P_GO_MODE)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 (mac_ctx->lim.gpSession[i].limSystemRole ==
388 eLIM_AP_ROLE)) &&
389 (mac_ctx->lim.gpSession[i].limSmeState ==
390 eLIM_SME_NORMAL_STATE)))) {
391 valid_state = false;
392 break;
393 }
394 }
395 }
396
397 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
398
399 if ((valid_state) &&
400 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
401 return true;
402 else
403 return false;
404}
405
406/**
407 * __lim_is_sme_assoc_cnf_valid()
408 *
409 ***FUNCTION:
410 * This function is called by __lim_process_sme_assoc_cnf_new() upon
411 * receiving SME_ASSOC_CNF.
412 *
413 ***LOGIC:
414 * Message validity checks are performed in this function
415 *
416 ***ASSUMPTIONS:
417 *
418 ***NOTE:
419 *
420 * @param pMeasReq Pointer to Received ASSOC_CNF message
421 * @return true When received SME_ASSOC_CNF is formatted
422 * correctly
423 * false otherwise
424 */
425
426static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
427{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530428 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 return false;
430 else
431 return true;
432} /*** end __lim_is_sme_assoc_cnf_valid() ***/
433
434/**
435 * __lim_get_sme_join_req_size_for_alloc()
436 *
437 ***FUNCTION:
438 * This function is called in various places to get IE length
439 * from tSirBssDescription structure
440 * number being scanned.
441 *
442 ***PARAMS:
443 *
444 ***LOGIC:
445 *
446 ***ASSUMPTIONS:
447 * NA
448 *
449 ***NOTE:
450 * NA
451 *
452 * @param pBssDescr
453 * @return Total IE length
454 */
455
456static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
457{
458 uint16_t len = 0;
459
460 if (!pBuf)
461 return len;
462
463 pBuf += sizeof(uint16_t);
464 len = lim_get_u16(pBuf);
465 return len + sizeof(uint16_t);
466}
467
468/**
469 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
470 * @pMac: Global MAC context
471 * @pMsg: Pointer to message posted from SME to LIM.
472 *
473 * Has role only if 11h is enabled. Not used on STA side.
474 * Defers the message if SME is in learn state and brings
475 * the LIM back to normal mode.
476 *
477 * Return: true - If defered false - Otherwise
478 */
479
480static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
481{
482 if (lim_is_system_in_scan_state(pMac)) {
483 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
484 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
485 pMsg->type);
486 return false;
487 }
488 lim_log(pMac, LOG1,
489 FL("Defer the message, in learn mode type = %d"),
490 pMsg->type);
491 return true;
492 }
493 return false;
494}
495
496/**
497 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
498 * @mac_ctx: Pointer to Global MAC structure
499 * @message: Pointer to message posted from SME to LIM.
500 *
501 * Has role only if 11h is enabled. Not used on STA side.
502 * Defers the message if radar is detected.
503 *
504 * Return: true, if defered otherwise return false.
505 */
506static bool
507__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
508{
509 /*
510 * fRadarDetCurOperChan will be set only if we
511 * detect radar in current operating channel and
512 * System Role == AP ROLE
513 *
514 * TODO: Need to take care radar detection.
515 *
516 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
517 */
518 if (0) {
519 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
520 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
521 message->type);
522 return false;
523 }
524 lim_log(mac_ctx, LOG1,
525 FL("Defer the message, in learn mode type = %d"),
526 message->type);
527 return true;
528 }
529 return false;
530}
531
532/**
533 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
534 * @pMac: Global MAC context
535 * @pMsgBuf: Message from WMA
536 *
537 * handles the notification from HDD. PE just forwards this message to HAL.
538 *
539 * Return: true-Posting to HAL failed, so PE will consume the buffer.
540 * false-Posting to HAL successful, so HAL will consume the buffer.
541 */
542
543static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
544{
545 tSirMsgQ msg;
546 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
547
548 msg.type = WMA_SYS_READY_IND;
549 msg.reserved = 0;
550 msg.bodyptr = pMsgBuf;
551 msg.bodyval = 0;
552
553 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800554 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
555 pe_register_wma_handle(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
557 }
558 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
559 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
560
561 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
562 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
563 return true;
564 }
565 return false;
566}
567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568/**
569 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
570 *@mac_ctx: Pointer to Global MAC structure
571 *@session: A pointer to session entry
572 *@sme_start_bss_req: Start BSS Request from upper layers.
573 *
574 * This function is used to configure the start bss parameters
575 * in to the session.
576 *
577 * Return: None.
578 */
579static void
580lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
581 tpSirSmeStartBssReq sme_start_bss_req)
582{
583 session->limSystemRole = eLIM_AP_ROLE;
584 session->privacy = sme_start_bss_req->privacy;
585 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
586 session->authType = sme_start_bss_req->authType;
587 /* Store the DTIM period */
588 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
589 /* Enable/disable UAPSD */
590 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530591 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 session->proxyProbeRspEn = 0;
593 } else {
594 /*
595 * To detect PBC overlap in SAP WPS mode,
596 * Host handles Probe Requests.
597 */
598 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
599 session->proxyProbeRspEn = 1;
600 else
601 session->proxyProbeRspEn = 0;
602 }
603 session->ssidHidden = sme_start_bss_req->ssidHidden;
604 session->wps_state = sme_start_bss_req->wps_state;
605 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
606 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
607 &session->shortSlotTimeSupported);
608 session->isCoalesingInIBSSAllowed =
609 sme_start_bss_req->isCoalesingInIBSSAllowed;
610
611}
612
613/**
614 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
615 *@mac_ctx: Pointer to Global MAC structure
616 *@msg_buf: A pointer to the SME message buffer
617 *
618 * This function is called to process SME_START_BSS_REQ message
619 * from HDD or upper layer application.
620 *
621 * Return: None
622 */
623static void
624__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
625{
626 uint16_t size;
627 uint32_t val = 0;
628 tSirRetStatus ret_status;
629 tSirMacChanNum channel_number;
630 tLimMlmStartReq *mlm_start_req = NULL;
631 tpSirSmeStartBssReq sme_start_bss_req = NULL;
632 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
633 /* Flag Used in case of IBSS to Auto generate BSSID. */
634 uint32_t auto_gen_bssid = false;
635 uint8_t session_id;
636 tpPESession session = NULL;
637 uint8_t sme_session_id = 0;
638 uint16_t sme_transaction_id = 0;
639 uint32_t chanwidth;
640 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
641
642/* FEATURE_WLAN_DIAG_SUPPORT */
643#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
644 /*
645 * Since the session is not created yet, sending NULL.
646 * The response should have the correct state.
647 */
648 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
649 NULL, 0, 0);
650#endif /* FEATURE_WLAN_DIAG_SUPPORT */
651
652 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
653
654 /*
655 * Global Sme state and mlm states are not defined yet,
656 * for BT-AMP Suppoprt . TO BE DONE
657 */
658 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
659 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
660 size = sizeof(tSirSmeStartBssReq);
661
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530662 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 if (NULL == sme_start_bss_req) {
664 lim_log(mac_ctx, LOGE,
665 FL("Allocate Memory fail for LimStartBssReq"));
666 /* Send failure response to host */
667 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
668 goto end;
669 }
670
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530671 qdf_mem_set((void *)sme_start_bss_req, size, 0);
672 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 sizeof(tSirSmeStartBssReq));
674 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
675 sme_start_bss_req)) {
676 lim_log(mac_ctx, LOGW,
677 FL("Received invalid eWNI_SME_START_BSS_REQ"));
678 ret_code = eSIR_SME_INVALID_PARAMETERS;
679 goto free;
680 }
681
682 /*
683 * This is the place where PE is going to create a session.
684 * If session is not existed, then create a new session
685 */
686 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800687 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 if (session != NULL) {
689 lim_log(mac_ctx, LOGW,
690 FL("Session Already exists for given BSSID"));
691 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
692 session = NULL;
693 goto free;
694 } else {
695 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800696 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 &session_id, mac_ctx->lim.maxStation,
698 sme_start_bss_req->bssType);
699 if (session == NULL) {
700 lim_log(mac_ctx, LOGW,
701 FL("Session Can not be created "));
702 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
703 goto free;
704 }
705 }
706
707 /* Probe resp add ie */
708 lim_start_bss_update_add_ie_buffer(mac_ctx,
709 &session->addIeParams.probeRespData_buff,
710 &session->addIeParams.probeRespDataLen,
711 sme_start_bss_req->addIeParams.probeRespData_buff,
712 sme_start_bss_req->addIeParams.probeRespDataLen);
713
714 /* Probe Beacon add ie */
715 lim_start_bss_update_add_ie_buffer(mac_ctx,
716 &session->addIeParams.probeRespBCNData_buff,
717 &session->addIeParams.probeRespBCNDataLen,
718 sme_start_bss_req->addIeParams.probeRespBCNData_buff,
719 sme_start_bss_req->addIeParams.probeRespBCNDataLen);
720
721 /* Assoc resp IE */
722 lim_start_bss_update_add_ie_buffer(mac_ctx,
723 &session->addIeParams.assocRespData_buff,
724 &session->addIeParams.assocRespDataLen,
725 sme_start_bss_req->addIeParams.assocRespData_buff,
726 sme_start_bss_req->addIeParams.assocRespDataLen);
727
728 /* Store the session related params in newly created session */
729 session->pLimStartBssReq = sme_start_bss_req;
730
731 /* Store PE session_id in session Table */
732 session->peSessionId = session_id;
733
734 /* Store SME session Id in sessionTable */
735 session->smeSessionId = sme_start_bss_req->sessionId;
736
737 session->transactionId = sme_start_bss_req->transactionId;
738
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530739 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 &(sme_start_bss_req->htConfig),
741 sizeof(session->htConfig));
742
743 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800744 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745
746 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 (uint8_t *) &sme_start_bss_req->ssId,
749 (sme_start_bss_req->ssId.length + 1));
750
751 session->bssType = sme_start_bss_req->bssType;
752
753 session->nwType = sme_start_bss_req->nwType;
754
755 session->beaconParams.beaconInterval =
756 sme_start_bss_req->beaconInterval;
757
758 /* Store the channel number in session Table */
759 session->currentOperChannel =
760 sme_start_bss_req->channelId;
761
762 /* Store Persona */
763 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530764 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 FL("PE PERSONA=%d"), session->pePersona);
766
767 /* Update the phymode */
768 session->gLimPhyMode = sme_start_bss_req->nwType;
769
770 session->maxTxPower =
771 cfg_get_regulatory_max_transmit_power(mac_ctx,
772 session->currentOperChannel);
773 /* Store the dot 11 mode in to the session Table */
774 session->dot11mode = sme_start_bss_req->dot11mode;
775#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
776 session->cc_switch_mode =
777 sme_start_bss_req->cc_switch_mode;
778#endif
779 session->htCapability =
780 IS_DOT11_MODE_HT(session->dot11mode);
781 session->vhtCapability =
782 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530783 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 FL("*****session->vhtCapability = %d"),
785 session->vhtCapability);
786 session->txLdpcIniFeatureEnabled =
787 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 if (mac_ctx->roam.configParam.enable2x2)
789 session->nss = 2;
790 else
791 session->nss = 1;
792#ifdef WLAN_FEATURE_11W
793 session->limRmfEnabled =
794 sme_start_bss_req->pmfCapable ? 1 : 0;
795 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
796 session->limRmfEnabled);
797#endif
798
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530799 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 (void *)&sme_start_bss_req->operationalRateSet,
801 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 (void *)&sme_start_bss_req->extendedRateSet,
804 sizeof(tSirMacRateSet));
805
806 switch (sme_start_bss_req->bssType) {
807 case eSIR_INFRA_AP_MODE:
808 lim_configure_ap_start_bss_session(mac_ctx, session,
809 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530810 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800811 session->txBFIniFeatureEnabled =
812 sme_start_bss_req->txbf_ini_enabled;
813 session->txbf_csn_value =
814 sme_start_bss_req->txbf_csn_val;
815 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 break;
817 case eSIR_IBSS_MODE:
818 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
819 lim_get_short_slot_from_phy_mode(mac_ctx, session,
820 session->gLimPhyMode,
821 &session->shortSlotTimeSupported);
822
823 /*
824 * initialize to "OPEN".
825 * will be updated upon key installation
826 */
827 session->encryptType = eSIR_ED_NONE;
828
829 break;
830
831 case eSIR_BTAMP_AP_MODE:
832 session->limSystemRole = eLIM_BT_AMP_AP_ROLE;
833 break;
834
835 case eSIR_BTAMP_STA_MODE:
836 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
837 break;
838
839 /*
840 * There is one more mode called auto mode.
841 * which is used no where
842 */
843
844 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
845
846 default:
847 /* not used anywhere...used in scan function */
848 break;
849 }
850
851 /*
852 * BT-AMP: Allocate memory for the array of
853 * parsed (Re)Assoc request structure
854 */
855 if ((sme_start_bss_req->bssType == eSIR_BTAMP_AP_MODE) ||
856 (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE)) {
857 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530858 qdf_mem_malloc(session->dph.dphHashTable.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 size * sizeof(tpSirAssocReq));
860 if (NULL == session->parsedAssocReq) {
861 lim_log(mac_ctx, LOGW,
862 FL("AllocateMemory() failed"));
863 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
864 goto free;
865 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530866 qdf_mem_set(session->parsedAssocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 (session->dph.dphHashTable.size *
868 sizeof(tpSirAssocReq)), 0);
869 }
870
871 if (!sme_start_bss_req->channelId) {
872 lim_log(mac_ctx, LOGE,
873 FL("Received invalid eWNI_SME_START_BSS_REQ"));
874 ret_code = eSIR_SME_INVALID_PARAMETERS;
875 goto free;
876 }
877 channel_number = sme_start_bss_req->channelId;
878#ifdef QCA_HT_2040_COEX
879 if (sme_start_bss_req->obssEnabled)
880 session->htSupportedChannelWidthSet =
881 session->htCapability;
882 else
883#endif
884 session->htSupportedChannelWidthSet =
885 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
886 session->htSecondaryChannelOffset =
887 sme_start_bss_req->sec_ch_offset;
888 session->htRecommendedTxWidthSet =
889 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530890 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 FL("cbMode %u"), sme_start_bss_req->cbMode);
892 if (session->vhtCapability || session->htCapability) {
893 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800894 lim_log(mac_ctx, LOG1,
895 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
896 sme_start_bss_req->vht_channel_width,
897 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 session->ch_width = chanwidth;
899 if (session->htSupportedChannelWidthSet) {
900 session->ch_center_freq_seg0 =
901 sme_start_bss_req->center_freq_seg0;
902 session->ch_center_freq_seg1 =
903 sme_start_bss_req->center_freq_seg1;
904 } else {
905 session->ch_center_freq_seg0 = 0;
906 session->ch_center_freq_seg1 = 0;
907 }
908 }
909
910 if (session->vhtCapability &&
911 (CH_WIDTH_160MHZ > session->ch_width)) {
912 if (wlan_cfg_get_int(mac_ctx,
913 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
914 eSIR_SUCCESS)
915 lim_log(mac_ctx, LOGE, FL(
916 "cfg get vht su bformer failed"));
917
918 session->enable_su_tx_bformer = val;
919 } else {
920 session->nss = 1;
921 }
922 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
923
924 /* Delete pre-auth list if any */
925 lim_delete_pre_auth_list(mac_ctx);
926
927 /*
928 * keep the RSN/WPA IE information in PE Session Entry
929 * later will be using this to check when received (Re)Assoc req
930 */
931 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
932 &sme_start_bss_req->rsnIE, session);
933
934 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
935 session->gLimProtectionControl =
936 sme_start_bss_req->protEnabled;
937 /*
938 * each byte will have the following info
939 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
940 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
941 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530942 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 (void *)&sme_start_bss_req->ht_capab,
944 sizeof(uint16_t));
945 /* Initialize WPS PBC session link list */
946 session->pAPWPSPBCSession = NULL;
947 }
948 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530949 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 if (NULL == mlm_start_req) {
951 lim_log(mac_ctx, LOGP,
952 FL("Allocate Memory failed for mlmStartReq"));
953 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
954 goto free;
955 }
956
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530957 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
959 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 (uint8_t *) &sme_start_bss_req->ssId,
962 sme_start_bss_req->ssId.length + 1);
963 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
964 mlm_start_req->obssProtEnabled =
965 sme_start_bss_req->obssProtEnabled;
966
967 mlm_start_req->bssType = session->bssType;
968
969 /* Fill PE session Id from the session Table */
970 mlm_start_req->sessionId = session->peSessionId;
971
972 if ((mlm_start_req->bssType == eSIR_BTAMP_STA_MODE) ||
973 (mlm_start_req->bssType == eSIR_BTAMP_AP_MODE) ||
974 (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)) {
975 /*
976 * Copy the BSSId from sessionTable to
977 * mlmStartReq struct
978 */
979 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
980 } else {
981 /* ibss mode */
982 mac_ctx->lim.gLimIbssCoalescingHappened = false;
983
984 ret_status = wlan_cfg_get_int(mac_ctx,
985 WNI_CFG_IBSS_AUTO_BSSID,
986 &auto_gen_bssid);
987 if (ret_status != eSIR_SUCCESS) {
988 lim_log(mac_ctx, LOGP,
989 FL("Get Auto Gen BSSID fail,Status=%d"),
990 ret_status);
991 ret_code = eSIR_LOGP_EXCEPTION;
992 goto free;
993 }
994
995 if (!auto_gen_bssid) {
996 /*
997 * We're not auto generating BSSID.
998 * Instead, get it from session entry
999 */
1000 sir_copy_mac_addr(mlm_start_req->bssId,
1001 session->bssId);
1002 /*
1003 * Start IBSS group BSSID
1004 * Auto Generating BSSID.
1005 */
1006 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1007 0x01) ? true : false);
1008 }
1009
1010 if (auto_gen_bssid) {
1011 /*
1012 * if BSSID is not any uc id.
1013 * then use locally generated BSSID.
1014 * Autogenerate the BSSID
1015 */
1016 lim_get_random_bssid(mac_ctx,
1017 mlm_start_req->bssId);
1018 mlm_start_req->bssId[0] = 0x02;
1019
1020 /*
1021 * Copy randomly generated BSSID
1022 * to the session Table
1023 */
1024 sir_copy_mac_addr(session->bssId,
1025 mlm_start_req->bssId);
1026 }
1027 }
1028 /* store the channel num in mlmstart req structure */
1029 mlm_start_req->channelNumber = session->currentOperChannel;
1030 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1031 mlm_start_req->beaconPeriod =
1032 session->beaconParams.beaconInterval;
1033
1034 if (LIM_IS_AP_ROLE(session)) {
1035 mlm_start_req->dtimPeriod = session->dtimPeriod;
1036 mlm_start_req->wps_state = session->wps_state;
1037
1038 } else {
1039 if (wlan_cfg_get_int(mac_ctx,
1040 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1041 lim_log(mac_ctx, LOGP,
1042 FL("could not retrieve DTIM Period"));
1043 mlm_start_req->dtimPeriod = (uint8_t) val;
1044 }
1045
1046 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1047 eSIR_SUCCESS)
1048 lim_log(mac_ctx, LOGP,
1049 FL("could not retrieve Beacon interval"));
1050 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1051
1052 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1053 eSIR_SUCCESS)
1054 lim_log(mac_ctx, LOGP,
1055 FL("could not retrieve CFPMaxDuration"));
1056 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1057
1058 /*
1059 * this may not be needed anymore now,
1060 * as rateSet is now included in the
1061 * session entry and MLM has session context.
1062 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301063 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 (void *)&session->rateSet,
1065 sizeof(tSirMacRateSet));
1066
1067 /* Now populate the 11n related parameters */
1068 mlm_start_req->nwType = session->nwType;
1069 mlm_start_req->htCapable = session->htCapability;
1070
1071 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1072 /* Unused */
1073 mlm_start_req->dualCTSProtection =
1074 mac_ctx->lim.gHTDualCTSProtection;
1075 mlm_start_req->txChannelWidthSet =
1076 session->htRecommendedTxWidthSet;
1077
1078 session->limRFBand = lim_get_rf_band(channel_number);
1079
1080 /* Initialize 11h Enable Flag */
1081 session->lim11hEnable = 0;
1082 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1083 (SIR_BAND_5_GHZ == session->limRFBand)) {
1084 if (wlan_cfg_get_int(mac_ctx,
1085 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1086 lim_log(mac_ctx, LOGP,
1087 FL("Fail to get WNI_CFG_11H_ENABLED "));
1088 else
1089 session->lim11hEnable = val;
1090
1091 if (session->lim11hEnable &&
1092 (eSIR_INFRA_AP_MODE ==
1093 mlm_start_req->bssType)) {
1094 cfg_get_wmi_dfs_master_param =
1095 wlan_cfg_get_int(mac_ctx,
1096 WNI_CFG_DFS_MASTER_ENABLED,
1097 &val);
1098 session->lim11hEnable = val;
1099 }
1100 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1101 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1102 lim_log(mac_ctx, LOGE,
1103 FL("Get Fail, CFG DFS ENABLE"));
1104 }
1105
1106 if (!session->lim11hEnable) {
1107 if (cfg_set_int(mac_ctx,
1108 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1109 eSIR_SUCCESS)
1110 /*
1111 * Failed to set the CFG param
1112 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1113 */
1114 lim_log(mac_ctx, LOGE,
1115 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1116 }
1117
1118 session->limPrevSmeState = session->limSmeState;
1119 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1120 MTRACE(mac_trace
1121 (mac_ctx, TRACE_CODE_SME_STATE,
1122 session->peSessionId,
1123 session->limSmeState));
1124
1125 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1126 (uint32_t *) mlm_start_req);
1127 return;
1128 } else {
1129
1130 lim_log(mac_ctx, LOGE,
1131 FL("Received unexpected START_BSS_REQ, in state %X"),
1132 mac_ctx->lim.gLimSmeState);
1133 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1134 goto end;
1135 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1136
1137free:
1138 if ((session != NULL) &&
1139 (session->pLimStartBssReq == sme_start_bss_req)) {
1140 session->pLimStartBssReq = NULL;
1141 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301142 qdf_mem_free(sme_start_bss_req);
1143 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144
1145end:
1146 if (sme_start_bss_req != NULL) {
1147 sme_session_id = sme_start_bss_req->sessionId;
1148 sme_transaction_id = sme_start_bss_req->transactionId;
1149 }
1150 if (NULL != session) {
1151 pe_delete_session(mac_ctx, session);
1152 session = NULL;
1153 }
1154 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1155 session, sme_session_id, sme_transaction_id);
1156}
1157
1158/**
1159 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1160 *
1161 * @pMac: Global MAC context
1162 * @pMsg: Message pointer
1163 *
1164 * Wrapper for the function __lim_handle_sme_start_bss_request
1165 * This message will be defered until softmac come out of
1166 * scan mode or if we have detected radar on the current
1167 * operating channel.
1168 *
1169 * return true - If we consumed the buffer
1170 * false - If have defered the message.
1171 */
1172static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1173{
1174 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1175 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1176 /**
1177 * If message defered, buffer is not consumed yet.
1178 * So return false
1179 */
1180 return false;
1181 }
1182
1183 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1184 return true;
1185}
1186
1187/**
1188 * lim_get_random_bssid()
1189 *
1190 * FUNCTION:This function is called to process generate the random number for bssid
1191 * This function is called to process SME_SCAN_REQ message
1192 * from HDD or upper layer application.
1193 *
1194 * LOGIC:
1195 *
1196 * ASSUMPTIONS:
1197 *
1198 * NOTE:
1199 * 1. geneartes the unique random number for bssid in ibss
1200 *
1201 * @param pMac Pointer to Global MAC structure
1202 * @param *data Pointer to bssid buffer
1203 * @return None
1204 */
1205void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1206{
1207 uint32_t random[2];
1208 random[0] = tx_time_get();
1209 random[0] |= (random[0] << 15);
1210 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301211 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212}
1213
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301214static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 tpSirSmeScanReq pScanReq)
1216{
1217 tSirScanOffloadReq *pScanOffloadReq;
1218 uint8_t *p;
1219 uint8_t *ht_cap_ie;
1220 tSirMsgQ msg;
1221 uint16_t i, len;
1222 uint16_t ht_cap_len = 0, addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 uint8_t *vht_cap_ie;
1224 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 tSirRetStatus status, rc = eSIR_SUCCESS;
1226 tDot11fIEExtCap extracted_extcap = {0};
1227 bool extcap_present = true;
1228
1229 if (pScanReq->uIEFieldLen) {
1230 status = lim_strip_extcap_update_struct(pMac,
1231 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1232 &pScanReq->uIEFieldLen, &extracted_extcap);
1233
1234 if (eSIR_SUCCESS != status) {
1235 extcap_present = false;
1236 lim_log(pMac, LOG1,
1237 FL("Unable to Strip ExtCap IE from Scan Req"));
1238 }
1239
1240 if (extcap_present) {
1241 lim_log(pMac, LOG1,
1242 FL("Extcap was part of SCAN IE - Updating FW"));
1243 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1244 &extracted_extcap, true);
1245 }
1246 } else {
1247 lim_log(pMac, LOG1,
1248 FL("No IEs in the scan request from supplicant"));
1249 }
1250
1251 /**
1252 * The tSirScanOffloadReq will reserve the space for first channel,
1253 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1254 */
1255 len = sizeof(tSirScanOffloadReq) +
1256 (pScanReq->channelList.numChannels - 1) + pScanReq->uIEFieldLen;
1257
1258 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1259 lim_log(pMac, LOG1,
1260 FL("Adding HT Caps IE since dot11mode=%d"),
1261 pScanReq->dot11mode);
1262 /* 2 bytes for EID and Length */
1263 ht_cap_len = 2 + sizeof(tHtCaps);
1264 len += ht_cap_len;
1265 addn_ie_len += ht_cap_len;
1266 }
1267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1269 lim_log(pMac, LOG1,
1270 FL("Adding VHT Caps IE since dot11mode=%d"),
1271 pScanReq->dot11mode);
1272 /* 2 bytes for EID and Length */
1273 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1274 sizeof(tSirVhtMcsInfo);
1275 len += vht_cap_len;
1276 addn_ie_len += vht_cap_len;
1277 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301279 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 if (NULL == pScanOffloadReq) {
1281 lim_log(pMac, LOGE,
1282 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301283 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 }
1285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301286 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287
1288 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1289 msg.bodyptr = pScanOffloadReq;
1290 msg.bodyval = 0;
1291
Anurag Chouhanc5548422016-02-24 18:33:27 +05301292 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
1294 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1295 lim_log(pMac, LOGE,
1296 FL("Invalid value (%d) for numSsid"),
1297 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301298 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301299 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 }
1301
1302 pScanOffloadReq->numSsid = pScanReq->numSsid;
1303 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1304 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301305 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 (uint8_t *) pScanReq->ssId[i].ssId,
1307 pScanOffloadReq->ssId[i].length);
1308 }
1309
1310 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301311 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 pScanOffloadReq->bssType = pScanReq->bssType;
1313 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1314 pScanOffloadReq->scanType = pScanReq->scanType;
1315 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1316 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1317 pScanOffloadReq->restTime = pScanReq->restTime;
1318
1319 /* for normal scan, the value for p2pScanType should be 0
1320 always */
1321 if (pScanReq->p2pSearch)
1322 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1323
1324 pScanOffloadReq->sessionId = pScanReq->sessionId;
1325 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001326 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
1328 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1329 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1330 pScanOffloadReq->sessionId);
1331
1332 pScanOffloadReq->channelList.numChannels =
1333 pScanReq->channelList.numChannels;
1334 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1335 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1336 p[i] = pScanReq->channelList.channelNumber[i];
1337
1338 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1339 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1340 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301341 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 pScanOffloadReq->uIEFieldOffset,
1343 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1344 pScanReq->uIEFieldLen);
1345
1346 /* Copy HT Capability info if dot11mode is HT */
1347 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1348 /* Populate EID and Length field here */
1349 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1350 pScanOffloadReq->uIEFieldOffset +
1351 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301352 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1354 *(ht_cap_ie + 1) = ht_cap_len - 2;
1355 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1356 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1357 }
1358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 /* Copy VHT Capability info if dot11mode is VHT Capable */
1360 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1361 /* Populate EID and Length field here */
1362 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1363 pScanOffloadReq->uIEFieldOffset +
1364 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301365 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1367 *(vht_cap_ie + 1) = vht_cap_len - 2;
1368 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1369 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
1372 rc = wma_post_ctrl_msg(pMac, &msg);
1373 if (rc != eSIR_SUCCESS) {
1374 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301375 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301376 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 }
1378
1379 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1380
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301381 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382}
1383
1384/**
1385 * __lim_process_sme_scan_req() - Process the SME Scan Request
1386 * @mac_ctx: Global MAC Context
1387 * @msg_buf: Buffer which contains the request and pertinent parameters
1388 *
1389 * This function is called to process SME_SCAN_REQ message
1390 * from HDD or upper layer application.
1391 *
1392 * Return: None
1393 */
1394
1395static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1396 uint32_t *msg_buf)
1397{
1398 tpSirSmeScanReq scan_req;
1399 uint8_t valid_req = 0;
1400
1401#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1402 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1403 eSIR_SUCCESS, eSIR_SUCCESS);
1404#endif
1405
1406 scan_req = (tpSirSmeScanReq) msg_buf;
1407 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301408 FL("SME SCAN REQ id %d numChan %d min %d max %d IELen %d first %d fresh %d unique %d type %s (%d) rsp %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 scan_req->scan_id, scan_req->channelList.numChannels,
1410 scan_req->minChannelTime, scan_req->maxChannelTime,
1411 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1412 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301413 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1415 /*
1416 * Since scan req always requires a response, we will overwrite response
1417 * required here. This is added esp to take care of the condition where
1418 * in p2p go case, we hold the scan req and insert single NOA. We send
1419 * the held scan request to FW later on getting start NOA ind from FW so
1420 * we lose state of the gLimRspReqd flag for the scan req if any other
1421 * request comes by then. e.g. While unit testing, we found when insert
1422 * single NOA is done, we see a get stats request which turns the flag
1423 * gLimRspReqd to false; now when we actually start the saved scan req
1424 * for init scan after getting NOA started, the gLimRspReqd being a
1425 * global flag is showing false instead of true value for this saved
1426 * scan req. Since all scan reqs coming to lim require a response,
1427 * there is no harm in setting the global flag gLimRspReqd to true here.
1428 */
1429 mac_ctx->lim.gLimRspReqd = true;
1430
1431 /*
1432 * copy the Self MAC address from SmeReq to the globalplace,
1433 * used for sending probe req
1434 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001435 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1436 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1438
1439 if (!valid_req || mac_ctx->lim.scan_disabled) {
1440 lim_log(mac_ctx, LOGE,
1441 FL("Scan disabled %d, Valid Scan Req %d"),
1442 mac_ctx->lim.scan_disabled, valid_req);
1443
1444 if (mac_ctx->lim.gLimRspReqd) {
1445 mac_ctx->lim.gLimRspReqd = false;
1446
1447 lim_send_sme_scan_rsp(mac_ctx,
1448 eSIR_SME_INVALID_PARAMETERS,
1449 scan_req->sessionId,
1450 scan_req->transactionId,
1451 scan_req->scan_id);
1452 }
1453 return;
1454 }
1455
1456 /*
1457 * If scan request is received in idle, joinFailed
1458 * states or in link established state (in STA role)
1459 * or in normal state (in STA-in-IBSS/AP role) with
1460 * 'return fresh scan results' request from HDD or
1461 * it is periodic background scanning request,
1462 * trigger fresh scan request to MLM
1463 */
1464 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1465
1466 mac_ctx->lim.gLim24Band11dScanDone = 0;
1467 mac_ctx->lim.gLim50Band11dScanDone = 0;
1468 mac_ctx->lim.gLimReturnAfterFirstMatch =
1469 scan_req->returnAfterFirstMatch;
1470 mac_ctx->lim.gLimReturnUniqueResults =
1471 ((scan_req->returnUniqueResults) > 0 ? true : false);
1472
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301473 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 lim_send_hal_start_scan_offload_req(mac_ctx,
1475 scan_req)) {
1476 lim_log(mac_ctx, LOGE, FL(
1477 "Couldn't send Offload scan request"));
1478 lim_send_sme_scan_rsp(mac_ctx,
1479 eSIR_SME_INVALID_PARAMETERS,
1480 scan_req->sessionId,
1481 scan_req->transactionId,
1482 scan_req->scan_id);
1483 return;
1484 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301485 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486 /* In all other cases return 'cached' scan results */
1487 if (mac_ctx->lim.gLimRspReqd) {
1488 mac_ctx->lim.gLimRspReqd = false;
1489 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1490 scan_req->sessionId,
1491 scan_req->transactionId, scan_req->scan_id);
1492 }
1493 }
1494}
1495
1496#ifdef FEATURE_OEM_DATA_SUPPORT
1497
1498static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1499{
1500 tpSirOemDataReq pOemDataReq;
1501 tLimMlmOemDataReq *pMlmOemDataReq;
1502
1503 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1504
1505 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301506 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 if (NULL == pMlmOemDataReq) {
1508 lim_log(pMac, LOGP,
1509 FL("AllocateMemory failed for mlmOemDataReq"));
1510 return;
1511 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001513 if (!pMlmOemDataReq->data) {
1514 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301515 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001516 return;
1517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518
Anurag Chouhanc5548422016-02-24 18:33:27 +05301519 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001520 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001521 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301522 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001523 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001524 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1527 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1528 (uint32_t *) pMlmOemDataReq);
1529
1530 return;
1531
1532} /*** end __lim_process_sme_oem_data_req() ***/
1533
1534#endif /* FEATURE_OEM_DATA_SUPPORT */
1535
1536/**
1537 * __lim_process_clear_dfs_channel_list()
1538 *
1539 ***FUNCTION:
1540 ***Clear DFS channel list when country is changed/aquired.
1541 .*This message is sent from SME.
1542 *
1543 ***LOGIC:
1544 *
1545 ***ASSUMPTIONS:
1546 *
1547 ***NOTE:
1548 *
1549 * @param pMac Pointer to Global MAC structure
1550 * @param *pMsgBuf A pointer to the SME message buffer
1551 * @return None
1552 */
1553static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1554{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301555 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556}
1557
1558/**
1559 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1560 * @mac_ctx: Pointer to Global MAC structure
1561 * @msg_buf: A pointer to the SME message buffer
1562 *
1563 * This function is called to process SME_JOIN_REQ message
1564 * from HDD or upper layer application.
1565 *
1566 * Return: None
1567 */
1568static void
1569__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1570{
1571 tpSirSmeJoinReq sme_join_req = NULL;
1572 tLimMlmJoinReq *mlm_join_req;
1573 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1574 uint32_t val = 0;
1575 uint16_t n_size;
1576 uint8_t session_id;
1577 tpPESession session = NULL;
1578 uint8_t sme_session_id;
1579 uint16_t sme_transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001580 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 uint16_t ie_len;
1582 uint8_t *vendor_ie;
1583 tSirBssDescription bss_desc;
1584
1585/* FEATURE_WLAN_DIAG_SUPPORT */
1586#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1587 /*
1588 * Not sending any session, since it is not created yet.
1589 * The response whould have correct state.
1590 */
1591 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1592#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1593
1594 lim_log(mac_ctx, LOG1, FL("Received SME_JOIN_REQ"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595
1596 /*
1597 * Expect Join request in idle state.
1598 * Reassociate request is expected in link established state.
1599 */
1600
1601 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1602 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1603 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1604 msg_buf);
1605
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301606 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 if (NULL == sme_join_req) {
1608 lim_log(mac_ctx, LOGP,
1609 FL("AllocateMemory failed for sme_join_req"));
1610 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1611 return;
1612 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301613 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1614 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 n_size);
1616
1617 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1618 /* Received invalid eWNI_SME_JOIN_REQ */
1619 /* Log the event */
1620 lim_log(mac_ctx, LOGW,
1621 FL("SessionId:%d JOIN REQ with invalid data"),
1622 sme_join_req->sessionId);
1623 ret_code = eSIR_SME_INVALID_PARAMETERS;
1624 goto end;
1625 }
1626
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001627 /*
1628 * Update the capability here itself as this is used in
1629 * lim_extract_ap_capability() below. If not updated issues
1630 * like not honoring power constraint on 1st association after
1631 * driver loading might occur.
1632 */
1633 lim_update_rrm_capability(mac_ctx, sme_join_req);
1634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 bss_desc = sme_join_req->bssDescription;
1636 /* check for the existence of start BSS session */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 session = pe_find_session_by_bssid(mac_ctx, bss_desc.bssId,
1638 &session_id);
1639
1640 if (session != NULL) {
1641 lim_log(mac_ctx, LOGE,
1642 FL("Session(%d) Already exists for BSSID: "
1643 MAC_ADDRESS_STR " in limSmeState = %X"),
1644 session_id,
1645 MAC_ADDR_ARRAY(bss_desc.bssId),
1646 session->limSmeState);
1647
1648 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1649 session->smeSessionId == sme_join_req->sessionId) {
1650 /*
1651 * Received eWNI_SME_JOIN_REQ for same
1652 * BSS as currently associated.
1653 * Log the event and send success
1654 */
1655 lim_log(mac_ctx, LOGW,
1656 FL("SessionId: %d"), session_id);
1657 lim_log(mac_ctx, LOGW,
1658 FL("JOIN_REQ for current joined BSS"));
1659 /* Send Join success response to host */
1660 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1661 session = NULL;
1662 goto end;
1663 } else {
1664 lim_log(mac_ctx, LOGE,
1665 FL("JOIN_REQ not for current joined BSS"));
1666 ret_code = eSIR_SME_REFUSED;
1667 session = NULL;
1668 goto end;
1669 }
1670 } else {
1671 /*
1672 * Session Entry does not exist for given BSSId
1673 * Try to Create a new session
1674 */
1675 session = pe_create_session(mac_ctx, bss_desc.bssId,
1676 &session_id, mac_ctx->lim.maxStation,
1677 eSIR_INFRASTRUCTURE_MODE);
1678 if (session == NULL) {
1679 lim_log(mac_ctx, LOGE,
1680 FL("Session Can not be created "));
1681 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1682 goto end;
1683 } else
1684 lim_log(mac_ctx, LOG1,
1685 FL("SessionId:%d New session created"),
1686 session_id);
1687 }
1688 session->isAmsduSupportInAMPDU =
1689 sme_join_req->isAmsduSupportInAMPDU;
1690
1691 /*
1692 * Store Session related parameters
1693 * Store PE session Id in session Table
1694 */
1695 session->peSessionId = session_id;
1696
1697 /* store the smejoin req handle in session table */
1698 session->pLimJoinReq = sme_join_req;
1699
1700 /* Store SME session Id in sessionTable */
1701 session->smeSessionId = sme_join_req->sessionId;
1702
1703 /* Store SME transaction Id in session Table */
1704 session->transactionId = sme_join_req->transactionId;
1705
1706 /* Store beaconInterval */
1707 session->beaconParams.beaconInterval =
1708 bss_desc.beaconInterval;
1709
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301710 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 sizeof(session->htConfig));
1712
1713 /* Copying of bssId is already done, while creating session */
1714 sir_copy_mac_addr(session->selfMacAddr,
1715 sme_join_req->selfMacAddr);
1716 session->bssType = sme_join_req->bsstype;
1717
1718 session->statypeForBss = STA_ENTRY_PEER;
1719 session->limWmeEnabled = sme_join_req->isWMEenabled;
1720 session->limQosEnabled = sme_join_req->isQosEnabled;
1721
1722 /* Store vendor specfic IE for CISCO AP */
1723 ie_len = (bss_desc.length + sizeof(bss_desc.length) -
1724 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1725
1726 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1727 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
1728 ((uint8_t *)&bss_desc.ieFields), ie_len);
1729
1730 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001731 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 session->isCiscoVendorAP = true;
1733 } else {
1734 session->isCiscoVendorAP = false;
1735 }
1736
1737 /* Copy the dot 11 mode in to the session table */
1738
1739 session->dot11mode = sme_join_req->dot11mode;
1740#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1741 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1742#endif
1743 session->nwType = bss_desc.nwType;
1744 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1745 session->enableHtSmps = sme_join_req->enableHtSmps;
1746 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001747 lim_log(mac_ctx, LOG1,
1748 FL("enableHtSmps: %d htSmps: %d"),
1749 session->enableHtSmps,
1750 session->htSmpsvalue);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751
1752 /*Store Persona */
1753 session->pePersona = sme_join_req->staPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301754 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 FL("PE PERSONA=%d cbMode %u"),
1756 session->pePersona, sme_join_req->cbMode);
1757 if (mac_ctx->roam.configParam.enable2x2)
1758 session->nss = 2;
1759 else
1760 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 session->vhtCapability =
1762 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301763 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 "***__lim_process_sme_join_req: vhtCapability=%d****",
1765 session->vhtCapability);
1766 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301767 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 session->txBFIniFeatureEnabled =
1769 sme_join_req->txBFIniFeatureEnabled;
1770 } else {
1771 session->txBFIniFeatureEnabled = 0;
1772 }
1773 session->txMuBformee = sme_join_req->txMuBformee;
1774 session->enableVhtpAid =
1775 sme_join_req->enableVhtpAid;
1776 session->enableVhtGid =
1777 sme_join_req->enableVhtGid;
1778
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301779 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 FL("***txBFIniFeatureEnabled=%d***"),
1781 session->txBFIniFeatureEnabled);
1782 if (wlan_cfg_get_int(mac_ctx,
1783 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1784 eSIR_SUCCESS)
1785 lim_log(mac_ctx, LOGE, FL(
1786 "cfg get vht su bformer failed"));
1787
1788 session->enable_su_tx_bformer = val;
1789 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1790 }
1791 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1792 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1793 session->txBFIniFeatureEnabled) !=
1794 eSIR_SUCCESS) {
1795 /*
1796 * Set failed for
1797 * CFG_VHT_SU_BEAMFORMEE_CAP
1798 */
1799 lim_log(mac_ctx, LOGP,
1800 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1801 ret_code = eSIR_LOGP_EXCEPTION;
1802 goto end;
1803 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301804 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 "%s: txBFCsnValue=%d", __func__,
1806 sme_join_req->txBFCsnValue);
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001807 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 /*Phy mode */
1810 session->gLimPhyMode = bss_desc.nwType;
1811 handle_ht_capabilityand_ht_info(mac_ctx, session);
1812 /* Copy The channel Id to the session Table */
1813 session->currentOperChannel = bss_desc.channelId;
1814 /* cbMode is already merged value of peer and self -
1815 * done by csr in csr_get_cb_mode_from_ies */
1816 session->htSupportedChannelWidthSet =
1817 (sme_join_req->cbMode) ? 1 : 0;
1818 session->htRecommendedTxWidthSet =
1819 session->htSupportedChannelWidthSet;
1820 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1821
1822 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1823 session->ch_center_freq_seg0 =
1824 session->currentOperChannel - 2;
1825 session->ch_width = CH_WIDTH_40MHZ;
1826 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1827 sme_join_req->cbMode) {
1828 session->ch_center_freq_seg0 =
1829 session->currentOperChannel + 2;
1830 session->ch_width = CH_WIDTH_40MHZ;
1831 } else {
1832 session->ch_center_freq_seg0 = 0;
1833 session->ch_width = CH_WIDTH_20MHZ;
1834 }
1835
1836 /* Record if management frames need to be protected */
1837#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001838 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001840 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842#endif
1843
1844#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1845 session->rssi = bss_desc.rssi;
1846#endif
1847
1848 /* Copy the SSID from smejoinreq to session entry */
1849 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301850 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 session->ssId.length);
1852
1853 /*
1854 * Determin 11r or ESE connection based on input from SME
1855 * which inturn is dependent on the profile the user wants
1856 * to connect to, So input is coming from supplicant
1857 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859#ifdef FEATURE_WLAN_ESE
1860 session->isESEconnection = sme_join_req->isESEconnection;
1861#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 session->isFastTransitionEnabled =
1863 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 session->isFastRoamIniFeatureEnabled =
1866 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 session->txLdpcIniFeatureEnabled =
1868 sme_join_req->txLdpcIniFeatureEnabled;
1869
1870 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1871 session->limSystemRole = eLIM_STA_ROLE;
1872 } else if (session->bssType == eSIR_BTAMP_AP_MODE) {
1873 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1874 } else {
1875 /*
1876 * Throw an error and return and make
1877 * sure to delete the session.
1878 */
1879 lim_log(mac_ctx, LOGE,
1880 FL("recvd JOIN_REQ with invalid bss type %d"),
1881 session->bssType);
1882 ret_code = eSIR_SME_INVALID_PARAMETERS;
1883 goto end;
1884 }
1885
1886 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301887 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 &sme_join_req->addIEScan, sizeof(tSirAddie));
1889
1890 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301891 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1893
1894 val = sizeof(tLimMlmJoinReq) +
1895 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301896 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 if (NULL == mlm_join_req) {
1898 lim_log(mac_ctx, LOGP,
1899 FL("AllocateMemory failed for mlmJoinReq"));
1900 return;
1901 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301902 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903
1904 /* PE SessionId is stored as a part of JoinReq */
1905 mlm_join_req->sessionId = session->peSessionId;
1906
1907 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1908 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1909 eSIR_SUCCESS) {
1910 lim_log(mac_ctx, LOGP,
1911 FL("couldn't retrieve JoinFailureTimer value"
1912 " setting to default value"));
1913 mlm_join_req->joinFailureTimeout =
1914 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1915 }
1916
1917 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301918 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919 (void *)&sme_join_req->operationalRateSet,
1920 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301921 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 (void *)&sme_join_req->extendedRateSet,
1923 sizeof(tSirMacRateSet));
1924 /*
1925 * this may not be needed anymore now, as rateSet is now
1926 * included in the session entry and MLM has session context.
1927 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301928 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 (void *)&session->rateSet,
1930 sizeof(tSirMacRateSet));
1931
1932 session->encryptType = sme_join_req->UCEncryptionType;
1933
1934 mlm_join_req->bssDescription.length =
1935 session->pLimJoinReq->bssDescription.length;
1936
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301937 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 (uint8_t *)
1939 &session->pLimJoinReq->bssDescription.bssId,
1940 session->pLimJoinReq->bssDescription.length + 2);
1941
1942 session->limCurrentBssCaps =
1943 session->pLimJoinReq->bssDescription.capabilityInfo;
1944
1945 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1946 session->currentOperChannel);
1947 local_power_constraint = reg_max;
1948
1949 lim_extract_ap_capability(mac_ctx,
1950 (uint8_t *)
1951 session->pLimJoinReq->bssDescription.ieFields,
1952 lim_get_ielen_from_bss_description(
1953 &session->pLimJoinReq->bssDescription),
1954 &session->limCurrentBssQosCaps,
1955 &session->limCurrentBssPropCap,
1956 &session->gLimCurrentBssUapsd,
1957 &local_power_constraint, session);
1958
1959#ifdef FEATURE_WLAN_ESE
1960 session->maxTxPower = lim_get_max_tx_power(reg_max,
1961 local_power_constraint,
1962 mac_ctx->roam.configParam.nTxPowerCap);
1963#else
1964 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301965 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966#endif
1967#if defined WLAN_VOWIFI_DEBUG
1968 lim_log(mac_ctx, LOGE,
1969 "Regulatory max = %d, local power constraint = %d"
1970 reg_max, local_power_constraint);
1971 lim_log(mac_ctx, LOGE, FL(" max tx = %d"),
1972 session->maxTxPower);
1973#endif
1974
1975 if (session->gLimCurrentBssUapsd) {
1976 session->gUapsdPerAcBitmask =
1977 session->pLimJoinReq->uapsdPerAcBitmask;
1978 lim_log(mac_ctx, LOG1,
1979 FL("UAPSD flag for all AC - 0x%2x"),
1980 session->gUapsdPerAcBitmask);
1981
1982 /* resetting the dynamic uapsd mask */
1983 session->gUapsdPerAcDeliveryEnableMask = 0;
1984 session->gUapsdPerAcTriggerEnableMask = 0;
1985 }
1986
1987 session->limRFBand =
1988 lim_get_rf_band(session->currentOperChannel);
1989
1990 /* Initialize 11h Enable Flag */
1991 if (SIR_BAND_5_GHZ == session->limRFBand) {
1992 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1993 &val) != eSIR_SUCCESS) {
1994 lim_log(mac_ctx, LOGP,
1995 FL("Fail to get WNI_CFG_11H_ENABLED "));
1996 session->lim11hEnable =
1997 WNI_CFG_11H_ENABLED_STADEF;
1998 } else {
1999 session->lim11hEnable = val;
2000 }
2001 } else {
2002 session->lim11hEnable = 0;
2003 }
2004
2005 /*
2006 * To care of the scenario when STA transitions from
2007 * IBSS to Infrastructure mode.
2008 */
2009 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2010
2011 session->limPrevSmeState = session->limSmeState;
2012 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2013 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2014 session->peSessionId,
2015 session->limSmeState));
2016
2017 lim_log(mac_ctx, LOG1,
2018 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
2019 mlm_join_req->sessionId, session->ssId.length,
2020 session->ssId.ssId, session->currentOperChannel,
2021 MAC_ADDR_ARRAY(session->bssId));
2022
2023 /* Indicate whether spectrum management is enabled */
2024 session->spectrumMgtEnabled =
2025 sme_join_req->spectrumMgtIndicator;
2026
2027 /* Enable the spectrum management if this is a DFS channel */
2028 if (session->country_info_present &&
2029 lim_isconnected_on_dfs_channel(
2030 session->currentOperChannel))
2031 session->spectrumMgtEnabled = true;
2032
2033 session->isOSENConnection = sme_join_req->isOSENConnection;
2034
2035 lim_log(mac_ctx, LOG1,
2036 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
2037 mlm_join_req->sessionId);
2038 /* Issue LIM_MLM_JOIN_REQ to MLM */
2039 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2040 (uint32_t *) mlm_join_req);
2041 return;
2042
2043 } else {
2044 /* Received eWNI_SME_JOIN_REQ un expected state */
2045 lim_log(mac_ctx, LOGE,
2046 FL("received unexpected SME_JOIN_REQ in state %X"),
2047 mac_ctx->lim.gLimSmeState);
2048 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2049 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2050 session = NULL;
2051 goto end;
2052 }
2053
2054end:
2055 sme_session_id = sme_join_req->sessionId;
2056 sme_transaction_id = sme_join_req->transactionId;
2057
2058 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302059 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 sme_join_req = NULL;
2061 if (NULL != session)
2062 session->pLimJoinReq = NULL;
2063 }
2064 if (ret_code != eSIR_SME_SUCCESS) {
2065 if (NULL != session) {
2066 pe_delete_session(mac_ctx, session);
2067 session = NULL;
2068 }
2069 }
2070 lim_log(mac_ctx, LOG1,
2071 FL("Send failure status on sessionid: %d with ret_code = %d"),
2072 sme_session_id, ret_code);
2073 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2074 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2075 sme_transaction_id);
2076}
2077
Amar Singhala297bfa2015-10-15 15:07:29 -07002078uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 uint8_t iniTxPower)
2080{
2081 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302082 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2083 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2085 maxTxPower = txPower;
2086 else if (txPower < MIN_TX_PWR_CAP)
2087 maxTxPower = MIN_TX_PWR_CAP;
2088 else
2089 maxTxPower = MAX_TX_PWR_CAP;
2090
2091 return maxTxPower;
2092}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093
2094/**
2095 * __lim_process_sme_reassoc_req() - process reassoc req
2096 *
2097 * @mac_ctx: Pointer to Global MAC structure
2098 * @msg_buf: pointer to the SME message buffer
2099 *
2100 * This function is called to process SME_REASSOC_REQ message
2101 * from HDD or upper layer application.
2102 *
2103 * Return: None
2104 */
2105
2106static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2107 uint32_t *msg_buf)
2108{
2109 uint16_t caps;
2110 uint32_t val;
2111 tpSirSmeJoinReq reassoc_req = NULL;
2112 tLimMlmReassocReq *mlm_reassoc_req;
2113 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2114 tpPESession session_entry = NULL;
2115 uint8_t session_id;
2116 uint8_t sme_session_id;
2117 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002118 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 uint32_t tele_bcn_en = 0;
2120 uint16_t size;
2121
2122 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2123
2124 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302125 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 if (NULL == reassoc_req) {
2127 lim_log(mac_ctx, LOGP,
2128 FL("call to AllocateMemory failed for reassoc_req"));
2129
2130 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2131 goto end;
2132 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302133 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2134 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135
2136 if (!lim_is_sme_join_req_valid(mac_ctx,
2137 (tpSirSmeJoinReq)reassoc_req)) {
2138 /*
2139 * Received invalid eWNI_SME_REASSOC_REQ
2140 */
2141 lim_log(mac_ctx, LOGW,
2142 FL("received SME_REASSOC_REQ with invalid data"));
2143
2144 ret_code = eSIR_SME_INVALID_PARAMETERS;
2145 goto end;
2146 }
2147
2148 session_entry = pe_find_session_by_bssid(mac_ctx,
2149 reassoc_req->bssDescription.bssId,
2150 &session_id);
2151 if (session_entry == NULL) {
2152 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2153 LOGE);
2154 lim_log(mac_ctx, LOGE,
2155 FL("Session does not exist for given bssId"));
2156 ret_code = eSIR_SME_INVALID_PARAMETERS;
2157 goto end;
2158 }
2159#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2160 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2161 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2162#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2163 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2164
2165 /* Store the reassoc handle in the session Table */
2166 session_entry->pLimReAssocReq = reassoc_req;
2167
2168 session_entry->dot11mode = reassoc_req->dot11mode;
2169 session_entry->vhtCapability =
2170 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002171
2172 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2173 session_entry->htSmpsvalue = reassoc_req->htSmps;
2174 lim_log(mac_ctx, LOG1, FL("enableHtSmps: %d htSmps: %d"),
2175 session_entry->enableHtSmps,
2176 session_entry->htSmpsvalue);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 /*
2178 * Reassociate request is expected
2179 * in link established state only.
2180 */
2181
2182 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2184 /*
2185 * May be from 11r FT pre-auth. So lets check it
2186 * before we bail out
2187 */
2188 lim_log(mac_ctx, LOG1, FL(
2189 "Session in reassoc state is %d"),
2190 session_entry->peSessionId);
2191
2192 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 session_entry->limReAssocbssId,
2195 6)) {
2196 lim_print_mac_addr(mac_ctx,
2197 reassoc_req->bssDescription.
2198 bssId, LOGE);
2199 lim_log(mac_ctx, LOGP,
2200 FL("Unknown bssId in reassoc state"));
2201 ret_code = eSIR_SME_INVALID_PARAMETERS;
2202 goto end;
2203 }
2204
2205 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2206 session_entry);
2207 return;
2208 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 /*
2210 * Should not have received eWNI_SME_REASSOC_REQ
2211 */
2212 lim_log(mac_ctx, LOGE,
2213 FL("received unexpected SME_REASSOC_REQ in state %X"),
2214 session_entry->limSmeState);
2215 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2216
2217 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2218 goto end;
2219 }
2220
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302221 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 session_entry->pLimReAssocReq->bssDescription.bssId,
2223 sizeof(tSirMacAddr));
2224
2225 session_entry->limReassocChannelId =
2226 session_entry->pLimReAssocReq->bssDescription.channelId;
2227
2228 session_entry->reAssocHtSupportedChannelWidthSet =
2229 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2230 session_entry->reAssocHtRecommendedTxWidthSet =
2231 session_entry->reAssocHtSupportedChannelWidthSet;
2232 session_entry->reAssocHtSecondaryChannelOffset =
2233 session_entry->pLimReAssocReq->cbMode;
2234
2235 session_entry->limReassocBssCaps =
2236 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2237 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2238 session_entry->currentOperChannel);
2239 local_pwr_constraint = reg_max;
2240
2241 lim_extract_ap_capability(mac_ctx,
2242 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2243 lim_get_ielen_from_bss_description(
2244 &session_entry->pLimReAssocReq->bssDescription),
2245 &session_entry->limReassocBssQosCaps,
2246 &session_entry->limReassocBssPropCap,
2247 &session_entry->gLimCurrentBssUapsd,
2248 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302249 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250#if defined WLAN_VOWIFI_DEBUG
2251 lim_log(mac_ctx, LOGE,
2252 "Regulatory max = %d, local pwr constraint = %d, max tx = %d",
2253 reg_max, local_pwr_constraint,
2254 session_entry->maxTxPower);
2255#endif
2256 /* Copy the SSID from session entry to local variable */
2257 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302258 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 reassoc_req->ssId.ssId,
2260 session_entry->limReassocSSID.length);
2261 if (session_entry->gLimCurrentBssUapsd) {
2262 session_entry->gUapsdPerAcBitmask =
2263 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2264 lim_log(mac_ctx, LOG1,
2265 FL("UAPSD flag for all AC - 0x%2x"),
2266 session_entry->gUapsdPerAcBitmask);
2267 }
2268
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302269 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 if (NULL == mlm_reassoc_req) {
2271 lim_log(mac_ctx, LOGP,
2272 FL("call to AllocateMemory failed for mlmReassocReq"));
2273
2274 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2275 goto end;
2276 }
2277
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302278 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2280
2281 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2282 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2283 eSIR_SUCCESS) {
2284 /*
2285 * Could not get ReassocFailureTimeout value
2286 * from CFG. Log error.
2287 */
2288 lim_log(mac_ctx, LOGP,
2289 FL("could not retrieve ReassocFailureTimeout value"));
2290 }
2291
2292 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2293 eSIR_SUCCESS) {
2294 /*
2295 * Could not get Capabilities value
2296 * from CFG. Log error.
2297 */
2298 lim_log(mac_ctx, LOGP, FL(
2299 "could not retrieve Capabilities value"));
2300 }
2301 mlm_reassoc_req->capabilityInfo = caps;
2302
2303 /* Update PE session_id */
2304 mlm_reassoc_req->sessionId = session_id;
2305
2306 /*
2307 * If telescopic beaconing is enabled, set listen interval to
2308 * WNI_CFG_TELE_BCN_MAX_LI
2309 */
2310 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2311 &tele_bcn_en) != eSIR_SUCCESS)
2312 lim_log(mac_ctx, LOGP,
2313 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2314
2315 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2316
2317 if (tele_bcn_en) {
2318 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2319 eSIR_SUCCESS)
2320 /*
2321 * Could not get ListenInterval value
2322 * from CFG. Log error.
2323 */
2324 lim_log(mac_ctx, LOGP,
2325 FL("could not retrieve ListenInterval"));
2326 } else {
2327 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2328 eSIR_SUCCESS)
2329 /*
2330 * Could not get ListenInterval value
2331 * from CFG. Log error.
2332 */
2333 lim_log(mac_ctx, LOGP,
2334 FL("could not retrieve ListenInterval"));
2335 }
2336
2337 mlm_reassoc_req->listenInterval = (uint16_t) val;
2338
2339 /* Indicate whether spectrum management is enabled */
2340 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2341
2342 /* Enable the spectrum management if this is a DFS channel */
2343 if (session_entry->country_info_present &&
2344 lim_isconnected_on_dfs_channel(
2345 session_entry->currentOperChannel))
2346 session_entry->spectrumMgtEnabled = true;
2347
2348 session_entry->limPrevSmeState = session_entry->limSmeState;
2349 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2350
2351 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2352 session_entry->peSessionId,
2353 session_entry->limSmeState));
2354
2355 lim_post_mlm_message(mac_ctx,
2356 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2357 return;
2358end:
2359 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302360 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 if (session_entry)
2362 session_entry->pLimReAssocReq = NULL;
2363 }
2364
2365 if (session_entry) {
2366 /*
2367 * error occurred after we determined the session so extract
2368 * session and transaction info from there
2369 */
2370 sme_session_id = session_entry->smeSessionId;
2371 transaction_id = session_entry->transactionId;
2372 } else
2373 /*
2374 * error occurred before or during the time we determined
2375 * the session so extract the session and transaction info
2376 * from the message
2377 */
2378 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2379 &sme_session_id, &transaction_id);
2380
2381 /*
2382 * Send Reassoc failure response to host
2383 * (note session_entry may be NULL, but that's OK)
2384 */
2385 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2386 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2387 session_entry, sme_session_id,
2388 transaction_id);
2389}
2390
2391bool send_disassoc_frame = 1;
2392/**
2393 * __lim_process_sme_disassoc_req()
2394 *
2395 ***FUNCTION:
2396 * This function is called to process SME_DISASSOC_REQ message
2397 * from HDD or upper layer application.
2398 *
2399 ***LOGIC:
2400 *
2401 ***ASSUMPTIONS:
2402 *
2403 ***NOTE:
2404 *
2405 * @param pMac Pointer to Global MAC structure
2406 * @param *pMsgBuf A pointer to the SME message buffer
2407 * @return None
2408 */
2409
2410static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2411{
2412 uint16_t disassocTrigger, reasonCode;
2413 tLimMlmDisassocReq *pMlmDisassocReq;
2414 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2415 tSirSmeDisassocReq smeDisassocReq;
2416 tpPESession psessionEntry = NULL;
2417 uint8_t sessionId;
2418 uint8_t smesessionId;
2419 uint16_t smetransactionId;
2420
2421 if (pMsgBuf == NULL) {
2422 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2423 return;
2424 }
2425
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302426 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 smesessionId = smeDisassocReq.sessionId;
2428 smetransactionId = smeDisassocReq.transactionId;
2429 if (!lim_is_sme_disassoc_req_valid(pMac,
2430 &smeDisassocReq,
2431 psessionEntry)) {
2432 PELOGE(lim_log(pMac, LOGE,
2433 FL("received invalid SME_DISASSOC_REQ message"));)
2434 if (pMac->lim.gLimRspReqd) {
2435 pMac->lim.gLimRspReqd = false;
2436
2437 retCode = eSIR_SME_INVALID_PARAMETERS;
2438 disassocTrigger = eLIM_HOST_DISASSOC;
2439 goto sendDisassoc;
2440 }
2441
2442 return;
2443 }
2444
2445 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002446 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 &sessionId);
2448 if (psessionEntry == NULL) {
2449 lim_log(pMac, LOGE,
2450 FL("session does not exist for given bssId "
2451 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002452 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 retCode = eSIR_SME_INVALID_PARAMETERS;
2454 disassocTrigger = eLIM_HOST_DISASSOC;
2455 goto sendDisassoc;
2456 }
2457 lim_log(pMac, LOG1,
2458 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2459 MAC_ADDRESS_STR), smesessionId,
2460 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2461 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002462 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463
2464#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2465 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2466 0, smeDisassocReq.reasonCode);
2467#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2468
2469 /* Update SME session Id and SME transaction ID */
2470
2471 psessionEntry->smeSessionId = smesessionId;
2472 psessionEntry->transactionId = smetransactionId;
2473
2474 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2475 case eLIM_STA_ROLE:
2476 case eLIM_BT_AMP_STA_ROLE:
2477 switch (psessionEntry->limSmeState) {
2478 case eLIM_SME_ASSOCIATED_STATE:
2479 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002480 lim_log(pMac, LOG1,
2481 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2482 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 psessionEntry->limPrevSmeState =
2484 psessionEntry->limSmeState;
2485 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2486#ifdef FEATURE_WLAN_TDLS
2487 /* Delete all TDLS peers connected before leaving BSS */
2488 lim_delete_tdls_peers(pMac, psessionEntry);
2489#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002490 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2491 psessionEntry->peSessionId,
2492 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 break;
2494
2495 case eLIM_SME_WT_DEAUTH_STATE:
2496 /* PE shall still process the DISASSOC_REQ and proceed with
2497 * link tear down even if it had already sent a DEAUTH_IND to
2498 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2499 * its been set when PE entered WT_DEAUTH_STATE.
2500 */
2501 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2502 MTRACE(mac_trace
2503 (pMac, TRACE_CODE_SME_STATE,
2504 psessionEntry->peSessionId,
2505 psessionEntry->limSmeState));
2506 lim_log(pMac, LOG1,
2507 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2508 break;
2509
2510 case eLIM_SME_WT_DISASSOC_STATE:
2511 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2512 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2513 * PE can continue processing DISASSOC_REQ and send the response instead
2514 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2515 * for disassoc frame.
2516 *
2517 * It will send a disassoc, which is ok. However, we can use the global flag
2518 * sendDisassoc to not send disassoc frame.
2519 */
2520 lim_log(pMac, LOG1,
2521 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2522 break;
2523
2524 case eLIM_SME_JOIN_FAILURE_STATE: {
2525 /* Already in Disconnected State, return success */
2526 lim_log(pMac, LOG1,
2527 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2528 if (pMac->lim.gLimRspReqd) {
2529 retCode = eSIR_SME_SUCCESS;
2530 disassocTrigger = eLIM_HOST_DISASSOC;
2531 goto sendDisassoc;
2532 }
2533 }
2534 break;
2535 default:
2536 /**
2537 * STA is not currently associated.
2538 * Log error and send response to host
2539 */
2540 lim_log(pMac, LOGE,
2541 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2542 psessionEntry->limSmeState);
2543 lim_print_sme_state(pMac, LOGE,
2544 psessionEntry->limSmeState);
2545
2546 if (pMac->lim.gLimRspReqd) {
2547 if (psessionEntry->limSmeState !=
2548 eLIM_SME_WT_ASSOC_STATE)
2549 pMac->lim.gLimRspReqd = false;
2550
2551 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2552 disassocTrigger = eLIM_HOST_DISASSOC;
2553 goto sendDisassoc;
2554 }
2555
2556 return;
2557 }
2558
2559 break;
2560
2561 case eLIM_AP_ROLE:
2562 case eLIM_BT_AMP_AP_ROLE:
2563 /* Fall through */
2564 break;
2565
2566 case eLIM_STA_IN_IBSS_ROLE:
2567 default:
2568 /* eLIM_UNKNOWN_ROLE */
2569 lim_log(pMac, LOGE,
2570 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2571 GET_LIM_SYSTEM_ROLE(psessionEntry));
2572
2573 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2574 disassocTrigger = eLIM_HOST_DISASSOC;
2575 goto sendDisassoc;
2576 } /* end switch (pMac->lim.gLimSystemRole) */
2577
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302578 disassocTrigger = eLIM_HOST_DISASSOC;
2579 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580
2581 if (smeDisassocReq.doNotSendOverTheAir) {
2582 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2583 send_disassoc_frame = 0;
2584 }
2585 /* Trigger Disassociation frame to peer MAC entity */
2586 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2587 " : %d, reasonCode : %d"),
2588 disassocTrigger, reasonCode);
2589
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302590 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 if (NULL == pMlmDisassocReq) {
2592 /* Log error */
2593 lim_log(pMac, LOGP,
2594 FL("call to AllocateMemory failed for mlmDisassocReq"));
2595
2596 return;
2597 }
2598
Anurag Chouhanc5548422016-02-24 18:33:27 +05302599 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002600 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601
2602 pMlmDisassocReq->reasonCode = reasonCode;
2603 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2604
2605 /* Update PE session ID */
2606 pMlmDisassocReq->sessionId = sessionId;
2607
2608 lim_post_mlm_message(pMac,
2609 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2610 return;
2611
2612sendDisassoc:
2613 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002614 lim_send_sme_disassoc_ntf(pMac,
2615 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 retCode,
2617 disassocTrigger,
2618 1, smesessionId, smetransactionId,
2619 psessionEntry);
2620 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002621 lim_send_sme_disassoc_ntf(pMac,
2622 smeDisassocReq.peer_macaddr.bytes,
2623 retCode, disassocTrigger, 1,
2624 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625
2626} /*** end __lim_process_sme_disassoc_req() ***/
2627
2628/** -----------------------------------------------------------------
2629 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2630
2631 This function is called to process SME_DISASSOC_CNF message
2632 from HDD or upper layer application.
2633
2634 \param pMac - global mac structure
2635 \param pStaDs - station dph hash node
2636 \return none
2637 \sa
2638 ----------------------------------------------------------------- */
2639static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2640{
2641 tSirSmeDisassocCnf smeDisassocCnf;
2642 uint16_t aid;
2643 tpDphHashNode pStaDs;
2644 tpPESession psessionEntry;
2645 uint8_t sessionId;
2646
2647 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2648
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302649 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 sizeof(struct sSirSmeDisassocCnf));
2651
2652 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002653 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 &sessionId);
2655 if (psessionEntry == NULL) {
2656 lim_log(pMac, LOGE,
2657 FL("session does not exist for given bssId"));
2658 return;
2659 }
2660
2661 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2662 lim_log(pMac, LOGE,
2663 FL("received invalid SME_DISASSOC_CNF message"));
2664 return;
2665 }
2666#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2667 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2668 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2669 psessionEntry,
2670 (uint16_t) smeDisassocCnf.statusCode, 0);
2671 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2672 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2673 psessionEntry,
2674 (uint16_t) smeDisassocCnf.statusCode, 0);
2675#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2676
2677 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2678 case eLIM_STA_ROLE:
2679 case eLIM_BT_AMP_STA_ROLE: /* To test reconn */
2680 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2681 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2682 && (psessionEntry->limSmeState !=
2683 eLIM_SME_WT_DEAUTH_STATE)) {
2684 lim_log(pMac, LOGE,
2685 FL
2686 ("received unexp SME_DISASSOC_CNF in state %X"),
2687 psessionEntry->limSmeState);
2688 lim_print_sme_state(pMac, LOGE,
2689 psessionEntry->limSmeState);
2690 return;
2691 }
2692 break;
2693
2694 case eLIM_AP_ROLE:
2695 /* Fall through */
2696 break;
2697
2698 case eLIM_STA_IN_IBSS_ROLE:
2699 default: /* eLIM_UNKNOWN_ROLE */
2700 lim_log(pMac, LOGE,
2701 FL("received unexpected SME_DISASSOC_CNF role %d"),
2702 GET_LIM_SYSTEM_ROLE(psessionEntry));
2703
2704 return;
2705 }
2706
2707 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2708 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2709 LIM_IS_AP_ROLE(psessionEntry)) {
2710 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002711 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 &psessionEntry->dph.dphHashTable);
2713 if (pStaDs == NULL) {
2714 lim_log(pMac, LOGE,
2715 FL("DISASSOC_CNF for a STA with no context, addr= "
2716 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002717 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 return;
2719 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302720
2721 if ((pStaDs->mlmStaContext.mlmState ==
2722 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2723 (pStaDs->mlmStaContext.mlmState ==
2724 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2725 lim_log(pMac, LOGE,
2726 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002727 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302728 pStaDs->mlmStaContext.mlmState);
2729 return;
2730 }
2731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 /* Delete FT session if there exists one */
2733 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2735
2736 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002737 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 }
2739
2740 return;
2741}
2742
2743/**
2744 * __lim_process_sme_deauth_req() - process sme deauth req
2745 * @mac_ctx: Pointer to Global MAC structure
2746 * @msg_buf: pointer to the SME message buffer
2747 *
2748 * This function is called to process SME_DEAUTH_REQ message
2749 * from HDD or upper layer application.
2750 *
2751 * Return: None
2752 */
2753
2754static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2755 uint32_t *msg_buf)
2756{
2757 uint16_t deauth_trigger, reason_code;
2758 tLimMlmDeauthReq *mlm_deauth_req;
2759 tSirSmeDeauthReq sme_deauth_req;
2760 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2761 tpPESession session_entry;
2762 uint8_t session_id; /* PE sessionId */
2763 uint8_t sme_session_id;
2764 uint16_t sme_transaction_id;
2765
2766 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2767
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302768 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 sme_session_id = sme_deauth_req.sessionId;
2770 sme_transaction_id = sme_deauth_req.transactionId;
2771
2772 /*
2773 * We need to get a session first but we don't even know
2774 * if the message is correct.
2775 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002776 session_entry = pe_find_session_by_bssid(mac_ctx,
2777 sme_deauth_req.bssid.bytes,
2778 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 if (session_entry == NULL) {
2780 lim_log(mac_ctx, LOGE,
2781 FL("session does not exist for given bssId"));
2782 ret_code = eSIR_SME_INVALID_PARAMETERS;
2783 deauth_trigger = eLIM_HOST_DEAUTH;
2784 goto send_deauth;
2785 }
2786
2787 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2788 session_entry)) {
2789 lim_log(mac_ctx, LOGE,
2790 FL("received invalid SME_DEAUTH_REQ message"));
2791 mac_ctx->lim.gLimRspReqd = false;
2792
2793 ret_code = eSIR_SME_INVALID_PARAMETERS;
2794 deauth_trigger = eLIM_HOST_DEAUTH;
2795 goto send_deauth;
2796 }
2797 lim_log(mac_ctx, LOG1,
2798 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2799 MAC_ADDRESS_STR), sme_session_id,
2800 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2801 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002802 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2804 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2805 session_entry, 0, sme_deauth_req.reasonCode);
2806#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2807
2808 /* Update SME session ID and Transaction ID */
2809 session_entry->smeSessionId = sme_session_id;
2810 session_entry->transactionId = sme_transaction_id;
2811
2812 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2813 case eLIM_STA_ROLE:
2814 case eLIM_BT_AMP_STA_ROLE:
2815
2816 switch (session_entry->limSmeState) {
2817 case eLIM_SME_ASSOCIATED_STATE:
2818 case eLIM_SME_LINK_EST_STATE:
2819 case eLIM_SME_WT_ASSOC_STATE:
2820 case eLIM_SME_JOIN_FAILURE_STATE:
2821 case eLIM_SME_IDLE_STATE:
2822 session_entry->limPrevSmeState =
2823 session_entry->limSmeState;
2824 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2825 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2826 session_entry->peSessionId,
2827 session_entry->limSmeState));
2828 /* Send Deauthentication request to MLM below */
2829 break;
2830 case eLIM_SME_WT_DEAUTH_STATE:
2831 case eLIM_SME_WT_DISASSOC_STATE:
2832 /*
2833 * PE Recieved a Deauth/Disassoc frame. Normally it get
2834 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2835 * Which means host is also trying to disconnect.
2836 * PE can continue processing DEAUTH_REQ and send
2837 * the response instead of failing the request.
2838 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2839 * was sent for deauth/disassoc frame.
2840 */
2841 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2842 lim_log(mac_ctx, LOG1, FL(
2843 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2844 break;
2845 default:
2846 /*
2847 * STA is not in a state to deauthenticate with
2848 * peer. Log error and send response to host.
2849 */
2850 lim_log(mac_ctx, LOGE, FL(
2851 "received unexp SME_DEAUTH_REQ in state %X"),
2852 session_entry->limSmeState);
2853 lim_print_sme_state(mac_ctx, LOGE,
2854 session_entry->limSmeState);
2855
2856 if (mac_ctx->lim.gLimRspReqd) {
2857 mac_ctx->lim.gLimRspReqd = false;
2858
2859 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2860 deauth_trigger = eLIM_HOST_DEAUTH;
2861
2862 /*
2863 * here we received deauth request from AP so sme state
2864 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2865 * delSta then mlm state should be
2866 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2867 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2868 * so the below condition captures the state where
2869 * delSta not done and firmware still in
2870 * connected state.
2871 */
2872 if (session_entry->limSmeState ==
2873 eLIM_SME_WT_DEAUTH_STATE &&
2874 session_entry->limMlmState !=
2875 eLIM_MLM_IDLE_STATE &&
2876 session_entry->limMlmState !=
2877 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2878 ret_code = eSIR_SME_DEAUTH_STATUS;
2879 goto send_deauth;
2880 }
2881 return;
2882 }
2883 break;
2884
2885 case eLIM_STA_IN_IBSS_ROLE:
2886 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2887 if (mac_ctx->lim.gLimRspReqd) {
2888 mac_ctx->lim.gLimRspReqd = false;
2889 ret_code = eSIR_SME_INVALID_PARAMETERS;
2890 deauth_trigger = eLIM_HOST_DEAUTH;
2891 goto send_deauth;
2892 }
2893 return;
2894 case eLIM_AP_ROLE:
2895 break;
2896 default:
2897 lim_log(mac_ctx, LOGE,
2898 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2899 GET_LIM_SYSTEM_ROLE(session_entry));
2900 if (mac_ctx->lim.gLimRspReqd) {
2901 mac_ctx->lim.gLimRspReqd = false;
2902 ret_code = eSIR_SME_INVALID_PARAMETERS;
2903 deauth_trigger = eLIM_HOST_DEAUTH;
2904 goto send_deauth;
2905 }
2906 return;
2907 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2908
2909 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2910 /* Deauthentication is triggered by Link Monitoring */
2911 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2912 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2913 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2914 } else {
2915 deauth_trigger = eLIM_HOST_DEAUTH;
2916 reason_code = sme_deauth_req.reasonCode;
2917 }
2918
2919 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302920 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921 if (NULL == mlm_deauth_req) {
2922 lim_log(mac_ctx, LOGP,
2923 FL("call to AllocateMemory failed for mlmDeauthReq"));
2924 if (mac_ctx->lim.gLimRspReqd) {
2925 mac_ctx->lim.gLimRspReqd = false;
2926 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2927 deauth_trigger = eLIM_HOST_DEAUTH;
2928 goto send_deauth;
2929 }
2930 return;
2931 }
2932
Anurag Chouhanc5548422016-02-24 18:33:27 +05302933 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002934 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935
2936 mlm_deauth_req->reasonCode = reason_code;
2937 mlm_deauth_req->deauthTrigger = deauth_trigger;
2938
2939 /* Update PE session Id */
2940 mlm_deauth_req->sessionId = session_id;
2941
2942 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2943 (uint32_t *)mlm_deauth_req);
2944 return;
2945
2946send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002947 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2948 ret_code, deauth_trigger, 1,
2949 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950}
2951
2952/**
2953 * __lim_process_sme_set_context_req()
2954 *
2955 * @mac_ctx: Pointer to Global MAC structure
2956 * @msg_buf: pointer to the SME message buffer
2957 *
2958 * This function is called to process SME_SETCONTEXT_REQ message
2959 * from HDD or upper layer application.
2960 *
2961 * Return: None
2962 */
2963
2964static void
2965__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2966{
2967 tpSirSmeSetContextReq set_context_req;
2968 tLimMlmSetKeysReq *mlm_set_key_req;
2969 tpPESession session_entry;
2970 uint8_t session_id; /* PE sessionID */
2971 uint8_t sme_session_id;
2972 uint16_t sme_transaction_id;
2973
2974 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2975
2976 if (msg_buf == NULL) {
2977 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2978 return;
2979 }
2980
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302981 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 if (NULL == set_context_req) {
2983 lim_log(mac_ctx, LOGP, FL(
2984 "call to AllocateMemory failed for set_context_req"));
2985 return;
2986 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302987 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 sizeof(struct sSirSmeSetContextReq));
2989 sme_session_id = set_context_req->sessionId;
2990 sme_transaction_id = set_context_req->transactionId;
2991
2992 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2993 lim_log(mac_ctx, LOGW,
2994 FL("received invalid SME_SETCONTEXT_REQ message"));
2995 goto end;
2996 }
2997
2998 if (set_context_req->keyMaterial.numKeys >
2999 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3000 lim_log(mac_ctx, LOGE, FL(
3001 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3002 set_context_req->keyMaterial.numKeys);
3003 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003004 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 eSIR_SME_INVALID_PARAMETERS, NULL,
3006 sme_session_id, sme_transaction_id);
3007 goto end;
3008 }
3009
3010 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003011 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 if (session_entry == NULL) {
3013 lim_log(mac_ctx, LOGW,
3014 FL("Session does not exist for given BSSID"));
3015 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003016 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 eSIR_SME_INVALID_PARAMETERS, NULL,
3018 sme_session_id, sme_transaction_id);
3019 goto end;
3020 }
3021#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3022 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3023 session_entry, 0, 0);
3024#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3025
3026 if (((LIM_IS_STA_ROLE(session_entry) ||
3027 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
3028 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3029 ((LIM_IS_IBSS_ROLE(session_entry) ||
3030 LIM_IS_AP_ROLE(session_entry) ||
3031 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
3032 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3033 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303034 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 if (NULL == mlm_set_key_req) {
3036 lim_log(mac_ctx, LOGP, FL(
3037 "mem alloc failed for mlmSetKeysReq"));
3038 goto end;
3039 }
3040 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3041 mlm_set_key_req->numKeys =
3042 set_context_req->keyMaterial.numKeys;
3043 if (mlm_set_key_req->numKeys >
3044 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3045 lim_log(mac_ctx, LOGP, FL(
3046 "no.of keys exceeded max num of default keys limit"));
3047 goto end;
3048 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303049 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003050 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303052 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 (uint8_t *) &set_context_req->keyMaterial.key,
3054 sizeof(tSirKeys) *
3055 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3056 numKeys : 1));
3057
3058 mlm_set_key_req->sessionId = session_id;
3059 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 lim_log(mac_ctx, LOG1, FL(
3061 "received SETCONTEXT_REQ message sessionId=%d"),
3062 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063
3064 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3065 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3066 LIM_IS_AP_ROLE(session_entry)) {
3067 if (set_context_req->keyMaterial.key[0].keyLength) {
3068 uint8_t key_id;
3069 key_id =
3070 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303071 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 &session_entry->WEPKeyMaterial[key_id],
3073 (uint8_t *) &set_context_req->keyMaterial,
3074 sizeof(tSirKeyMaterial));
3075 } else {
3076 uint32_t i;
3077 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3078 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303079 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 &mlm_set_key_req->key[i],
3081 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3082 sizeof(tSirKeys));
3083 }
3084 }
3085 }
3086 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3087 (uint32_t *) mlm_set_key_req);
3088 } else {
3089 lim_log(mac_ctx, LOGE, FL(
3090 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3091 GET_LIM_SYSTEM_ROLE(session_entry),
3092 session_entry->limSmeState);
3093 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3094
3095 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003096 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3098 session_entry, sme_session_id,
3099 sme_transaction_id);
3100 }
3101end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303102 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 return;
3104}
3105
3106/**
3107 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3108 *
3109 * @mac_ctx: Pointer to Global MAC structure
3110 * @msg_buf: pointer to the SME message buffer
3111 *
3112 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3113 * from HDD or upper layer application.
3114 *
3115 * Return: None
3116 */
3117
3118void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3119 uint32_t *msg_buf)
3120{
3121 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3122 tpDphHashNode sta_ds = NULL;
3123 tpPESession session_entry = NULL;
3124 tSap_Event sap_event;
3125 tpWLAN_SAPEventCB sap_event_cb = NULL;
3126 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3127 uint8_t session_id = CSR_SESSION_ID_INVALID;
3128 uint8_t assoc_id = 0;
3129 uint8_t sta_cnt = 0;
3130
3131 if (msg_buf == NULL) {
3132 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3133 return;
3134 }
3135
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303136 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137 sizeof(struct sSirSmeGetAssocSTAsReq));
3138 /*
3139 * Get Associated stations from PE.
3140 * Find PE session Entry
3141 */
3142 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003143 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 &session_id);
3145 if (session_entry == NULL) {
3146 lim_log(mac_ctx, LOGE,
3147 FL("session does not exist for given bssId"));
3148 goto lim_assoc_sta_end;
3149 }
3150
3151 if (!LIM_IS_AP_ROLE(session_entry)) {
3152 lim_log(mac_ctx, LOGE, FL(
3153 "Received unexpected message in state %X, in role %X"),
3154 session_entry->limSmeState,
3155 GET_LIM_SYSTEM_ROLE(session_entry));
3156 goto lim_assoc_sta_end;
3157 }
3158 /* Retrieve values obtained in the request message */
3159 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3160 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3161
3162 if (NULL == assoc_sta_tmp)
3163 goto lim_assoc_sta_end;
3164 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3165 assoc_id++) {
3166 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3167 &session_entry->dph.dphHashTable);
3168 if (NULL == sta_ds)
3169 continue;
3170 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303171 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303173 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3175 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3176
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303177 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 (uint8_t *)&sta_ds->supportedRates,
3179 sizeof(tSirSupportedRates));
3180 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3181 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3182 assoc_sta_tmp->Support40Mhz =
3183 sta_ds->htDsssCckRate40MHzSupport;
3184
3185 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3186 sta_cnt + 1);
3187 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3188 MAC_ADDR_ARRAY(sta_ds->staAddr));
3189 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3190 sta_ds->assocId);
3191 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3192 sta_ds->staIndex);
3193 assoc_sta_tmp++;
3194 sta_cnt++;
3195 }
3196 }
3197lim_assoc_sta_end:
3198 /*
3199 * Call hdd callback with sap event to send the list of
3200 * associated stations from PE
3201 */
3202 if (sap_event_cb != NULL) {
3203 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3204 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303205 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3207 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3208 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3209 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3210 }
3211}
3212
3213/**
3214 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3215 *
3216 * @mac_ctx: Pointer to Global MAC structure
3217 * @msg_buf: pointer to WPS PBC overlap query message
3218 *
3219 * This function parses get WPS PBC overlap information
3220 * message and call callback to pass WPS PBC overlap
3221 * information back to hdd.
3222 *
3223 * Return: None
3224 */
3225void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3226 uint32_t *msg_buf)
3227{
3228 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3229 tpPESession session_entry = NULL;
3230 tSap_Event sap_event;
3231 tpWLAN_SAPEventCB sap_event_cb = NULL;
3232 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3234
3235 if (msg_buf == NULL) {
3236 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3237 return;
3238 }
3239
3240 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303241 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303243 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3245 /*
3246 * Get Associated stations from PE
3247 * Find PE session Entry
3248 */
3249 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003250 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 if (session_entry == NULL) {
3252 lim_log(mac_ctx, LOGE,
3253 FL("session does not exist for given bssId"));
3254 goto lim_get_wpspbc_sessions_end;
3255 }
3256
3257 if (!LIM_IS_AP_ROLE(session_entry)) {
3258 lim_log(mac_ctx, LOGE,
3259 FL("Received unexpected message in role %X"),
3260 GET_LIM_SYSTEM_ROLE(session_entry));
3261 goto lim_get_wpspbc_sessions_end;
3262 }
3263 /*
3264 * Call hdd callback with sap event to send the
3265 * WPS PBC overlap information
3266 */
3267 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303268 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269
Anurag Chouhanc5548422016-02-24 18:33:27 +05303270 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003272 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 sap_get_wpspbc_event->UUID_E,
3274 &sap_get_wpspbc_event->wpsPBCOverlap,
3275 session_entry);
3276 } else {
3277 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003278 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 session_entry);
3280 /* don't have to inform the HDD/Host */
3281 return;
3282 }
3283
3284 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3285 sap_get_wpspbc_event->wpsPBCOverlap);
3286 lim_print_mac_addr(mac_ctx,
3287 sap_get_wpspbc_event->addr.bytes, LOG4);
3288
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303289 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290
3291lim_get_wpspbc_sessions_end:
3292 sap_event_cb =
3293 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3294 if (NULL != sap_event_cb)
3295 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3296}
3297
3298/**
3299 * __lim_counter_measures()
3300 *
3301 * FUNCTION:
3302 * This function is called to "implement" MIC counter measure
3303 * and is *temporary* only
3304 *
3305 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3306 * we don't do the proper STA disassoc sequence since the
3307 * BSS will be stoped anyway
3308 *
3309 ***ASSUMPTIONS:
3310 *
3311 ***NOTE:
3312 *
3313 * @param pMac Pointer to Global MAC structure
3314 * @return None
3315 */
3316
3317static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3318{
3319 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3320 if (LIM_IS_AP_ROLE(psessionEntry) ||
3321 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3322 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3323 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3324 mac, psessionEntry, false);
3325};
3326
3327void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3328{
3329 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3330 tpPESession psessionEntry;
3331 uint8_t sessionId; /* PE sessionId */
3332
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303333 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 sizeof(struct sSirSmeTkipCntrMeasReq));
3335
3336 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003337 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 if (NULL == psessionEntry) {
3339 lim_log(pMac, LOGE,
3340 FL("session does not exist for given BSSID "));
3341 return;
3342 }
3343
3344 if (tkipCntrMeasReq.bEnable)
3345 __lim_counter_measures(pMac, psessionEntry);
3346
3347 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3348}
3349
3350static void
3351__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3352{
3353 tSirSmeStopBssReq stopBssReq;
3354 tSirRetStatus status;
3355 tLimSmeStates prevState;
3356 tpPESession psessionEntry;
3357 uint8_t smesessionId;
3358 uint8_t sessionId;
3359 uint16_t smetransactionId;
3360 uint8_t i = 0;
3361 tpDphHashNode pStaDs = NULL;
3362
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303363 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 smesessionId = stopBssReq.sessionId;
3365 smetransactionId = stopBssReq.transactionId;
3366
3367 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3368 PELOGW(lim_log(pMac, LOGW,
3369 FL("received invalid SME_STOP_BSS_REQ message"));)
3370 /* Send Stop BSS response to host */
3371 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3372 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3373 smetransactionId);
3374 return;
3375 }
3376
3377 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003378 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379 &sessionId);
3380 if (psessionEntry == NULL) {
3381 lim_log(pMac, LOGW,
3382 FL("session does not exist for given BSSID "));
3383 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3384 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3385 smetransactionId);
3386 return;
3387 }
3388#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3389 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3390 0, 0);
3391#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3392
3393 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3394 LIM_IS_STA_ROLE(psessionEntry)) {
3395 /**
3396 * Should not have received STOP_BSS_REQ in states
3397 * other than 'normal' state or on STA in Infrastructure
3398 * mode. Log error and return response to host.
3399 */
3400 lim_log(pMac, LOGE,
3401 FL
3402 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3403 psessionEntry->limSmeState,
3404 GET_LIM_SYSTEM_ROLE(psessionEntry));
3405 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3406 /* / Send Stop BSS response to host */
3407 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3408 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3409 smetransactionId);
3410 return;
3411 }
3412
3413 if (LIM_IS_AP_ROLE(psessionEntry))
3414 lim_wpspbc_close(pMac, psessionEntry);
3415
3416 lim_log(pMac, LOGW,
3417 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3418 stopBssReq.reasonCode);
3419
3420 prevState = psessionEntry->limSmeState;
3421
3422 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3423 MTRACE(mac_trace
3424 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3425 psessionEntry->limSmeState));
3426
3427 /* Update SME session Id and Transaction Id */
3428 psessionEntry->smeSessionId = smesessionId;
3429 psessionEntry->transactionId = smetransactionId;
3430
3431 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3432 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3433 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3434 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3435 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3436 /* Send disassoc all stations associated thru TKIP */
3437 __lim_counter_measures(pMac, psessionEntry);
3438 else
3439 lim_send_disassoc_mgmt_frame(pMac,
3440 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3441 bcAddr, psessionEntry, false);
3442 }
3443
3444 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303445 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 psessionEntry->addIeParams.probeRespDataLen = 0;
3447 psessionEntry->addIeParams.probeRespData_buff = NULL;
3448
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303449 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 psessionEntry->addIeParams.assocRespDataLen = 0;
3451 psessionEntry->addIeParams.assocRespData_buff = NULL;
3452
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303453 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3455 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3456
3457 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3458 pMac->lim.gLimIbssCoalescingHappened = false;
3459
3460 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3461 pStaDs =
3462 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3463 if (NULL == pStaDs)
3464 continue;
3465 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3466 if (eSIR_SUCCESS == status) {
3467 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3468 pStaDs->assocId, psessionEntry);
3469 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3470 } else {
3471 lim_log(pMac, LOGE,
3472 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303473 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 }
3475 }
3476 /* send a delBss to HAL and wait for a response */
3477 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3478
3479 if (status != eSIR_SUCCESS) {
3480 PELOGE(lim_log
3481 (pMac, LOGE, FL("delBss failed for bss %d"),
3482 psessionEntry->bssIdx);
3483 )
3484 psessionEntry->limSmeState = prevState;
3485
3486 MTRACE(mac_trace
3487 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3488 psessionEntry->limSmeState));
3489
3490 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3491 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3492 smetransactionId);
3493 }
3494}
3495
3496/**
3497 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3498 * @pMac: Global MAC context
3499 * @pMsg: Message from SME
3500 *
3501 * Wrapper for the function __lim_handle_sme_stop_bss_request
3502 * This message will be defered until softmac come out of
3503 * scan mode. Message should be handled even if we have
3504 * detected radar in the current operating channel.
3505 *
3506 * Return: true - If we consumed the buffer
3507 * false - If have defered the message.
3508 */
3509
3510static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3511{
3512 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3513 /**
3514 * If message defered, buffer is not consumed yet.
3515 * So return false
3516 */
3517 return false;
3518 }
3519 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3520 return true;
3521} /*** end __lim_process_sme_stop_bss_req() ***/
3522
3523void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3524 uint32_t body, tpPESession psessionEntry)
3525{
3526
3527 (void)body;
3528 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3529 lim_ibss_delete(pMac, psessionEntry);
3530 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3531 lim_delete_pre_auth_list(pMac);
3532 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3533 psessionEntry->smeSessionId,
3534 psessionEntry->transactionId);
3535 return;
3536}
3537
3538/**
3539 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3540 *
3541 * @mac_ctx: pointer to mac context
3542 * @msg_type: message type
3543 * @msg_buf: pointer to the SME message buffer
3544 *
3545 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3546 * in BTAMP AP.
3547 *
3548 * Return: None
3549 */
3550
3551void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3552 uint32_t *msg_buf)
3553{
3554 tSirSmeAssocCnf assoc_cnf;
3555 tpDphHashNode sta_ds = NULL;
3556 tpPESession session_entry = NULL;
3557 uint8_t session_id;
3558 tpSirAssocReq assoc_req;
3559
3560 if (msg_buf == NULL) {
3561 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3562 goto end;
3563 }
3564
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303565 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3567 lim_log(mac_ctx, LOGE,
3568 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3569 goto end;
3570 }
3571
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003572 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 &session_id);
3574 if (session_entry == NULL) {
3575 lim_log(mac_ctx, LOGE,
3576 FL("session does not exist for given bssId"));
3577 goto end;
3578 }
3579
3580 if ((!LIM_IS_AP_ROLE(session_entry) &&
3581 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3582 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3583 (session_entry->limSmeState !=
3584 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3585 lim_log(mac_ctx, LOGE, FL(
3586 "Rcvd unexpected msg %X in state %X, in role %X"),
3587 msg_type, session_entry->limSmeState,
3588 GET_LIM_SYSTEM_ROLE(session_entry));
3589 goto end;
3590 }
3591 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3592 &session_entry->dph.dphHashTable);
3593 if (sta_ds == NULL) {
3594 lim_log(mac_ctx, LOGE, FL(
3595 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3596 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003597 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598
3599 /*
3600 * send a DISASSOC_IND message to WSM to make sure
3601 * the state in WSM and LIM is the same
3602 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003603 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 eSIR_SME_STA_NOT_ASSOCIATED,
3605 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3606 session_entry->smeSessionId,
3607 session_entry->transactionId,
3608 session_entry);
3609 goto end;
3610 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303611 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003612 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303613 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 lim_log(mac_ctx, LOG1, FL(
3615 "peerMacAddr mismatched for aid %d, peer "),
3616 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003617 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 goto end;
3619 }
3620
3621 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3622 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3623 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3624 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3625 (msg_type != eWNI_SME_ASSOC_CNF))) {
3626 lim_log(mac_ctx, LOG1, FL(
3627 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3628 "StaD mlmState : %d"),
3629 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003630 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 goto end;
3632 }
3633 /*
3634 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3635 * has been received
3636 */
3637 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3638 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3639 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3640
3641 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3642 /*
3643 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3644 * when it had received Assoc Request frame. Now, PE just needs
3645 * to send association rsp frame to the requesting BTAMP-STA.
3646 */
3647 sta_ds->mlmStaContext.mlmState =
3648 eLIM_MLM_LINK_ESTABLISHED_STATE;
3649 lim_log(mac_ctx, LOG1,
3650 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3651 sta_ds->assocId);
3652 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3653 sta_ds->assocId, sta_ds->staAddr,
3654 sta_ds->mlmStaContext.subType, sta_ds,
3655 session_entry);
3656 goto end;
3657 } else {
3658 /*
3659 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3660 * to be associated since the HAL sta entry is created for
3661 * denied STA we need to remove this HAL entry.
3662 * So to do that set updateContext to 1
3663 */
3664 if (!sta_ds->mlmStaContext.updateContext)
3665 sta_ds->mlmStaContext.updateContext = 1;
3666 lim_log(mac_ctx, LOG1,
3667 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3668 assoc_cnf.statusCode, sta_ds->assocId);
3669 lim_reject_association(mac_ctx, sta_ds->staAddr,
3670 sta_ds->mlmStaContext.subType,
3671 true, sta_ds->mlmStaContext.authType,
3672 sta_ds->assocId, true,
3673 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3674 session_entry);
3675 }
3676end:
3677 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3678 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3679 assoc_req = (tpSirAssocReq)
3680 session_entry->parsedAssocReq[sta_ds->assocId];
3681 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303682 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 assoc_req->assocReqFrame = NULL;
3684 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303685 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3687 }
3688}
3689
3690static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3691{
3692 tpDphHashNode pStaDs;
3693 tSirMacAddr peerMac;
3694 tpSirAddtsReq pSirAddts;
3695 uint32_t timeout;
3696 tpPESession psessionEntry;
3697 uint8_t sessionId; /* PE sessionId */
3698 uint8_t smesessionId;
3699 uint16_t smetransactionId;
3700
3701 if (pMsgBuf == NULL) {
3702 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3703 return;
3704 }
3705
3706 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3707 &smetransactionId);
3708
3709 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3710
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003711 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3712 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 if (psessionEntry == NULL) {
3714 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3715 return;
3716 }
3717#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3718 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3719 0);
3720#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3721
3722 /* if sta
3723 * - verify assoc state
3724 * - send addts request to ap
3725 * - wait for addts response from ap
3726 * if ap, just ignore with error log
3727 */
3728 PELOG1(lim_log(pMac, LOG1,
3729 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3730 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3731 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3732 )
3733
3734 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3735 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3736 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3737 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3738 psessionEntry, pSirAddts->req.tspec,
3739 smesessionId, smetransactionId);
3740 return;
3741 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742
3743 pStaDs =
3744 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3745 &psessionEntry->dph.dphHashTable);
3746
3747 if (pStaDs == NULL) {
3748 PELOGE(lim_log
3749 (pMac, LOGE, "Cannot find AP context for addts req");
3750 )
3751 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3752 psessionEntry, pSirAddts->req.tspec,
3753 smesessionId, smetransactionId);
3754 return;
3755 }
3756
3757 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3758 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3759 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3760 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3761 psessionEntry, pSirAddts->req.tspec,
3762 smesessionId, smetransactionId);
3763 return;
3764 }
3765
3766 pSirAddts->req.wsmTspecPresent = 0;
3767 pSirAddts->req.wmeTspecPresent = 0;
3768 pSirAddts->req.lleTspecPresent = 0;
3769
3770 if ((pStaDs->wsmEnabled) &&
3771 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3772 SIR_MAC_ACCESSPOLICY_EDCA))
3773 pSirAddts->req.wsmTspecPresent = 1;
3774 else if (pStaDs->wmeEnabled)
3775 pSirAddts->req.wmeTspecPresent = 1;
3776 else if (pStaDs->lleEnabled)
3777 pSirAddts->req.lleTspecPresent = 1;
3778 else {
3779 PELOGW(lim_log
3780 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3781 )
3782 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3783 psessionEntry, pSirAddts->req.tspec,
3784 smesessionId, smetransactionId);
3785 return;
3786 }
3787
3788 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3789 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3790 lim_log(pMac, LOGE,
3791 "AddTs received in invalid LIMsme state (%d)",
3792 psessionEntry->limSmeState);
3793 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3794 psessionEntry, pSirAddts->req.tspec,
3795 smesessionId, smetransactionId);
3796 return;
3797 }
3798
3799 if (pMac->lim.gLimAddtsSent) {
3800 lim_log(pMac, LOGE,
3801 "Addts (token %d, tsid %d, up %d) is still pending",
3802 pMac->lim.gLimAddtsReq.req.dialogToken,
3803 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3804 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3805 userPrio);
3806 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3807 psessionEntry, pSirAddts->req.tspec,
3808 smesessionId, smetransactionId);
3809 return;
3810 }
3811
3812 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3813
3814 /* save the addts request */
3815 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303816 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3818
3819 /* ship out the message now */
3820 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3821 psessionEntry);
3822 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3823 /* start a timer to wait for the response */
3824 if (pSirAddts->timeout)
3825 timeout = pSirAddts->timeout;
3826 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3827 eSIR_SUCCESS) {
3828 lim_log(pMac, LOGP,
3829 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3830 WNI_CFG_ADDTS_RSP_TIMEOUT);
3831 return;
3832 }
3833
3834 timeout = SYS_MS_TO_TICKS(timeout);
3835 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3836 != TX_SUCCESS) {
3837 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3838 return;
3839 }
3840 pMac->lim.gLimAddtsRspTimerCount++;
3841 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3842 pMac->lim.gLimAddtsRspTimerCount) !=
3843 TX_SUCCESS) {
3844 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3845 return;
3846 }
3847 MTRACE(mac_trace
3848 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3849 eLIM_ADDTS_RSP_TIMER));
3850
3851 /* add the sessionId to the timer object */
3852 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3853 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3854 TX_SUCCESS) {
3855 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3856 return;
3857 }
3858 return;
3859}
3860
3861static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3862{
3863 tSirMacAddr peerMacAddr;
3864 uint8_t ac;
3865 tSirMacTSInfo *pTsinfo;
3866 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3867 tpDphHashNode pStaDs = NULL;
3868 tpPESession psessionEntry;
3869 uint8_t sessionId;
3870 uint32_t status = eSIR_SUCCESS;
3871 uint8_t smesessionId;
3872 uint16_t smetransactionId;
3873
3874 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3875 &smetransactionId);
3876
3877 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003878 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 &sessionId);
3880 if (psessionEntry == NULL) {
3881 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3882 status = eSIR_FAILURE;
3883 goto end;
3884 }
3885#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3886 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3887 0);
3888#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3889
3890 if (eSIR_SUCCESS !=
3891 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3892 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3893 status = eSIR_FAILURE;
3894 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3895 smesessionId, smetransactionId);
3896 return;
3897 }
3898
3899 lim_log(pMac, LOG1,
3900 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3901 MAC_ADDRESS_STR),
3902 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3903
3904 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3905 pDeltsReq->req.wmeTspecPresent,
3906 &pDeltsReq->req.tsinfo,
3907 &pDeltsReq->req.tspec, psessionEntry);
3908
3909 pTsinfo =
3910 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3911 tsinfo : &pDeltsReq->req.tsinfo;
3912
3913 /* We've successfully send DELTS frame to AP. Update the
3914 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3915 * is no longer trigger enabled or delivery enabled
3916 */
3917 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3918 pTsinfo, CLEAR_UAPSD_MASK);
3919
3920 /* We're deleting the TSPEC, so this particular AC is no longer
3921 * admitted. PE needs to downgrade the EDCA
3922 * parameters(for the AC for which TS is being deleted) to the
3923 * next best AC for which ACM is not enabled, and send the
3924 * updated values to HAL.
3925 */
3926 ac = upToAc(pTsinfo->traffic.userPrio);
3927
3928 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3929 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3930 ~(1 << ac);
3931 } else if (pTsinfo->traffic.direction ==
3932 SIR_MAC_DIRECTION_DNLINK) {
3933 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3934 ~(1 << ac);
3935 } else if (pTsinfo->traffic.direction ==
3936 SIR_MAC_DIRECTION_BIDIR) {
3937 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3938 ~(1 << ac);
3939 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3940 ~(1 << ac);
3941 }
3942
3943 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3944 psessionEntry);
3945
3946 pStaDs =
3947 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3948 &psessionEntry->dph.dphHashTable);
3949 if (pStaDs != NULL) {
3950 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3951 pStaDs->bssId);
3952 status = eSIR_SUCCESS;
3953 } else {
3954 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3955 status = eSIR_FAILURE;
3956 }
3957#ifdef FEATURE_WLAN_ESE
3958#ifdef FEATURE_WLAN_ESE_UPLOAD
3959 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960#endif /* FEATURE_WLAN_ESE_UPLOAD */
3961#endif
3962
3963 /* send an sme response back */
3964end:
3965 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3966 smesessionId, smetransactionId);
3967}
3968
3969void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3970{
3971 /* fetch the sessionEntry based on the sessionId */
3972 tpPESession psessionEntry;
3973 psessionEntry = pe_find_session_by_session_id(pMac,
3974 pMac->lim.limTimers.gLimAddtsRspTimer.
3975 sessionId);
3976 if (psessionEntry == NULL) {
3977 lim_log(pMac, LOGP,
3978 FL("Session Does not exist for given sessionID"));
3979 return;
3980 }
3981
3982 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3983 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3984 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3985 GET_LIM_SYSTEM_ROLE(psessionEntry));
3986 pMac->lim.gLimAddtsSent = false;
3987 return;
3988 }
3989
3990 if (!pMac->lim.gLimAddtsSent) {
3991 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3992 return;
3993 }
3994
3995 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3996 lim_log(pMac, LOGE,
3997 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3998 pMac->lim.gLimAddtsRspTimerCount);
3999 return;
4000 }
4001 /* this a real response timeout */
4002 pMac->lim.gLimAddtsSent = false;
4003 pMac->lim.gLimAddtsRspTimerCount++;
4004
4005 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4006 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4007 psessionEntry->smeSessionId,
4008 psessionEntry->transactionId);
4009}
4010
4011/**
4012 * __lim_process_sme_get_statistics_request()
4013 *
4014 ***FUNCTION:
4015 *
4016 *
4017 ***NOTE:
4018 *
4019 * @param pMac Pointer to Global MAC structure
4020 * @param *pMsgBuf A pointer to the SME message buffer
4021 * @return None
4022 */
4023static void
4024__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4025{
4026 tpAniGetPEStatsReq pPEStatsReq;
4027 tSirMsgQ msgQ;
4028
4029 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4030
4031 msgQ.type = WMA_GET_STATISTICS_REQ;
4032
4033 msgQ.reserved = 0;
4034 msgQ.bodyptr = pMsgBuf;
4035 msgQ.bodyval = 0;
4036 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4037
4038 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304039 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 pMsgBuf = NULL;
4041 lim_log(pMac, LOGP, "Unable to forward request");
4042 return;
4043 }
4044
4045 return;
4046}
4047
4048#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4049/**
4050 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
4051 *
4052 ***NOTE:
4053 *
4054 * @param pMac Pointer to Global MAC structure
4055 * @param *pMsgBuf A pointer to the SME message buffer
4056 * @return None
4057 */
4058static void
4059__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4060{
4061 tSirMsgQ msgQ;
4062
4063 msgQ.type = WMA_TSM_STATS_REQ;
4064 msgQ.reserved = 0;
4065 msgQ.bodyptr = pMsgBuf;
4066 msgQ.bodyval = 0;
4067 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4068
4069 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 pMsgBuf = NULL;
4072 lim_log(pMac, LOGP, "Unable to forward request");
4073 return;
4074 }
4075}
4076#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4077
4078static void
4079__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4080{
4081 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4082 tpPESession psessionEntry;
4083 uint8_t sessionId; /* PE sessionID */
4084
4085 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4086
4087 if (pMsgBuf == NULL) {
4088 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4089 return;
4090 }
4091
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 if (NULL == pUpdateAPWPSIEsReq) {
4094 lim_log(pMac, LOGP,
4095 FL
4096 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4097 return;
4098 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304099 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 sizeof(struct sSirUpdateAPWPSIEsReq));
4101
4102 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004103 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 &sessionId);
4105 if (psessionEntry == NULL) {
4106 lim_log(pMac, LOGW,
4107 FL("Session does not exist for given BSSID"));
4108 goto end;
4109 }
4110
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304111 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 sizeof(tSirAPWPSIEs));
4113
4114 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4115 lim_send_beacon_ind(pMac, psessionEntry);
4116
4117end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304118 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 return;
4120}
4121
4122void
4123lim_send_vdev_restart(tpAniSirGlobal pMac,
4124 tpPESession psessionEntry, uint8_t sessionId)
4125{
4126 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4127 tSirMsgQ msgQ;
4128 tSirRetStatus retCode = eSIR_SUCCESS;
4129
4130 if (psessionEntry == NULL) {
4131 PELOGE(lim_log
4132 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4133 __LINE__);
4134 )
4135 return;
4136 }
4137
4138 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304139 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 if (NULL == pHalHiddenSsidVdevRestart) {
4141 PELOGE(lim_log
4142 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4143 __func__, __LINE__);
4144 )
4145 return;
4146 }
4147
4148 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4149 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4150
4151 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4152 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4153 msgQ.bodyval = 0;
4154
4155 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4156 if (eSIR_SUCCESS != retCode) {
4157 PELOGE(lim_log
4158 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4159 __LINE__);
4160 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304161 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 }
4163}
4164
4165static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4166{
4167 tpSirUpdateParams pUpdateParams;
4168 tpPESession psessionEntry;
4169
4170 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4171
4172 if (pMsgBuf == NULL) {
4173 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4174 return;
4175 }
4176
4177 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4178
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004179 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 pUpdateParams->sessionId);
4181 if (psessionEntry == NULL) {
4182 lim_log(pMac, LOGW,
4183 "Session does not exist for given sessionId %d",
4184 pUpdateParams->sessionId);
4185 return;
4186 }
4187
4188 /* Update the session entry */
4189 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4190
4191 /* Send vdev restart */
4192 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4193
4194 /* Update beacon */
4195 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4196 lim_send_beacon_ind(pMac, psessionEntry);
4197
4198 return;
4199} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4200
4201static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4202{
4203 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4204 tpPESession psessionEntry;
4205 uint8_t sessionId; /* PE sessionID */
4206
4207 if (pMsgBuf == NULL) {
4208 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4209 return;
4210 }
4211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304212 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 if (NULL == pUpdateAPWPARSNIEsReq) {
4214 lim_log(pMac, LOGP,
4215 FL
4216 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4217 return;
4218 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304219 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4221
4222 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004223 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 &sessionId);
4225 if (psessionEntry == NULL) {
4226 lim_log(pMac, LOGW,
4227 FL("Session does not exist for given BSSID"));
4228 goto end;
4229 }
4230
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304231 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4233
4234 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4235 &psessionEntry->
4236 pLimStartBssReq->rsnIE,
4237 psessionEntry);
4238
4239 psessionEntry->pLimStartBssReq->privacy = 1;
4240 psessionEntry->privacy = 1;
4241
4242 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4243 lim_send_beacon_ind(pMac, psessionEntry);
4244
4245end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304246 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 return;
4248} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4249
4250/*
4251 Update the beacon Interval dynamically if beaconInterval is different in MCC
4252 */
4253static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4254{
4255 tpSirChangeBIParams pChangeBIParams;
4256 tpPESession psessionEntry;
4257 uint8_t sessionId = 0;
4258 tUpdateBeaconParams beaconParams;
4259
4260 PELOG1(lim_log(pMac, LOG1,
4261 FL("received Update Beacon Interval message"));
4262 );
4263
4264 if (pMsgBuf == NULL) {
4265 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4266 return;
4267 }
4268
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304269 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4271
4272 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004273 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 &sessionId);
4275 if (psessionEntry == NULL) {
4276 lim_log(pMac, LOGE,
4277 FL("Session does not exist for given BSSID"));
4278 return;
4279 }
4280
4281 /*Update sessionEntry Beacon Interval */
4282 if (psessionEntry->beaconParams.beaconInterval !=
4283 pChangeBIParams->beaconInterval) {
4284 psessionEntry->beaconParams.beaconInterval =
4285 pChangeBIParams->beaconInterval;
4286 }
4287
4288 /*Update sch beaconInterval */
4289 if (pMac->sch.schObject.gSchBeaconInterval !=
4290 pChangeBIParams->beaconInterval) {
4291 pMac->sch.schObject.gSchBeaconInterval =
4292 pChangeBIParams->beaconInterval;
4293
4294 PELOG1(lim_log(pMac, LOG1,
4295 FL
4296 ("LIM send update BeaconInterval Indication : %d"),
4297 pChangeBIParams->beaconInterval);
4298 );
4299
4300 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4301 /* Update beacon */
4302 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4303
4304 beaconParams.bssIdx = psessionEntry->bssIdx;
4305 /* Set change in beacon Interval */
4306 beaconParams.beaconInterval =
4307 pChangeBIParams->beaconInterval;
4308 beaconParams.paramChangeBitmap =
4309 PARAM_BCN_INTERVAL_CHANGED;
4310 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4311 }
4312 }
4313
4314 return;
4315} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4316
4317#ifdef QCA_HT_2040_COEX
4318static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4319 uint32_t *pMsgBuf)
4320{
4321 tpSirSetHT2040Mode pSetHT2040Mode;
4322 tpPESession psessionEntry;
4323 uint8_t sessionId = 0;
4324 cds_msg_t msg;
4325 tUpdateVHTOpMode *pHtOpMode = NULL;
4326 uint16_t staId = 0;
4327 tpDphHashNode pStaDs = NULL;
4328
4329 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4330 if (pMsgBuf == NULL) {
4331 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4332 return;
4333 }
4334
4335 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4336
4337 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004338 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 &sessionId);
4340 if (psessionEntry == NULL) {
4341 lim_log(pMac, LOG1,
4342 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004343 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 return;
4345 }
4346
4347 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4348 pSetHT2040Mode->cbMode);
4349 /*Update sessionEntry HT related fields */
4350 switch (pSetHT2040Mode->cbMode) {
4351 case PHY_SINGLE_CHANNEL_CENTERED:
4352 psessionEntry->htSecondaryChannelOffset =
4353 PHY_SINGLE_CHANNEL_CENTERED;
4354 psessionEntry->htRecommendedTxWidthSet = 0;
4355 if (pSetHT2040Mode->obssEnabled)
4356 psessionEntry->htSupportedChannelWidthSet
4357 = eHT_CHANNEL_WIDTH_40MHZ;
4358 else
4359 psessionEntry->htSupportedChannelWidthSet
4360 = eHT_CHANNEL_WIDTH_20MHZ;
4361 break;
4362 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4363 psessionEntry->htSecondaryChannelOffset =
4364 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4365 psessionEntry->htRecommendedTxWidthSet = 1;
4366 break;
4367 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4368 psessionEntry->htSecondaryChannelOffset =
4369 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4370 psessionEntry->htRecommendedTxWidthSet = 1;
4371 break;
4372 default:
4373 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4374 return;
4375 }
4376
4377 /* Update beacon */
4378 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4379 lim_send_beacon_ind(pMac, psessionEntry);
4380
4381 /* update OP Mode for each associated peer */
4382 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4383 pStaDs = dph_get_hash_entry(pMac, staId,
4384 &psessionEntry->dph.dphHashTable);
4385 if (NULL == pStaDs)
4386 continue;
4387
4388 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304389 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390 if (NULL == pHtOpMode) {
4391 lim_log(pMac, LOGE,
4392 FL
4393 ("%s: Not able to allocate memory for setting OP mode"),
4394 __func__);
4395 return;
4396 }
4397 pHtOpMode->opMode =
4398 (psessionEntry->htSecondaryChannelOffset ==
4399 PHY_SINGLE_CHANNEL_CENTERED) ?
4400 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4401 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304402 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 sizeof(tSirMacAddr));
4404 pHtOpMode->smesessionId = sessionId;
4405
4406 msg.type = WMA_UPDATE_OP_MODE;
4407 msg.reserved = 0;
4408 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304409 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304410 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 lim_log(pMac, LOGE,
4412 FL
4413 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4414 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304415 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 return;
4417 }
4418 lim_log(pMac, LOG1,
4419 FL
4420 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4421 __func__, pHtOpMode->opMode, staId);
4422
4423 } else
4424 lim_log(pMac, LOG1,
4425 FL("%s: station %d does not support HT40\n"),
4426 __func__, staId);
4427 }
4428
4429 return;
4430}
4431#endif
4432
4433/* -------------------------------------------------------------------- */
4434/**
4435 * __lim_process_report_message
4436 *
4437 * FUNCTION: Processes the next received Radio Resource Management message
4438 *
4439 * LOGIC:
4440 *
4441 * ASSUMPTIONS:
4442 *
4443 * NOTE:
4444 *
4445 * @param None
4446 * @return None
4447 */
4448
4449void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4450{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 switch (pMsg->type) {
4452 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4453 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4454 break;
4455 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004457 break;
4458 default:
4459 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461}
4462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463/* -------------------------------------------------------------------- */
4464/**
4465 * lim_send_set_max_tx_power_req
4466 *
4467 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4468 *
4469 * LOGIC:
4470 *
4471 * ASSUMPTIONS:
4472 *
4473 * NOTE:
4474 *
4475 * @param txPower txPower to be set.
4476 * @param pSessionEntry session entry.
4477 * @return None
4478 */
4479tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004480lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 tpPESession pSessionEntry)
4482{
4483 tpMaxTxPowerParams pMaxTxParams = NULL;
4484 tSirRetStatus retCode = eSIR_SUCCESS;
4485 tSirMsgQ msgQ;
4486
4487 if (pSessionEntry == NULL) {
4488 PELOGE(lim_log
4489 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4490 __LINE__);
4491 )
4492 return eSIR_FAILURE;
4493 }
4494
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304495 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 if (NULL == pMaxTxParams) {
4497 lim_log(pMac, LOGP,
4498 FL("Unable to allocate memory for pMaxTxParams "));
4499 return eSIR_MEM_ALLOC_FAILED;
4500
4501 }
4502#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4503 lim_log(pMac, LOG1,
4504 FL("pMaxTxParams allocated...will be freed in other module"));
4505#endif
4506 if (pMaxTxParams == NULL) {
4507 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4508 return eSIR_FAILURE;
4509 }
4510 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304511 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304512 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304513 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004514 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304515 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516
4517 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4518 msgQ.bodyptr = pMaxTxParams;
4519 msgQ.bodyval = 0;
4520 PELOG1(lim_log
4521 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4522 )
4523 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4524 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4525 if (eSIR_SUCCESS != retCode) {
4526 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304527 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 }
4529 return retCode;
4530}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531
4532/**
4533 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4534 *
4535 * @mac_ctx: Pointer to Global MAC structure
4536 * @msg_buf: pointer to the SME message buffer
4537 *
4538 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4539 * from SME. It Register this information within PE.
4540 *
4541 * Return: None
4542 */
4543static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4544 uint32_t *msg_buf)
4545{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304546 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4548 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4549 struct mgmt_frm_reg_info *next = NULL;
4550 bool match = false;
4551
4552 lim_log(mac_ctx, LOG1, FL(
4553 "registerFrame %d, frameType %d, matchLen %d"),
4554 sme_req->registerFrame, sme_req->frameType,
4555 sme_req->matchLen);
4556 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304557 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304558 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4559 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304560 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561
4562 while (lim_mgmt_regn != NULL) {
4563 if (lim_mgmt_regn->frameType != sme_req->frameType)
4564 goto skip_match;
4565 if (sme_req->matchLen) {
4566 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304567 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 sme_req->matchData,
4569 lim_mgmt_regn->matchLen))) {
4570 /* found match! */
4571 match = true;
4572 break;
4573 }
4574 } else {
4575 /* found match! */
4576 match = true;
4577 break;
4578 }
4579skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304580 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304581 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304583 (qdf_list_node_t *)lim_mgmt_regn,
4584 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304585 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 lim_mgmt_regn = next;
4587 next = NULL;
4588 }
4589 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304590 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304591 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304593 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304594 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304595 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 }
4597
4598 if (sme_req->registerFrame) {
4599 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304600 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 sme_req->matchLen);
4602 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304603 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 sizeof(struct mgmt_frm_reg_info) +
4605 sme_req->matchLen, 0);
4606 lim_mgmt_regn->frameType = sme_req->frameType;
4607 lim_mgmt_regn->matchLen = sme_req->matchLen;
4608 lim_mgmt_regn->sessionId = sme_req->sessionId;
4609 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304610 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 sme_req->matchData,
4612 sme_req->matchLen);
4613 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304614 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304616 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 gLimMgmtFrameRegistratinQueue,
4618 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304619 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 &mac_ctx->lim.lim_frame_register_lock);
4621 }
4622 }
4623 return;
4624}
4625
4626static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4627{
4628 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4629 pMac->lim.gDeferMsgTypeForNOA);
4630 pMac->lim.gDeferMsgTypeForNOA = 0;
4631 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4632 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304633 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4635 }
4636}
4637
4638/**
4639 * lim_process_regd_defd_sme_req_after_noa_start()
4640 *
4641 * mac_ctx: Pointer to Global MAC structure
4642 *
4643 * This function is called to process deferred sme req message
4644 * after noa start.
4645 *
4646 * Return: None
4647 */
4648void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4649{
4650 bool buf_consumed = true;
4651
4652 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4653 mac_ctx->lim.gDeferMsgTypeForNOA);
4654
4655 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4656 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4657 lim_log(mac_ctx, LOGW,
4658 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4659 lim_log(mac_ctx, LOGW,
4660 FL("It may happen when NOA start ind and timeout happen at the same time"));
4661 return;
4662 }
4663 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4664 case eWNI_SME_SCAN_REQ:
4665 __lim_process_sme_scan_req(mac_ctx,
4666 mac_ctx->lim.gpDefdSmeMsgForNOA);
4667 break;
4668#ifdef FEATURE_OEM_DATA_SUPPORT
4669 case eWNI_SME_OEM_DATA_REQ:
4670 __lim_process_sme_oem_data_req(mac_ctx,
4671 mac_ctx->lim.gpDefdSmeMsgForNOA);
4672 break;
4673#endif
4674 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4675 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4676 mac_ctx->lim.gpDefdSmeMsgForNOA);
4677 /*
4678 * lim_process_remain_on_chnl_req doesnt want us to free
4679 * the buffer since it is freed in lim_remain_on_chn_rsp.
4680 * this change is to avoid "double free"
4681 */
4682 if (false == buf_consumed)
4683 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4684 break;
4685 case eWNI_SME_JOIN_REQ:
4686 __lim_process_sme_join_req(mac_ctx,
4687 mac_ctx->lim.gpDefdSmeMsgForNOA);
4688 break;
4689 default:
4690 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4691 mac_ctx->lim.gDeferMsgTypeForNOA);
4692 break;
4693 }
4694 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4695}
4696
4697static void
4698__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4699{
4700 tpSirResetAPCapsChange pResetCapsChange;
4701 tpPESession psessionEntry;
4702 uint8_t sessionId = 0;
4703 if (pMsgBuf == NULL) {
4704 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4705 return;
4706 }
4707
4708 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4709 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004710 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4711 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 if (psessionEntry == NULL) {
4713 lim_log(pMac, LOGE,
4714 FL("Session does not exist for given BSSID"));
4715 return;
4716 }
4717
4718 psessionEntry->limSentCapsChangeNtf = false;
4719 return;
4720}
4721
4722/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304723 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4724 * indication callback in PE.
4725 * @mac_ptr: Mac pointer
4726 * @msg_buf: Msg pointer containing the callback
4727 *
4728 * This function is used save the Management frame
4729 * indication callback in PE.
4730 *
4731 * Return: None
4732 */
4733static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4734 uint32_t *msg_buf)
4735{
4736 struct sir_sme_mgmt_frame_cb_req *sme_req =
4737 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4738
4739 if (NULL == msg_buf) {
4740 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4741 return;
4742 }
4743 if (sme_req->callback)
4744 mac_ctx->mgmt_frame_ind_cb =
4745 (sir_mgmt_frame_ind_callback)sme_req->callback;
4746 else
4747 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4748}
4749
4750/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 * lim_process_sme_req_messages()
4752 *
4753 ***FUNCTION:
4754 * This function is called by limProcessMessageQueue(). This
4755 * function processes SME request messages from HDD or upper layer
4756 * application.
4757 *
4758 ***LOGIC:
4759 *
4760 ***ASSUMPTIONS:
4761 *
4762 ***NOTE:
4763 *
4764 * @param pMac Pointer to Global MAC structure
4765 * @param msgType Indicates the SME message type
4766 * @param *pMsgBuf A pointer to the SME message buffer
4767 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4768 * false - if pMsgBuf is not to be freed.
4769 */
4770
4771bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4772{
4773 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4774 uint32_t *pMsgBuf = pMsg->bodyptr;
4775 tpSirSmeScanReq pScanReq;
4776 PELOG1(lim_log
4777 (pMac, LOG1,
4778 FL
4779 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4780 lim_msg_str(pMsg->type), pMsg->type,
4781 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4782 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4783 )
4784
4785 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4786 /* If no insert NOA required then execute the code below */
4787
4788 switch (pMsg->type) {
4789 case eWNI_SME_SYS_READY_IND:
4790 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4791 break;
4792
4793 case eWNI_SME_START_BSS_REQ:
4794 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4795 break;
4796
4797 case eWNI_SME_SCAN_REQ:
4798 __lim_process_sme_scan_req(pMac, pMsgBuf);
4799 break;
4800
4801#ifdef FEATURE_OEM_DATA_SUPPORT
4802 case eWNI_SME_OEM_DATA_REQ:
4803 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4804 break;
4805#endif
4806 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4807 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4808 break;
4809
4810 case eWNI_SME_UPDATE_NOA:
4811 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4812 break;
4813 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4814 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4815 break;
4816 case eWNI_SME_JOIN_REQ:
4817 __lim_process_sme_join_req(pMac, pMsgBuf);
4818 break;
4819
4820 case eWNI_SME_REASSOC_REQ:
4821 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4822 break;
4823
4824 case eWNI_SME_DISASSOC_REQ:
4825 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4826 break;
4827
4828 case eWNI_SME_DISASSOC_CNF:
4829 case eWNI_SME_DEAUTH_CNF:
4830 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4831 break;
4832
4833 case eWNI_SME_DEAUTH_REQ:
4834 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4835 break;
4836
4837 case eWNI_SME_SETCONTEXT_REQ:
4838 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4839 break;
4840
4841 case eWNI_SME_STOP_BSS_REQ:
4842 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4843 break;
4844
4845 case eWNI_SME_ASSOC_CNF:
4846 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4847 PELOG1(lim_log(pMac,
4848 LOG1, FL("Received ASSOC_CNF message"));)
4849 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4850 pMsgBuf);
4851 break;
4852
4853 case eWNI_SME_ADDTS_REQ:
4854 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4855 __lim_process_sme_addts_req(pMac, pMsgBuf);
4856 break;
4857
4858 case eWNI_SME_DELTS_REQ:
4859 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4860 __lim_process_sme_delts_req(pMac, pMsgBuf);
4861 break;
4862
4863 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4864 PELOG1(lim_log
4865 (pMac, LOG1,
4866 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4867 )
4868 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4869 break;
4870
4871 case eWNI_SME_GET_STATISTICS_REQ:
4872 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4873 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4874 bufConsumed = false;
4875 break;
4876#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4877 case eWNI_SME_GET_TSM_STATS_REQ:
4878 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4879 bufConsumed = false;
4880 break;
4881#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4882 case eWNI_SME_GET_ASSOC_STAS_REQ:
4883 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4884 break;
4885 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4886 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4887 break;
4888
4889 case eWNI_SME_HIDE_SSID_REQ:
4890 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4891 break;
4892 case eWNI_SME_UPDATE_APWPSIE_REQ:
4893 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4894 break;
4895 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4896 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4897 break;
4898
4899 case eWNI_SME_SET_APWPARSNIEs_REQ:
4900 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4901 break;
4902
4903 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4904 /* Update the beaconInterval */
4905 __lim_process_sme_change_bi(pMac, pMsgBuf);
4906 break;
4907
4908#ifdef QCA_HT_2040_COEX
4909 case eWNI_SME_SET_HT_2040_MODE:
4910 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4911 break;
4912#endif
4913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4915 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4916 __lim_process_report_message(pMac, pMsg);
4917 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 case eWNI_SME_FT_PRE_AUTH_REQ:
4920 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4921 break;
4922 case eWNI_SME_FT_UPDATE_KEY:
4923 lim_process_ft_update_key(pMac, pMsgBuf);
4924 break;
4925
4926 case eWNI_SME_FT_AGGR_QOS_REQ:
4927 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4928 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929
4930 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4931 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4932 break;
4933#ifdef FEATURE_WLAN_TDLS
4934 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4935 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4936 break;
4937 case eWNI_SME_TDLS_ADD_STA_REQ:
4938 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4939 break;
4940 case eWNI_SME_TDLS_DEL_STA_REQ:
4941 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4942 break;
4943 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4944 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4945 break;
4946#endif
4947 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4948 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4949 break;
4950
4951 case eWNI_SME_CHANNEL_CHANGE_REQ:
4952 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4953 break;
4954
4955 case eWNI_SME_START_BEACON_REQ:
4956 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4957 break;
4958
4959 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4960 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4961 break;
4962
4963 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4964 lim_process_update_add_ies(pMac, pMsgBuf);
4965 break;
4966
4967 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4968 lim_process_modify_add_ies(pMac, pMsgBuf);
4969 break;
4970 case eWNI_SME_SET_HW_MODE_REQ:
4971 lim_process_set_hw_mode(pMac, pMsgBuf);
4972 break;
4973 case eWNI_SME_NSS_UPDATE_REQ:
4974 lim_process_nss_update_request(pMac, pMsgBuf);
4975 break;
4976 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4977 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4978 break;
4979 case eWNI_SME_SET_IE_REQ:
4980 lim_process_set_ie_req(pMac, pMsgBuf);
4981 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304982 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4983 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4984 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304985 case eWNI_SME_EXT_CHANGE_CHANNEL:
4986 lim_process_ext_change_channel(pMac, pMsgBuf);
4987 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004988 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4989 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4990 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304992 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 pMsg->bodyptr = NULL;
4994 break;
4995 } /* switch (msgType) */
4996
4997 return bufConsumed;
4998} /*** end lim_process_sme_req_messages() ***/
4999
5000/**
5001 * lim_process_sme_start_beacon_req()
5002 *
5003 ***FUNCTION:
5004 * This function is called by limProcessMessageQueue(). This
5005 * function processes SME request messages from HDD or upper layer
5006 * application.
5007 *
5008 ***LOGIC:
5009 *
5010 ***ASSUMPTIONS:
5011 *
5012 ***NOTE:
5013 *
5014 * @param pMac Pointer to Global MAC structure
5015 * @param msgType Indicates the SME message type
5016 * @param *pMsgBuf A pointer to the SME message buffer
5017 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5018 * false - if pMsgBuf is not to be freed.
5019 */
5020static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5021{
5022 tpSirStartBeaconIndication pBeaconStartInd;
5023 tpPESession psessionEntry;
5024 uint8_t sessionId; /* PE sessionID */
5025
5026 if (pMsg == NULL) {
5027 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5028 return;
5029 }
5030
5031 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5032 psessionEntry = pe_find_session_by_bssid(pMac,
5033 pBeaconStartInd->bssid,
5034 &sessionId);
5035 if (psessionEntry == NULL) {
5036 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5037 lim_log(pMac, LOGE,
5038 FL("Session does not exist for given bssId"));
5039 return;
5040 }
5041
5042 if (pBeaconStartInd->beaconStartStatus == true) {
5043 /*
5044 * Currently this Indication comes from SAP
5045 * to start Beacon Tx on a DFS channel
5046 * since beaconing has to be done on DFS
5047 * channel only after CAC WAIT is completed.
5048 * On a DFS Channel LIM does not start beacon
5049 * Tx right after the WMA_ADD_BSS_RSP.
5050 */
5051 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305052 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 FL("Start Beacon with ssid %s Ch %d"),
5054 psessionEntry->ssId.ssId,
5055 psessionEntry->currentOperChannel);
5056 lim_send_beacon_ind(pMac, psessionEntry);
5057 } else {
5058 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5059 return;
5060 }
5061}
5062
5063/**
5064 * lim_process_sme_channel_change_request() - process sme ch change req
5065 *
5066 * @mac_ctx: Pointer to Global MAC structure
5067 * @msg_buf: pointer to the SME message buffer
5068 *
5069 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5070 *
5071 * Return: None
5072 */
5073static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5074 uint32_t *msg_buf)
5075{
5076 tpSirChanChangeRequest ch_change_req;
5077 tpPESession session_entry;
5078 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005079 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 uint32_t val = 0;
5081
5082 if (msg_buf == NULL) {
5083 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5084 return;
5085 }
5086 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5087
5088 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5089 ch_change_req->targetChannel);
5090
5091 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5092 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5093 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5094 return;
5095 }
5096
5097 session_entry = pe_find_session_by_bssid(mac_ctx,
5098 ch_change_req->bssid, &session_id);
5099 if (session_entry == NULL) {
5100 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5101 lim_log(mac_ctx, LOGE, FL(
5102 "Session does not exist for given bssId"));
5103 return;
5104 }
5105
5106 if (session_entry->currentOperChannel ==
5107 ch_change_req->targetChannel) {
5108 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5109 return;
5110 }
5111
5112 if (LIM_IS_AP_ROLE(session_entry))
5113 session_entry->channelChangeReasonCode =
5114 LIM_SWITCH_CHANNEL_SAP_DFS;
5115 else
5116 session_entry->channelChangeReasonCode =
5117 LIM_SWITCH_CHANNEL_OPERATION;
5118
5119 lim_log(mac_ctx, LOGW, FL(
5120 "switch old chnl %d to new chnl %d, ch_bw %d"),
5121 session_entry->currentOperChannel,
5122 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005123 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005124
5125 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005126 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 session_entry->ch_center_freq_seg0 =
5128 ch_change_req->center_freq_seg_0;
5129 session_entry->ch_center_freq_seg1 =
5130 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005131 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005133 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 session_entry->htRecommendedTxWidthSet =
5135 session_entry->htSupportedChannelWidthSet;
5136 session_entry->currentOperChannel =
5137 ch_change_req->targetChannel;
5138 session_entry->limRFBand =
5139 lim_get_rf_band(session_entry->currentOperChannel);
5140 /* Initialize 11h Enable Flag */
5141 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5142 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5143 eSIR_SUCCESS)
5144 lim_log(mac_ctx, LOGP,
5145 FL("Fail to get WNI_CFG_11H_ENABLED"));
5146 }
5147
5148 session_entry->lim11hEnable = val;
5149 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305150 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 &ch_change_req->operational_rateset,
5152 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305153 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 &ch_change_req->extended_rateset,
5155 sizeof(session_entry->extRateSet));
5156 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5157 session_entry->ch_center_freq_seg0,
5158 session_entry->ch_center_freq_seg1,
5159 session_entry->ch_width,
5160 max_tx_pwr, session_entry->peSessionId);
5161}
5162
5163/******************************************************************************
5164* lim_start_bss_update_add_ie_buffer()
5165*
5166***FUNCTION:
5167* This function checks the src buffer and its length and then malloc for
5168* dst buffer update the same
5169*
5170***LOGIC:
5171*
5172***ASSUMPTIONS:
5173*
5174***NOTE:
5175*
5176* @param pMac Pointer to Global MAC structure
5177* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5178* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5179* @param *pSrcData_buff A pointer of uint8_t src buffer
5180* @param srcDataLen src buffer length
5181******************************************************************************/
5182
5183static void
5184lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5185 uint8_t **pDstData_buff,
5186 uint16_t *pDstDataLen,
5187 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5188{
5189
5190 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5191 *pDstDataLen = srcDataLen;
5192
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305193 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194
5195 if (NULL == *pDstData_buff) {
5196 lim_log(pMac, LOGE,
5197 FL("AllocateMemory failed for pDstData_buff"));
5198 return;
5199 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305200 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 } else {
5202 *pDstData_buff = NULL;
5203 *pDstDataLen = 0;
5204 }
5205}
5206
5207/******************************************************************************
5208* lim_update_add_ie_buffer()
5209*
5210***FUNCTION:
5211* This function checks the src buffer and length if src buffer length more
5212* than dst buffer length then free the dst buffer and malloc for the new src
5213* length, and update the dst buffer and length. But if dst buffer is bigger
5214* than src buffer length then it just update the dst buffer and length
5215*
5216***LOGIC:
5217*
5218***ASSUMPTIONS:
5219*
5220***NOTE:
5221*
5222* @param pMac Pointer to Global MAC structure
5223* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5224* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5225* @param *pSrcData_buff A pointer of uint8_t src buffer
5226* @param srcDataLen src buffer length
5227******************************************************************************/
5228
5229static void
5230lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5231 uint8_t **pDstData_buff,
5232 uint16_t *pDstDataLen,
5233 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5234{
5235
5236 if (NULL == pSrcData_buff) {
5237 lim_log(pMac, LOGE, FL("src buffer is null."));
5238 return;
5239 }
5240
5241 if (srcDataLen > *pDstDataLen) {
5242 *pDstDataLen = srcDataLen;
5243 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305244 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305246 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247
5248 if (NULL == *pDstData_buff) {
5249 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5250 *pDstDataLen = 0;
5251 return;
5252 }
5253 }
5254
5255 /* copy the content of buffer into dst buffer
5256 */
5257 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305258 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259
5260}
5261
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005262/**
5263 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5264 * @pMac : Pointer to Global MAC structure
5265 * @pDstData_buff : A pointer to pointer of dst buffer
5266 * @pDstDataLen : A pointer to pointer of dst buffer length
5267 * @pModifyIE : A pointer to tSirModifyIE
5268 *
5269 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5270 *
5271 * Return:
5272 * True or false depending upon whether IE is updated or not
5273 */
5274static bool
5275lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5276 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5277{
5278 int32_t oui_length;
5279 uint8_t *ibss_ie = NULL;
5280
5281 ibss_ie = pModifyIE->pIEBuffer;
5282 oui_length = pModifyIE->oui_length;
5283
5284 if ((0 == oui_length) || (NULL == ibss_ie)) {
5285 PELOGE(lim_log(pMac, LOGE,
5286 FL("Invalid set IBSS vendor IE command length %d "),
5287 oui_length);)
5288 return false;
5289 }
5290
5291 lim_update_add_ie_buffer(pMac,
5292 pDstData_buff,
5293 pDstDataLen,
5294 pModifyIE->pIEBuffer,
5295 pModifyIE->ieBufferlength);
5296
5297 return true;
5298}
5299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300/*
5301* lim_process_modify_add_ies() - process modify additional IE req.
5302*
5303* @mac_ctx: Pointer to Global MAC structure
5304* @msg_buf: pointer to the SME message buffer
5305*
5306* This function update the PE buffers for additional IEs.
5307*
5308* Return: None
5309*/
5310static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5311 uint32_t *msg_buf)
5312{
5313 tpSirModifyIEsInd modify_add_ies;
5314 tpPESession session_entry;
5315 uint8_t session_id;
5316 bool ret = false;
5317 tSirAddIeParams *add_ie_params;
5318
5319 if (msg_buf == NULL) {
5320 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5321 return;
5322 }
5323
5324 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5325 /* Incoming message has smeSession, use BSSID to find PE session */
5326 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005327 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328
5329 if (NULL == session_entry) {
5330 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5331 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005332 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 goto end;
5334 }
5335 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5336 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5337 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5338 lim_log(mac_ctx, LOGE,
5339 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5340 modify_add_ies->modifyIE.pIEBuffer,
5341 modify_add_ies->modifyIE.ieBufferlength,
5342 modify_add_ies->modifyIE.ieID,
5343 modify_add_ies->modifyIE.ieIDLen,
5344 modify_add_ies->updateType);
5345 goto end;
5346 }
5347 add_ie_params = &session_entry->addIeParams;
5348 switch (modify_add_ies->updateType) {
5349 case eUPDATE_IE_PROBE_RESP:
5350 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005351 if (LIM_IS_IBSS_ROLE(session_entry)) {
5352 lim_update_ibss_prop_add_ies(mac_ctx,
5353 &add_ie_params->probeRespData_buff,
5354 &add_ie_params->probeRespDataLen,
5355 &modify_add_ies->modifyIE);
5356 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 break;
5358 case eUPDATE_IE_ASSOC_RESP:
5359 /* assoc resp IE */
5360 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305361 QDF_TRACE(QDF_MODULE_ID_PE,
5362 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363 "assoc resp add ie not present %d"),
5364 add_ie_params->assocRespDataLen);
5365 }
5366 /* search through the buffer and modify the IE */
5367 break;
5368 case eUPDATE_IE_PROBE_BCN:
5369 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005370 if (LIM_IS_IBSS_ROLE(session_entry)) {
5371 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5372 &add_ie_params->probeRespBCNData_buff,
5373 &add_ie_params->probeRespBCNDataLen,
5374 &modify_add_ies->modifyIE);
5375 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 if (ret == true && modify_add_ies->modifyIE.notify) {
5377 lim_handle_param_update(mac_ctx,
5378 modify_add_ies->updateType);
5379 }
5380 break;
5381 default:
5382 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5383 modify_add_ies->updateType);
5384 break;
5385 }
5386end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305387 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 modify_add_ies->modifyIE.pIEBuffer = NULL;
5389}
5390
5391/*
5392* lim_process_update_add_ies() - process additional IE update req
5393*
5394* @mac_ctx: Pointer to Global MAC structure
5395* @msg_buf: pointer to the SME message buffer
5396*
5397* This function update the PE buffers for additional IEs.
5398*
5399* Return: None
5400*/
5401static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5402 uint32_t *msg_buf)
5403{
5404 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5405 uint8_t session_id;
5406 tpPESession session_entry;
5407 tSirAddIeParams *addn_ie;
5408 uint16_t new_length = 0;
5409 uint8_t *new_ptr = NULL;
5410 tSirUpdateIE *update_ie;
5411
5412 if (msg_buf == NULL) {
5413 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5414 return;
5415 }
5416 update_ie = &update_add_ies->updateIE;
5417 /* incoming message has smeSession, use BSSID to find PE session */
5418 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005419 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005420
5421 if (NULL == session_entry) {
5422 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5423 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005424 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005425 goto end;
5426 }
5427 addn_ie = &session_entry->addIeParams;
5428 /* if len is 0, upper layer requested freeing of buffer */
5429 if (0 == update_ie->ieBufferlength) {
5430 switch (update_add_ies->updateType) {
5431 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305432 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 addn_ie->probeRespData_buff = NULL;
5434 addn_ie->probeRespDataLen = 0;
5435 break;
5436 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305437 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 addn_ie->assocRespData_buff = NULL;
5439 addn_ie->assocRespDataLen = 0;
5440 break;
5441 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305442 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 addn_ie->probeRespBCNData_buff = NULL;
5444 addn_ie->probeRespBCNDataLen = 0;
5445
5446 if (update_ie->notify)
5447 lim_handle_param_update(mac_ctx,
5448 update_add_ies->updateType);
5449 break;
5450 default:
5451 break;
5452 }
5453 return;
5454 }
5455 switch (update_add_ies->updateType) {
5456 case eUPDATE_IE_PROBE_RESP:
5457 if (update_ie->append) {
5458 /*
5459 * In case of append, allocate new memory
5460 * with combined length
5461 */
5462 new_length = update_ie->ieBufferlength +
5463 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305464 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 if (NULL == new_ptr) {
5466 lim_log(mac_ctx, LOGE, FL(
5467 "Memory allocation failed."));
5468 goto end;
5469 }
5470 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305471 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305473 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 update_ie->pAdditionIEBuffer,
5475 update_ie->ieBufferlength);
5476 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305477 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 /* adjust length accordingly */
5479 addn_ie->probeRespDataLen = new_length;
5480 /* save refernece of local buffer in PE session */
5481 addn_ie->probeRespData_buff = new_ptr;
5482 goto end;
5483 }
5484 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5485 &addn_ie->probeRespDataLen,
5486 update_ie->pAdditionIEBuffer,
5487 update_ie->ieBufferlength);
5488 break;
5489 case eUPDATE_IE_ASSOC_RESP:
5490 /* assoc resp IE */
5491 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5492 &addn_ie->assocRespDataLen,
5493 update_ie->pAdditionIEBuffer,
5494 update_ie->ieBufferlength);
5495 break;
5496 case eUPDATE_IE_PROBE_BCN:
5497 /* probe resp Bcn IE */
5498 lim_update_add_ie_buffer(mac_ctx,
5499 &addn_ie->probeRespBCNData_buff,
5500 &addn_ie->probeRespBCNDataLen,
5501 update_ie->pAdditionIEBuffer,
5502 update_ie->ieBufferlength);
5503 if (update_ie->notify)
5504 lim_handle_param_update(mac_ctx,
5505 update_add_ies->updateType);
5506 break;
5507 default:
5508 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5509 update_add_ies->updateType);
5510 break;
5511 }
5512end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305513 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 update_ie->pAdditionIEBuffer = NULL;
5515}
5516
5517/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305518 * send_extended_chan_switch_action_frame()- function to send ECSA
5519 * action frame for each sta connected to SAP/GO and AP in case of
5520 * STA .
5521 * @mac_ctx: pointer to global mac structure
5522 * @new_channel: new channel to switch to.
5523 * @ch_bandwidth: BW of channel to calculate op_class
5524 * @session_entry: pe session
5525 *
5526 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5527 *
5528 * Return: void
5529 */
5530
5531static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5532 uint16_t new_channel, uint8_t ch_bandwidth,
5533 tpPESession session_entry)
5534{
5535 uint16_t op_class;
5536 uint8_t switch_mode = 0, i;
5537 tpDphHashNode psta;
5538
5539
5540 op_class = cds_regdm_get_opclass_from_channel(
5541 mac_ctx->scan.countryCodeCurrent,
5542 new_channel,
5543 ch_bandwidth);
5544
5545 if (LIM_IS_AP_ROLE(session_entry) &&
5546 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5547 switch_mode = 1;
5548
5549 if (LIM_IS_AP_ROLE(session_entry)) {
5550 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5551 psta =
5552 session_entry->dph.dphHashTable.pDphNodeArray + i;
5553 if (psta && psta->added)
5554 lim_send_extended_chan_switch_action_frame(
5555 mac_ctx,
5556 psta->staAddr,
5557 switch_mode, op_class, new_channel,
5558 LIM_MAX_CSA_IE_UPDATES, session_entry);
5559 }
5560 } else if (LIM_IS_STA_ROLE(session_entry)) {
5561 lim_send_extended_chan_switch_action_frame(mac_ctx,
5562 session_entry->bssId,
5563 switch_mode, op_class, new_channel,
5564 LIM_MAX_CSA_IE_UPDATES, session_entry);
5565 }
5566
5567}
5568
5569/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5571 *
5572 * @mac_ctx: Pointer to Global MAC structure
5573 * @msg_buf: pointer to the SME message buffer
5574 *
5575 * This function processes SME request messages from HDD or upper layer
5576 * application.
5577 *
5578 * Return: None
5579 */
5580static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5581 uint32_t *msg_buf)
5582{
5583 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5584 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 uint8_t session_id;
5586 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305587 offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588
5589 if (msg_buf == NULL) {
5590 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5591 return;
5592 }
5593
5594 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5595 session_entry = pe_find_session_by_bssid(mac_ctx,
5596 dfs_csa_ie_req->bssid, &session_id);
5597 if (session_entry == NULL) {
5598 lim_log(mac_ctx, LOGE, FL(
5599 "Session not found for given BSSID" MAC_ADDRESS_STR),
5600 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5601 return;
5602 }
5603
5604 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5605 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5606 GET_LIM_SYSTEM_ROLE(session_entry));
5607 return;
5608 }
5609
5610 /* target channel */
5611 session_entry->gLimChannelSwitch.primaryChannel =
5612 dfs_csa_ie_req->targetChannel;
5613
5614 /* Channel switch announcement needs to be included in beacon */
5615 session_entry->dfsIncludeChanSwIe = true;
5616 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5617 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005618 dfs_csa_ie_req->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5620 session_entry->gLimChannelSwitch.switchMode = 1;
5621
5622 /*
5623 * Validate if SAP is operating HT or VHT mode and set the Channel
5624 * Switch Wrapper element with the Wide Band Switch subelement.
5625 */
5626 if (true != session_entry->vhtCapability)
5627 goto skip_vht;
5628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629 /* Now encode the Wider Ch BW element depending on the ch width */
5630 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005631 switch (dfs_csa_ie_req->ch_params.ch_width) {
5632 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633 /*
5634 * Wide channel BW sublement in channel wrapper element is not
5635 * required in case of 20 Mhz operation. Currently It is set
5636 * only set in case of 40/80 Mhz Operation.
5637 */
5638 session_entry->dfsIncludeChanWrapperIe = false;
5639 wider_bw_ch_switch->newChanWidth =
5640 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5641 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005642 case CH_WIDTH_40MHZ:
5643 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 wider_bw_ch_switch->newChanWidth =
5645 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5646 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005647 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 session_entry->dfsIncludeChanWrapperIe = true;
5649 wider_bw_ch_switch->newChanWidth =
5650 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5651 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005652 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 session_entry->dfsIncludeChanWrapperIe = true;
5654 wider_bw_ch_switch->newChanWidth =
5655 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5656 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005657 case CH_WIDTH_80P80MHZ:
5658 session_entry->dfsIncludeChanWrapperIe = true;
5659 wider_bw_ch_switch->newChanWidth =
5660 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
5661 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005662 default:
5663 session_entry->dfsIncludeChanWrapperIe = false;
5664 /*
5665 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5666 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5667 */
5668 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5669 break;
5670 }
5671 /* Fetch the center channel based on the channel width */
5672 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005673 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674 /*
5675 * This is not applicable for 20/40/80 Mhz.Only used when we support
5676 * 80+80 Mhz operation. In case of 80+80 Mhz, this parameter indicates
5677 * center channel frequency index of 80 Mhz channel of
5678 * frequency segment 1.
5679 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005680 wider_bw_ch_switch->newCenterChanFreq1 =
5681 dfs_csa_ie_req->ch_params.center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682skip_vht:
5683 /* Send CSA IE request from here */
5684 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5685 eSIR_SUCCESS) {
5686 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5687 return;
5688 }
5689
5690 /*
5691 * First beacon update request is sent here, the remaining updates are
5692 * done when the FW responds back after sending the first beacon after
5693 * the template update
5694 */
5695 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305696
5697 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5698 ch_offset = BW80;
5699 else
5700 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5701
5702 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5703 session_entry->gLimChannelSwitch.switchCount,
5704 session_entry->gLimChannelSwitch.primaryChannel,
5705 session_entry->gLimChannelSwitch.ch_width,
5706 session_entry->dfsIncludeChanWrapperIe,
5707 ch_offset);
5708
Abhishek Singh518323d2015-10-19 17:42:01 +05305709 /* Send ECSA Action frame after updating the beacon */
5710 send_extended_chan_switch_action_frame(mac_ctx,
5711 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305712 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 session_entry->gLimChannelSwitch.switchCount--;
5714}
5715
5716/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305717 * lim_process_ext_change_channel()- function to send ECSA
5718 * action frame for STA/CLI .
5719 * @mac_ctx: pointer to global mac structure
5720 * @msg: params from sme for new channel.
5721 *
5722 * This function is called to send ECSA frame for STA/CLI.
5723 *
5724 * Return: void
5725 */
5726
5727static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5728 uint32_t *msg)
5729{
5730 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5731 (struct sir_sme_ext_cng_chan_req *) msg;
5732 tpPESession session_entry = NULL;
5733
5734 if (NULL == msg) {
5735 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5736 return;
5737 }
5738 session_entry =
5739 pe_find_session_by_sme_session_id(mac_ctx,
5740 ext_chng_channel->session_id);
5741 if (NULL == session_entry) {
5742 lim_log(mac_ctx, LOGE,
5743 FL("Session not found for given session %d"),
5744 ext_chng_channel->session_id);
5745 return;
5746 }
5747 if (LIM_IS_AP_ROLE(session_entry)) {
5748 lim_log(mac_ctx, LOGE,
5749 FL("not an STA/CLI session"));
5750 return;
5751 }
5752 send_extended_chan_switch_action_frame(mac_ctx,
5753 ext_chng_channel->new_channel,
5754 0, session_entry);
5755}
5756
5757/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 * lim_process_nss_update_request() - process sme nss update req
5759 *
5760 * @mac_ctx: Pointer to Global MAC structure
5761 * @msg_buf: pointer to the SME message buffer
5762 *
5763 * This function processes SME request messages from HDD or upper layer
5764 * application.
5765 *
5766 * Return: None
5767 */
5768static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5769 uint32_t *msg_buf)
5770{
5771 struct sir_nss_update_request *nss_update_req_ptr;
5772 tpPESession session_entry = NULL;
5773
5774 if (msg_buf == NULL) {
5775 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5776 return;
5777 }
5778
5779 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305780 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 nss_update_req_ptr->vdev_id);
5782 if (session_entry == NULL) {
5783 lim_log(mac_ctx, LOGE, FL(
5784 "Session not found for given session_id %d"),
5785 nss_update_req_ptr->vdev_id);
5786 return;
5787 }
5788
5789 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5790 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5791 GET_LIM_SYSTEM_ROLE(session_entry));
5792 return;
5793 }
5794
5795 /* populate nss field in the beacon */
5796 session_entry->gLimOperatingMode.present = 1;
5797 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5798 /* Send nss update request from here */
5799 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5800 eSIR_SUCCESS) {
5801 lim_log(mac_ctx, LOGE,
5802 FL("Unable to set op mode IE in beacon"));
5803 return;
5804 }
5805
5806 lim_send_beacon_ind(mac_ctx, session_entry);
5807}
5808
5809/**
5810 * lim_process_set_ie_req() - process sme set IE request
5811 *
5812 * @mac_ctx: Pointer to Global MAC structure
5813 * @msg_buf: pointer to the SME message buffer
5814 *
5815 * This function processes SME request messages from HDD or upper layer
5816 * application.
5817 *
5818 * Return: None
5819 */
5820static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5821{
5822 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305823 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824
5825 if (msg_buf == NULL) {
5826 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5827 return;
5828 }
5829
5830 msg = (struct send_extcap_ie *)msg_buf;
5831 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305832 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5834
5835}