blob: 425af96ecc6bda7980b43f2379a3a27bc1645bea [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;
1747
1748 /*Store Persona */
1749 session->pePersona = sme_join_req->staPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301750 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 FL("PE PERSONA=%d cbMode %u"),
1752 session->pePersona, sme_join_req->cbMode);
1753 if (mac_ctx->roam.configParam.enable2x2)
1754 session->nss = 2;
1755 else
1756 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 session->vhtCapability =
1758 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301759 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 "***__lim_process_sme_join_req: vhtCapability=%d****",
1761 session->vhtCapability);
1762 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301763 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 session->txBFIniFeatureEnabled =
1765 sme_join_req->txBFIniFeatureEnabled;
1766 } else {
1767 session->txBFIniFeatureEnabled = 0;
1768 }
1769 session->txMuBformee = sme_join_req->txMuBformee;
1770 session->enableVhtpAid =
1771 sme_join_req->enableVhtpAid;
1772 session->enableVhtGid =
1773 sme_join_req->enableVhtGid;
1774
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301775 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 FL("***txBFIniFeatureEnabled=%d***"),
1777 session->txBFIniFeatureEnabled);
1778 if (wlan_cfg_get_int(mac_ctx,
1779 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1780 eSIR_SUCCESS)
1781 lim_log(mac_ctx, LOGE, FL(
1782 "cfg get vht su bformer failed"));
1783
1784 session->enable_su_tx_bformer = val;
1785 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1786 }
1787 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1788 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1789 session->txBFIniFeatureEnabled) !=
1790 eSIR_SUCCESS) {
1791 /*
1792 * Set failed for
1793 * CFG_VHT_SU_BEAMFORMEE_CAP
1794 */
1795 lim_log(mac_ctx, LOGP,
1796 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1797 ret_code = eSIR_LOGP_EXCEPTION;
1798 goto end;
1799 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301800 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 "%s: txBFCsnValue=%d", __func__,
1802 sme_join_req->txBFCsnValue);
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001803 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 /*Phy mode */
1806 session->gLimPhyMode = bss_desc.nwType;
1807 handle_ht_capabilityand_ht_info(mac_ctx, session);
1808 /* Copy The channel Id to the session Table */
1809 session->currentOperChannel = bss_desc.channelId;
1810 /* cbMode is already merged value of peer and self -
1811 * done by csr in csr_get_cb_mode_from_ies */
1812 session->htSupportedChannelWidthSet =
1813 (sme_join_req->cbMode) ? 1 : 0;
1814 session->htRecommendedTxWidthSet =
1815 session->htSupportedChannelWidthSet;
1816 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1817
1818 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1819 session->ch_center_freq_seg0 =
1820 session->currentOperChannel - 2;
1821 session->ch_width = CH_WIDTH_40MHZ;
1822 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1823 sme_join_req->cbMode) {
1824 session->ch_center_freq_seg0 =
1825 session->currentOperChannel + 2;
1826 session->ch_width = CH_WIDTH_40MHZ;
1827 } else {
1828 session->ch_center_freq_seg0 = 0;
1829 session->ch_width = CH_WIDTH_20MHZ;
1830 }
1831
1832 /* Record if management frames need to be protected */
1833#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001834 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001836 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838#endif
1839
1840#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1841 session->rssi = bss_desc.rssi;
1842#endif
1843
1844 /* Copy the SSID from smejoinreq to session entry */
1845 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301846 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 session->ssId.length);
1848
1849 /*
1850 * Determin 11r or ESE connection based on input from SME
1851 * which inturn is dependent on the profile the user wants
1852 * to connect to, So input is coming from supplicant
1853 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855#ifdef FEATURE_WLAN_ESE
1856 session->isESEconnection = sme_join_req->isESEconnection;
1857#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 session->isFastTransitionEnabled =
1859 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 session->isFastRoamIniFeatureEnabled =
1862 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 session->txLdpcIniFeatureEnabled =
1864 sme_join_req->txLdpcIniFeatureEnabled;
1865
1866 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1867 session->limSystemRole = eLIM_STA_ROLE;
1868 } else if (session->bssType == eSIR_BTAMP_AP_MODE) {
1869 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1870 } else {
1871 /*
1872 * Throw an error and return and make
1873 * sure to delete the session.
1874 */
1875 lim_log(mac_ctx, LOGE,
1876 FL("recvd JOIN_REQ with invalid bss type %d"),
1877 session->bssType);
1878 ret_code = eSIR_SME_INVALID_PARAMETERS;
1879 goto end;
1880 }
1881
1882 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301883 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 &sme_join_req->addIEScan, sizeof(tSirAddie));
1885
1886 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301887 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1889
1890 val = sizeof(tLimMlmJoinReq) +
1891 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301892 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 if (NULL == mlm_join_req) {
1894 lim_log(mac_ctx, LOGP,
1895 FL("AllocateMemory failed for mlmJoinReq"));
1896 return;
1897 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301898 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899
1900 /* PE SessionId is stored as a part of JoinReq */
1901 mlm_join_req->sessionId = session->peSessionId;
1902
1903 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1904 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1905 eSIR_SUCCESS) {
1906 lim_log(mac_ctx, LOGP,
1907 FL("couldn't retrieve JoinFailureTimer value"
1908 " setting to default value"));
1909 mlm_join_req->joinFailureTimeout =
1910 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1911 }
1912
1913 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301914 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 (void *)&sme_join_req->operationalRateSet,
1916 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301917 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 (void *)&sme_join_req->extendedRateSet,
1919 sizeof(tSirMacRateSet));
1920 /*
1921 * this may not be needed anymore now, as rateSet is now
1922 * included in the session entry and MLM has session context.
1923 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301924 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 (void *)&session->rateSet,
1926 sizeof(tSirMacRateSet));
1927
1928 session->encryptType = sme_join_req->UCEncryptionType;
1929
1930 mlm_join_req->bssDescription.length =
1931 session->pLimJoinReq->bssDescription.length;
1932
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301933 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934 (uint8_t *)
1935 &session->pLimJoinReq->bssDescription.bssId,
1936 session->pLimJoinReq->bssDescription.length + 2);
1937
1938 session->limCurrentBssCaps =
1939 session->pLimJoinReq->bssDescription.capabilityInfo;
1940
1941 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1942 session->currentOperChannel);
1943 local_power_constraint = reg_max;
1944
1945 lim_extract_ap_capability(mac_ctx,
1946 (uint8_t *)
1947 session->pLimJoinReq->bssDescription.ieFields,
1948 lim_get_ielen_from_bss_description(
1949 &session->pLimJoinReq->bssDescription),
1950 &session->limCurrentBssQosCaps,
1951 &session->limCurrentBssPropCap,
1952 &session->gLimCurrentBssUapsd,
1953 &local_power_constraint, session);
1954
1955#ifdef FEATURE_WLAN_ESE
1956 session->maxTxPower = lim_get_max_tx_power(reg_max,
1957 local_power_constraint,
1958 mac_ctx->roam.configParam.nTxPowerCap);
1959#else
1960 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301961 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962#endif
1963#if defined WLAN_VOWIFI_DEBUG
1964 lim_log(mac_ctx, LOGE,
1965 "Regulatory max = %d, local power constraint = %d"
1966 reg_max, local_power_constraint);
1967 lim_log(mac_ctx, LOGE, FL(" max tx = %d"),
1968 session->maxTxPower);
1969#endif
1970
1971 if (session->gLimCurrentBssUapsd) {
1972 session->gUapsdPerAcBitmask =
1973 session->pLimJoinReq->uapsdPerAcBitmask;
1974 lim_log(mac_ctx, LOG1,
1975 FL("UAPSD flag for all AC - 0x%2x"),
1976 session->gUapsdPerAcBitmask);
1977
1978 /* resetting the dynamic uapsd mask */
1979 session->gUapsdPerAcDeliveryEnableMask = 0;
1980 session->gUapsdPerAcTriggerEnableMask = 0;
1981 }
1982
1983 session->limRFBand =
1984 lim_get_rf_band(session->currentOperChannel);
1985
1986 /* Initialize 11h Enable Flag */
1987 if (SIR_BAND_5_GHZ == session->limRFBand) {
1988 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1989 &val) != eSIR_SUCCESS) {
1990 lim_log(mac_ctx, LOGP,
1991 FL("Fail to get WNI_CFG_11H_ENABLED "));
1992 session->lim11hEnable =
1993 WNI_CFG_11H_ENABLED_STADEF;
1994 } else {
1995 session->lim11hEnable = val;
1996 }
1997 } else {
1998 session->lim11hEnable = 0;
1999 }
2000
2001 /*
2002 * To care of the scenario when STA transitions from
2003 * IBSS to Infrastructure mode.
2004 */
2005 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2006
2007 session->limPrevSmeState = session->limSmeState;
2008 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2009 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2010 session->peSessionId,
2011 session->limSmeState));
2012
2013 lim_log(mac_ctx, LOG1,
2014 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
2015 mlm_join_req->sessionId, session->ssId.length,
2016 session->ssId.ssId, session->currentOperChannel,
2017 MAC_ADDR_ARRAY(session->bssId));
2018
2019 /* Indicate whether spectrum management is enabled */
2020 session->spectrumMgtEnabled =
2021 sme_join_req->spectrumMgtIndicator;
2022
2023 /* Enable the spectrum management if this is a DFS channel */
2024 if (session->country_info_present &&
2025 lim_isconnected_on_dfs_channel(
2026 session->currentOperChannel))
2027 session->spectrumMgtEnabled = true;
2028
2029 session->isOSENConnection = sme_join_req->isOSENConnection;
2030
2031 lim_log(mac_ctx, LOG1,
2032 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
2033 mlm_join_req->sessionId);
2034 /* Issue LIM_MLM_JOIN_REQ to MLM */
2035 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2036 (uint32_t *) mlm_join_req);
2037 return;
2038
2039 } else {
2040 /* Received eWNI_SME_JOIN_REQ un expected state */
2041 lim_log(mac_ctx, LOGE,
2042 FL("received unexpected SME_JOIN_REQ in state %X"),
2043 mac_ctx->lim.gLimSmeState);
2044 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2045 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2046 session = NULL;
2047 goto end;
2048 }
2049
2050end:
2051 sme_session_id = sme_join_req->sessionId;
2052 sme_transaction_id = sme_join_req->transactionId;
2053
2054 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302055 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 sme_join_req = NULL;
2057 if (NULL != session)
2058 session->pLimJoinReq = NULL;
2059 }
2060 if (ret_code != eSIR_SME_SUCCESS) {
2061 if (NULL != session) {
2062 pe_delete_session(mac_ctx, session);
2063 session = NULL;
2064 }
2065 }
2066 lim_log(mac_ctx, LOG1,
2067 FL("Send failure status on sessionid: %d with ret_code = %d"),
2068 sme_session_id, ret_code);
2069 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2070 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2071 sme_transaction_id);
2072}
2073
Amar Singhala297bfa2015-10-15 15:07:29 -07002074uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 uint8_t iniTxPower)
2076{
2077 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302078 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2079 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2081 maxTxPower = txPower;
2082 else if (txPower < MIN_TX_PWR_CAP)
2083 maxTxPower = MIN_TX_PWR_CAP;
2084 else
2085 maxTxPower = MAX_TX_PWR_CAP;
2086
2087 return maxTxPower;
2088}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089
2090/**
2091 * __lim_process_sme_reassoc_req() - process reassoc req
2092 *
2093 * @mac_ctx: Pointer to Global MAC structure
2094 * @msg_buf: pointer to the SME message buffer
2095 *
2096 * This function is called to process SME_REASSOC_REQ message
2097 * from HDD or upper layer application.
2098 *
2099 * Return: None
2100 */
2101
2102static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2103 uint32_t *msg_buf)
2104{
2105 uint16_t caps;
2106 uint32_t val;
2107 tpSirSmeJoinReq reassoc_req = NULL;
2108 tLimMlmReassocReq *mlm_reassoc_req;
2109 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2110 tpPESession session_entry = NULL;
2111 uint8_t session_id;
2112 uint8_t sme_session_id;
2113 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002114 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 uint32_t tele_bcn_en = 0;
2116 uint16_t size;
2117
2118 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2119
2120 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302121 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 if (NULL == reassoc_req) {
2123 lim_log(mac_ctx, LOGP,
2124 FL("call to AllocateMemory failed for reassoc_req"));
2125
2126 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2127 goto end;
2128 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302129 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2130 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131
2132 if (!lim_is_sme_join_req_valid(mac_ctx,
2133 (tpSirSmeJoinReq)reassoc_req)) {
2134 /*
2135 * Received invalid eWNI_SME_REASSOC_REQ
2136 */
2137 lim_log(mac_ctx, LOGW,
2138 FL("received SME_REASSOC_REQ with invalid data"));
2139
2140 ret_code = eSIR_SME_INVALID_PARAMETERS;
2141 goto end;
2142 }
2143
2144 session_entry = pe_find_session_by_bssid(mac_ctx,
2145 reassoc_req->bssDescription.bssId,
2146 &session_id);
2147 if (session_entry == NULL) {
2148 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2149 LOGE);
2150 lim_log(mac_ctx, LOGE,
2151 FL("Session does not exist for given bssId"));
2152 ret_code = eSIR_SME_INVALID_PARAMETERS;
2153 goto end;
2154 }
2155#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2156 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2157 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2158#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2159 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2160
2161 /* Store the reassoc handle in the session Table */
2162 session_entry->pLimReAssocReq = reassoc_req;
2163
2164 session_entry->dot11mode = reassoc_req->dot11mode;
2165 session_entry->vhtCapability =
2166 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
2167 /*
2168 * Reassociate request is expected
2169 * in link established state only.
2170 */
2171
2172 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2174 /*
2175 * May be from 11r FT pre-auth. So lets check it
2176 * before we bail out
2177 */
2178 lim_log(mac_ctx, LOG1, FL(
2179 "Session in reassoc state is %d"),
2180 session_entry->peSessionId);
2181
2182 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302183 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 session_entry->limReAssocbssId,
2185 6)) {
2186 lim_print_mac_addr(mac_ctx,
2187 reassoc_req->bssDescription.
2188 bssId, LOGE);
2189 lim_log(mac_ctx, LOGP,
2190 FL("Unknown bssId in reassoc state"));
2191 ret_code = eSIR_SME_INVALID_PARAMETERS;
2192 goto end;
2193 }
2194
2195 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2196 session_entry);
2197 return;
2198 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 /*
2200 * Should not have received eWNI_SME_REASSOC_REQ
2201 */
2202 lim_log(mac_ctx, LOGE,
2203 FL("received unexpected SME_REASSOC_REQ in state %X"),
2204 session_entry->limSmeState);
2205 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2206
2207 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2208 goto end;
2209 }
2210
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302211 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 session_entry->pLimReAssocReq->bssDescription.bssId,
2213 sizeof(tSirMacAddr));
2214
2215 session_entry->limReassocChannelId =
2216 session_entry->pLimReAssocReq->bssDescription.channelId;
2217
2218 session_entry->reAssocHtSupportedChannelWidthSet =
2219 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2220 session_entry->reAssocHtRecommendedTxWidthSet =
2221 session_entry->reAssocHtSupportedChannelWidthSet;
2222 session_entry->reAssocHtSecondaryChannelOffset =
2223 session_entry->pLimReAssocReq->cbMode;
2224
2225 session_entry->limReassocBssCaps =
2226 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2227 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2228 session_entry->currentOperChannel);
2229 local_pwr_constraint = reg_max;
2230
2231 lim_extract_ap_capability(mac_ctx,
2232 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2233 lim_get_ielen_from_bss_description(
2234 &session_entry->pLimReAssocReq->bssDescription),
2235 &session_entry->limReassocBssQosCaps,
2236 &session_entry->limReassocBssPropCap,
2237 &session_entry->gLimCurrentBssUapsd,
2238 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302239 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240#if defined WLAN_VOWIFI_DEBUG
2241 lim_log(mac_ctx, LOGE,
2242 "Regulatory max = %d, local pwr constraint = %d, max tx = %d",
2243 reg_max, local_pwr_constraint,
2244 session_entry->maxTxPower);
2245#endif
2246 /* Copy the SSID from session entry to local variable */
2247 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302248 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 reassoc_req->ssId.ssId,
2250 session_entry->limReassocSSID.length);
2251 if (session_entry->gLimCurrentBssUapsd) {
2252 session_entry->gUapsdPerAcBitmask =
2253 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2254 lim_log(mac_ctx, LOG1,
2255 FL("UAPSD flag for all AC - 0x%2x"),
2256 session_entry->gUapsdPerAcBitmask);
2257 }
2258
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302259 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 if (NULL == mlm_reassoc_req) {
2261 lim_log(mac_ctx, LOGP,
2262 FL("call to AllocateMemory failed for mlmReassocReq"));
2263
2264 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2265 goto end;
2266 }
2267
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302268 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2270
2271 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2272 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2273 eSIR_SUCCESS) {
2274 /*
2275 * Could not get ReassocFailureTimeout value
2276 * from CFG. Log error.
2277 */
2278 lim_log(mac_ctx, LOGP,
2279 FL("could not retrieve ReassocFailureTimeout value"));
2280 }
2281
2282 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2283 eSIR_SUCCESS) {
2284 /*
2285 * Could not get Capabilities value
2286 * from CFG. Log error.
2287 */
2288 lim_log(mac_ctx, LOGP, FL(
2289 "could not retrieve Capabilities value"));
2290 }
2291 mlm_reassoc_req->capabilityInfo = caps;
2292
2293 /* Update PE session_id */
2294 mlm_reassoc_req->sessionId = session_id;
2295
2296 /*
2297 * If telescopic beaconing is enabled, set listen interval to
2298 * WNI_CFG_TELE_BCN_MAX_LI
2299 */
2300 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2301 &tele_bcn_en) != eSIR_SUCCESS)
2302 lim_log(mac_ctx, LOGP,
2303 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2304
2305 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2306
2307 if (tele_bcn_en) {
2308 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2309 eSIR_SUCCESS)
2310 /*
2311 * Could not get ListenInterval value
2312 * from CFG. Log error.
2313 */
2314 lim_log(mac_ctx, LOGP,
2315 FL("could not retrieve ListenInterval"));
2316 } else {
2317 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2318 eSIR_SUCCESS)
2319 /*
2320 * Could not get ListenInterval value
2321 * from CFG. Log error.
2322 */
2323 lim_log(mac_ctx, LOGP,
2324 FL("could not retrieve ListenInterval"));
2325 }
2326
2327 mlm_reassoc_req->listenInterval = (uint16_t) val;
2328
2329 /* Indicate whether spectrum management is enabled */
2330 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2331
2332 /* Enable the spectrum management if this is a DFS channel */
2333 if (session_entry->country_info_present &&
2334 lim_isconnected_on_dfs_channel(
2335 session_entry->currentOperChannel))
2336 session_entry->spectrumMgtEnabled = true;
2337
2338 session_entry->limPrevSmeState = session_entry->limSmeState;
2339 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2340
2341 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2342 session_entry->peSessionId,
2343 session_entry->limSmeState));
2344
2345 lim_post_mlm_message(mac_ctx,
2346 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2347 return;
2348end:
2349 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302350 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 if (session_entry)
2352 session_entry->pLimReAssocReq = NULL;
2353 }
2354
2355 if (session_entry) {
2356 /*
2357 * error occurred after we determined the session so extract
2358 * session and transaction info from there
2359 */
2360 sme_session_id = session_entry->smeSessionId;
2361 transaction_id = session_entry->transactionId;
2362 } else
2363 /*
2364 * error occurred before or during the time we determined
2365 * the session so extract the session and transaction info
2366 * from the message
2367 */
2368 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2369 &sme_session_id, &transaction_id);
2370
2371 /*
2372 * Send Reassoc failure response to host
2373 * (note session_entry may be NULL, but that's OK)
2374 */
2375 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2376 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2377 session_entry, sme_session_id,
2378 transaction_id);
2379}
2380
2381bool send_disassoc_frame = 1;
2382/**
2383 * __lim_process_sme_disassoc_req()
2384 *
2385 ***FUNCTION:
2386 * This function is called to process SME_DISASSOC_REQ message
2387 * from HDD or upper layer application.
2388 *
2389 ***LOGIC:
2390 *
2391 ***ASSUMPTIONS:
2392 *
2393 ***NOTE:
2394 *
2395 * @param pMac Pointer to Global MAC structure
2396 * @param *pMsgBuf A pointer to the SME message buffer
2397 * @return None
2398 */
2399
2400static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2401{
2402 uint16_t disassocTrigger, reasonCode;
2403 tLimMlmDisassocReq *pMlmDisassocReq;
2404 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2405 tSirSmeDisassocReq smeDisassocReq;
2406 tpPESession psessionEntry = NULL;
2407 uint8_t sessionId;
2408 uint8_t smesessionId;
2409 uint16_t smetransactionId;
2410
2411 if (pMsgBuf == NULL) {
2412 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2413 return;
2414 }
2415
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302416 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 smesessionId = smeDisassocReq.sessionId;
2418 smetransactionId = smeDisassocReq.transactionId;
2419 if (!lim_is_sme_disassoc_req_valid(pMac,
2420 &smeDisassocReq,
2421 psessionEntry)) {
2422 PELOGE(lim_log(pMac, LOGE,
2423 FL("received invalid SME_DISASSOC_REQ message"));)
2424 if (pMac->lim.gLimRspReqd) {
2425 pMac->lim.gLimRspReqd = false;
2426
2427 retCode = eSIR_SME_INVALID_PARAMETERS;
2428 disassocTrigger = eLIM_HOST_DISASSOC;
2429 goto sendDisassoc;
2430 }
2431
2432 return;
2433 }
2434
2435 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002436 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 &sessionId);
2438 if (psessionEntry == NULL) {
2439 lim_log(pMac, LOGE,
2440 FL("session does not exist for given bssId "
2441 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002442 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 retCode = eSIR_SME_INVALID_PARAMETERS;
2444 disassocTrigger = eLIM_HOST_DISASSOC;
2445 goto sendDisassoc;
2446 }
2447 lim_log(pMac, LOG1,
2448 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2449 MAC_ADDRESS_STR), smesessionId,
2450 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2451 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002452 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453
2454#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2455 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2456 0, smeDisassocReq.reasonCode);
2457#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2458
2459 /* Update SME session Id and SME transaction ID */
2460
2461 psessionEntry->smeSessionId = smesessionId;
2462 psessionEntry->transactionId = smetransactionId;
2463
2464 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2465 case eLIM_STA_ROLE:
2466 case eLIM_BT_AMP_STA_ROLE:
2467 switch (psessionEntry->limSmeState) {
2468 case eLIM_SME_ASSOCIATED_STATE:
2469 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002470 lim_log(pMac, LOG1,
2471 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2472 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 psessionEntry->limPrevSmeState =
2474 psessionEntry->limSmeState;
2475 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2476#ifdef FEATURE_WLAN_TDLS
2477 /* Delete all TDLS peers connected before leaving BSS */
2478 lim_delete_tdls_peers(pMac, psessionEntry);
2479#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002480 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2481 psessionEntry->peSessionId,
2482 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 break;
2484
2485 case eLIM_SME_WT_DEAUTH_STATE:
2486 /* PE shall still process the DISASSOC_REQ and proceed with
2487 * link tear down even if it had already sent a DEAUTH_IND to
2488 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2489 * its been set when PE entered WT_DEAUTH_STATE.
2490 */
2491 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2492 MTRACE(mac_trace
2493 (pMac, TRACE_CODE_SME_STATE,
2494 psessionEntry->peSessionId,
2495 psessionEntry->limSmeState));
2496 lim_log(pMac, LOG1,
2497 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2498 break;
2499
2500 case eLIM_SME_WT_DISASSOC_STATE:
2501 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2502 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2503 * PE can continue processing DISASSOC_REQ and send the response instead
2504 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2505 * for disassoc frame.
2506 *
2507 * It will send a disassoc, which is ok. However, we can use the global flag
2508 * sendDisassoc to not send disassoc frame.
2509 */
2510 lim_log(pMac, LOG1,
2511 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2512 break;
2513
2514 case eLIM_SME_JOIN_FAILURE_STATE: {
2515 /* Already in Disconnected State, return success */
2516 lim_log(pMac, LOG1,
2517 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2518 if (pMac->lim.gLimRspReqd) {
2519 retCode = eSIR_SME_SUCCESS;
2520 disassocTrigger = eLIM_HOST_DISASSOC;
2521 goto sendDisassoc;
2522 }
2523 }
2524 break;
2525 default:
2526 /**
2527 * STA is not currently associated.
2528 * Log error and send response to host
2529 */
2530 lim_log(pMac, LOGE,
2531 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2532 psessionEntry->limSmeState);
2533 lim_print_sme_state(pMac, LOGE,
2534 psessionEntry->limSmeState);
2535
2536 if (pMac->lim.gLimRspReqd) {
2537 if (psessionEntry->limSmeState !=
2538 eLIM_SME_WT_ASSOC_STATE)
2539 pMac->lim.gLimRspReqd = false;
2540
2541 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2542 disassocTrigger = eLIM_HOST_DISASSOC;
2543 goto sendDisassoc;
2544 }
2545
2546 return;
2547 }
2548
2549 break;
2550
2551 case eLIM_AP_ROLE:
2552 case eLIM_BT_AMP_AP_ROLE:
2553 /* Fall through */
2554 break;
2555
2556 case eLIM_STA_IN_IBSS_ROLE:
2557 default:
2558 /* eLIM_UNKNOWN_ROLE */
2559 lim_log(pMac, LOGE,
2560 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2561 GET_LIM_SYSTEM_ROLE(psessionEntry));
2562
2563 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2564 disassocTrigger = eLIM_HOST_DISASSOC;
2565 goto sendDisassoc;
2566 } /* end switch (pMac->lim.gLimSystemRole) */
2567
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302568 disassocTrigger = eLIM_HOST_DISASSOC;
2569 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570
2571 if (smeDisassocReq.doNotSendOverTheAir) {
2572 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2573 send_disassoc_frame = 0;
2574 }
2575 /* Trigger Disassociation frame to peer MAC entity */
2576 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2577 " : %d, reasonCode : %d"),
2578 disassocTrigger, reasonCode);
2579
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302580 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 if (NULL == pMlmDisassocReq) {
2582 /* Log error */
2583 lim_log(pMac, LOGP,
2584 FL("call to AllocateMemory failed for mlmDisassocReq"));
2585
2586 return;
2587 }
2588
Anurag Chouhanc5548422016-02-24 18:33:27 +05302589 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002590 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591
2592 pMlmDisassocReq->reasonCode = reasonCode;
2593 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2594
2595 /* Update PE session ID */
2596 pMlmDisassocReq->sessionId = sessionId;
2597
2598 lim_post_mlm_message(pMac,
2599 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2600 return;
2601
2602sendDisassoc:
2603 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002604 lim_send_sme_disassoc_ntf(pMac,
2605 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 retCode,
2607 disassocTrigger,
2608 1, smesessionId, smetransactionId,
2609 psessionEntry);
2610 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002611 lim_send_sme_disassoc_ntf(pMac,
2612 smeDisassocReq.peer_macaddr.bytes,
2613 retCode, disassocTrigger, 1,
2614 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615
2616} /*** end __lim_process_sme_disassoc_req() ***/
2617
2618/** -----------------------------------------------------------------
2619 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2620
2621 This function is called to process SME_DISASSOC_CNF message
2622 from HDD or upper layer application.
2623
2624 \param pMac - global mac structure
2625 \param pStaDs - station dph hash node
2626 \return none
2627 \sa
2628 ----------------------------------------------------------------- */
2629static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2630{
2631 tSirSmeDisassocCnf smeDisassocCnf;
2632 uint16_t aid;
2633 tpDphHashNode pStaDs;
2634 tpPESession psessionEntry;
2635 uint8_t sessionId;
2636
2637 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2638
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302639 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 sizeof(struct sSirSmeDisassocCnf));
2641
2642 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002643 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 &sessionId);
2645 if (psessionEntry == NULL) {
2646 lim_log(pMac, LOGE,
2647 FL("session does not exist for given bssId"));
2648 return;
2649 }
2650
2651 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2652 lim_log(pMac, LOGE,
2653 FL("received invalid SME_DISASSOC_CNF message"));
2654 return;
2655 }
2656#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2657 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2658 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2659 psessionEntry,
2660 (uint16_t) smeDisassocCnf.statusCode, 0);
2661 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2662 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2663 psessionEntry,
2664 (uint16_t) smeDisassocCnf.statusCode, 0);
2665#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2666
2667 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2668 case eLIM_STA_ROLE:
2669 case eLIM_BT_AMP_STA_ROLE: /* To test reconn */
2670 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2671 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2672 && (psessionEntry->limSmeState !=
2673 eLIM_SME_WT_DEAUTH_STATE)) {
2674 lim_log(pMac, LOGE,
2675 FL
2676 ("received unexp SME_DISASSOC_CNF in state %X"),
2677 psessionEntry->limSmeState);
2678 lim_print_sme_state(pMac, LOGE,
2679 psessionEntry->limSmeState);
2680 return;
2681 }
2682 break;
2683
2684 case eLIM_AP_ROLE:
2685 /* Fall through */
2686 break;
2687
2688 case eLIM_STA_IN_IBSS_ROLE:
2689 default: /* eLIM_UNKNOWN_ROLE */
2690 lim_log(pMac, LOGE,
2691 FL("received unexpected SME_DISASSOC_CNF role %d"),
2692 GET_LIM_SYSTEM_ROLE(psessionEntry));
2693
2694 return;
2695 }
2696
2697 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2698 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2699 LIM_IS_AP_ROLE(psessionEntry)) {
2700 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002701 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 &psessionEntry->dph.dphHashTable);
2703 if (pStaDs == NULL) {
2704 lim_log(pMac, LOGE,
2705 FL("DISASSOC_CNF for a STA with no context, addr= "
2706 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002707 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 return;
2709 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302710
2711 if ((pStaDs->mlmStaContext.mlmState ==
2712 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2713 (pStaDs->mlmStaContext.mlmState ==
2714 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2715 lim_log(pMac, LOGE,
2716 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002717 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302718 pStaDs->mlmStaContext.mlmState);
2719 return;
2720 }
2721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 /* Delete FT session if there exists one */
2723 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2725
2726 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002727 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 }
2729
2730 return;
2731}
2732
2733/**
2734 * __lim_process_sme_deauth_req() - process sme deauth req
2735 * @mac_ctx: Pointer to Global MAC structure
2736 * @msg_buf: pointer to the SME message buffer
2737 *
2738 * This function is called to process SME_DEAUTH_REQ message
2739 * from HDD or upper layer application.
2740 *
2741 * Return: None
2742 */
2743
2744static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2745 uint32_t *msg_buf)
2746{
2747 uint16_t deauth_trigger, reason_code;
2748 tLimMlmDeauthReq *mlm_deauth_req;
2749 tSirSmeDeauthReq sme_deauth_req;
2750 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2751 tpPESession session_entry;
2752 uint8_t session_id; /* PE sessionId */
2753 uint8_t sme_session_id;
2754 uint16_t sme_transaction_id;
2755
2756 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2757
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302758 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 sme_session_id = sme_deauth_req.sessionId;
2760 sme_transaction_id = sme_deauth_req.transactionId;
2761
2762 /*
2763 * We need to get a session first but we don't even know
2764 * if the message is correct.
2765 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002766 session_entry = pe_find_session_by_bssid(mac_ctx,
2767 sme_deauth_req.bssid.bytes,
2768 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 if (session_entry == NULL) {
2770 lim_log(mac_ctx, LOGE,
2771 FL("session does not exist for given bssId"));
2772 ret_code = eSIR_SME_INVALID_PARAMETERS;
2773 deauth_trigger = eLIM_HOST_DEAUTH;
2774 goto send_deauth;
2775 }
2776
2777 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2778 session_entry)) {
2779 lim_log(mac_ctx, LOGE,
2780 FL("received invalid SME_DEAUTH_REQ message"));
2781 mac_ctx->lim.gLimRspReqd = false;
2782
2783 ret_code = eSIR_SME_INVALID_PARAMETERS;
2784 deauth_trigger = eLIM_HOST_DEAUTH;
2785 goto send_deauth;
2786 }
2787 lim_log(mac_ctx, LOG1,
2788 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2789 MAC_ADDRESS_STR), sme_session_id,
2790 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2791 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002792 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2794 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2795 session_entry, 0, sme_deauth_req.reasonCode);
2796#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2797
2798 /* Update SME session ID and Transaction ID */
2799 session_entry->smeSessionId = sme_session_id;
2800 session_entry->transactionId = sme_transaction_id;
2801
2802 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2803 case eLIM_STA_ROLE:
2804 case eLIM_BT_AMP_STA_ROLE:
2805
2806 switch (session_entry->limSmeState) {
2807 case eLIM_SME_ASSOCIATED_STATE:
2808 case eLIM_SME_LINK_EST_STATE:
2809 case eLIM_SME_WT_ASSOC_STATE:
2810 case eLIM_SME_JOIN_FAILURE_STATE:
2811 case eLIM_SME_IDLE_STATE:
2812 session_entry->limPrevSmeState =
2813 session_entry->limSmeState;
2814 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2815 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2816 session_entry->peSessionId,
2817 session_entry->limSmeState));
2818 /* Send Deauthentication request to MLM below */
2819 break;
2820 case eLIM_SME_WT_DEAUTH_STATE:
2821 case eLIM_SME_WT_DISASSOC_STATE:
2822 /*
2823 * PE Recieved a Deauth/Disassoc frame. Normally it get
2824 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2825 * Which means host is also trying to disconnect.
2826 * PE can continue processing DEAUTH_REQ and send
2827 * the response instead of failing the request.
2828 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2829 * was sent for deauth/disassoc frame.
2830 */
2831 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2832 lim_log(mac_ctx, LOG1, FL(
2833 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2834 break;
2835 default:
2836 /*
2837 * STA is not in a state to deauthenticate with
2838 * peer. Log error and send response to host.
2839 */
2840 lim_log(mac_ctx, LOGE, FL(
2841 "received unexp SME_DEAUTH_REQ in state %X"),
2842 session_entry->limSmeState);
2843 lim_print_sme_state(mac_ctx, LOGE,
2844 session_entry->limSmeState);
2845
2846 if (mac_ctx->lim.gLimRspReqd) {
2847 mac_ctx->lim.gLimRspReqd = false;
2848
2849 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2850 deauth_trigger = eLIM_HOST_DEAUTH;
2851
2852 /*
2853 * here we received deauth request from AP so sme state
2854 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2855 * delSta then mlm state should be
2856 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2857 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2858 * so the below condition captures the state where
2859 * delSta not done and firmware still in
2860 * connected state.
2861 */
2862 if (session_entry->limSmeState ==
2863 eLIM_SME_WT_DEAUTH_STATE &&
2864 session_entry->limMlmState !=
2865 eLIM_MLM_IDLE_STATE &&
2866 session_entry->limMlmState !=
2867 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2868 ret_code = eSIR_SME_DEAUTH_STATUS;
2869 goto send_deauth;
2870 }
2871 return;
2872 }
2873 break;
2874
2875 case eLIM_STA_IN_IBSS_ROLE:
2876 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2877 if (mac_ctx->lim.gLimRspReqd) {
2878 mac_ctx->lim.gLimRspReqd = false;
2879 ret_code = eSIR_SME_INVALID_PARAMETERS;
2880 deauth_trigger = eLIM_HOST_DEAUTH;
2881 goto send_deauth;
2882 }
2883 return;
2884 case eLIM_AP_ROLE:
2885 break;
2886 default:
2887 lim_log(mac_ctx, LOGE,
2888 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2889 GET_LIM_SYSTEM_ROLE(session_entry));
2890 if (mac_ctx->lim.gLimRspReqd) {
2891 mac_ctx->lim.gLimRspReqd = false;
2892 ret_code = eSIR_SME_INVALID_PARAMETERS;
2893 deauth_trigger = eLIM_HOST_DEAUTH;
2894 goto send_deauth;
2895 }
2896 return;
2897 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2898
2899 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2900 /* Deauthentication is triggered by Link Monitoring */
2901 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2902 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2903 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2904 } else {
2905 deauth_trigger = eLIM_HOST_DEAUTH;
2906 reason_code = sme_deauth_req.reasonCode;
2907 }
2908
2909 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302910 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 if (NULL == mlm_deauth_req) {
2912 lim_log(mac_ctx, LOGP,
2913 FL("call to AllocateMemory failed for mlmDeauthReq"));
2914 if (mac_ctx->lim.gLimRspReqd) {
2915 mac_ctx->lim.gLimRspReqd = false;
2916 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2917 deauth_trigger = eLIM_HOST_DEAUTH;
2918 goto send_deauth;
2919 }
2920 return;
2921 }
2922
Anurag Chouhanc5548422016-02-24 18:33:27 +05302923 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002924 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925
2926 mlm_deauth_req->reasonCode = reason_code;
2927 mlm_deauth_req->deauthTrigger = deauth_trigger;
2928
2929 /* Update PE session Id */
2930 mlm_deauth_req->sessionId = session_id;
2931
2932 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2933 (uint32_t *)mlm_deauth_req);
2934 return;
2935
2936send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002937 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2938 ret_code, deauth_trigger, 1,
2939 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940}
2941
2942/**
2943 * __lim_process_sme_set_context_req()
2944 *
2945 * @mac_ctx: Pointer to Global MAC structure
2946 * @msg_buf: pointer to the SME message buffer
2947 *
2948 * This function is called to process SME_SETCONTEXT_REQ message
2949 * from HDD or upper layer application.
2950 *
2951 * Return: None
2952 */
2953
2954static void
2955__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2956{
2957 tpSirSmeSetContextReq set_context_req;
2958 tLimMlmSetKeysReq *mlm_set_key_req;
2959 tpPESession session_entry;
2960 uint8_t session_id; /* PE sessionID */
2961 uint8_t sme_session_id;
2962 uint16_t sme_transaction_id;
2963
2964 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2965
2966 if (msg_buf == NULL) {
2967 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2968 return;
2969 }
2970
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302971 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 if (NULL == set_context_req) {
2973 lim_log(mac_ctx, LOGP, FL(
2974 "call to AllocateMemory failed for set_context_req"));
2975 return;
2976 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302977 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 sizeof(struct sSirSmeSetContextReq));
2979 sme_session_id = set_context_req->sessionId;
2980 sme_transaction_id = set_context_req->transactionId;
2981
2982 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2983 lim_log(mac_ctx, LOGW,
2984 FL("received invalid SME_SETCONTEXT_REQ message"));
2985 goto end;
2986 }
2987
2988 if (set_context_req->keyMaterial.numKeys >
2989 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2990 lim_log(mac_ctx, LOGE, FL(
2991 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2992 set_context_req->keyMaterial.numKeys);
2993 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002994 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 eSIR_SME_INVALID_PARAMETERS, NULL,
2996 sme_session_id, sme_transaction_id);
2997 goto end;
2998 }
2999
3000 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003001 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 if (session_entry == NULL) {
3003 lim_log(mac_ctx, LOGW,
3004 FL("Session does not exist for given BSSID"));
3005 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003006 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 eSIR_SME_INVALID_PARAMETERS, NULL,
3008 sme_session_id, sme_transaction_id);
3009 goto end;
3010 }
3011#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3012 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3013 session_entry, 0, 0);
3014#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3015
3016 if (((LIM_IS_STA_ROLE(session_entry) ||
3017 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
3018 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3019 ((LIM_IS_IBSS_ROLE(session_entry) ||
3020 LIM_IS_AP_ROLE(session_entry) ||
3021 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
3022 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3023 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303024 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025 if (NULL == mlm_set_key_req) {
3026 lim_log(mac_ctx, LOGP, FL(
3027 "mem alloc failed for mlmSetKeysReq"));
3028 goto end;
3029 }
3030 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3031 mlm_set_key_req->numKeys =
3032 set_context_req->keyMaterial.numKeys;
3033 if (mlm_set_key_req->numKeys >
3034 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3035 lim_log(mac_ctx, LOGP, FL(
3036 "no.of keys exceeded max num of default keys limit"));
3037 goto end;
3038 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303039 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003040 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303042 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 (uint8_t *) &set_context_req->keyMaterial.key,
3044 sizeof(tSirKeys) *
3045 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3046 numKeys : 1));
3047
3048 mlm_set_key_req->sessionId = session_id;
3049 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 lim_log(mac_ctx, LOG1, FL(
3051 "received SETCONTEXT_REQ message sessionId=%d"),
3052 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053
3054 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3055 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3056 LIM_IS_AP_ROLE(session_entry)) {
3057 if (set_context_req->keyMaterial.key[0].keyLength) {
3058 uint8_t key_id;
3059 key_id =
3060 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303061 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 &session_entry->WEPKeyMaterial[key_id],
3063 (uint8_t *) &set_context_req->keyMaterial,
3064 sizeof(tSirKeyMaterial));
3065 } else {
3066 uint32_t i;
3067 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3068 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303069 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 &mlm_set_key_req->key[i],
3071 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3072 sizeof(tSirKeys));
3073 }
3074 }
3075 }
3076 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3077 (uint32_t *) mlm_set_key_req);
3078 } else {
3079 lim_log(mac_ctx, LOGE, FL(
3080 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3081 GET_LIM_SYSTEM_ROLE(session_entry),
3082 session_entry->limSmeState);
3083 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3084
3085 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003086 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3088 session_entry, sme_session_id,
3089 sme_transaction_id);
3090 }
3091end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303092 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 return;
3094}
3095
3096/**
3097 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3098 *
3099 * @mac_ctx: Pointer to Global MAC structure
3100 * @msg_buf: pointer to the SME message buffer
3101 *
3102 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3103 * from HDD or upper layer application.
3104 *
3105 * Return: None
3106 */
3107
3108void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3109 uint32_t *msg_buf)
3110{
3111 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3112 tpDphHashNode sta_ds = NULL;
3113 tpPESession session_entry = NULL;
3114 tSap_Event sap_event;
3115 tpWLAN_SAPEventCB sap_event_cb = NULL;
3116 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3117 uint8_t session_id = CSR_SESSION_ID_INVALID;
3118 uint8_t assoc_id = 0;
3119 uint8_t sta_cnt = 0;
3120
3121 if (msg_buf == NULL) {
3122 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3123 return;
3124 }
3125
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303126 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 sizeof(struct sSirSmeGetAssocSTAsReq));
3128 /*
3129 * Get Associated stations from PE.
3130 * Find PE session Entry
3131 */
3132 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003133 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 &session_id);
3135 if (session_entry == NULL) {
3136 lim_log(mac_ctx, LOGE,
3137 FL("session does not exist for given bssId"));
3138 goto lim_assoc_sta_end;
3139 }
3140
3141 if (!LIM_IS_AP_ROLE(session_entry)) {
3142 lim_log(mac_ctx, LOGE, FL(
3143 "Received unexpected message in state %X, in role %X"),
3144 session_entry->limSmeState,
3145 GET_LIM_SYSTEM_ROLE(session_entry));
3146 goto lim_assoc_sta_end;
3147 }
3148 /* Retrieve values obtained in the request message */
3149 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3150 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3151
3152 if (NULL == assoc_sta_tmp)
3153 goto lim_assoc_sta_end;
3154 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3155 assoc_id++) {
3156 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3157 &session_entry->dph.dphHashTable);
3158 if (NULL == sta_ds)
3159 continue;
3160 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303161 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303163 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3165 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3166
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303167 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 (uint8_t *)&sta_ds->supportedRates,
3169 sizeof(tSirSupportedRates));
3170 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3171 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3172 assoc_sta_tmp->Support40Mhz =
3173 sta_ds->htDsssCckRate40MHzSupport;
3174
3175 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3176 sta_cnt + 1);
3177 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3178 MAC_ADDR_ARRAY(sta_ds->staAddr));
3179 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3180 sta_ds->assocId);
3181 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3182 sta_ds->staIndex);
3183 assoc_sta_tmp++;
3184 sta_cnt++;
3185 }
3186 }
3187lim_assoc_sta_end:
3188 /*
3189 * Call hdd callback with sap event to send the list of
3190 * associated stations from PE
3191 */
3192 if (sap_event_cb != NULL) {
3193 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3194 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303195 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3197 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3198 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3199 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3200 }
3201}
3202
3203/**
3204 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3205 *
3206 * @mac_ctx: Pointer to Global MAC structure
3207 * @msg_buf: pointer to WPS PBC overlap query message
3208 *
3209 * This function parses get WPS PBC overlap information
3210 * message and call callback to pass WPS PBC overlap
3211 * information back to hdd.
3212 *
3213 * Return: None
3214 */
3215void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3216 uint32_t *msg_buf)
3217{
3218 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3219 tpPESession session_entry = NULL;
3220 tSap_Event sap_event;
3221 tpWLAN_SAPEventCB sap_event_cb = NULL;
3222 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3224
3225 if (msg_buf == NULL) {
3226 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3227 return;
3228 }
3229
3230 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303231 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303233 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3235 /*
3236 * Get Associated stations from PE
3237 * Find PE session Entry
3238 */
3239 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003240 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 if (session_entry == NULL) {
3242 lim_log(mac_ctx, LOGE,
3243 FL("session does not exist for given bssId"));
3244 goto lim_get_wpspbc_sessions_end;
3245 }
3246
3247 if (!LIM_IS_AP_ROLE(session_entry)) {
3248 lim_log(mac_ctx, LOGE,
3249 FL("Received unexpected message in role %X"),
3250 GET_LIM_SYSTEM_ROLE(session_entry));
3251 goto lim_get_wpspbc_sessions_end;
3252 }
3253 /*
3254 * Call hdd callback with sap event to send the
3255 * WPS PBC overlap information
3256 */
3257 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303258 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259
Anurag Chouhanc5548422016-02-24 18:33:27 +05303260 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003262 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 sap_get_wpspbc_event->UUID_E,
3264 &sap_get_wpspbc_event->wpsPBCOverlap,
3265 session_entry);
3266 } else {
3267 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003268 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 session_entry);
3270 /* don't have to inform the HDD/Host */
3271 return;
3272 }
3273
3274 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3275 sap_get_wpspbc_event->wpsPBCOverlap);
3276 lim_print_mac_addr(mac_ctx,
3277 sap_get_wpspbc_event->addr.bytes, LOG4);
3278
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303279 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280
3281lim_get_wpspbc_sessions_end:
3282 sap_event_cb =
3283 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3284 if (NULL != sap_event_cb)
3285 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3286}
3287
3288/**
3289 * __lim_counter_measures()
3290 *
3291 * FUNCTION:
3292 * This function is called to "implement" MIC counter measure
3293 * and is *temporary* only
3294 *
3295 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3296 * we don't do the proper STA disassoc sequence since the
3297 * BSS will be stoped anyway
3298 *
3299 ***ASSUMPTIONS:
3300 *
3301 ***NOTE:
3302 *
3303 * @param pMac Pointer to Global MAC structure
3304 * @return None
3305 */
3306
3307static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3308{
3309 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3310 if (LIM_IS_AP_ROLE(psessionEntry) ||
3311 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3312 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3313 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3314 mac, psessionEntry, false);
3315};
3316
3317void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3318{
3319 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3320 tpPESession psessionEntry;
3321 uint8_t sessionId; /* PE sessionId */
3322
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303323 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 sizeof(struct sSirSmeTkipCntrMeasReq));
3325
3326 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003327 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 if (NULL == psessionEntry) {
3329 lim_log(pMac, LOGE,
3330 FL("session does not exist for given BSSID "));
3331 return;
3332 }
3333
3334 if (tkipCntrMeasReq.bEnable)
3335 __lim_counter_measures(pMac, psessionEntry);
3336
3337 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3338}
3339
3340static void
3341__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3342{
3343 tSirSmeStopBssReq stopBssReq;
3344 tSirRetStatus status;
3345 tLimSmeStates prevState;
3346 tpPESession psessionEntry;
3347 uint8_t smesessionId;
3348 uint8_t sessionId;
3349 uint16_t smetransactionId;
3350 uint8_t i = 0;
3351 tpDphHashNode pStaDs = NULL;
3352
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303353 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 smesessionId = stopBssReq.sessionId;
3355 smetransactionId = stopBssReq.transactionId;
3356
3357 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3358 PELOGW(lim_log(pMac, LOGW,
3359 FL("received invalid SME_STOP_BSS_REQ message"));)
3360 /* Send Stop BSS response to host */
3361 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3362 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3363 smetransactionId);
3364 return;
3365 }
3366
3367 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003368 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 &sessionId);
3370 if (psessionEntry == NULL) {
3371 lim_log(pMac, LOGW,
3372 FL("session does not exist for given BSSID "));
3373 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3374 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3375 smetransactionId);
3376 return;
3377 }
3378#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3379 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3380 0, 0);
3381#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3382
3383 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3384 LIM_IS_STA_ROLE(psessionEntry)) {
3385 /**
3386 * Should not have received STOP_BSS_REQ in states
3387 * other than 'normal' state or on STA in Infrastructure
3388 * mode. Log error and return response to host.
3389 */
3390 lim_log(pMac, LOGE,
3391 FL
3392 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3393 psessionEntry->limSmeState,
3394 GET_LIM_SYSTEM_ROLE(psessionEntry));
3395 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3396 /* / Send Stop BSS response to host */
3397 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3398 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3399 smetransactionId);
3400 return;
3401 }
3402
3403 if (LIM_IS_AP_ROLE(psessionEntry))
3404 lim_wpspbc_close(pMac, psessionEntry);
3405
3406 lim_log(pMac, LOGW,
3407 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3408 stopBssReq.reasonCode);
3409
3410 prevState = psessionEntry->limSmeState;
3411
3412 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3413 MTRACE(mac_trace
3414 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3415 psessionEntry->limSmeState));
3416
3417 /* Update SME session Id and Transaction Id */
3418 psessionEntry->smeSessionId = smesessionId;
3419 psessionEntry->transactionId = smetransactionId;
3420
3421 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3422 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3423 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3424 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3425 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3426 /* Send disassoc all stations associated thru TKIP */
3427 __lim_counter_measures(pMac, psessionEntry);
3428 else
3429 lim_send_disassoc_mgmt_frame(pMac,
3430 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3431 bcAddr, psessionEntry, false);
3432 }
3433
3434 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303435 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 psessionEntry->addIeParams.probeRespDataLen = 0;
3437 psessionEntry->addIeParams.probeRespData_buff = NULL;
3438
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303439 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 psessionEntry->addIeParams.assocRespDataLen = 0;
3441 psessionEntry->addIeParams.assocRespData_buff = NULL;
3442
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303443 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3445 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3446
3447 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3448 pMac->lim.gLimIbssCoalescingHappened = false;
3449
3450 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3451 pStaDs =
3452 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3453 if (NULL == pStaDs)
3454 continue;
3455 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3456 if (eSIR_SUCCESS == status) {
3457 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3458 pStaDs->assocId, psessionEntry);
3459 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3460 } else {
3461 lim_log(pMac, LOGE,
3462 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303463 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 }
3465 }
3466 /* send a delBss to HAL and wait for a response */
3467 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3468
3469 if (status != eSIR_SUCCESS) {
3470 PELOGE(lim_log
3471 (pMac, LOGE, FL("delBss failed for bss %d"),
3472 psessionEntry->bssIdx);
3473 )
3474 psessionEntry->limSmeState = prevState;
3475
3476 MTRACE(mac_trace
3477 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3478 psessionEntry->limSmeState));
3479
3480 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3481 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3482 smetransactionId);
3483 }
3484}
3485
3486/**
3487 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3488 * @pMac: Global MAC context
3489 * @pMsg: Message from SME
3490 *
3491 * Wrapper for the function __lim_handle_sme_stop_bss_request
3492 * This message will be defered until softmac come out of
3493 * scan mode. Message should be handled even if we have
3494 * detected radar in the current operating channel.
3495 *
3496 * Return: true - If we consumed the buffer
3497 * false - If have defered the message.
3498 */
3499
3500static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3501{
3502 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3503 /**
3504 * If message defered, buffer is not consumed yet.
3505 * So return false
3506 */
3507 return false;
3508 }
3509 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3510 return true;
3511} /*** end __lim_process_sme_stop_bss_req() ***/
3512
3513void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3514 uint32_t body, tpPESession psessionEntry)
3515{
3516
3517 (void)body;
3518 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3519 lim_ibss_delete(pMac, psessionEntry);
3520 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3521 lim_delete_pre_auth_list(pMac);
3522 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3523 psessionEntry->smeSessionId,
3524 psessionEntry->transactionId);
3525 return;
3526}
3527
3528/**
3529 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3530 *
3531 * @mac_ctx: pointer to mac context
3532 * @msg_type: message type
3533 * @msg_buf: pointer to the SME message buffer
3534 *
3535 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3536 * in BTAMP AP.
3537 *
3538 * Return: None
3539 */
3540
3541void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3542 uint32_t *msg_buf)
3543{
3544 tSirSmeAssocCnf assoc_cnf;
3545 tpDphHashNode sta_ds = NULL;
3546 tpPESession session_entry = NULL;
3547 uint8_t session_id;
3548 tpSirAssocReq assoc_req;
3549
3550 if (msg_buf == NULL) {
3551 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3552 goto end;
3553 }
3554
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303555 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3557 lim_log(mac_ctx, LOGE,
3558 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3559 goto end;
3560 }
3561
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003562 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 &session_id);
3564 if (session_entry == NULL) {
3565 lim_log(mac_ctx, LOGE,
3566 FL("session does not exist for given bssId"));
3567 goto end;
3568 }
3569
3570 if ((!LIM_IS_AP_ROLE(session_entry) &&
3571 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3572 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3573 (session_entry->limSmeState !=
3574 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3575 lim_log(mac_ctx, LOGE, FL(
3576 "Rcvd unexpected msg %X in state %X, in role %X"),
3577 msg_type, session_entry->limSmeState,
3578 GET_LIM_SYSTEM_ROLE(session_entry));
3579 goto end;
3580 }
3581 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3582 &session_entry->dph.dphHashTable);
3583 if (sta_ds == NULL) {
3584 lim_log(mac_ctx, LOGE, FL(
3585 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3586 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003587 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588
3589 /*
3590 * send a DISASSOC_IND message to WSM to make sure
3591 * the state in WSM and LIM is the same
3592 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003593 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 eSIR_SME_STA_NOT_ASSOCIATED,
3595 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3596 session_entry->smeSessionId,
3597 session_entry->transactionId,
3598 session_entry);
3599 goto end;
3600 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303601 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003602 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303603 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 lim_log(mac_ctx, LOG1, FL(
3605 "peerMacAddr mismatched for aid %d, peer "),
3606 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003607 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 goto end;
3609 }
3610
3611 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3612 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3613 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3614 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3615 (msg_type != eWNI_SME_ASSOC_CNF))) {
3616 lim_log(mac_ctx, LOG1, FL(
3617 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3618 "StaD mlmState : %d"),
3619 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003620 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 goto end;
3622 }
3623 /*
3624 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3625 * has been received
3626 */
3627 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3628 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3629 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3630
3631 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3632 /*
3633 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3634 * when it had received Assoc Request frame. Now, PE just needs
3635 * to send association rsp frame to the requesting BTAMP-STA.
3636 */
3637 sta_ds->mlmStaContext.mlmState =
3638 eLIM_MLM_LINK_ESTABLISHED_STATE;
3639 lim_log(mac_ctx, LOG1,
3640 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3641 sta_ds->assocId);
3642 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3643 sta_ds->assocId, sta_ds->staAddr,
3644 sta_ds->mlmStaContext.subType, sta_ds,
3645 session_entry);
3646 goto end;
3647 } else {
3648 /*
3649 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3650 * to be associated since the HAL sta entry is created for
3651 * denied STA we need to remove this HAL entry.
3652 * So to do that set updateContext to 1
3653 */
3654 if (!sta_ds->mlmStaContext.updateContext)
3655 sta_ds->mlmStaContext.updateContext = 1;
3656 lim_log(mac_ctx, LOG1,
3657 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3658 assoc_cnf.statusCode, sta_ds->assocId);
3659 lim_reject_association(mac_ctx, sta_ds->staAddr,
3660 sta_ds->mlmStaContext.subType,
3661 true, sta_ds->mlmStaContext.authType,
3662 sta_ds->assocId, true,
3663 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3664 session_entry);
3665 }
3666end:
3667 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3668 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3669 assoc_req = (tpSirAssocReq)
3670 session_entry->parsedAssocReq[sta_ds->assocId];
3671 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303672 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 assoc_req->assocReqFrame = NULL;
3674 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303675 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3677 }
3678}
3679
3680static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3681{
3682 tpDphHashNode pStaDs;
3683 tSirMacAddr peerMac;
3684 tpSirAddtsReq pSirAddts;
3685 uint32_t timeout;
3686 tpPESession psessionEntry;
3687 uint8_t sessionId; /* PE sessionId */
3688 uint8_t smesessionId;
3689 uint16_t smetransactionId;
3690
3691 if (pMsgBuf == NULL) {
3692 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3693 return;
3694 }
3695
3696 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3697 &smetransactionId);
3698
3699 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3700
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003701 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3702 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 if (psessionEntry == NULL) {
3704 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3705 return;
3706 }
3707#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3708 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3709 0);
3710#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3711
3712 /* if sta
3713 * - verify assoc state
3714 * - send addts request to ap
3715 * - wait for addts response from ap
3716 * if ap, just ignore with error log
3717 */
3718 PELOG1(lim_log(pMac, LOG1,
3719 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3720 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3721 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3722 )
3723
3724 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3725 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3726 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3727 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3728 psessionEntry, pSirAddts->req.tspec,
3729 smesessionId, smetransactionId);
3730 return;
3731 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732
3733 pStaDs =
3734 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3735 &psessionEntry->dph.dphHashTable);
3736
3737 if (pStaDs == NULL) {
3738 PELOGE(lim_log
3739 (pMac, LOGE, "Cannot find AP context for addts req");
3740 )
3741 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3742 psessionEntry, pSirAddts->req.tspec,
3743 smesessionId, smetransactionId);
3744 return;
3745 }
3746
3747 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3748 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3749 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3750 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3751 psessionEntry, pSirAddts->req.tspec,
3752 smesessionId, smetransactionId);
3753 return;
3754 }
3755
3756 pSirAddts->req.wsmTspecPresent = 0;
3757 pSirAddts->req.wmeTspecPresent = 0;
3758 pSirAddts->req.lleTspecPresent = 0;
3759
3760 if ((pStaDs->wsmEnabled) &&
3761 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3762 SIR_MAC_ACCESSPOLICY_EDCA))
3763 pSirAddts->req.wsmTspecPresent = 1;
3764 else if (pStaDs->wmeEnabled)
3765 pSirAddts->req.wmeTspecPresent = 1;
3766 else if (pStaDs->lleEnabled)
3767 pSirAddts->req.lleTspecPresent = 1;
3768 else {
3769 PELOGW(lim_log
3770 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3771 )
3772 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3773 psessionEntry, pSirAddts->req.tspec,
3774 smesessionId, smetransactionId);
3775 return;
3776 }
3777
3778 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3779 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3780 lim_log(pMac, LOGE,
3781 "AddTs received in invalid LIMsme state (%d)",
3782 psessionEntry->limSmeState);
3783 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3784 psessionEntry, pSirAddts->req.tspec,
3785 smesessionId, smetransactionId);
3786 return;
3787 }
3788
3789 if (pMac->lim.gLimAddtsSent) {
3790 lim_log(pMac, LOGE,
3791 "Addts (token %d, tsid %d, up %d) is still pending",
3792 pMac->lim.gLimAddtsReq.req.dialogToken,
3793 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3794 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3795 userPrio);
3796 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3797 psessionEntry, pSirAddts->req.tspec,
3798 smesessionId, smetransactionId);
3799 return;
3800 }
3801
3802 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3803
3804 /* save the addts request */
3805 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303806 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3808
3809 /* ship out the message now */
3810 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3811 psessionEntry);
3812 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3813 /* start a timer to wait for the response */
3814 if (pSirAddts->timeout)
3815 timeout = pSirAddts->timeout;
3816 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3817 eSIR_SUCCESS) {
3818 lim_log(pMac, LOGP,
3819 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3820 WNI_CFG_ADDTS_RSP_TIMEOUT);
3821 return;
3822 }
3823
3824 timeout = SYS_MS_TO_TICKS(timeout);
3825 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3826 != TX_SUCCESS) {
3827 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3828 return;
3829 }
3830 pMac->lim.gLimAddtsRspTimerCount++;
3831 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3832 pMac->lim.gLimAddtsRspTimerCount) !=
3833 TX_SUCCESS) {
3834 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3835 return;
3836 }
3837 MTRACE(mac_trace
3838 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3839 eLIM_ADDTS_RSP_TIMER));
3840
3841 /* add the sessionId to the timer object */
3842 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3843 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3844 TX_SUCCESS) {
3845 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3846 return;
3847 }
3848 return;
3849}
3850
3851static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3852{
3853 tSirMacAddr peerMacAddr;
3854 uint8_t ac;
3855 tSirMacTSInfo *pTsinfo;
3856 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3857 tpDphHashNode pStaDs = NULL;
3858 tpPESession psessionEntry;
3859 uint8_t sessionId;
3860 uint32_t status = eSIR_SUCCESS;
3861 uint8_t smesessionId;
3862 uint16_t smetransactionId;
3863
3864 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3865 &smetransactionId);
3866
3867 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003868 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 &sessionId);
3870 if (psessionEntry == NULL) {
3871 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3872 status = eSIR_FAILURE;
3873 goto end;
3874 }
3875#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3876 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3877 0);
3878#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3879
3880 if (eSIR_SUCCESS !=
3881 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3882 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3883 status = eSIR_FAILURE;
3884 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3885 smesessionId, smetransactionId);
3886 return;
3887 }
3888
3889 lim_log(pMac, LOG1,
3890 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3891 MAC_ADDRESS_STR),
3892 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3893
3894 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3895 pDeltsReq->req.wmeTspecPresent,
3896 &pDeltsReq->req.tsinfo,
3897 &pDeltsReq->req.tspec, psessionEntry);
3898
3899 pTsinfo =
3900 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3901 tsinfo : &pDeltsReq->req.tsinfo;
3902
3903 /* We've successfully send DELTS frame to AP. Update the
3904 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3905 * is no longer trigger enabled or delivery enabled
3906 */
3907 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3908 pTsinfo, CLEAR_UAPSD_MASK);
3909
3910 /* We're deleting the TSPEC, so this particular AC is no longer
3911 * admitted. PE needs to downgrade the EDCA
3912 * parameters(for the AC for which TS is being deleted) to the
3913 * next best AC for which ACM is not enabled, and send the
3914 * updated values to HAL.
3915 */
3916 ac = upToAc(pTsinfo->traffic.userPrio);
3917
3918 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3919 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3920 ~(1 << ac);
3921 } else if (pTsinfo->traffic.direction ==
3922 SIR_MAC_DIRECTION_DNLINK) {
3923 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3924 ~(1 << ac);
3925 } else if (pTsinfo->traffic.direction ==
3926 SIR_MAC_DIRECTION_BIDIR) {
3927 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3928 ~(1 << ac);
3929 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3930 ~(1 << ac);
3931 }
3932
3933 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3934 psessionEntry);
3935
3936 pStaDs =
3937 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3938 &psessionEntry->dph.dphHashTable);
3939 if (pStaDs != NULL) {
3940 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3941 pStaDs->bssId);
3942 status = eSIR_SUCCESS;
3943 } else {
3944 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3945 status = eSIR_FAILURE;
3946 }
3947#ifdef FEATURE_WLAN_ESE
3948#ifdef FEATURE_WLAN_ESE_UPLOAD
3949 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950#endif /* FEATURE_WLAN_ESE_UPLOAD */
3951#endif
3952
3953 /* send an sme response back */
3954end:
3955 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3956 smesessionId, smetransactionId);
3957}
3958
3959void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3960{
3961 /* fetch the sessionEntry based on the sessionId */
3962 tpPESession psessionEntry;
3963 psessionEntry = pe_find_session_by_session_id(pMac,
3964 pMac->lim.limTimers.gLimAddtsRspTimer.
3965 sessionId);
3966 if (psessionEntry == NULL) {
3967 lim_log(pMac, LOGP,
3968 FL("Session Does not exist for given sessionID"));
3969 return;
3970 }
3971
3972 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3973 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3974 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3975 GET_LIM_SYSTEM_ROLE(psessionEntry));
3976 pMac->lim.gLimAddtsSent = false;
3977 return;
3978 }
3979
3980 if (!pMac->lim.gLimAddtsSent) {
3981 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3982 return;
3983 }
3984
3985 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3986 lim_log(pMac, LOGE,
3987 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3988 pMac->lim.gLimAddtsRspTimerCount);
3989 return;
3990 }
3991 /* this a real response timeout */
3992 pMac->lim.gLimAddtsSent = false;
3993 pMac->lim.gLimAddtsRspTimerCount++;
3994
3995 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3996 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3997 psessionEntry->smeSessionId,
3998 psessionEntry->transactionId);
3999}
4000
4001/**
4002 * __lim_process_sme_get_statistics_request()
4003 *
4004 ***FUNCTION:
4005 *
4006 *
4007 ***NOTE:
4008 *
4009 * @param pMac Pointer to Global MAC structure
4010 * @param *pMsgBuf A pointer to the SME message buffer
4011 * @return None
4012 */
4013static void
4014__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4015{
4016 tpAniGetPEStatsReq pPEStatsReq;
4017 tSirMsgQ msgQ;
4018
4019 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4020
4021 msgQ.type = WMA_GET_STATISTICS_REQ;
4022
4023 msgQ.reserved = 0;
4024 msgQ.bodyptr = pMsgBuf;
4025 msgQ.bodyval = 0;
4026 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4027
4028 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304029 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 pMsgBuf = NULL;
4031 lim_log(pMac, LOGP, "Unable to forward request");
4032 return;
4033 }
4034
4035 return;
4036}
4037
4038#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4039/**
4040 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
4041 *
4042 ***NOTE:
4043 *
4044 * @param pMac Pointer to Global MAC structure
4045 * @param *pMsgBuf A pointer to the SME message buffer
4046 * @return None
4047 */
4048static void
4049__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4050{
4051 tSirMsgQ msgQ;
4052
4053 msgQ.type = WMA_TSM_STATS_REQ;
4054 msgQ.reserved = 0;
4055 msgQ.bodyptr = pMsgBuf;
4056 msgQ.bodyval = 0;
4057 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4058
4059 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304060 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 pMsgBuf = NULL;
4062 lim_log(pMac, LOGP, "Unable to forward request");
4063 return;
4064 }
4065}
4066#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4067
4068static void
4069__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4070{
4071 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4072 tpPESession psessionEntry;
4073 uint8_t sessionId; /* PE sessionID */
4074
4075 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4076
4077 if (pMsgBuf == NULL) {
4078 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4079 return;
4080 }
4081
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304082 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 if (NULL == pUpdateAPWPSIEsReq) {
4084 lim_log(pMac, LOGP,
4085 FL
4086 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4087 return;
4088 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304089 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 sizeof(struct sSirUpdateAPWPSIEsReq));
4091
4092 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004093 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 &sessionId);
4095 if (psessionEntry == NULL) {
4096 lim_log(pMac, LOGW,
4097 FL("Session does not exist for given BSSID"));
4098 goto end;
4099 }
4100
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304101 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 sizeof(tSirAPWPSIEs));
4103
4104 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4105 lim_send_beacon_ind(pMac, psessionEntry);
4106
4107end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304108 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 return;
4110}
4111
4112void
4113lim_send_vdev_restart(tpAniSirGlobal pMac,
4114 tpPESession psessionEntry, uint8_t sessionId)
4115{
4116 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4117 tSirMsgQ msgQ;
4118 tSirRetStatus retCode = eSIR_SUCCESS;
4119
4120 if (psessionEntry == NULL) {
4121 PELOGE(lim_log
4122 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4123 __LINE__);
4124 )
4125 return;
4126 }
4127
4128 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304129 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 if (NULL == pHalHiddenSsidVdevRestart) {
4131 PELOGE(lim_log
4132 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4133 __func__, __LINE__);
4134 )
4135 return;
4136 }
4137
4138 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4139 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4140
4141 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4142 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4143 msgQ.bodyval = 0;
4144
4145 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4146 if (eSIR_SUCCESS != retCode) {
4147 PELOGE(lim_log
4148 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4149 __LINE__);
4150 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304151 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 }
4153}
4154
4155static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4156{
4157 tpSirUpdateParams pUpdateParams;
4158 tpPESession psessionEntry;
4159
4160 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4161
4162 if (pMsgBuf == NULL) {
4163 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4164 return;
4165 }
4166
4167 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4168
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004169 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 pUpdateParams->sessionId);
4171 if (psessionEntry == NULL) {
4172 lim_log(pMac, LOGW,
4173 "Session does not exist for given sessionId %d",
4174 pUpdateParams->sessionId);
4175 return;
4176 }
4177
4178 /* Update the session entry */
4179 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4180
4181 /* Send vdev restart */
4182 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4183
4184 /* Update beacon */
4185 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4186 lim_send_beacon_ind(pMac, psessionEntry);
4187
4188 return;
4189} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4190
4191static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4192{
4193 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4194 tpPESession psessionEntry;
4195 uint8_t sessionId; /* PE sessionID */
4196
4197 if (pMsgBuf == NULL) {
4198 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4199 return;
4200 }
4201
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304202 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 if (NULL == pUpdateAPWPARSNIEsReq) {
4204 lim_log(pMac, LOGP,
4205 FL
4206 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4207 return;
4208 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304209 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4211
4212 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004213 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 &sessionId);
4215 if (psessionEntry == NULL) {
4216 lim_log(pMac, LOGW,
4217 FL("Session does not exist for given BSSID"));
4218 goto end;
4219 }
4220
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304221 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4223
4224 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4225 &psessionEntry->
4226 pLimStartBssReq->rsnIE,
4227 psessionEntry);
4228
4229 psessionEntry->pLimStartBssReq->privacy = 1;
4230 psessionEntry->privacy = 1;
4231
4232 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4233 lim_send_beacon_ind(pMac, psessionEntry);
4234
4235end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304236 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 return;
4238} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4239
4240/*
4241 Update the beacon Interval dynamically if beaconInterval is different in MCC
4242 */
4243static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4244{
4245 tpSirChangeBIParams pChangeBIParams;
4246 tpPESession psessionEntry;
4247 uint8_t sessionId = 0;
4248 tUpdateBeaconParams beaconParams;
4249
4250 PELOG1(lim_log(pMac, LOG1,
4251 FL("received Update Beacon Interval message"));
4252 );
4253
4254 if (pMsgBuf == NULL) {
4255 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4256 return;
4257 }
4258
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304259 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4261
4262 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004263 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 &sessionId);
4265 if (psessionEntry == NULL) {
4266 lim_log(pMac, LOGE,
4267 FL("Session does not exist for given BSSID"));
4268 return;
4269 }
4270
4271 /*Update sessionEntry Beacon Interval */
4272 if (psessionEntry->beaconParams.beaconInterval !=
4273 pChangeBIParams->beaconInterval) {
4274 psessionEntry->beaconParams.beaconInterval =
4275 pChangeBIParams->beaconInterval;
4276 }
4277
4278 /*Update sch beaconInterval */
4279 if (pMac->sch.schObject.gSchBeaconInterval !=
4280 pChangeBIParams->beaconInterval) {
4281 pMac->sch.schObject.gSchBeaconInterval =
4282 pChangeBIParams->beaconInterval;
4283
4284 PELOG1(lim_log(pMac, LOG1,
4285 FL
4286 ("LIM send update BeaconInterval Indication : %d"),
4287 pChangeBIParams->beaconInterval);
4288 );
4289
4290 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4291 /* Update beacon */
4292 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4293
4294 beaconParams.bssIdx = psessionEntry->bssIdx;
4295 /* Set change in beacon Interval */
4296 beaconParams.beaconInterval =
4297 pChangeBIParams->beaconInterval;
4298 beaconParams.paramChangeBitmap =
4299 PARAM_BCN_INTERVAL_CHANGED;
4300 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4301 }
4302 }
4303
4304 return;
4305} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4306
4307#ifdef QCA_HT_2040_COEX
4308static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4309 uint32_t *pMsgBuf)
4310{
4311 tpSirSetHT2040Mode pSetHT2040Mode;
4312 tpPESession psessionEntry;
4313 uint8_t sessionId = 0;
4314 cds_msg_t msg;
4315 tUpdateVHTOpMode *pHtOpMode = NULL;
4316 uint16_t staId = 0;
4317 tpDphHashNode pStaDs = NULL;
4318
4319 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4320 if (pMsgBuf == NULL) {
4321 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4322 return;
4323 }
4324
4325 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4326
4327 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004328 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 &sessionId);
4330 if (psessionEntry == NULL) {
4331 lim_log(pMac, LOG1,
4332 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004333 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 return;
4335 }
4336
4337 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4338 pSetHT2040Mode->cbMode);
4339 /*Update sessionEntry HT related fields */
4340 switch (pSetHT2040Mode->cbMode) {
4341 case PHY_SINGLE_CHANNEL_CENTERED:
4342 psessionEntry->htSecondaryChannelOffset =
4343 PHY_SINGLE_CHANNEL_CENTERED;
4344 psessionEntry->htRecommendedTxWidthSet = 0;
4345 if (pSetHT2040Mode->obssEnabled)
4346 psessionEntry->htSupportedChannelWidthSet
4347 = eHT_CHANNEL_WIDTH_40MHZ;
4348 else
4349 psessionEntry->htSupportedChannelWidthSet
4350 = eHT_CHANNEL_WIDTH_20MHZ;
4351 break;
4352 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4353 psessionEntry->htSecondaryChannelOffset =
4354 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4355 psessionEntry->htRecommendedTxWidthSet = 1;
4356 break;
4357 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4358 psessionEntry->htSecondaryChannelOffset =
4359 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4360 psessionEntry->htRecommendedTxWidthSet = 1;
4361 break;
4362 default:
4363 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4364 return;
4365 }
4366
4367 /* Update beacon */
4368 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4369 lim_send_beacon_ind(pMac, psessionEntry);
4370
4371 /* update OP Mode for each associated peer */
4372 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4373 pStaDs = dph_get_hash_entry(pMac, staId,
4374 &psessionEntry->dph.dphHashTable);
4375 if (NULL == pStaDs)
4376 continue;
4377
4378 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304379 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 if (NULL == pHtOpMode) {
4381 lim_log(pMac, LOGE,
4382 FL
4383 ("%s: Not able to allocate memory for setting OP mode"),
4384 __func__);
4385 return;
4386 }
4387 pHtOpMode->opMode =
4388 (psessionEntry->htSecondaryChannelOffset ==
4389 PHY_SINGLE_CHANNEL_CENTERED) ?
4390 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4391 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304392 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 sizeof(tSirMacAddr));
4394 pHtOpMode->smesessionId = sessionId;
4395
4396 msg.type = WMA_UPDATE_OP_MODE;
4397 msg.reserved = 0;
4398 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304399 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304400 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 lim_log(pMac, LOGE,
4402 FL
4403 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4404 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304405 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 return;
4407 }
4408 lim_log(pMac, LOG1,
4409 FL
4410 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4411 __func__, pHtOpMode->opMode, staId);
4412
4413 } else
4414 lim_log(pMac, LOG1,
4415 FL("%s: station %d does not support HT40\n"),
4416 __func__, staId);
4417 }
4418
4419 return;
4420}
4421#endif
4422
4423/* -------------------------------------------------------------------- */
4424/**
4425 * __lim_process_report_message
4426 *
4427 * FUNCTION: Processes the next received Radio Resource Management message
4428 *
4429 * LOGIC:
4430 *
4431 * ASSUMPTIONS:
4432 *
4433 * NOTE:
4434 *
4435 * @param None
4436 * @return None
4437 */
4438
4439void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4440{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 switch (pMsg->type) {
4442 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4443 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4444 break;
4445 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004447 break;
4448 default:
4449 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451}
4452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453/* -------------------------------------------------------------------- */
4454/**
4455 * lim_send_set_max_tx_power_req
4456 *
4457 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4458 *
4459 * LOGIC:
4460 *
4461 * ASSUMPTIONS:
4462 *
4463 * NOTE:
4464 *
4465 * @param txPower txPower to be set.
4466 * @param pSessionEntry session entry.
4467 * @return None
4468 */
4469tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004470lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 tpPESession pSessionEntry)
4472{
4473 tpMaxTxPowerParams pMaxTxParams = NULL;
4474 tSirRetStatus retCode = eSIR_SUCCESS;
4475 tSirMsgQ msgQ;
4476
4477 if (pSessionEntry == NULL) {
4478 PELOGE(lim_log
4479 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4480 __LINE__);
4481 )
4482 return eSIR_FAILURE;
4483 }
4484
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304485 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 if (NULL == pMaxTxParams) {
4487 lim_log(pMac, LOGP,
4488 FL("Unable to allocate memory for pMaxTxParams "));
4489 return eSIR_MEM_ALLOC_FAILED;
4490
4491 }
4492#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4493 lim_log(pMac, LOG1,
4494 FL("pMaxTxParams allocated...will be freed in other module"));
4495#endif
4496 if (pMaxTxParams == NULL) {
4497 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4498 return eSIR_FAILURE;
4499 }
4500 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304501 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304502 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304503 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004504 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304505 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506
4507 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4508 msgQ.bodyptr = pMaxTxParams;
4509 msgQ.bodyval = 0;
4510 PELOG1(lim_log
4511 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4512 )
4513 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4514 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4515 if (eSIR_SUCCESS != retCode) {
4516 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 }
4519 return retCode;
4520}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521
4522/**
4523 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4524 *
4525 * @mac_ctx: Pointer to Global MAC structure
4526 * @msg_buf: pointer to the SME message buffer
4527 *
4528 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4529 * from SME. It Register this information within PE.
4530 *
4531 * Return: None
4532 */
4533static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4534 uint32_t *msg_buf)
4535{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304536 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4538 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4539 struct mgmt_frm_reg_info *next = NULL;
4540 bool match = false;
4541
4542 lim_log(mac_ctx, LOG1, FL(
4543 "registerFrame %d, frameType %d, matchLen %d"),
4544 sme_req->registerFrame, sme_req->frameType,
4545 sme_req->matchLen);
4546 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304547 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304548 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4549 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304550 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551
4552 while (lim_mgmt_regn != NULL) {
4553 if (lim_mgmt_regn->frameType != sme_req->frameType)
4554 goto skip_match;
4555 if (sme_req->matchLen) {
4556 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304557 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 sme_req->matchData,
4559 lim_mgmt_regn->matchLen))) {
4560 /* found match! */
4561 match = true;
4562 break;
4563 }
4564 } else {
4565 /* found match! */
4566 match = true;
4567 break;
4568 }
4569skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304570 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304571 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304573 (qdf_list_node_t *)lim_mgmt_regn,
4574 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304575 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 lim_mgmt_regn = next;
4577 next = NULL;
4578 }
4579 if (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_list_remove_node(
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);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304584 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304585 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 }
4587
4588 if (sme_req->registerFrame) {
4589 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304590 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 sme_req->matchLen);
4592 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304593 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 sizeof(struct mgmt_frm_reg_info) +
4595 sme_req->matchLen, 0);
4596 lim_mgmt_regn->frameType = sme_req->frameType;
4597 lim_mgmt_regn->matchLen = sme_req->matchLen;
4598 lim_mgmt_regn->sessionId = sme_req->sessionId;
4599 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304600 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 sme_req->matchData,
4602 sme_req->matchLen);
4603 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304604 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304606 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 gLimMgmtFrameRegistratinQueue,
4608 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304609 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 &mac_ctx->lim.lim_frame_register_lock);
4611 }
4612 }
4613 return;
4614}
4615
4616static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4617{
4618 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4619 pMac->lim.gDeferMsgTypeForNOA);
4620 pMac->lim.gDeferMsgTypeForNOA = 0;
4621 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4622 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304623 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4625 }
4626}
4627
4628/**
4629 * lim_process_regd_defd_sme_req_after_noa_start()
4630 *
4631 * mac_ctx: Pointer to Global MAC structure
4632 *
4633 * This function is called to process deferred sme req message
4634 * after noa start.
4635 *
4636 * Return: None
4637 */
4638void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4639{
4640 bool buf_consumed = true;
4641
4642 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4643 mac_ctx->lim.gDeferMsgTypeForNOA);
4644
4645 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4646 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4647 lim_log(mac_ctx, LOGW,
4648 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4649 lim_log(mac_ctx, LOGW,
4650 FL("It may happen when NOA start ind and timeout happen at the same time"));
4651 return;
4652 }
4653 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4654 case eWNI_SME_SCAN_REQ:
4655 __lim_process_sme_scan_req(mac_ctx,
4656 mac_ctx->lim.gpDefdSmeMsgForNOA);
4657 break;
4658#ifdef FEATURE_OEM_DATA_SUPPORT
4659 case eWNI_SME_OEM_DATA_REQ:
4660 __lim_process_sme_oem_data_req(mac_ctx,
4661 mac_ctx->lim.gpDefdSmeMsgForNOA);
4662 break;
4663#endif
4664 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4665 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4666 mac_ctx->lim.gpDefdSmeMsgForNOA);
4667 /*
4668 * lim_process_remain_on_chnl_req doesnt want us to free
4669 * the buffer since it is freed in lim_remain_on_chn_rsp.
4670 * this change is to avoid "double free"
4671 */
4672 if (false == buf_consumed)
4673 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4674 break;
4675 case eWNI_SME_JOIN_REQ:
4676 __lim_process_sme_join_req(mac_ctx,
4677 mac_ctx->lim.gpDefdSmeMsgForNOA);
4678 break;
4679 default:
4680 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4681 mac_ctx->lim.gDeferMsgTypeForNOA);
4682 break;
4683 }
4684 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4685}
4686
4687static void
4688__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4689{
4690 tpSirResetAPCapsChange pResetCapsChange;
4691 tpPESession psessionEntry;
4692 uint8_t sessionId = 0;
4693 if (pMsgBuf == NULL) {
4694 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4695 return;
4696 }
4697
4698 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4699 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004700 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4701 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 if (psessionEntry == NULL) {
4703 lim_log(pMac, LOGE,
4704 FL("Session does not exist for given BSSID"));
4705 return;
4706 }
4707
4708 psessionEntry->limSentCapsChangeNtf = false;
4709 return;
4710}
4711
4712/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304713 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4714 * indication callback in PE.
4715 * @mac_ptr: Mac pointer
4716 * @msg_buf: Msg pointer containing the callback
4717 *
4718 * This function is used save the Management frame
4719 * indication callback in PE.
4720 *
4721 * Return: None
4722 */
4723static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4724 uint32_t *msg_buf)
4725{
4726 struct sir_sme_mgmt_frame_cb_req *sme_req =
4727 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4728
4729 if (NULL == msg_buf) {
4730 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4731 return;
4732 }
4733 if (sme_req->callback)
4734 mac_ctx->mgmt_frame_ind_cb =
4735 (sir_mgmt_frame_ind_callback)sme_req->callback;
4736 else
4737 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4738}
4739
4740/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 * lim_process_sme_req_messages()
4742 *
4743 ***FUNCTION:
4744 * This function is called by limProcessMessageQueue(). This
4745 * function processes SME request messages from HDD or upper layer
4746 * application.
4747 *
4748 ***LOGIC:
4749 *
4750 ***ASSUMPTIONS:
4751 *
4752 ***NOTE:
4753 *
4754 * @param pMac Pointer to Global MAC structure
4755 * @param msgType Indicates the SME message type
4756 * @param *pMsgBuf A pointer to the SME message buffer
4757 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4758 * false - if pMsgBuf is not to be freed.
4759 */
4760
4761bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4762{
4763 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4764 uint32_t *pMsgBuf = pMsg->bodyptr;
4765 tpSirSmeScanReq pScanReq;
4766 PELOG1(lim_log
4767 (pMac, LOG1,
4768 FL
4769 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4770 lim_msg_str(pMsg->type), pMsg->type,
4771 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4772 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4773 )
4774
4775 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4776 /* If no insert NOA required then execute the code below */
4777
4778 switch (pMsg->type) {
4779 case eWNI_SME_SYS_READY_IND:
4780 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4781 break;
4782
4783 case eWNI_SME_START_BSS_REQ:
4784 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4785 break;
4786
4787 case eWNI_SME_SCAN_REQ:
4788 __lim_process_sme_scan_req(pMac, pMsgBuf);
4789 break;
4790
4791#ifdef FEATURE_OEM_DATA_SUPPORT
4792 case eWNI_SME_OEM_DATA_REQ:
4793 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4794 break;
4795#endif
4796 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4797 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4798 break;
4799
4800 case eWNI_SME_UPDATE_NOA:
4801 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4802 break;
4803 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4804 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4805 break;
4806 case eWNI_SME_JOIN_REQ:
4807 __lim_process_sme_join_req(pMac, pMsgBuf);
4808 break;
4809
4810 case eWNI_SME_REASSOC_REQ:
4811 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4812 break;
4813
4814 case eWNI_SME_DISASSOC_REQ:
4815 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4816 break;
4817
4818 case eWNI_SME_DISASSOC_CNF:
4819 case eWNI_SME_DEAUTH_CNF:
4820 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4821 break;
4822
4823 case eWNI_SME_DEAUTH_REQ:
4824 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4825 break;
4826
4827 case eWNI_SME_SETCONTEXT_REQ:
4828 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4829 break;
4830
4831 case eWNI_SME_STOP_BSS_REQ:
4832 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4833 break;
4834
4835 case eWNI_SME_ASSOC_CNF:
4836 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4837 PELOG1(lim_log(pMac,
4838 LOG1, FL("Received ASSOC_CNF message"));)
4839 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4840 pMsgBuf);
4841 break;
4842
4843 case eWNI_SME_ADDTS_REQ:
4844 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4845 __lim_process_sme_addts_req(pMac, pMsgBuf);
4846 break;
4847
4848 case eWNI_SME_DELTS_REQ:
4849 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4850 __lim_process_sme_delts_req(pMac, pMsgBuf);
4851 break;
4852
4853 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4854 PELOG1(lim_log
4855 (pMac, LOG1,
4856 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4857 )
4858 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4859 break;
4860
4861 case eWNI_SME_GET_STATISTICS_REQ:
4862 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4863 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4864 bufConsumed = false;
4865 break;
4866#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4867 case eWNI_SME_GET_TSM_STATS_REQ:
4868 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4869 bufConsumed = false;
4870 break;
4871#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4872 case eWNI_SME_GET_ASSOC_STAS_REQ:
4873 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4874 break;
4875 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4876 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4877 break;
4878
4879 case eWNI_SME_HIDE_SSID_REQ:
4880 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4881 break;
4882 case eWNI_SME_UPDATE_APWPSIE_REQ:
4883 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4884 break;
4885 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4886 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4887 break;
4888
4889 case eWNI_SME_SET_APWPARSNIEs_REQ:
4890 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4891 break;
4892
4893 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4894 /* Update the beaconInterval */
4895 __lim_process_sme_change_bi(pMac, pMsgBuf);
4896 break;
4897
4898#ifdef QCA_HT_2040_COEX
4899 case eWNI_SME_SET_HT_2040_MODE:
4900 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4901 break;
4902#endif
4903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4905 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4906 __lim_process_report_message(pMac, pMsg);
4907 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 case eWNI_SME_FT_PRE_AUTH_REQ:
4910 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4911 break;
4912 case eWNI_SME_FT_UPDATE_KEY:
4913 lim_process_ft_update_key(pMac, pMsgBuf);
4914 break;
4915
4916 case eWNI_SME_FT_AGGR_QOS_REQ:
4917 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4918 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919
4920 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4921 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4922 break;
4923#ifdef FEATURE_WLAN_TDLS
4924 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4925 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4926 break;
4927 case eWNI_SME_TDLS_ADD_STA_REQ:
4928 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4929 break;
4930 case eWNI_SME_TDLS_DEL_STA_REQ:
4931 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4932 break;
4933 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4934 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4935 break;
4936#endif
4937 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4938 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4939 break;
4940
4941 case eWNI_SME_CHANNEL_CHANGE_REQ:
4942 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4943 break;
4944
4945 case eWNI_SME_START_BEACON_REQ:
4946 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4947 break;
4948
4949 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4950 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4951 break;
4952
4953 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4954 lim_process_update_add_ies(pMac, pMsgBuf);
4955 break;
4956
4957 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4958 lim_process_modify_add_ies(pMac, pMsgBuf);
4959 break;
4960 case eWNI_SME_SET_HW_MODE_REQ:
4961 lim_process_set_hw_mode(pMac, pMsgBuf);
4962 break;
4963 case eWNI_SME_NSS_UPDATE_REQ:
4964 lim_process_nss_update_request(pMac, pMsgBuf);
4965 break;
4966 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4967 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4968 break;
4969 case eWNI_SME_SET_IE_REQ:
4970 lim_process_set_ie_req(pMac, pMsgBuf);
4971 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304972 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4973 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4974 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304975 case eWNI_SME_EXT_CHANGE_CHANNEL:
4976 lim_process_ext_change_channel(pMac, pMsgBuf);
4977 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004978 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4979 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4980 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304982 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983 pMsg->bodyptr = NULL;
4984 break;
4985 } /* switch (msgType) */
4986
4987 return bufConsumed;
4988} /*** end lim_process_sme_req_messages() ***/
4989
4990/**
4991 * lim_process_sme_start_beacon_req()
4992 *
4993 ***FUNCTION:
4994 * This function is called by limProcessMessageQueue(). This
4995 * function processes SME request messages from HDD or upper layer
4996 * application.
4997 *
4998 ***LOGIC:
4999 *
5000 ***ASSUMPTIONS:
5001 *
5002 ***NOTE:
5003 *
5004 * @param pMac Pointer to Global MAC structure
5005 * @param msgType Indicates the SME message type
5006 * @param *pMsgBuf A pointer to the SME message buffer
5007 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5008 * false - if pMsgBuf is not to be freed.
5009 */
5010static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5011{
5012 tpSirStartBeaconIndication pBeaconStartInd;
5013 tpPESession psessionEntry;
5014 uint8_t sessionId; /* PE sessionID */
5015
5016 if (pMsg == NULL) {
5017 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5018 return;
5019 }
5020
5021 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5022 psessionEntry = pe_find_session_by_bssid(pMac,
5023 pBeaconStartInd->bssid,
5024 &sessionId);
5025 if (psessionEntry == NULL) {
5026 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5027 lim_log(pMac, LOGE,
5028 FL("Session does not exist for given bssId"));
5029 return;
5030 }
5031
5032 if (pBeaconStartInd->beaconStartStatus == true) {
5033 /*
5034 * Currently this Indication comes from SAP
5035 * to start Beacon Tx on a DFS channel
5036 * since beaconing has to be done on DFS
5037 * channel only after CAC WAIT is completed.
5038 * On a DFS Channel LIM does not start beacon
5039 * Tx right after the WMA_ADD_BSS_RSP.
5040 */
5041 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305042 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 FL("Start Beacon with ssid %s Ch %d"),
5044 psessionEntry->ssId.ssId,
5045 psessionEntry->currentOperChannel);
5046 lim_send_beacon_ind(pMac, psessionEntry);
5047 } else {
5048 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5049 return;
5050 }
5051}
5052
5053/**
5054 * lim_process_sme_channel_change_request() - process sme ch change req
5055 *
5056 * @mac_ctx: Pointer to Global MAC structure
5057 * @msg_buf: pointer to the SME message buffer
5058 *
5059 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5060 *
5061 * Return: None
5062 */
5063static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5064 uint32_t *msg_buf)
5065{
5066 tpSirChanChangeRequest ch_change_req;
5067 tpPESession session_entry;
5068 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005069 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 uint32_t val = 0;
5071
5072 if (msg_buf == NULL) {
5073 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5074 return;
5075 }
5076 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5077
5078 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5079 ch_change_req->targetChannel);
5080
5081 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5082 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5083 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5084 return;
5085 }
5086
5087 session_entry = pe_find_session_by_bssid(mac_ctx,
5088 ch_change_req->bssid, &session_id);
5089 if (session_entry == NULL) {
5090 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5091 lim_log(mac_ctx, LOGE, FL(
5092 "Session does not exist for given bssId"));
5093 return;
5094 }
5095
5096 if (session_entry->currentOperChannel ==
5097 ch_change_req->targetChannel) {
5098 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5099 return;
5100 }
5101
5102 if (LIM_IS_AP_ROLE(session_entry))
5103 session_entry->channelChangeReasonCode =
5104 LIM_SWITCH_CHANNEL_SAP_DFS;
5105 else
5106 session_entry->channelChangeReasonCode =
5107 LIM_SWITCH_CHANNEL_OPERATION;
5108
5109 lim_log(mac_ctx, LOGW, FL(
5110 "switch old chnl %d to new chnl %d, ch_bw %d"),
5111 session_entry->currentOperChannel,
5112 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005113 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005114
5115 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005116 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 session_entry->ch_center_freq_seg0 =
5118 ch_change_req->center_freq_seg_0;
5119 session_entry->ch_center_freq_seg1 =
5120 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005121 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005123 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005124 session_entry->htRecommendedTxWidthSet =
5125 session_entry->htSupportedChannelWidthSet;
5126 session_entry->currentOperChannel =
5127 ch_change_req->targetChannel;
5128 session_entry->limRFBand =
5129 lim_get_rf_band(session_entry->currentOperChannel);
5130 /* Initialize 11h Enable Flag */
5131 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5132 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5133 eSIR_SUCCESS)
5134 lim_log(mac_ctx, LOGP,
5135 FL("Fail to get WNI_CFG_11H_ENABLED"));
5136 }
5137
5138 session_entry->lim11hEnable = val;
5139 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305140 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141 &ch_change_req->operational_rateset,
5142 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305143 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 &ch_change_req->extended_rateset,
5145 sizeof(session_entry->extRateSet));
5146 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5147 session_entry->ch_center_freq_seg0,
5148 session_entry->ch_center_freq_seg1,
5149 session_entry->ch_width,
5150 max_tx_pwr, session_entry->peSessionId);
5151}
5152
5153/******************************************************************************
5154* lim_start_bss_update_add_ie_buffer()
5155*
5156***FUNCTION:
5157* This function checks the src buffer and its length and then malloc for
5158* dst buffer update the same
5159*
5160***LOGIC:
5161*
5162***ASSUMPTIONS:
5163*
5164***NOTE:
5165*
5166* @param pMac Pointer to Global MAC structure
5167* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5168* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5169* @param *pSrcData_buff A pointer of uint8_t src buffer
5170* @param srcDataLen src buffer length
5171******************************************************************************/
5172
5173static void
5174lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5175 uint8_t **pDstData_buff,
5176 uint16_t *pDstDataLen,
5177 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5178{
5179
5180 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5181 *pDstDataLen = srcDataLen;
5182
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305183 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184
5185 if (NULL == *pDstData_buff) {
5186 lim_log(pMac, LOGE,
5187 FL("AllocateMemory failed for pDstData_buff"));
5188 return;
5189 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305190 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005191 } else {
5192 *pDstData_buff = NULL;
5193 *pDstDataLen = 0;
5194 }
5195}
5196
5197/******************************************************************************
5198* lim_update_add_ie_buffer()
5199*
5200***FUNCTION:
5201* This function checks the src buffer and length if src buffer length more
5202* than dst buffer length then free the dst buffer and malloc for the new src
5203* length, and update the dst buffer and length. But if dst buffer is bigger
5204* than src buffer length then it just update the dst buffer and length
5205*
5206***LOGIC:
5207*
5208***ASSUMPTIONS:
5209*
5210***NOTE:
5211*
5212* @param pMac Pointer to Global MAC structure
5213* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5214* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5215* @param *pSrcData_buff A pointer of uint8_t src buffer
5216* @param srcDataLen src buffer length
5217******************************************************************************/
5218
5219static void
5220lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5221 uint8_t **pDstData_buff,
5222 uint16_t *pDstDataLen,
5223 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5224{
5225
5226 if (NULL == pSrcData_buff) {
5227 lim_log(pMac, LOGE, FL("src buffer is null."));
5228 return;
5229 }
5230
5231 if (srcDataLen > *pDstDataLen) {
5232 *pDstDataLen = srcDataLen;
5233 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305234 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005235 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305236 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237
5238 if (NULL == *pDstData_buff) {
5239 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5240 *pDstDataLen = 0;
5241 return;
5242 }
5243 }
5244
5245 /* copy the content of buffer into dst buffer
5246 */
5247 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305248 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249
5250}
5251
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005252/**
5253 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5254 * @pMac : Pointer to Global MAC structure
5255 * @pDstData_buff : A pointer to pointer of dst buffer
5256 * @pDstDataLen : A pointer to pointer of dst buffer length
5257 * @pModifyIE : A pointer to tSirModifyIE
5258 *
5259 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5260 *
5261 * Return:
5262 * True or false depending upon whether IE is updated or not
5263 */
5264static bool
5265lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5266 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5267{
5268 int32_t oui_length;
5269 uint8_t *ibss_ie = NULL;
5270
5271 ibss_ie = pModifyIE->pIEBuffer;
5272 oui_length = pModifyIE->oui_length;
5273
5274 if ((0 == oui_length) || (NULL == ibss_ie)) {
5275 PELOGE(lim_log(pMac, LOGE,
5276 FL("Invalid set IBSS vendor IE command length %d "),
5277 oui_length);)
5278 return false;
5279 }
5280
5281 lim_update_add_ie_buffer(pMac,
5282 pDstData_buff,
5283 pDstDataLen,
5284 pModifyIE->pIEBuffer,
5285 pModifyIE->ieBufferlength);
5286
5287 return true;
5288}
5289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290/*
5291* lim_process_modify_add_ies() - process modify additional IE req.
5292*
5293* @mac_ctx: Pointer to Global MAC structure
5294* @msg_buf: pointer to the SME message buffer
5295*
5296* This function update the PE buffers for additional IEs.
5297*
5298* Return: None
5299*/
5300static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5301 uint32_t *msg_buf)
5302{
5303 tpSirModifyIEsInd modify_add_ies;
5304 tpPESession session_entry;
5305 uint8_t session_id;
5306 bool ret = false;
5307 tSirAddIeParams *add_ie_params;
5308
5309 if (msg_buf == NULL) {
5310 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5311 return;
5312 }
5313
5314 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5315 /* Incoming message has smeSession, use BSSID to find PE session */
5316 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005317 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318
5319 if (NULL == session_entry) {
5320 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5321 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005322 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 goto end;
5324 }
5325 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5326 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5327 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5328 lim_log(mac_ctx, LOGE,
5329 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5330 modify_add_ies->modifyIE.pIEBuffer,
5331 modify_add_ies->modifyIE.ieBufferlength,
5332 modify_add_ies->modifyIE.ieID,
5333 modify_add_ies->modifyIE.ieIDLen,
5334 modify_add_ies->updateType);
5335 goto end;
5336 }
5337 add_ie_params = &session_entry->addIeParams;
5338 switch (modify_add_ies->updateType) {
5339 case eUPDATE_IE_PROBE_RESP:
5340 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005341 if (LIM_IS_IBSS_ROLE(session_entry)) {
5342 lim_update_ibss_prop_add_ies(mac_ctx,
5343 &add_ie_params->probeRespData_buff,
5344 &add_ie_params->probeRespDataLen,
5345 &modify_add_ies->modifyIE);
5346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 break;
5348 case eUPDATE_IE_ASSOC_RESP:
5349 /* assoc resp IE */
5350 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305351 QDF_TRACE(QDF_MODULE_ID_PE,
5352 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 "assoc resp add ie not present %d"),
5354 add_ie_params->assocRespDataLen);
5355 }
5356 /* search through the buffer and modify the IE */
5357 break;
5358 case eUPDATE_IE_PROBE_BCN:
5359 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005360 if (LIM_IS_IBSS_ROLE(session_entry)) {
5361 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5362 &add_ie_params->probeRespBCNData_buff,
5363 &add_ie_params->probeRespBCNDataLen,
5364 &modify_add_ies->modifyIE);
5365 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 if (ret == true && modify_add_ies->modifyIE.notify) {
5367 lim_handle_param_update(mac_ctx,
5368 modify_add_ies->updateType);
5369 }
5370 break;
5371 default:
5372 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5373 modify_add_ies->updateType);
5374 break;
5375 }
5376end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305377 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 modify_add_ies->modifyIE.pIEBuffer = NULL;
5379}
5380
5381/*
5382* lim_process_update_add_ies() - process additional IE update req
5383*
5384* @mac_ctx: Pointer to Global MAC structure
5385* @msg_buf: pointer to the SME message buffer
5386*
5387* This function update the PE buffers for additional IEs.
5388*
5389* Return: None
5390*/
5391static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5392 uint32_t *msg_buf)
5393{
5394 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5395 uint8_t session_id;
5396 tpPESession session_entry;
5397 tSirAddIeParams *addn_ie;
5398 uint16_t new_length = 0;
5399 uint8_t *new_ptr = NULL;
5400 tSirUpdateIE *update_ie;
5401
5402 if (msg_buf == NULL) {
5403 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5404 return;
5405 }
5406 update_ie = &update_add_ies->updateIE;
5407 /* incoming message has smeSession, use BSSID to find PE session */
5408 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005409 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410
5411 if (NULL == session_entry) {
5412 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5413 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005414 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 goto end;
5416 }
5417 addn_ie = &session_entry->addIeParams;
5418 /* if len is 0, upper layer requested freeing of buffer */
5419 if (0 == update_ie->ieBufferlength) {
5420 switch (update_add_ies->updateType) {
5421 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305422 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 addn_ie->probeRespData_buff = NULL;
5424 addn_ie->probeRespDataLen = 0;
5425 break;
5426 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305427 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 addn_ie->assocRespData_buff = NULL;
5429 addn_ie->assocRespDataLen = 0;
5430 break;
5431 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305432 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 addn_ie->probeRespBCNData_buff = NULL;
5434 addn_ie->probeRespBCNDataLen = 0;
5435
5436 if (update_ie->notify)
5437 lim_handle_param_update(mac_ctx,
5438 update_add_ies->updateType);
5439 break;
5440 default:
5441 break;
5442 }
5443 return;
5444 }
5445 switch (update_add_ies->updateType) {
5446 case eUPDATE_IE_PROBE_RESP:
5447 if (update_ie->append) {
5448 /*
5449 * In case of append, allocate new memory
5450 * with combined length
5451 */
5452 new_length = update_ie->ieBufferlength +
5453 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305454 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 if (NULL == new_ptr) {
5456 lim_log(mac_ctx, LOGE, FL(
5457 "Memory allocation failed."));
5458 goto end;
5459 }
5460 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305461 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305463 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 update_ie->pAdditionIEBuffer,
5465 update_ie->ieBufferlength);
5466 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305467 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 /* adjust length accordingly */
5469 addn_ie->probeRespDataLen = new_length;
5470 /* save refernece of local buffer in PE session */
5471 addn_ie->probeRespData_buff = new_ptr;
5472 goto end;
5473 }
5474 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5475 &addn_ie->probeRespDataLen,
5476 update_ie->pAdditionIEBuffer,
5477 update_ie->ieBufferlength);
5478 break;
5479 case eUPDATE_IE_ASSOC_RESP:
5480 /* assoc resp IE */
5481 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5482 &addn_ie->assocRespDataLen,
5483 update_ie->pAdditionIEBuffer,
5484 update_ie->ieBufferlength);
5485 break;
5486 case eUPDATE_IE_PROBE_BCN:
5487 /* probe resp Bcn IE */
5488 lim_update_add_ie_buffer(mac_ctx,
5489 &addn_ie->probeRespBCNData_buff,
5490 &addn_ie->probeRespBCNDataLen,
5491 update_ie->pAdditionIEBuffer,
5492 update_ie->ieBufferlength);
5493 if (update_ie->notify)
5494 lim_handle_param_update(mac_ctx,
5495 update_add_ies->updateType);
5496 break;
5497 default:
5498 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5499 update_add_ies->updateType);
5500 break;
5501 }
5502end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305503 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 update_ie->pAdditionIEBuffer = NULL;
5505}
5506
5507/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305508 * send_extended_chan_switch_action_frame()- function to send ECSA
5509 * action frame for each sta connected to SAP/GO and AP in case of
5510 * STA .
5511 * @mac_ctx: pointer to global mac structure
5512 * @new_channel: new channel to switch to.
5513 * @ch_bandwidth: BW of channel to calculate op_class
5514 * @session_entry: pe session
5515 *
5516 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5517 *
5518 * Return: void
5519 */
5520
5521static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5522 uint16_t new_channel, uint8_t ch_bandwidth,
5523 tpPESession session_entry)
5524{
5525 uint16_t op_class;
5526 uint8_t switch_mode = 0, i;
5527 tpDphHashNode psta;
5528
5529
5530 op_class = cds_regdm_get_opclass_from_channel(
5531 mac_ctx->scan.countryCodeCurrent,
5532 new_channel,
5533 ch_bandwidth);
5534
5535 if (LIM_IS_AP_ROLE(session_entry) &&
5536 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5537 switch_mode = 1;
5538
5539 if (LIM_IS_AP_ROLE(session_entry)) {
5540 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5541 psta =
5542 session_entry->dph.dphHashTable.pDphNodeArray + i;
5543 if (psta && psta->added)
5544 lim_send_extended_chan_switch_action_frame(
5545 mac_ctx,
5546 psta->staAddr,
5547 switch_mode, op_class, new_channel,
5548 LIM_MAX_CSA_IE_UPDATES, session_entry);
5549 }
5550 } else if (LIM_IS_STA_ROLE(session_entry)) {
5551 lim_send_extended_chan_switch_action_frame(mac_ctx,
5552 session_entry->bssId,
5553 switch_mode, op_class, new_channel,
5554 LIM_MAX_CSA_IE_UPDATES, session_entry);
5555 }
5556
5557}
5558
5559/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5561 *
5562 * @mac_ctx: Pointer to Global MAC structure
5563 * @msg_buf: pointer to the SME message buffer
5564 *
5565 * This function processes SME request messages from HDD or upper layer
5566 * application.
5567 *
5568 * Return: None
5569 */
5570static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5571 uint32_t *msg_buf)
5572{
5573 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5574 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 uint8_t session_id;
5576 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305577 offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578
5579 if (msg_buf == NULL) {
5580 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5581 return;
5582 }
5583
5584 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5585 session_entry = pe_find_session_by_bssid(mac_ctx,
5586 dfs_csa_ie_req->bssid, &session_id);
5587 if (session_entry == NULL) {
5588 lim_log(mac_ctx, LOGE, FL(
5589 "Session not found for given BSSID" MAC_ADDRESS_STR),
5590 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5591 return;
5592 }
5593
5594 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5595 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5596 GET_LIM_SYSTEM_ROLE(session_entry));
5597 return;
5598 }
5599
5600 /* target channel */
5601 session_entry->gLimChannelSwitch.primaryChannel =
5602 dfs_csa_ie_req->targetChannel;
5603
5604 /* Channel switch announcement needs to be included in beacon */
5605 session_entry->dfsIncludeChanSwIe = true;
5606 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5607 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005608 dfs_csa_ie_req->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5610 session_entry->gLimChannelSwitch.switchMode = 1;
5611
5612 /*
5613 * Validate if SAP is operating HT or VHT mode and set the Channel
5614 * Switch Wrapper element with the Wide Band Switch subelement.
5615 */
5616 if (true != session_entry->vhtCapability)
5617 goto skip_vht;
5618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 /* Now encode the Wider Ch BW element depending on the ch width */
5620 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005621 switch (dfs_csa_ie_req->ch_params.ch_width) {
5622 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 /*
5624 * Wide channel BW sublement in channel wrapper element is not
5625 * required in case of 20 Mhz operation. Currently It is set
5626 * only set in case of 40/80 Mhz Operation.
5627 */
5628 session_entry->dfsIncludeChanWrapperIe = false;
5629 wider_bw_ch_switch->newChanWidth =
5630 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5631 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005632 case CH_WIDTH_40MHZ:
5633 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 wider_bw_ch_switch->newChanWidth =
5635 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5636 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005637 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 session_entry->dfsIncludeChanWrapperIe = true;
5639 wider_bw_ch_switch->newChanWidth =
5640 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5641 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005642 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 session_entry->dfsIncludeChanWrapperIe = true;
5644 wider_bw_ch_switch->newChanWidth =
5645 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5646 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005647 case CH_WIDTH_80P80MHZ:
5648 session_entry->dfsIncludeChanWrapperIe = true;
5649 wider_bw_ch_switch->newChanWidth =
5650 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
5651 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 default:
5653 session_entry->dfsIncludeChanWrapperIe = false;
5654 /*
5655 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5656 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5657 */
5658 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5659 break;
5660 }
5661 /* Fetch the center channel based on the channel width */
5662 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005663 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 /*
5665 * This is not applicable for 20/40/80 Mhz.Only used when we support
5666 * 80+80 Mhz operation. In case of 80+80 Mhz, this parameter indicates
5667 * center channel frequency index of 80 Mhz channel of
5668 * frequency segment 1.
5669 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005670 wider_bw_ch_switch->newCenterChanFreq1 =
5671 dfs_csa_ie_req->ch_params.center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672skip_vht:
5673 /* Send CSA IE request from here */
5674 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5675 eSIR_SUCCESS) {
5676 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5677 return;
5678 }
5679
5680 /*
5681 * First beacon update request is sent here, the remaining updates are
5682 * done when the FW responds back after sending the first beacon after
5683 * the template update
5684 */
5685 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305686
5687 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5688 ch_offset = BW80;
5689 else
5690 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5691
5692 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5693 session_entry->gLimChannelSwitch.switchCount,
5694 session_entry->gLimChannelSwitch.primaryChannel,
5695 session_entry->gLimChannelSwitch.ch_width,
5696 session_entry->dfsIncludeChanWrapperIe,
5697 ch_offset);
5698
Abhishek Singh518323d2015-10-19 17:42:01 +05305699 /* Send ECSA Action frame after updating the beacon */
5700 send_extended_chan_switch_action_frame(mac_ctx,
5701 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305702 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 session_entry->gLimChannelSwitch.switchCount--;
5704}
5705
5706/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305707 * lim_process_ext_change_channel()- function to send ECSA
5708 * action frame for STA/CLI .
5709 * @mac_ctx: pointer to global mac structure
5710 * @msg: params from sme for new channel.
5711 *
5712 * This function is called to send ECSA frame for STA/CLI.
5713 *
5714 * Return: void
5715 */
5716
5717static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5718 uint32_t *msg)
5719{
5720 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5721 (struct sir_sme_ext_cng_chan_req *) msg;
5722 tpPESession session_entry = NULL;
5723
5724 if (NULL == msg) {
5725 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5726 return;
5727 }
5728 session_entry =
5729 pe_find_session_by_sme_session_id(mac_ctx,
5730 ext_chng_channel->session_id);
5731 if (NULL == session_entry) {
5732 lim_log(mac_ctx, LOGE,
5733 FL("Session not found for given session %d"),
5734 ext_chng_channel->session_id);
5735 return;
5736 }
5737 if (LIM_IS_AP_ROLE(session_entry)) {
5738 lim_log(mac_ctx, LOGE,
5739 FL("not an STA/CLI session"));
5740 return;
5741 }
5742 send_extended_chan_switch_action_frame(mac_ctx,
5743 ext_chng_channel->new_channel,
5744 0, session_entry);
5745}
5746
5747/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 * lim_process_nss_update_request() - process sme nss update req
5749 *
5750 * @mac_ctx: Pointer to Global MAC structure
5751 * @msg_buf: pointer to the SME message buffer
5752 *
5753 * This function processes SME request messages from HDD or upper layer
5754 * application.
5755 *
5756 * Return: None
5757 */
5758static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5759 uint32_t *msg_buf)
5760{
5761 struct sir_nss_update_request *nss_update_req_ptr;
5762 tpPESession session_entry = NULL;
5763
5764 if (msg_buf == NULL) {
5765 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5766 return;
5767 }
5768
5769 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305770 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 nss_update_req_ptr->vdev_id);
5772 if (session_entry == NULL) {
5773 lim_log(mac_ctx, LOGE, FL(
5774 "Session not found for given session_id %d"),
5775 nss_update_req_ptr->vdev_id);
5776 return;
5777 }
5778
5779 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5780 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5781 GET_LIM_SYSTEM_ROLE(session_entry));
5782 return;
5783 }
5784
5785 /* populate nss field in the beacon */
5786 session_entry->gLimOperatingMode.present = 1;
5787 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5788 /* Send nss update request from here */
5789 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5790 eSIR_SUCCESS) {
5791 lim_log(mac_ctx, LOGE,
5792 FL("Unable to set op mode IE in beacon"));
5793 return;
5794 }
5795
5796 lim_send_beacon_ind(mac_ctx, session_entry);
5797}
5798
5799/**
5800 * lim_process_set_ie_req() - process sme set IE request
5801 *
5802 * @mac_ctx: Pointer to Global MAC structure
5803 * @msg_buf: pointer to the SME message buffer
5804 *
5805 * This function processes SME request messages from HDD or upper layer
5806 * application.
5807 *
5808 * Return: None
5809 */
5810static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5811{
5812 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305813 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814
5815 if (msg_buf == NULL) {
5816 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5817 return;
5818 }
5819
5820 msg = (struct send_extcap_ie *)msg_buf;
5821 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305822 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5824
5825}