blob: d9291d2d3e3a01b1e1ec1bb4b27d82786473d58e [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);
109
110static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
111
112static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800114extern void pe_register_wma_handle(tpAniSirGlobal pMac,
115 tSirSmeReadyReq *ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116
Abhishek Singh518323d2015-10-19 17:42:01 +0530117static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
118 uint32_t *msg);
119
120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121/**
122 * lim_process_set_hw_mode() - Send set HW mode command to WMA
123 * @mac: Globacl MAC pointer
124 * @msg: Message containing the hw mode index
125 *
126 * Send the set HW mode command to WMA
127 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530128 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530130static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 cds_msg_t cds_message;
134 struct sir_hw_mode *req_msg;
135 uint32_t len;
136 struct s_sir_set_hw_mode *buf;
137 tSirMsgQ resp_msg;
138 struct sir_set_hw_mode_resp *param;
139
140 buf = (struct s_sir_set_hw_mode *) msg;
141 if (!buf) {
142 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
143 /* To free the active command list */
144 goto fail;
145 }
146
147 len = sizeof(*req_msg);
148
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530149 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530151 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 /* Free the active command list
153 * Probably the malloc is going to fail there as well?!
154 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530155 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 }
157
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159
160 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530161 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 /* Other parameters are not needed for WMA */
163
164 cds_message.bodyptr = req_msg;
165 cds_message.type = SIR_HAL_SOC_SET_HW_MODE;
166
167 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
168 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530169 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 lim_log(mac, LOGE,
171 FL("vos_mq_post_message failed!(err=%d)"),
172 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 goto fail;
175 }
176 return status;
177fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530178 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 if (!param) {
180 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530181 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 }
183 param->status = SET_HW_MODE_STATUS_ECANCELED;
184 param->cfgd_hw_mode_index = 0;
185 param->num_vdev_mac_entries = 0;
186 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
187 resp_msg.bodyptr = param;
188 resp_msg.bodyval = 0;
189 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530190 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191}
192
193/**
194 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
195 * @mac: Global MAC pointer
196 * @msg: Message containing the dual mac config parameter
197 *
198 * Send the set dual mac config command to WMA
199 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 uint32_t *msg)
204{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 cds_msg_t cds_message;
207 struct sir_dual_mac_config *req_msg;
208 uint32_t len;
209 struct sir_set_dual_mac_cfg *buf;
210 tSirMsgQ resp_msg;
211 struct sir_dual_mac_config_resp *param;
212
213 buf = (struct sir_set_dual_mac_cfg *) msg;
214 if (!buf) {
215 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
216 /* To free the active command list */
217 goto fail;
218 }
219
220 len = sizeof(*req_msg);
221
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530222 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 if (!req_msg) {
224 lim_log(mac, LOGE, FL("vos_mem_malloc failed"));
225 /* Free the active command list
226 * Probably the malloc is going to fail there as well?!
227 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530228 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 }
230
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530231 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232
233 req_msg->scan_config = buf->set_dual_mac.scan_config;
234 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
235 /* Other parameters are not needed for WMA */
236
237 cds_message.bodyptr = req_msg;
238 cds_message.type = SIR_HAL_SOC_DUAL_MAC_CFG_REQ;
239
240 lim_log(mac, LOG1,
241 FL("Post SIR_HAL_SOC_DUAL_MAC_CFG_REQ to WMA: %x %x"),
242 req_msg->scan_config, req_msg->fw_mode_config);
243 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 lim_log(mac, LOGE,
246 FL("vos_mq_post_message failed!(err=%d)"),
247 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530248 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 goto fail;
250 }
251 return status;
252fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530253 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 if (!param) {
255 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530256 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 }
258 param->status = SET_HW_MODE_STATUS_ECANCELED;
259 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
260 resp_msg.bodyptr = param;
261 resp_msg.bodyval = 0;
262 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530263 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264}
265
266/**
267 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
268 * @mac_ctx: Pointer to Global MAC structure
269 * @return_fresh_results: Trigger fresh scan.
270 *
271 * PE will do fresh scan, if all of the active sessions are in
272 * good state (Link Est or BSS Started). If one of the sessions
273 * is not in one of the above states, then PE does not do fresh
274 * scan. If no session exists (scanning very first time),
275 * then PE will always do fresh scan if SME asks it to do that.
276 *
277 * Return: true for fresh scan results, false if in invalid state.
278 */
279static uint8_t
280__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
281{
282 uint8_t valid_state = true;
283 int i;
284
285 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
286 mac_ctx->lim.gLimSmeState, return_fresh_results);
287
288 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
289 lim_log(mac_ctx, LOG1, FL("return FALSE"));
290 return false;
291 }
292
293 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
294 lim_log(mac_ctx, LOG1,
295 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
296 i, mac_ctx->lim.gpSession[i].bssType,
297 mac_ctx->lim.gpSession[i].limSystemRole,
298 mac_ctx->lim.gpSession[i].limSmeState);
299 if (mac_ctx->lim.gpSession[i].valid == true) {
300 if (!((((mac_ctx->lim.gpSession[i].bssType ==
301 eSIR_INFRASTRUCTURE_MODE) ||
302 (mac_ctx->lim.gpSession[i].limSystemRole ==
303 eLIM_BT_AMP_STA_ROLE)) &&
304 (mac_ctx->lim.gpSession[i].limSmeState ==
305 eLIM_SME_LINK_EST_STATE)) ||
306 (((mac_ctx->lim.gpSession[i].bssType ==
307 eSIR_IBSS_MODE) ||
308 (mac_ctx->lim.gpSession[i].limSystemRole ==
309 eLIM_BT_AMP_AP_ROLE) ||
310 (mac_ctx->lim.gpSession[i].limSystemRole ==
311 eLIM_BT_AMP_STA_ROLE)) &&
312 (mac_ctx->lim.gpSession[i].limSmeState ==
313 eLIM_SME_NORMAL_STATE)) ||
314 ((((mac_ctx->lim.gpSession[i].bssType ==
315 eSIR_INFRA_AP_MODE) &&
316 (mac_ctx->lim.gpSession[i].pePersona ==
Anurag Chouhan6d760662016-02-20 16:05:43 +0530317 QDF_P2P_GO_MODE)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318 (mac_ctx->lim.gpSession[i].limSystemRole ==
319 eLIM_AP_ROLE)) &&
320 (mac_ctx->lim.gpSession[i].limSmeState ==
321 eLIM_SME_NORMAL_STATE)))) {
322 valid_state = false;
323 break;
324 }
325 }
326 }
327
328 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
329
330 if ((valid_state) &&
331 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
332 return true;
333 else
334 return false;
335}
336
337/**
338 * __lim_is_sme_assoc_cnf_valid()
339 *
340 ***FUNCTION:
341 * This function is called by __lim_process_sme_assoc_cnf_new() upon
342 * receiving SME_ASSOC_CNF.
343 *
344 ***LOGIC:
345 * Message validity checks are performed in this function
346 *
347 ***ASSUMPTIONS:
348 *
349 ***NOTE:
350 *
351 * @param pMeasReq Pointer to Received ASSOC_CNF message
352 * @return true When received SME_ASSOC_CNF is formatted
353 * correctly
354 * false otherwise
355 */
356
357static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
358{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530359 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 return false;
361 else
362 return true;
363} /*** end __lim_is_sme_assoc_cnf_valid() ***/
364
365/**
366 * __lim_get_sme_join_req_size_for_alloc()
367 *
368 ***FUNCTION:
369 * This function is called in various places to get IE length
370 * from tSirBssDescription structure
371 * number being scanned.
372 *
373 ***PARAMS:
374 *
375 ***LOGIC:
376 *
377 ***ASSUMPTIONS:
378 * NA
379 *
380 ***NOTE:
381 * NA
382 *
383 * @param pBssDescr
384 * @return Total IE length
385 */
386
387static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
388{
389 uint16_t len = 0;
390
391 if (!pBuf)
392 return len;
393
394 pBuf += sizeof(uint16_t);
395 len = lim_get_u16(pBuf);
396 return len + sizeof(uint16_t);
397}
398
399/**
400 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
401 * @pMac: Global MAC context
402 * @pMsg: Pointer to message posted from SME to LIM.
403 *
404 * Has role only if 11h is enabled. Not used on STA side.
405 * Defers the message if SME is in learn state and brings
406 * the LIM back to normal mode.
407 *
408 * Return: true - If defered false - Otherwise
409 */
410
411static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
412{
413 if (lim_is_system_in_scan_state(pMac)) {
414 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
415 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
416 pMsg->type);
417 return false;
418 }
419 lim_log(pMac, LOG1,
420 FL("Defer the message, in learn mode type = %d"),
421 pMsg->type);
422 return true;
423 }
424 return false;
425}
426
427/**
428 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
429 * @mac_ctx: Pointer to Global MAC structure
430 * @message: Pointer to message posted from SME to LIM.
431 *
432 * Has role only if 11h is enabled. Not used on STA side.
433 * Defers the message if radar is detected.
434 *
435 * Return: true, if defered otherwise return false.
436 */
437static bool
438__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
439{
440 /*
441 * fRadarDetCurOperChan will be set only if we
442 * detect radar in current operating channel and
443 * System Role == AP ROLE
444 *
445 * TODO: Need to take care radar detection.
446 *
447 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
448 */
449 if (0) {
450 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
451 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
452 message->type);
453 return false;
454 }
455 lim_log(mac_ctx, LOG1,
456 FL("Defer the message, in learn mode type = %d"),
457 message->type);
458 return true;
459 }
460 return false;
461}
462
463/**
464 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
465 * @pMac: Global MAC context
466 * @pMsgBuf: Message from WMA
467 *
468 * handles the notification from HDD. PE just forwards this message to HAL.
469 *
470 * Return: true-Posting to HAL failed, so PE will consume the buffer.
471 * false-Posting to HAL successful, so HAL will consume the buffer.
472 */
473
474static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
475{
476 tSirMsgQ msg;
477 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
478
479 msg.type = WMA_SYS_READY_IND;
480 msg.reserved = 0;
481 msg.bodyptr = pMsgBuf;
482 msg.bodyval = 0;
483
484 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800485 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
486 pe_register_wma_handle(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
488 }
489 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
490 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
491
492 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
493 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
494 return true;
495 }
496 return false;
497}
498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499/**
500 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
501 *@mac_ctx: Pointer to Global MAC structure
502 *@session: A pointer to session entry
503 *@sme_start_bss_req: Start BSS Request from upper layers.
504 *
505 * This function is used to configure the start bss parameters
506 * in to the session.
507 *
508 * Return: None.
509 */
510static void
511lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
512 tpSirSmeStartBssReq sme_start_bss_req)
513{
514 session->limSystemRole = eLIM_AP_ROLE;
515 session->privacy = sme_start_bss_req->privacy;
516 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
517 session->authType = sme_start_bss_req->authType;
518 /* Store the DTIM period */
519 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
520 /* Enable/disable UAPSD */
521 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530522 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 session->proxyProbeRspEn = 0;
524 } else {
525 /*
526 * To detect PBC overlap in SAP WPS mode,
527 * Host handles Probe Requests.
528 */
529 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
530 session->proxyProbeRspEn = 1;
531 else
532 session->proxyProbeRspEn = 0;
533 }
534 session->ssidHidden = sme_start_bss_req->ssidHidden;
535 session->wps_state = sme_start_bss_req->wps_state;
536 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
537 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
538 &session->shortSlotTimeSupported);
539 session->isCoalesingInIBSSAllowed =
540 sme_start_bss_req->isCoalesingInIBSSAllowed;
541
542}
543
544/**
545 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
546 *@mac_ctx: Pointer to Global MAC structure
547 *@msg_buf: A pointer to the SME message buffer
548 *
549 * This function is called to process SME_START_BSS_REQ message
550 * from HDD or upper layer application.
551 *
552 * Return: None
553 */
554static void
555__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
556{
557 uint16_t size;
558 uint32_t val = 0;
559 tSirRetStatus ret_status;
560 tSirMacChanNum channel_number;
561 tLimMlmStartReq *mlm_start_req = NULL;
562 tpSirSmeStartBssReq sme_start_bss_req = NULL;
563 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
564 /* Flag Used in case of IBSS to Auto generate BSSID. */
565 uint32_t auto_gen_bssid = false;
566 uint8_t session_id;
567 tpPESession session = NULL;
568 uint8_t sme_session_id = 0;
569 uint16_t sme_transaction_id = 0;
570 uint32_t chanwidth;
571 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
572
573/* FEATURE_WLAN_DIAG_SUPPORT */
574#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
575 /*
576 * Since the session is not created yet, sending NULL.
577 * The response should have the correct state.
578 */
579 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
580 NULL, 0, 0);
581#endif /* FEATURE_WLAN_DIAG_SUPPORT */
582
583 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
584
585 /*
586 * Global Sme state and mlm states are not defined yet,
587 * for BT-AMP Suppoprt . TO BE DONE
588 */
589 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
590 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
591 size = sizeof(tSirSmeStartBssReq);
592
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530593 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 if (NULL == sme_start_bss_req) {
595 lim_log(mac_ctx, LOGE,
596 FL("Allocate Memory fail for LimStartBssReq"));
597 /* Send failure response to host */
598 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
599 goto end;
600 }
601
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530602 qdf_mem_set((void *)sme_start_bss_req, size, 0);
603 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 sizeof(tSirSmeStartBssReq));
605 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
606 sme_start_bss_req)) {
607 lim_log(mac_ctx, LOGW,
608 FL("Received invalid eWNI_SME_START_BSS_REQ"));
609 ret_code = eSIR_SME_INVALID_PARAMETERS;
610 goto free;
611 }
612
613 /*
614 * This is the place where PE is going to create a session.
615 * If session is not existed, then create a new session
616 */
617 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800618 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 if (session != NULL) {
620 lim_log(mac_ctx, LOGW,
621 FL("Session Already exists for given BSSID"));
622 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
623 session = NULL;
624 goto free;
625 } else {
626 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800627 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628 &session_id, mac_ctx->lim.maxStation,
629 sme_start_bss_req->bssType);
630 if (session == NULL) {
631 lim_log(mac_ctx, LOGW,
632 FL("Session Can not be created "));
633 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
634 goto free;
635 }
636 }
637
638 /* Probe resp add ie */
639 lim_start_bss_update_add_ie_buffer(mac_ctx,
640 &session->addIeParams.probeRespData_buff,
641 &session->addIeParams.probeRespDataLen,
642 sme_start_bss_req->addIeParams.probeRespData_buff,
643 sme_start_bss_req->addIeParams.probeRespDataLen);
644
645 /* Probe Beacon add ie */
646 lim_start_bss_update_add_ie_buffer(mac_ctx,
647 &session->addIeParams.probeRespBCNData_buff,
648 &session->addIeParams.probeRespBCNDataLen,
649 sme_start_bss_req->addIeParams.probeRespBCNData_buff,
650 sme_start_bss_req->addIeParams.probeRespBCNDataLen);
651
652 /* Assoc resp IE */
653 lim_start_bss_update_add_ie_buffer(mac_ctx,
654 &session->addIeParams.assocRespData_buff,
655 &session->addIeParams.assocRespDataLen,
656 sme_start_bss_req->addIeParams.assocRespData_buff,
657 sme_start_bss_req->addIeParams.assocRespDataLen);
658
659 /* Store the session related params in newly created session */
660 session->pLimStartBssReq = sme_start_bss_req;
661
662 /* Store PE session_id in session Table */
663 session->peSessionId = session_id;
664
665 /* Store SME session Id in sessionTable */
666 session->smeSessionId = sme_start_bss_req->sessionId;
667
668 session->transactionId = sme_start_bss_req->transactionId;
669
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530670 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 &(sme_start_bss_req->htConfig),
672 sizeof(session->htConfig));
673
674 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800675 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676
677 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530678 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 (uint8_t *) &sme_start_bss_req->ssId,
680 (sme_start_bss_req->ssId.length + 1));
681
682 session->bssType = sme_start_bss_req->bssType;
683
684 session->nwType = sme_start_bss_req->nwType;
685
686 session->beaconParams.beaconInterval =
687 sme_start_bss_req->beaconInterval;
688
689 /* Store the channel number in session Table */
690 session->currentOperChannel =
691 sme_start_bss_req->channelId;
692
693 /* Store Persona */
694 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530695 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 FL("PE PERSONA=%d"), session->pePersona);
697
698 /* Update the phymode */
699 session->gLimPhyMode = sme_start_bss_req->nwType;
700
701 session->maxTxPower =
702 cfg_get_regulatory_max_transmit_power(mac_ctx,
703 session->currentOperChannel);
704 /* Store the dot 11 mode in to the session Table */
705 session->dot11mode = sme_start_bss_req->dot11mode;
706#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
707 session->cc_switch_mode =
708 sme_start_bss_req->cc_switch_mode;
709#endif
710 session->htCapability =
711 IS_DOT11_MODE_HT(session->dot11mode);
712 session->vhtCapability =
713 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530714 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800715 FL("*****session->vhtCapability = %d"),
716 session->vhtCapability);
717 session->txLdpcIniFeatureEnabled =
718 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719 if (mac_ctx->roam.configParam.enable2x2)
720 session->nss = 2;
721 else
722 session->nss = 1;
723#ifdef WLAN_FEATURE_11W
724 session->limRmfEnabled =
725 sme_start_bss_req->pmfCapable ? 1 : 0;
726 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
727 session->limRmfEnabled);
728#endif
729
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530730 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 (void *)&sme_start_bss_req->operationalRateSet,
732 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530733 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 (void *)&sme_start_bss_req->extendedRateSet,
735 sizeof(tSirMacRateSet));
736
737 switch (sme_start_bss_req->bssType) {
738 case eSIR_INFRA_AP_MODE:
739 lim_configure_ap_start_bss_session(mac_ctx, session,
740 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530741 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800742 session->txBFIniFeatureEnabled =
743 sme_start_bss_req->txbf_ini_enabled;
744 session->txbf_csn_value =
745 sme_start_bss_req->txbf_csn_val;
746 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 break;
748 case eSIR_IBSS_MODE:
749 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
750 lim_get_short_slot_from_phy_mode(mac_ctx, session,
751 session->gLimPhyMode,
752 &session->shortSlotTimeSupported);
753
754 /*
755 * initialize to "OPEN".
756 * will be updated upon key installation
757 */
758 session->encryptType = eSIR_ED_NONE;
759
760 break;
761
762 case eSIR_BTAMP_AP_MODE:
763 session->limSystemRole = eLIM_BT_AMP_AP_ROLE;
764 break;
765
766 case eSIR_BTAMP_STA_MODE:
767 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
768 break;
769
770 /*
771 * There is one more mode called auto mode.
772 * which is used no where
773 */
774
775 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
776
777 default:
778 /* not used anywhere...used in scan function */
779 break;
780 }
781
782 /*
783 * BT-AMP: Allocate memory for the array of
784 * parsed (Re)Assoc request structure
785 */
786 if ((sme_start_bss_req->bssType == eSIR_BTAMP_AP_MODE) ||
787 (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE)) {
788 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530789 qdf_mem_malloc(session->dph.dphHashTable.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 size * sizeof(tpSirAssocReq));
791 if (NULL == session->parsedAssocReq) {
792 lim_log(mac_ctx, LOGW,
793 FL("AllocateMemory() failed"));
794 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
795 goto free;
796 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530797 qdf_mem_set(session->parsedAssocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 (session->dph.dphHashTable.size *
799 sizeof(tpSirAssocReq)), 0);
800 }
801
802 if (!sme_start_bss_req->channelId) {
803 lim_log(mac_ctx, LOGE,
804 FL("Received invalid eWNI_SME_START_BSS_REQ"));
805 ret_code = eSIR_SME_INVALID_PARAMETERS;
806 goto free;
807 }
808 channel_number = sme_start_bss_req->channelId;
809#ifdef QCA_HT_2040_COEX
810 if (sme_start_bss_req->obssEnabled)
811 session->htSupportedChannelWidthSet =
812 session->htCapability;
813 else
814#endif
815 session->htSupportedChannelWidthSet =
816 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
817 session->htSecondaryChannelOffset =
818 sme_start_bss_req->sec_ch_offset;
819 session->htRecommendedTxWidthSet =
820 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530821 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 FL("cbMode %u"), sme_start_bss_req->cbMode);
823 if (session->vhtCapability || session->htCapability) {
824 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800825 lim_log(mac_ctx, LOG1,
826 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
827 sme_start_bss_req->vht_channel_width,
828 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 session->ch_width = chanwidth;
830 if (session->htSupportedChannelWidthSet) {
831 session->ch_center_freq_seg0 =
832 sme_start_bss_req->center_freq_seg0;
833 session->ch_center_freq_seg1 =
834 sme_start_bss_req->center_freq_seg1;
835 } else {
836 session->ch_center_freq_seg0 = 0;
837 session->ch_center_freq_seg1 = 0;
838 }
839 }
840
841 if (session->vhtCapability &&
842 (CH_WIDTH_160MHZ > session->ch_width)) {
843 if (wlan_cfg_get_int(mac_ctx,
844 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
845 eSIR_SUCCESS)
846 lim_log(mac_ctx, LOGE, FL(
847 "cfg get vht su bformer failed"));
848
849 session->enable_su_tx_bformer = val;
850 } else {
851 session->nss = 1;
852 }
853 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
854
855 /* Delete pre-auth list if any */
856 lim_delete_pre_auth_list(mac_ctx);
857
858 /*
859 * keep the RSN/WPA IE information in PE Session Entry
860 * later will be using this to check when received (Re)Assoc req
861 */
862 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
863 &sme_start_bss_req->rsnIE, session);
864
865 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
866 session->gLimProtectionControl =
867 sme_start_bss_req->protEnabled;
868 /*
869 * each byte will have the following info
870 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
871 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
872 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530873 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 (void *)&sme_start_bss_req->ht_capab,
875 sizeof(uint16_t));
876 /* Initialize WPS PBC session link list */
877 session->pAPWPSPBCSession = NULL;
878 }
879 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530880 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 if (NULL == mlm_start_req) {
882 lim_log(mac_ctx, LOGP,
883 FL("Allocate Memory failed for mlmStartReq"));
884 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
885 goto free;
886 }
887
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530888 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889
890 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530891 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 (uint8_t *) &sme_start_bss_req->ssId,
893 sme_start_bss_req->ssId.length + 1);
894 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
895 mlm_start_req->obssProtEnabled =
896 sme_start_bss_req->obssProtEnabled;
897
898 mlm_start_req->bssType = session->bssType;
899
900 /* Fill PE session Id from the session Table */
901 mlm_start_req->sessionId = session->peSessionId;
902
903 if ((mlm_start_req->bssType == eSIR_BTAMP_STA_MODE) ||
904 (mlm_start_req->bssType == eSIR_BTAMP_AP_MODE) ||
905 (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)) {
906 /*
907 * Copy the BSSId from sessionTable to
908 * mlmStartReq struct
909 */
910 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
911 } else {
912 /* ibss mode */
913 mac_ctx->lim.gLimIbssCoalescingHappened = false;
914
915 ret_status = wlan_cfg_get_int(mac_ctx,
916 WNI_CFG_IBSS_AUTO_BSSID,
917 &auto_gen_bssid);
918 if (ret_status != eSIR_SUCCESS) {
919 lim_log(mac_ctx, LOGP,
920 FL("Get Auto Gen BSSID fail,Status=%d"),
921 ret_status);
922 ret_code = eSIR_LOGP_EXCEPTION;
923 goto free;
924 }
925
926 if (!auto_gen_bssid) {
927 /*
928 * We're not auto generating BSSID.
929 * Instead, get it from session entry
930 */
931 sir_copy_mac_addr(mlm_start_req->bssId,
932 session->bssId);
933 /*
934 * Start IBSS group BSSID
935 * Auto Generating BSSID.
936 */
937 auto_gen_bssid = ((mlm_start_req->bssId[0] &
938 0x01) ? true : false);
939 }
940
941 if (auto_gen_bssid) {
942 /*
943 * if BSSID is not any uc id.
944 * then use locally generated BSSID.
945 * Autogenerate the BSSID
946 */
947 lim_get_random_bssid(mac_ctx,
948 mlm_start_req->bssId);
949 mlm_start_req->bssId[0] = 0x02;
950
951 /*
952 * Copy randomly generated BSSID
953 * to the session Table
954 */
955 sir_copy_mac_addr(session->bssId,
956 mlm_start_req->bssId);
957 }
958 }
959 /* store the channel num in mlmstart req structure */
960 mlm_start_req->channelNumber = session->currentOperChannel;
961 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
962 mlm_start_req->beaconPeriod =
963 session->beaconParams.beaconInterval;
964
965 if (LIM_IS_AP_ROLE(session)) {
966 mlm_start_req->dtimPeriod = session->dtimPeriod;
967 mlm_start_req->wps_state = session->wps_state;
968
969 } else {
970 if (wlan_cfg_get_int(mac_ctx,
971 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
972 lim_log(mac_ctx, LOGP,
973 FL("could not retrieve DTIM Period"));
974 mlm_start_req->dtimPeriod = (uint8_t) val;
975 }
976
977 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
978 eSIR_SUCCESS)
979 lim_log(mac_ctx, LOGP,
980 FL("could not retrieve Beacon interval"));
981 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
982
983 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
984 eSIR_SUCCESS)
985 lim_log(mac_ctx, LOGP,
986 FL("could not retrieve CFPMaxDuration"));
987 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
988
989 /*
990 * this may not be needed anymore now,
991 * as rateSet is now included in the
992 * session entry and MLM has session context.
993 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530994 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 (void *)&session->rateSet,
996 sizeof(tSirMacRateSet));
997
998 /* Now populate the 11n related parameters */
999 mlm_start_req->nwType = session->nwType;
1000 mlm_start_req->htCapable = session->htCapability;
1001
1002 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1003 /* Unused */
1004 mlm_start_req->dualCTSProtection =
1005 mac_ctx->lim.gHTDualCTSProtection;
1006 mlm_start_req->txChannelWidthSet =
1007 session->htRecommendedTxWidthSet;
1008
1009 session->limRFBand = lim_get_rf_band(channel_number);
1010
1011 /* Initialize 11h Enable Flag */
1012 session->lim11hEnable = 0;
1013 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1014 (SIR_BAND_5_GHZ == session->limRFBand)) {
1015 if (wlan_cfg_get_int(mac_ctx,
1016 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1017 lim_log(mac_ctx, LOGP,
1018 FL("Fail to get WNI_CFG_11H_ENABLED "));
1019 else
1020 session->lim11hEnable = val;
1021
1022 if (session->lim11hEnable &&
1023 (eSIR_INFRA_AP_MODE ==
1024 mlm_start_req->bssType)) {
1025 cfg_get_wmi_dfs_master_param =
1026 wlan_cfg_get_int(mac_ctx,
1027 WNI_CFG_DFS_MASTER_ENABLED,
1028 &val);
1029 session->lim11hEnable = val;
1030 }
1031 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1032 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1033 lim_log(mac_ctx, LOGE,
1034 FL("Get Fail, CFG DFS ENABLE"));
1035 }
1036
1037 if (!session->lim11hEnable) {
1038 if (cfg_set_int(mac_ctx,
1039 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1040 eSIR_SUCCESS)
1041 /*
1042 * Failed to set the CFG param
1043 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1044 */
1045 lim_log(mac_ctx, LOGE,
1046 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1047 }
1048
1049 session->limPrevSmeState = session->limSmeState;
1050 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1051 MTRACE(mac_trace
1052 (mac_ctx, TRACE_CODE_SME_STATE,
1053 session->peSessionId,
1054 session->limSmeState));
1055
1056 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1057 (uint32_t *) mlm_start_req);
1058 return;
1059 } else {
1060
1061 lim_log(mac_ctx, LOGE,
1062 FL("Received unexpected START_BSS_REQ, in state %X"),
1063 mac_ctx->lim.gLimSmeState);
1064 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1065 goto end;
1066 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1067
1068free:
1069 if ((session != NULL) &&
1070 (session->pLimStartBssReq == sme_start_bss_req)) {
1071 session->pLimStartBssReq = NULL;
1072 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301073 qdf_mem_free(sme_start_bss_req);
1074 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075
1076end:
1077 if (sme_start_bss_req != NULL) {
1078 sme_session_id = sme_start_bss_req->sessionId;
1079 sme_transaction_id = sme_start_bss_req->transactionId;
1080 }
1081 if (NULL != session) {
1082 pe_delete_session(mac_ctx, session);
1083 session = NULL;
1084 }
1085 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1086 session, sme_session_id, sme_transaction_id);
1087}
1088
1089/**
1090 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1091 *
1092 * @pMac: Global MAC context
1093 * @pMsg: Message pointer
1094 *
1095 * Wrapper for the function __lim_handle_sme_start_bss_request
1096 * This message will be defered until softmac come out of
1097 * scan mode or if we have detected radar on the current
1098 * operating channel.
1099 *
1100 * return true - If we consumed the buffer
1101 * false - If have defered the message.
1102 */
1103static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1104{
1105 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1106 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1107 /**
1108 * If message defered, buffer is not consumed yet.
1109 * So return false
1110 */
1111 return false;
1112 }
1113
1114 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1115 return true;
1116}
1117
1118/**
1119 * lim_get_random_bssid()
1120 *
1121 * FUNCTION:This function is called to process generate the random number for bssid
1122 * This function is called to process SME_SCAN_REQ message
1123 * from HDD or upper layer application.
1124 *
1125 * LOGIC:
1126 *
1127 * ASSUMPTIONS:
1128 *
1129 * NOTE:
1130 * 1. geneartes the unique random number for bssid in ibss
1131 *
1132 * @param pMac Pointer to Global MAC structure
1133 * @param *data Pointer to bssid buffer
1134 * @return None
1135 */
1136void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1137{
1138 uint32_t random[2];
1139 random[0] = tx_time_get();
1140 random[0] |= (random[0] << 15);
1141 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301142 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143}
1144
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301145static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146 tpSirSmeScanReq pScanReq)
1147{
1148 tSirScanOffloadReq *pScanOffloadReq;
1149 uint8_t *p;
1150 uint8_t *ht_cap_ie;
1151 tSirMsgQ msg;
1152 uint16_t i, len;
1153 uint16_t ht_cap_len = 0, addn_ie_len = 0;
1154#ifdef WLAN_FEATURE_11AC
1155 uint8_t *vht_cap_ie;
1156 uint16_t vht_cap_len = 0;
1157#endif /* WLAN_FEATURE_11AC */
1158 tSirRetStatus status, rc = eSIR_SUCCESS;
1159 tDot11fIEExtCap extracted_extcap = {0};
1160 bool extcap_present = true;
1161
1162 if (pScanReq->uIEFieldLen) {
1163 status = lim_strip_extcap_update_struct(pMac,
1164 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1165 &pScanReq->uIEFieldLen, &extracted_extcap);
1166
1167 if (eSIR_SUCCESS != status) {
1168 extcap_present = false;
1169 lim_log(pMac, LOG1,
1170 FL("Unable to Strip ExtCap IE from Scan Req"));
1171 }
1172
1173 if (extcap_present) {
1174 lim_log(pMac, LOG1,
1175 FL("Extcap was part of SCAN IE - Updating FW"));
1176 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1177 &extracted_extcap, true);
1178 }
1179 } else {
1180 lim_log(pMac, LOG1,
1181 FL("No IEs in the scan request from supplicant"));
1182 }
1183
1184 /**
1185 * The tSirScanOffloadReq will reserve the space for first channel,
1186 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1187 */
1188 len = sizeof(tSirScanOffloadReq) +
1189 (pScanReq->channelList.numChannels - 1) + pScanReq->uIEFieldLen;
1190
1191 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1192 lim_log(pMac, LOG1,
1193 FL("Adding HT Caps IE since dot11mode=%d"),
1194 pScanReq->dot11mode);
1195 /* 2 bytes for EID and Length */
1196 ht_cap_len = 2 + sizeof(tHtCaps);
1197 len += ht_cap_len;
1198 addn_ie_len += ht_cap_len;
1199 }
1200
1201#ifdef WLAN_FEATURE_11AC
1202 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1203 lim_log(pMac, LOG1,
1204 FL("Adding VHT Caps IE since dot11mode=%d"),
1205 pScanReq->dot11mode);
1206 /* 2 bytes for EID and Length */
1207 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1208 sizeof(tSirVhtMcsInfo);
1209 len += vht_cap_len;
1210 addn_ie_len += vht_cap_len;
1211 }
1212#endif /* WLAN_FEATURE_11AC */
1213
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301214 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 if (NULL == pScanOffloadReq) {
1216 lim_log(pMac, LOGE,
1217 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301218 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 }
1220
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301221 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222
1223 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1224 msg.bodyptr = pScanOffloadReq;
1225 msg.bodyval = 0;
1226
Anurag Chouhanc5548422016-02-24 18:33:27 +05301227 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228
1229 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1230 lim_log(pMac, LOGE,
1231 FL("Invalid value (%d) for numSsid"),
1232 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301233 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301234 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 }
1236
1237 pScanOffloadReq->numSsid = pScanReq->numSsid;
1238 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1239 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301240 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 (uint8_t *) pScanReq->ssId[i].ssId,
1242 pScanOffloadReq->ssId[i].length);
1243 }
1244
1245 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301246 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 pScanOffloadReq->bssType = pScanReq->bssType;
1248 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1249 pScanOffloadReq->scanType = pScanReq->scanType;
1250 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1251 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1252 pScanOffloadReq->restTime = pScanReq->restTime;
1253
1254 /* for normal scan, the value for p2pScanType should be 0
1255 always */
1256 if (pScanReq->p2pSearch)
1257 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1258
1259 pScanOffloadReq->sessionId = pScanReq->sessionId;
1260 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001261 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262
1263 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1264 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1265 pScanOffloadReq->sessionId);
1266
1267 pScanOffloadReq->channelList.numChannels =
1268 pScanReq->channelList.numChannels;
1269 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1270 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1271 p[i] = pScanReq->channelList.channelNumber[i];
1272
1273 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1274 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1275 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301276 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 pScanOffloadReq->uIEFieldOffset,
1278 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1279 pScanReq->uIEFieldLen);
1280
1281 /* Copy HT Capability info if dot11mode is HT */
1282 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1283 /* Populate EID and Length field here */
1284 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1285 pScanOffloadReq->uIEFieldOffset +
1286 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1289 *(ht_cap_ie + 1) = ht_cap_len - 2;
1290 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1291 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1292 }
1293
1294#ifdef WLAN_FEATURE_11AC
1295 /* Copy VHT Capability info if dot11mode is VHT Capable */
1296 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1297 /* Populate EID and Length field here */
1298 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1299 pScanOffloadReq->uIEFieldOffset +
1300 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301301 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1303 *(vht_cap_ie + 1) = vht_cap_len - 2;
1304 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1305 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1306 }
1307#endif /* WLAN_FEATURE_11AC */
1308
1309 rc = wma_post_ctrl_msg(pMac, &msg);
1310 if (rc != eSIR_SUCCESS) {
1311 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301312 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301313 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 }
1315
1316 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301318 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319}
1320
1321/**
1322 * __lim_process_sme_scan_req() - Process the SME Scan Request
1323 * @mac_ctx: Global MAC Context
1324 * @msg_buf: Buffer which contains the request and pertinent parameters
1325 *
1326 * This function is called to process SME_SCAN_REQ message
1327 * from HDD or upper layer application.
1328 *
1329 * Return: None
1330 */
1331
1332static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1333 uint32_t *msg_buf)
1334{
1335 tpSirSmeScanReq scan_req;
1336 uint8_t valid_req = 0;
1337
1338#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1339 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1340 eSIR_SUCCESS, eSIR_SUCCESS);
1341#endif
1342
1343 scan_req = (tpSirSmeScanReq) msg_buf;
1344 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301345 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 -08001346 scan_req->scan_id, scan_req->channelList.numChannels,
1347 scan_req->minChannelTime, scan_req->maxChannelTime,
1348 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1349 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301350 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1352 /*
1353 * Since scan req always requires a response, we will overwrite response
1354 * required here. This is added esp to take care of the condition where
1355 * in p2p go case, we hold the scan req and insert single NOA. We send
1356 * the held scan request to FW later on getting start NOA ind from FW so
1357 * we lose state of the gLimRspReqd flag for the scan req if any other
1358 * request comes by then. e.g. While unit testing, we found when insert
1359 * single NOA is done, we see a get stats request which turns the flag
1360 * gLimRspReqd to false; now when we actually start the saved scan req
1361 * for init scan after getting NOA started, the gLimRspReqd being a
1362 * global flag is showing false instead of true value for this saved
1363 * scan req. Since all scan reqs coming to lim require a response,
1364 * there is no harm in setting the global flag gLimRspReqd to true here.
1365 */
1366 mac_ctx->lim.gLimRspReqd = true;
1367
1368 /*
1369 * copy the Self MAC address from SmeReq to the globalplace,
1370 * used for sending probe req
1371 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001372 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1373 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1375
1376 if (!valid_req || mac_ctx->lim.scan_disabled) {
1377 lim_log(mac_ctx, LOGE,
1378 FL("Scan disabled %d, Valid Scan Req %d"),
1379 mac_ctx->lim.scan_disabled, valid_req);
1380
1381 if (mac_ctx->lim.gLimRspReqd) {
1382 mac_ctx->lim.gLimRspReqd = false;
1383
1384 lim_send_sme_scan_rsp(mac_ctx,
1385 eSIR_SME_INVALID_PARAMETERS,
1386 scan_req->sessionId,
1387 scan_req->transactionId,
1388 scan_req->scan_id);
1389 }
1390 return;
1391 }
1392
1393 /*
1394 * If scan request is received in idle, joinFailed
1395 * states or in link established state (in STA role)
1396 * or in normal state (in STA-in-IBSS/AP role) with
1397 * 'return fresh scan results' request from HDD or
1398 * it is periodic background scanning request,
1399 * trigger fresh scan request to MLM
1400 */
1401 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1402
1403 mac_ctx->lim.gLim24Band11dScanDone = 0;
1404 mac_ctx->lim.gLim50Band11dScanDone = 0;
1405 mac_ctx->lim.gLimReturnAfterFirstMatch =
1406 scan_req->returnAfterFirstMatch;
1407 mac_ctx->lim.gLimReturnUniqueResults =
1408 ((scan_req->returnUniqueResults) > 0 ? true : false);
1409
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301410 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 lim_send_hal_start_scan_offload_req(mac_ctx,
1412 scan_req)) {
1413 lim_log(mac_ctx, LOGE, FL(
1414 "Couldn't send Offload scan request"));
1415 lim_send_sme_scan_rsp(mac_ctx,
1416 eSIR_SME_INVALID_PARAMETERS,
1417 scan_req->sessionId,
1418 scan_req->transactionId,
1419 scan_req->scan_id);
1420 return;
1421 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301422 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 /* In all other cases return 'cached' scan results */
1424 if (mac_ctx->lim.gLimRspReqd) {
1425 mac_ctx->lim.gLimRspReqd = false;
1426 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1427 scan_req->sessionId,
1428 scan_req->transactionId, scan_req->scan_id);
1429 }
1430 }
1431}
1432
1433#ifdef FEATURE_OEM_DATA_SUPPORT
1434
1435static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1436{
1437 tpSirOemDataReq pOemDataReq;
1438 tLimMlmOemDataReq *pMlmOemDataReq;
1439
1440 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1441
1442 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301443 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 if (NULL == pMlmOemDataReq) {
1445 lim_log(pMac, LOGP,
1446 FL("AllocateMemory failed for mlmOemDataReq"));
1447 return;
1448 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301449 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001450 if (!pMlmOemDataReq->data) {
1451 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301452 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001453 return;
1454 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455
Anurag Chouhanc5548422016-02-24 18:33:27 +05301456 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001457 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001458 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301459 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001460 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001461 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301462 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1464 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1465 (uint32_t *) pMlmOemDataReq);
1466
1467 return;
1468
1469} /*** end __lim_process_sme_oem_data_req() ***/
1470
1471#endif /* FEATURE_OEM_DATA_SUPPORT */
1472
1473/**
1474 * __lim_process_clear_dfs_channel_list()
1475 *
1476 ***FUNCTION:
1477 ***Clear DFS channel list when country is changed/aquired.
1478 .*This message is sent from SME.
1479 *
1480 ***LOGIC:
1481 *
1482 ***ASSUMPTIONS:
1483 *
1484 ***NOTE:
1485 *
1486 * @param pMac Pointer to Global MAC structure
1487 * @param *pMsgBuf A pointer to the SME message buffer
1488 * @return None
1489 */
1490static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1491{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301492 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493}
1494
1495/**
1496 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1497 * @mac_ctx: Pointer to Global MAC structure
1498 * @msg_buf: A pointer to the SME message buffer
1499 *
1500 * This function is called to process SME_JOIN_REQ message
1501 * from HDD or upper layer application.
1502 *
1503 * Return: None
1504 */
1505static void
1506__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1507{
1508 tpSirSmeJoinReq sme_join_req = NULL;
1509 tLimMlmJoinReq *mlm_join_req;
1510 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1511 uint32_t val = 0;
1512 uint16_t n_size;
1513 uint8_t session_id;
1514 tpPESession session = NULL;
1515 uint8_t sme_session_id;
1516 uint16_t sme_transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001517 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 uint16_t ie_len;
1519 uint8_t *vendor_ie;
1520 tSirBssDescription bss_desc;
1521
1522/* FEATURE_WLAN_DIAG_SUPPORT */
1523#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1524 /*
1525 * Not sending any session, since it is not created yet.
1526 * The response whould have correct state.
1527 */
1528 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1529#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1530
1531 lim_log(mac_ctx, LOG1, FL("Received SME_JOIN_REQ"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532
1533 /*
1534 * Expect Join request in idle state.
1535 * Reassociate request is expected in link established state.
1536 */
1537
1538 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1539 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1540 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1541 msg_buf);
1542
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301543 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 if (NULL == sme_join_req) {
1545 lim_log(mac_ctx, LOGP,
1546 FL("AllocateMemory failed for sme_join_req"));
1547 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1548 return;
1549 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301550 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1551 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 n_size);
1553
1554 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1555 /* Received invalid eWNI_SME_JOIN_REQ */
1556 /* Log the event */
1557 lim_log(mac_ctx, LOGW,
1558 FL("SessionId:%d JOIN REQ with invalid data"),
1559 sme_join_req->sessionId);
1560 ret_code = eSIR_SME_INVALID_PARAMETERS;
1561 goto end;
1562 }
1563
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001564 /*
1565 * Update the capability here itself as this is used in
1566 * lim_extract_ap_capability() below. If not updated issues
1567 * like not honoring power constraint on 1st association after
1568 * driver loading might occur.
1569 */
1570 lim_update_rrm_capability(mac_ctx, sme_join_req);
1571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 bss_desc = sme_join_req->bssDescription;
1573 /* check for the existence of start BSS session */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 session = pe_find_session_by_bssid(mac_ctx, bss_desc.bssId,
1575 &session_id);
1576
1577 if (session != NULL) {
1578 lim_log(mac_ctx, LOGE,
1579 FL("Session(%d) Already exists for BSSID: "
1580 MAC_ADDRESS_STR " in limSmeState = %X"),
1581 session_id,
1582 MAC_ADDR_ARRAY(bss_desc.bssId),
1583 session->limSmeState);
1584
1585 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1586 session->smeSessionId == sme_join_req->sessionId) {
1587 /*
1588 * Received eWNI_SME_JOIN_REQ for same
1589 * BSS as currently associated.
1590 * Log the event and send success
1591 */
1592 lim_log(mac_ctx, LOGW,
1593 FL("SessionId: %d"), session_id);
1594 lim_log(mac_ctx, LOGW,
1595 FL("JOIN_REQ for current joined BSS"));
1596 /* Send Join success response to host */
1597 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1598 session = NULL;
1599 goto end;
1600 } else {
1601 lim_log(mac_ctx, LOGE,
1602 FL("JOIN_REQ not for current joined BSS"));
1603 ret_code = eSIR_SME_REFUSED;
1604 session = NULL;
1605 goto end;
1606 }
1607 } else {
1608 /*
1609 * Session Entry does not exist for given BSSId
1610 * Try to Create a new session
1611 */
1612 session = pe_create_session(mac_ctx, bss_desc.bssId,
1613 &session_id, mac_ctx->lim.maxStation,
1614 eSIR_INFRASTRUCTURE_MODE);
1615 if (session == NULL) {
1616 lim_log(mac_ctx, LOGE,
1617 FL("Session Can not be created "));
1618 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1619 goto end;
1620 } else
1621 lim_log(mac_ctx, LOG1,
1622 FL("SessionId:%d New session created"),
1623 session_id);
1624 }
1625 session->isAmsduSupportInAMPDU =
1626 sme_join_req->isAmsduSupportInAMPDU;
1627
1628 /*
1629 * Store Session related parameters
1630 * Store PE session Id in session Table
1631 */
1632 session->peSessionId = session_id;
1633
1634 /* store the smejoin req handle in session table */
1635 session->pLimJoinReq = sme_join_req;
1636
1637 /* Store SME session Id in sessionTable */
1638 session->smeSessionId = sme_join_req->sessionId;
1639
1640 /* Store SME transaction Id in session Table */
1641 session->transactionId = sme_join_req->transactionId;
1642
1643 /* Store beaconInterval */
1644 session->beaconParams.beaconInterval =
1645 bss_desc.beaconInterval;
1646
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301647 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 sizeof(session->htConfig));
1649
1650 /* Copying of bssId is already done, while creating session */
1651 sir_copy_mac_addr(session->selfMacAddr,
1652 sme_join_req->selfMacAddr);
1653 session->bssType = sme_join_req->bsstype;
1654
1655 session->statypeForBss = STA_ENTRY_PEER;
1656 session->limWmeEnabled = sme_join_req->isWMEenabled;
1657 session->limQosEnabled = sme_join_req->isQosEnabled;
1658
1659 /* Store vendor specfic IE for CISCO AP */
1660 ie_len = (bss_desc.length + sizeof(bss_desc.length) -
1661 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1662
1663 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1664 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
1665 ((uint8_t *)&bss_desc.ieFields), ie_len);
1666
1667 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001668 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 session->isCiscoVendorAP = true;
1670 } else {
1671 session->isCiscoVendorAP = false;
1672 }
1673
1674 /* Copy the dot 11 mode in to the session table */
1675
1676 session->dot11mode = sme_join_req->dot11mode;
1677#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1678 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1679#endif
1680 session->nwType = bss_desc.nwType;
1681 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1682 session->enableHtSmps = sme_join_req->enableHtSmps;
1683 session->htSmpsvalue = sme_join_req->htSmps;
1684
1685 /*Store Persona */
1686 session->pePersona = sme_join_req->staPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301687 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 FL("PE PERSONA=%d cbMode %u"),
1689 session->pePersona, sme_join_req->cbMode);
1690 if (mac_ctx->roam.configParam.enable2x2)
1691 session->nss = 2;
1692 else
1693 session->nss = 1;
1694#ifdef WLAN_FEATURE_11AC
1695 session->vhtCapability =
1696 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301697 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 "***__lim_process_sme_join_req: vhtCapability=%d****",
1699 session->vhtCapability);
1700 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301701 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 session->txBFIniFeatureEnabled =
1703 sme_join_req->txBFIniFeatureEnabled;
1704 } else {
1705 session->txBFIniFeatureEnabled = 0;
1706 }
1707 session->txMuBformee = sme_join_req->txMuBformee;
1708 session->enableVhtpAid =
1709 sme_join_req->enableVhtpAid;
1710 session->enableVhtGid =
1711 sme_join_req->enableVhtGid;
1712
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301713 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 FL("***txBFIniFeatureEnabled=%d***"),
1715 session->txBFIniFeatureEnabled);
1716 if (wlan_cfg_get_int(mac_ctx,
1717 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1718 eSIR_SUCCESS)
1719 lim_log(mac_ctx, LOGE, FL(
1720 "cfg get vht su bformer failed"));
1721
1722 session->enable_su_tx_bformer = val;
1723 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1724 }
1725 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1726 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1727 session->txBFIniFeatureEnabled) !=
1728 eSIR_SUCCESS) {
1729 /*
1730 * Set failed for
1731 * CFG_VHT_SU_BEAMFORMEE_CAP
1732 */
1733 lim_log(mac_ctx, LOGP,
1734 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1735 ret_code = eSIR_LOGP_EXCEPTION;
1736 goto end;
1737 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301738 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO_MED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 "%s: txBFCsnValue=%d", __func__,
1740 sme_join_req->txBFCsnValue);
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001741 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 }
1743#endif
1744
1745 /*Phy mode */
1746 session->gLimPhyMode = bss_desc.nwType;
1747 handle_ht_capabilityand_ht_info(mac_ctx, session);
1748 /* Copy The channel Id to the session Table */
1749 session->currentOperChannel = bss_desc.channelId;
1750 /* cbMode is already merged value of peer and self -
1751 * done by csr in csr_get_cb_mode_from_ies */
1752 session->htSupportedChannelWidthSet =
1753 (sme_join_req->cbMode) ? 1 : 0;
1754 session->htRecommendedTxWidthSet =
1755 session->htSupportedChannelWidthSet;
1756 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1757
1758 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1759 session->ch_center_freq_seg0 =
1760 session->currentOperChannel - 2;
1761 session->ch_width = CH_WIDTH_40MHZ;
1762 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1763 sme_join_req->cbMode) {
1764 session->ch_center_freq_seg0 =
1765 session->currentOperChannel + 2;
1766 session->ch_width = CH_WIDTH_40MHZ;
1767 } else {
1768 session->ch_center_freq_seg0 = 0;
1769 session->ch_width = CH_WIDTH_20MHZ;
1770 }
1771
1772 /* Record if management frames need to be protected */
1773#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001774 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001776 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778#endif
1779
1780#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1781 session->rssi = bss_desc.rssi;
1782#endif
1783
1784 /* Copy the SSID from smejoinreq to session entry */
1785 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301786 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 session->ssId.length);
1788
1789 /*
1790 * Determin 11r or ESE connection based on input from SME
1791 * which inturn is dependent on the profile the user wants
1792 * to connect to, So input is coming from supplicant
1793 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795#ifdef FEATURE_WLAN_ESE
1796 session->isESEconnection = sme_join_req->isESEconnection;
1797#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 session->isFastTransitionEnabled =
1799 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 session->isFastRoamIniFeatureEnabled =
1802 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 session->txLdpcIniFeatureEnabled =
1804 sme_join_req->txLdpcIniFeatureEnabled;
1805
1806 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1807 session->limSystemRole = eLIM_STA_ROLE;
1808 } else if (session->bssType == eSIR_BTAMP_AP_MODE) {
1809 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1810 } else {
1811 /*
1812 * Throw an error and return and make
1813 * sure to delete the session.
1814 */
1815 lim_log(mac_ctx, LOGE,
1816 FL("recvd JOIN_REQ with invalid bss type %d"),
1817 session->bssType);
1818 ret_code = eSIR_SME_INVALID_PARAMETERS;
1819 goto end;
1820 }
1821
1822 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301823 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 &sme_join_req->addIEScan, sizeof(tSirAddie));
1825
1826 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301827 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1829
1830 val = sizeof(tLimMlmJoinReq) +
1831 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301832 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 if (NULL == mlm_join_req) {
1834 lim_log(mac_ctx, LOGP,
1835 FL("AllocateMemory failed for mlmJoinReq"));
1836 return;
1837 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301838 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839
1840 /* PE SessionId is stored as a part of JoinReq */
1841 mlm_join_req->sessionId = session->peSessionId;
1842
1843 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1844 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1845 eSIR_SUCCESS) {
1846 lim_log(mac_ctx, LOGP,
1847 FL("couldn't retrieve JoinFailureTimer value"
1848 " setting to default value"));
1849 mlm_join_req->joinFailureTimeout =
1850 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1851 }
1852
1853 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301854 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 (void *)&sme_join_req->operationalRateSet,
1856 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301857 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 (void *)&sme_join_req->extendedRateSet,
1859 sizeof(tSirMacRateSet));
1860 /*
1861 * this may not be needed anymore now, as rateSet is now
1862 * included in the session entry and MLM has session context.
1863 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301864 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 (void *)&session->rateSet,
1866 sizeof(tSirMacRateSet));
1867
1868 session->encryptType = sme_join_req->UCEncryptionType;
1869
1870 mlm_join_req->bssDescription.length =
1871 session->pLimJoinReq->bssDescription.length;
1872
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301873 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 (uint8_t *)
1875 &session->pLimJoinReq->bssDescription.bssId,
1876 session->pLimJoinReq->bssDescription.length + 2);
1877
1878 session->limCurrentBssCaps =
1879 session->pLimJoinReq->bssDescription.capabilityInfo;
1880
1881 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1882 session->currentOperChannel);
1883 local_power_constraint = reg_max;
1884
1885 lim_extract_ap_capability(mac_ctx,
1886 (uint8_t *)
1887 session->pLimJoinReq->bssDescription.ieFields,
1888 lim_get_ielen_from_bss_description(
1889 &session->pLimJoinReq->bssDescription),
1890 &session->limCurrentBssQosCaps,
1891 &session->limCurrentBssPropCap,
1892 &session->gLimCurrentBssUapsd,
1893 &local_power_constraint, session);
1894
1895#ifdef FEATURE_WLAN_ESE
1896 session->maxTxPower = lim_get_max_tx_power(reg_max,
1897 local_power_constraint,
1898 mac_ctx->roam.configParam.nTxPowerCap);
1899#else
1900 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301901 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902#endif
1903#if defined WLAN_VOWIFI_DEBUG
1904 lim_log(mac_ctx, LOGE,
1905 "Regulatory max = %d, local power constraint = %d"
1906 reg_max, local_power_constraint);
1907 lim_log(mac_ctx, LOGE, FL(" max tx = %d"),
1908 session->maxTxPower);
1909#endif
1910
1911 if (session->gLimCurrentBssUapsd) {
1912 session->gUapsdPerAcBitmask =
1913 session->pLimJoinReq->uapsdPerAcBitmask;
1914 lim_log(mac_ctx, LOG1,
1915 FL("UAPSD flag for all AC - 0x%2x"),
1916 session->gUapsdPerAcBitmask);
1917
1918 /* resetting the dynamic uapsd mask */
1919 session->gUapsdPerAcDeliveryEnableMask = 0;
1920 session->gUapsdPerAcTriggerEnableMask = 0;
1921 }
1922
1923 session->limRFBand =
1924 lim_get_rf_band(session->currentOperChannel);
1925
1926 /* Initialize 11h Enable Flag */
1927 if (SIR_BAND_5_GHZ == session->limRFBand) {
1928 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1929 &val) != eSIR_SUCCESS) {
1930 lim_log(mac_ctx, LOGP,
1931 FL("Fail to get WNI_CFG_11H_ENABLED "));
1932 session->lim11hEnable =
1933 WNI_CFG_11H_ENABLED_STADEF;
1934 } else {
1935 session->lim11hEnable = val;
1936 }
1937 } else {
1938 session->lim11hEnable = 0;
1939 }
1940
1941 /*
1942 * To care of the scenario when STA transitions from
1943 * IBSS to Infrastructure mode.
1944 */
1945 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1946
1947 session->limPrevSmeState = session->limSmeState;
1948 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1949 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1950 session->peSessionId,
1951 session->limSmeState));
1952
1953 lim_log(mac_ctx, LOG1,
1954 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
1955 mlm_join_req->sessionId, session->ssId.length,
1956 session->ssId.ssId, session->currentOperChannel,
1957 MAC_ADDR_ARRAY(session->bssId));
1958
1959 /* Indicate whether spectrum management is enabled */
1960 session->spectrumMgtEnabled =
1961 sme_join_req->spectrumMgtIndicator;
1962
1963 /* Enable the spectrum management if this is a DFS channel */
1964 if (session->country_info_present &&
1965 lim_isconnected_on_dfs_channel(
1966 session->currentOperChannel))
1967 session->spectrumMgtEnabled = true;
1968
1969 session->isOSENConnection = sme_join_req->isOSENConnection;
1970
1971 lim_log(mac_ctx, LOG1,
1972 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
1973 mlm_join_req->sessionId);
1974 /* Issue LIM_MLM_JOIN_REQ to MLM */
1975 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1976 (uint32_t *) mlm_join_req);
1977 return;
1978
1979 } else {
1980 /* Received eWNI_SME_JOIN_REQ un expected state */
1981 lim_log(mac_ctx, LOGE,
1982 FL("received unexpected SME_JOIN_REQ in state %X"),
1983 mac_ctx->lim.gLimSmeState);
1984 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1985 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1986 session = NULL;
1987 goto end;
1988 }
1989
1990end:
1991 sme_session_id = sme_join_req->sessionId;
1992 sme_transaction_id = sme_join_req->transactionId;
1993
1994 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301995 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 sme_join_req = NULL;
1997 if (NULL != session)
1998 session->pLimJoinReq = NULL;
1999 }
2000 if (ret_code != eSIR_SME_SUCCESS) {
2001 if (NULL != session) {
2002 pe_delete_session(mac_ctx, session);
2003 session = NULL;
2004 }
2005 }
2006 lim_log(mac_ctx, LOG1,
2007 FL("Send failure status on sessionid: %d with ret_code = %d"),
2008 sme_session_id, ret_code);
2009 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2010 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2011 sme_transaction_id);
2012}
2013
Amar Singhala297bfa2015-10-15 15:07:29 -07002014uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 uint8_t iniTxPower)
2016{
2017 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302018 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2019 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2021 maxTxPower = txPower;
2022 else if (txPower < MIN_TX_PWR_CAP)
2023 maxTxPower = MIN_TX_PWR_CAP;
2024 else
2025 maxTxPower = MAX_TX_PWR_CAP;
2026
2027 return maxTxPower;
2028}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029
2030/**
2031 * __lim_process_sme_reassoc_req() - process reassoc req
2032 *
2033 * @mac_ctx: Pointer to Global MAC structure
2034 * @msg_buf: pointer to the SME message buffer
2035 *
2036 * This function is called to process SME_REASSOC_REQ message
2037 * from HDD or upper layer application.
2038 *
2039 * Return: None
2040 */
2041
2042static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2043 uint32_t *msg_buf)
2044{
2045 uint16_t caps;
2046 uint32_t val;
2047 tpSirSmeJoinReq reassoc_req = NULL;
2048 tLimMlmReassocReq *mlm_reassoc_req;
2049 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2050 tpPESession session_entry = NULL;
2051 uint8_t session_id;
2052 uint8_t sme_session_id;
2053 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002054 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 uint32_t tele_bcn_en = 0;
2056 uint16_t size;
2057
2058 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2059
2060 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302061 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 if (NULL == reassoc_req) {
2063 lim_log(mac_ctx, LOGP,
2064 FL("call to AllocateMemory failed for reassoc_req"));
2065
2066 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2067 goto end;
2068 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302069 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2070 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071
2072 if (!lim_is_sme_join_req_valid(mac_ctx,
2073 (tpSirSmeJoinReq)reassoc_req)) {
2074 /*
2075 * Received invalid eWNI_SME_REASSOC_REQ
2076 */
2077 lim_log(mac_ctx, LOGW,
2078 FL("received SME_REASSOC_REQ with invalid data"));
2079
2080 ret_code = eSIR_SME_INVALID_PARAMETERS;
2081 goto end;
2082 }
2083
2084 session_entry = pe_find_session_by_bssid(mac_ctx,
2085 reassoc_req->bssDescription.bssId,
2086 &session_id);
2087 if (session_entry == NULL) {
2088 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2089 LOGE);
2090 lim_log(mac_ctx, LOGE,
2091 FL("Session does not exist for given bssId"));
2092 ret_code = eSIR_SME_INVALID_PARAMETERS;
2093 goto end;
2094 }
2095#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2096 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2097 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2098#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2099 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2100
2101 /* Store the reassoc handle in the session Table */
2102 session_entry->pLimReAssocReq = reassoc_req;
2103
2104 session_entry->dot11mode = reassoc_req->dot11mode;
2105 session_entry->vhtCapability =
2106 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
2107 /*
2108 * Reassociate request is expected
2109 * in link established state only.
2110 */
2111
2112 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2114 /*
2115 * May be from 11r FT pre-auth. So lets check it
2116 * before we bail out
2117 */
2118 lim_log(mac_ctx, LOG1, FL(
2119 "Session in reassoc state is %d"),
2120 session_entry->peSessionId);
2121
2122 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302123 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 session_entry->limReAssocbssId,
2125 6)) {
2126 lim_print_mac_addr(mac_ctx,
2127 reassoc_req->bssDescription.
2128 bssId, LOGE);
2129 lim_log(mac_ctx, LOGP,
2130 FL("Unknown bssId in reassoc state"));
2131 ret_code = eSIR_SME_INVALID_PARAMETERS;
2132 goto end;
2133 }
2134
2135 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2136 session_entry);
2137 return;
2138 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 /*
2140 * Should not have received eWNI_SME_REASSOC_REQ
2141 */
2142 lim_log(mac_ctx, LOGE,
2143 FL("received unexpected SME_REASSOC_REQ in state %X"),
2144 session_entry->limSmeState);
2145 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2146
2147 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2148 goto end;
2149 }
2150
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302151 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 session_entry->pLimReAssocReq->bssDescription.bssId,
2153 sizeof(tSirMacAddr));
2154
2155 session_entry->limReassocChannelId =
2156 session_entry->pLimReAssocReq->bssDescription.channelId;
2157
2158 session_entry->reAssocHtSupportedChannelWidthSet =
2159 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2160 session_entry->reAssocHtRecommendedTxWidthSet =
2161 session_entry->reAssocHtSupportedChannelWidthSet;
2162 session_entry->reAssocHtSecondaryChannelOffset =
2163 session_entry->pLimReAssocReq->cbMode;
2164
2165 session_entry->limReassocBssCaps =
2166 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2167 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2168 session_entry->currentOperChannel);
2169 local_pwr_constraint = reg_max;
2170
2171 lim_extract_ap_capability(mac_ctx,
2172 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2173 lim_get_ielen_from_bss_description(
2174 &session_entry->pLimReAssocReq->bssDescription),
2175 &session_entry->limReassocBssQosCaps,
2176 &session_entry->limReassocBssPropCap,
2177 &session_entry->gLimCurrentBssUapsd,
2178 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302179 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180#if defined WLAN_VOWIFI_DEBUG
2181 lim_log(mac_ctx, LOGE,
2182 "Regulatory max = %d, local pwr constraint = %d, max tx = %d",
2183 reg_max, local_pwr_constraint,
2184 session_entry->maxTxPower);
2185#endif
2186 /* Copy the SSID from session entry to local variable */
2187 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302188 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 reassoc_req->ssId.ssId,
2190 session_entry->limReassocSSID.length);
2191 if (session_entry->gLimCurrentBssUapsd) {
2192 session_entry->gUapsdPerAcBitmask =
2193 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2194 lim_log(mac_ctx, LOG1,
2195 FL("UAPSD flag for all AC - 0x%2x"),
2196 session_entry->gUapsdPerAcBitmask);
2197 }
2198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 if (NULL == mlm_reassoc_req) {
2201 lim_log(mac_ctx, LOGP,
2202 FL("call to AllocateMemory failed for mlmReassocReq"));
2203
2204 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2205 goto end;
2206 }
2207
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302208 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2210
2211 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2212 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2213 eSIR_SUCCESS) {
2214 /*
2215 * Could not get ReassocFailureTimeout value
2216 * from CFG. Log error.
2217 */
2218 lim_log(mac_ctx, LOGP,
2219 FL("could not retrieve ReassocFailureTimeout value"));
2220 }
2221
2222 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2223 eSIR_SUCCESS) {
2224 /*
2225 * Could not get Capabilities value
2226 * from CFG. Log error.
2227 */
2228 lim_log(mac_ctx, LOGP, FL(
2229 "could not retrieve Capabilities value"));
2230 }
2231 mlm_reassoc_req->capabilityInfo = caps;
2232
2233 /* Update PE session_id */
2234 mlm_reassoc_req->sessionId = session_id;
2235
2236 /*
2237 * If telescopic beaconing is enabled, set listen interval to
2238 * WNI_CFG_TELE_BCN_MAX_LI
2239 */
2240 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2241 &tele_bcn_en) != eSIR_SUCCESS)
2242 lim_log(mac_ctx, LOGP,
2243 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2244
2245 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2246
2247 if (tele_bcn_en) {
2248 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2249 eSIR_SUCCESS)
2250 /*
2251 * Could not get ListenInterval value
2252 * from CFG. Log error.
2253 */
2254 lim_log(mac_ctx, LOGP,
2255 FL("could not retrieve ListenInterval"));
2256 } else {
2257 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2258 eSIR_SUCCESS)
2259 /*
2260 * Could not get ListenInterval value
2261 * from CFG. Log error.
2262 */
2263 lim_log(mac_ctx, LOGP,
2264 FL("could not retrieve ListenInterval"));
2265 }
2266
2267 mlm_reassoc_req->listenInterval = (uint16_t) val;
2268
2269 /* Indicate whether spectrum management is enabled */
2270 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2271
2272 /* Enable the spectrum management if this is a DFS channel */
2273 if (session_entry->country_info_present &&
2274 lim_isconnected_on_dfs_channel(
2275 session_entry->currentOperChannel))
2276 session_entry->spectrumMgtEnabled = true;
2277
2278 session_entry->limPrevSmeState = session_entry->limSmeState;
2279 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2280
2281 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2282 session_entry->peSessionId,
2283 session_entry->limSmeState));
2284
2285 lim_post_mlm_message(mac_ctx,
2286 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2287 return;
2288end:
2289 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302290 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 if (session_entry)
2292 session_entry->pLimReAssocReq = NULL;
2293 }
2294
2295 if (session_entry) {
2296 /*
2297 * error occurred after we determined the session so extract
2298 * session and transaction info from there
2299 */
2300 sme_session_id = session_entry->smeSessionId;
2301 transaction_id = session_entry->transactionId;
2302 } else
2303 /*
2304 * error occurred before or during the time we determined
2305 * the session so extract the session and transaction info
2306 * from the message
2307 */
2308 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2309 &sme_session_id, &transaction_id);
2310
2311 /*
2312 * Send Reassoc failure response to host
2313 * (note session_entry may be NULL, but that's OK)
2314 */
2315 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2316 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2317 session_entry, sme_session_id,
2318 transaction_id);
2319}
2320
2321bool send_disassoc_frame = 1;
2322/**
2323 * __lim_process_sme_disassoc_req()
2324 *
2325 ***FUNCTION:
2326 * This function is called to process SME_DISASSOC_REQ message
2327 * from HDD or upper layer application.
2328 *
2329 ***LOGIC:
2330 *
2331 ***ASSUMPTIONS:
2332 *
2333 ***NOTE:
2334 *
2335 * @param pMac Pointer to Global MAC structure
2336 * @param *pMsgBuf A pointer to the SME message buffer
2337 * @return None
2338 */
2339
2340static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2341{
2342 uint16_t disassocTrigger, reasonCode;
2343 tLimMlmDisassocReq *pMlmDisassocReq;
2344 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2345 tSirSmeDisassocReq smeDisassocReq;
2346 tpPESession psessionEntry = NULL;
2347 uint8_t sessionId;
2348 uint8_t smesessionId;
2349 uint16_t smetransactionId;
2350
2351 if (pMsgBuf == NULL) {
2352 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2353 return;
2354 }
2355
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302356 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 smesessionId = smeDisassocReq.sessionId;
2358 smetransactionId = smeDisassocReq.transactionId;
2359 if (!lim_is_sme_disassoc_req_valid(pMac,
2360 &smeDisassocReq,
2361 psessionEntry)) {
2362 PELOGE(lim_log(pMac, LOGE,
2363 FL("received invalid SME_DISASSOC_REQ message"));)
2364 if (pMac->lim.gLimRspReqd) {
2365 pMac->lim.gLimRspReqd = false;
2366
2367 retCode = eSIR_SME_INVALID_PARAMETERS;
2368 disassocTrigger = eLIM_HOST_DISASSOC;
2369 goto sendDisassoc;
2370 }
2371
2372 return;
2373 }
2374
2375 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002376 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 &sessionId);
2378 if (psessionEntry == NULL) {
2379 lim_log(pMac, LOGE,
2380 FL("session does not exist for given bssId "
2381 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002382 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 retCode = eSIR_SME_INVALID_PARAMETERS;
2384 disassocTrigger = eLIM_HOST_DISASSOC;
2385 goto sendDisassoc;
2386 }
2387 lim_log(pMac, LOG1,
2388 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2389 MAC_ADDRESS_STR), smesessionId,
2390 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2391 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002392 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393
2394#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2395 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2396 0, smeDisassocReq.reasonCode);
2397#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2398
2399 /* Update SME session Id and SME transaction ID */
2400
2401 psessionEntry->smeSessionId = smesessionId;
2402 psessionEntry->transactionId = smetransactionId;
2403
2404 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2405 case eLIM_STA_ROLE:
2406 case eLIM_BT_AMP_STA_ROLE:
2407 switch (psessionEntry->limSmeState) {
2408 case eLIM_SME_ASSOCIATED_STATE:
2409 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002410 lim_log(pMac, LOG1,
2411 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2412 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 psessionEntry->limPrevSmeState =
2414 psessionEntry->limSmeState;
2415 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2416#ifdef FEATURE_WLAN_TDLS
2417 /* Delete all TDLS peers connected before leaving BSS */
2418 lim_delete_tdls_peers(pMac, psessionEntry);
2419#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002420 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2421 psessionEntry->peSessionId,
2422 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 break;
2424
2425 case eLIM_SME_WT_DEAUTH_STATE:
2426 /* PE shall still process the DISASSOC_REQ and proceed with
2427 * link tear down even if it had already sent a DEAUTH_IND to
2428 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2429 * its been set when PE entered WT_DEAUTH_STATE.
2430 */
2431 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2432 MTRACE(mac_trace
2433 (pMac, TRACE_CODE_SME_STATE,
2434 psessionEntry->peSessionId,
2435 psessionEntry->limSmeState));
2436 lim_log(pMac, LOG1,
2437 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2438 break;
2439
2440 case eLIM_SME_WT_DISASSOC_STATE:
2441 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2442 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2443 * PE can continue processing DISASSOC_REQ and send the response instead
2444 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2445 * for disassoc frame.
2446 *
2447 * It will send a disassoc, which is ok. However, we can use the global flag
2448 * sendDisassoc to not send disassoc frame.
2449 */
2450 lim_log(pMac, LOG1,
2451 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2452 break;
2453
2454 case eLIM_SME_JOIN_FAILURE_STATE: {
2455 /* Already in Disconnected State, return success */
2456 lim_log(pMac, LOG1,
2457 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2458 if (pMac->lim.gLimRspReqd) {
2459 retCode = eSIR_SME_SUCCESS;
2460 disassocTrigger = eLIM_HOST_DISASSOC;
2461 goto sendDisassoc;
2462 }
2463 }
2464 break;
2465 default:
2466 /**
2467 * STA is not currently associated.
2468 * Log error and send response to host
2469 */
2470 lim_log(pMac, LOGE,
2471 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2472 psessionEntry->limSmeState);
2473 lim_print_sme_state(pMac, LOGE,
2474 psessionEntry->limSmeState);
2475
2476 if (pMac->lim.gLimRspReqd) {
2477 if (psessionEntry->limSmeState !=
2478 eLIM_SME_WT_ASSOC_STATE)
2479 pMac->lim.gLimRspReqd = false;
2480
2481 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2482 disassocTrigger = eLIM_HOST_DISASSOC;
2483 goto sendDisassoc;
2484 }
2485
2486 return;
2487 }
2488
2489 break;
2490
2491 case eLIM_AP_ROLE:
2492 case eLIM_BT_AMP_AP_ROLE:
2493 /* Fall through */
2494 break;
2495
2496 case eLIM_STA_IN_IBSS_ROLE:
2497 default:
2498 /* eLIM_UNKNOWN_ROLE */
2499 lim_log(pMac, LOGE,
2500 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2501 GET_LIM_SYSTEM_ROLE(psessionEntry));
2502
2503 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2504 disassocTrigger = eLIM_HOST_DISASSOC;
2505 goto sendDisassoc;
2506 } /* end switch (pMac->lim.gLimSystemRole) */
2507
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302508 disassocTrigger = eLIM_HOST_DISASSOC;
2509 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510
2511 if (smeDisassocReq.doNotSendOverTheAir) {
2512 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2513 send_disassoc_frame = 0;
2514 }
2515 /* Trigger Disassociation frame to peer MAC entity */
2516 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2517 " : %d, reasonCode : %d"),
2518 disassocTrigger, reasonCode);
2519
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302520 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 if (NULL == pMlmDisassocReq) {
2522 /* Log error */
2523 lim_log(pMac, LOGP,
2524 FL("call to AllocateMemory failed for mlmDisassocReq"));
2525
2526 return;
2527 }
2528
Anurag Chouhanc5548422016-02-24 18:33:27 +05302529 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002530 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531
2532 pMlmDisassocReq->reasonCode = reasonCode;
2533 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2534
2535 /* Update PE session ID */
2536 pMlmDisassocReq->sessionId = sessionId;
2537
2538 lim_post_mlm_message(pMac,
2539 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2540 return;
2541
2542sendDisassoc:
2543 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002544 lim_send_sme_disassoc_ntf(pMac,
2545 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 retCode,
2547 disassocTrigger,
2548 1, smesessionId, smetransactionId,
2549 psessionEntry);
2550 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002551 lim_send_sme_disassoc_ntf(pMac,
2552 smeDisassocReq.peer_macaddr.bytes,
2553 retCode, disassocTrigger, 1,
2554 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555
2556} /*** end __lim_process_sme_disassoc_req() ***/
2557
2558/** -----------------------------------------------------------------
2559 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2560
2561 This function is called to process SME_DISASSOC_CNF message
2562 from HDD or upper layer application.
2563
2564 \param pMac - global mac structure
2565 \param pStaDs - station dph hash node
2566 \return none
2567 \sa
2568 ----------------------------------------------------------------- */
2569static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2570{
2571 tSirSmeDisassocCnf smeDisassocCnf;
2572 uint16_t aid;
2573 tpDphHashNode pStaDs;
2574 tpPESession psessionEntry;
2575 uint8_t sessionId;
2576
2577 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2578
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302579 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 sizeof(struct sSirSmeDisassocCnf));
2581
2582 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002583 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 &sessionId);
2585 if (psessionEntry == NULL) {
2586 lim_log(pMac, LOGE,
2587 FL("session does not exist for given bssId"));
2588 return;
2589 }
2590
2591 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2592 lim_log(pMac, LOGE,
2593 FL("received invalid SME_DISASSOC_CNF message"));
2594 return;
2595 }
2596#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2597 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2598 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2599 psessionEntry,
2600 (uint16_t) smeDisassocCnf.statusCode, 0);
2601 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2602 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2603 psessionEntry,
2604 (uint16_t) smeDisassocCnf.statusCode, 0);
2605#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2606
2607 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2608 case eLIM_STA_ROLE:
2609 case eLIM_BT_AMP_STA_ROLE: /* To test reconn */
2610 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2611 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2612 && (psessionEntry->limSmeState !=
2613 eLIM_SME_WT_DEAUTH_STATE)) {
2614 lim_log(pMac, LOGE,
2615 FL
2616 ("received unexp SME_DISASSOC_CNF in state %X"),
2617 psessionEntry->limSmeState);
2618 lim_print_sme_state(pMac, LOGE,
2619 psessionEntry->limSmeState);
2620 return;
2621 }
2622 break;
2623
2624 case eLIM_AP_ROLE:
2625 /* Fall through */
2626 break;
2627
2628 case eLIM_STA_IN_IBSS_ROLE:
2629 default: /* eLIM_UNKNOWN_ROLE */
2630 lim_log(pMac, LOGE,
2631 FL("received unexpected SME_DISASSOC_CNF role %d"),
2632 GET_LIM_SYSTEM_ROLE(psessionEntry));
2633
2634 return;
2635 }
2636
2637 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2638 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2639 LIM_IS_AP_ROLE(psessionEntry)) {
2640 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002641 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 &psessionEntry->dph.dphHashTable);
2643 if (pStaDs == NULL) {
2644 lim_log(pMac, LOGE,
2645 FL("DISASSOC_CNF for a STA with no context, addr= "
2646 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002647 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 return;
2649 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302650
2651 if ((pStaDs->mlmStaContext.mlmState ==
2652 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2653 (pStaDs->mlmStaContext.mlmState ==
2654 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2655 lim_log(pMac, LOGE,
2656 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002657 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302658 pStaDs->mlmStaContext.mlmState);
2659 return;
2660 }
2661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 /* Delete FT session if there exists one */
2663 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2665
2666 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002667 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 }
2669
2670 return;
2671}
2672
2673/**
2674 * __lim_process_sme_deauth_req() - process sme deauth req
2675 * @mac_ctx: Pointer to Global MAC structure
2676 * @msg_buf: pointer to the SME message buffer
2677 *
2678 * This function is called to process SME_DEAUTH_REQ message
2679 * from HDD or upper layer application.
2680 *
2681 * Return: None
2682 */
2683
2684static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2685 uint32_t *msg_buf)
2686{
2687 uint16_t deauth_trigger, reason_code;
2688 tLimMlmDeauthReq *mlm_deauth_req;
2689 tSirSmeDeauthReq sme_deauth_req;
2690 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2691 tpPESession session_entry;
2692 uint8_t session_id; /* PE sessionId */
2693 uint8_t sme_session_id;
2694 uint16_t sme_transaction_id;
2695
2696 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2697
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302698 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 sme_session_id = sme_deauth_req.sessionId;
2700 sme_transaction_id = sme_deauth_req.transactionId;
2701
2702 /*
2703 * We need to get a session first but we don't even know
2704 * if the message is correct.
2705 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002706 session_entry = pe_find_session_by_bssid(mac_ctx,
2707 sme_deauth_req.bssid.bytes,
2708 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 if (session_entry == NULL) {
2710 lim_log(mac_ctx, LOGE,
2711 FL("session does not exist for given bssId"));
2712 ret_code = eSIR_SME_INVALID_PARAMETERS;
2713 deauth_trigger = eLIM_HOST_DEAUTH;
2714 goto send_deauth;
2715 }
2716
2717 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2718 session_entry)) {
2719 lim_log(mac_ctx, LOGE,
2720 FL("received invalid SME_DEAUTH_REQ message"));
2721 mac_ctx->lim.gLimRspReqd = false;
2722
2723 ret_code = eSIR_SME_INVALID_PARAMETERS;
2724 deauth_trigger = eLIM_HOST_DEAUTH;
2725 goto send_deauth;
2726 }
2727 lim_log(mac_ctx, LOG1,
2728 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2729 MAC_ADDRESS_STR), sme_session_id,
2730 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2731 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002732 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2734 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2735 session_entry, 0, sme_deauth_req.reasonCode);
2736#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2737
2738 /* Update SME session ID and Transaction ID */
2739 session_entry->smeSessionId = sme_session_id;
2740 session_entry->transactionId = sme_transaction_id;
2741
2742 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2743 case eLIM_STA_ROLE:
2744 case eLIM_BT_AMP_STA_ROLE:
2745
2746 switch (session_entry->limSmeState) {
2747 case eLIM_SME_ASSOCIATED_STATE:
2748 case eLIM_SME_LINK_EST_STATE:
2749 case eLIM_SME_WT_ASSOC_STATE:
2750 case eLIM_SME_JOIN_FAILURE_STATE:
2751 case eLIM_SME_IDLE_STATE:
2752 session_entry->limPrevSmeState =
2753 session_entry->limSmeState;
2754 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2755 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2756 session_entry->peSessionId,
2757 session_entry->limSmeState));
2758 /* Send Deauthentication request to MLM below */
2759 break;
2760 case eLIM_SME_WT_DEAUTH_STATE:
2761 case eLIM_SME_WT_DISASSOC_STATE:
2762 /*
2763 * PE Recieved a Deauth/Disassoc frame. Normally it get
2764 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2765 * Which means host is also trying to disconnect.
2766 * PE can continue processing DEAUTH_REQ and send
2767 * the response instead of failing the request.
2768 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2769 * was sent for deauth/disassoc frame.
2770 */
2771 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2772 lim_log(mac_ctx, LOG1, FL(
2773 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2774 break;
2775 default:
2776 /*
2777 * STA is not in a state to deauthenticate with
2778 * peer. Log error and send response to host.
2779 */
2780 lim_log(mac_ctx, LOGE, FL(
2781 "received unexp SME_DEAUTH_REQ in state %X"),
2782 session_entry->limSmeState);
2783 lim_print_sme_state(mac_ctx, LOGE,
2784 session_entry->limSmeState);
2785
2786 if (mac_ctx->lim.gLimRspReqd) {
2787 mac_ctx->lim.gLimRspReqd = false;
2788
2789 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2790 deauth_trigger = eLIM_HOST_DEAUTH;
2791
2792 /*
2793 * here we received deauth request from AP so sme state
2794 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2795 * delSta then mlm state should be
2796 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2797 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2798 * so the below condition captures the state where
2799 * delSta not done and firmware still in
2800 * connected state.
2801 */
2802 if (session_entry->limSmeState ==
2803 eLIM_SME_WT_DEAUTH_STATE &&
2804 session_entry->limMlmState !=
2805 eLIM_MLM_IDLE_STATE &&
2806 session_entry->limMlmState !=
2807 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2808 ret_code = eSIR_SME_DEAUTH_STATUS;
2809 goto send_deauth;
2810 }
2811 return;
2812 }
2813 break;
2814
2815 case eLIM_STA_IN_IBSS_ROLE:
2816 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2817 if (mac_ctx->lim.gLimRspReqd) {
2818 mac_ctx->lim.gLimRspReqd = false;
2819 ret_code = eSIR_SME_INVALID_PARAMETERS;
2820 deauth_trigger = eLIM_HOST_DEAUTH;
2821 goto send_deauth;
2822 }
2823 return;
2824 case eLIM_AP_ROLE:
2825 break;
2826 default:
2827 lim_log(mac_ctx, LOGE,
2828 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2829 GET_LIM_SYSTEM_ROLE(session_entry));
2830 if (mac_ctx->lim.gLimRspReqd) {
2831 mac_ctx->lim.gLimRspReqd = false;
2832 ret_code = eSIR_SME_INVALID_PARAMETERS;
2833 deauth_trigger = eLIM_HOST_DEAUTH;
2834 goto send_deauth;
2835 }
2836 return;
2837 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2838
2839 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2840 /* Deauthentication is triggered by Link Monitoring */
2841 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2842 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2843 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2844 } else {
2845 deauth_trigger = eLIM_HOST_DEAUTH;
2846 reason_code = sme_deauth_req.reasonCode;
2847 }
2848
2849 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302850 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 if (NULL == mlm_deauth_req) {
2852 lim_log(mac_ctx, LOGP,
2853 FL("call to AllocateMemory failed for mlmDeauthReq"));
2854 if (mac_ctx->lim.gLimRspReqd) {
2855 mac_ctx->lim.gLimRspReqd = false;
2856 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2857 deauth_trigger = eLIM_HOST_DEAUTH;
2858 goto send_deauth;
2859 }
2860 return;
2861 }
2862
Anurag Chouhanc5548422016-02-24 18:33:27 +05302863 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002864 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865
2866 mlm_deauth_req->reasonCode = reason_code;
2867 mlm_deauth_req->deauthTrigger = deauth_trigger;
2868
2869 /* Update PE session Id */
2870 mlm_deauth_req->sessionId = session_id;
2871
2872 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2873 (uint32_t *)mlm_deauth_req);
2874 return;
2875
2876send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002877 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2878 ret_code, deauth_trigger, 1,
2879 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880}
2881
2882/**
2883 * __lim_process_sme_set_context_req()
2884 *
2885 * @mac_ctx: Pointer to Global MAC structure
2886 * @msg_buf: pointer to the SME message buffer
2887 *
2888 * This function is called to process SME_SETCONTEXT_REQ message
2889 * from HDD or upper layer application.
2890 *
2891 * Return: None
2892 */
2893
2894static void
2895__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2896{
2897 tpSirSmeSetContextReq set_context_req;
2898 tLimMlmSetKeysReq *mlm_set_key_req;
2899 tpPESession session_entry;
2900 uint8_t session_id; /* PE sessionID */
2901 uint8_t sme_session_id;
2902 uint16_t sme_transaction_id;
2903
2904 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2905
2906 if (msg_buf == NULL) {
2907 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2908 return;
2909 }
2910
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302911 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 if (NULL == set_context_req) {
2913 lim_log(mac_ctx, LOGP, FL(
2914 "call to AllocateMemory failed for set_context_req"));
2915 return;
2916 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302917 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 sizeof(struct sSirSmeSetContextReq));
2919 sme_session_id = set_context_req->sessionId;
2920 sme_transaction_id = set_context_req->transactionId;
2921
2922 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2923 lim_log(mac_ctx, LOGW,
2924 FL("received invalid SME_SETCONTEXT_REQ message"));
2925 goto end;
2926 }
2927
2928 if (set_context_req->keyMaterial.numKeys >
2929 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2930 lim_log(mac_ctx, LOGE, FL(
2931 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2932 set_context_req->keyMaterial.numKeys);
2933 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002934 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 eSIR_SME_INVALID_PARAMETERS, NULL,
2936 sme_session_id, sme_transaction_id);
2937 goto end;
2938 }
2939
2940 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002941 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 if (session_entry == NULL) {
2943 lim_log(mac_ctx, LOGW,
2944 FL("Session does not exist for given BSSID"));
2945 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002946 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 eSIR_SME_INVALID_PARAMETERS, NULL,
2948 sme_session_id, sme_transaction_id);
2949 goto end;
2950 }
2951#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2952 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2953 session_entry, 0, 0);
2954#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2955
2956 if (((LIM_IS_STA_ROLE(session_entry) ||
2957 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
2958 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2959 ((LIM_IS_IBSS_ROLE(session_entry) ||
2960 LIM_IS_AP_ROLE(session_entry) ||
2961 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
2962 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2963 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302964 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 if (NULL == mlm_set_key_req) {
2966 lim_log(mac_ctx, LOGP, FL(
2967 "mem alloc failed for mlmSetKeysReq"));
2968 goto end;
2969 }
2970 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2971 mlm_set_key_req->numKeys =
2972 set_context_req->keyMaterial.numKeys;
2973 if (mlm_set_key_req->numKeys >
2974 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2975 lim_log(mac_ctx, LOGP, FL(
2976 "no.of keys exceeded max num of default keys limit"));
2977 goto end;
2978 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302979 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002980 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302982 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 (uint8_t *) &set_context_req->keyMaterial.key,
2984 sizeof(tSirKeys) *
2985 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2986 numKeys : 1));
2987
2988 mlm_set_key_req->sessionId = session_id;
2989 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 lim_log(mac_ctx, LOG1, FL(
2991 "received SETCONTEXT_REQ message sessionId=%d"),
2992 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993
2994 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2995 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2996 LIM_IS_AP_ROLE(session_entry)) {
2997 if (set_context_req->keyMaterial.key[0].keyLength) {
2998 uint8_t key_id;
2999 key_id =
3000 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303001 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 &session_entry->WEPKeyMaterial[key_id],
3003 (uint8_t *) &set_context_req->keyMaterial,
3004 sizeof(tSirKeyMaterial));
3005 } else {
3006 uint32_t i;
3007 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3008 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303009 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 &mlm_set_key_req->key[i],
3011 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3012 sizeof(tSirKeys));
3013 }
3014 }
3015 }
3016 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3017 (uint32_t *) mlm_set_key_req);
3018 } else {
3019 lim_log(mac_ctx, LOGE, FL(
3020 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3021 GET_LIM_SYSTEM_ROLE(session_entry),
3022 session_entry->limSmeState);
3023 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3024
3025 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003026 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3028 session_entry, sme_session_id,
3029 sme_transaction_id);
3030 }
3031end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303032 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 return;
3034}
3035
3036/**
3037 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3038 *
3039 * @mac_ctx: Pointer to Global MAC structure
3040 * @msg_buf: pointer to the SME message buffer
3041 *
3042 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3043 * from HDD or upper layer application.
3044 *
3045 * Return: None
3046 */
3047
3048void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3049 uint32_t *msg_buf)
3050{
3051 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3052 tpDphHashNode sta_ds = NULL;
3053 tpPESession session_entry = NULL;
3054 tSap_Event sap_event;
3055 tpWLAN_SAPEventCB sap_event_cb = NULL;
3056 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3057 uint8_t session_id = CSR_SESSION_ID_INVALID;
3058 uint8_t assoc_id = 0;
3059 uint8_t sta_cnt = 0;
3060
3061 if (msg_buf == NULL) {
3062 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3063 return;
3064 }
3065
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303066 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 sizeof(struct sSirSmeGetAssocSTAsReq));
3068 /*
3069 * Get Associated stations from PE.
3070 * Find PE session Entry
3071 */
3072 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003073 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 &session_id);
3075 if (session_entry == NULL) {
3076 lim_log(mac_ctx, LOGE,
3077 FL("session does not exist for given bssId"));
3078 goto lim_assoc_sta_end;
3079 }
3080
3081 if (!LIM_IS_AP_ROLE(session_entry)) {
3082 lim_log(mac_ctx, LOGE, FL(
3083 "Received unexpected message in state %X, in role %X"),
3084 session_entry->limSmeState,
3085 GET_LIM_SYSTEM_ROLE(session_entry));
3086 goto lim_assoc_sta_end;
3087 }
3088 /* Retrieve values obtained in the request message */
3089 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3090 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3091
3092 if (NULL == assoc_sta_tmp)
3093 goto lim_assoc_sta_end;
3094 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3095 assoc_id++) {
3096 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3097 &session_entry->dph.dphHashTable);
3098 if (NULL == sta_ds)
3099 continue;
3100 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303101 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303103 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3105 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3106
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303107 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 (uint8_t *)&sta_ds->supportedRates,
3109 sizeof(tSirSupportedRates));
3110 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3111 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3112 assoc_sta_tmp->Support40Mhz =
3113 sta_ds->htDsssCckRate40MHzSupport;
3114
3115 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3116 sta_cnt + 1);
3117 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3118 MAC_ADDR_ARRAY(sta_ds->staAddr));
3119 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3120 sta_ds->assocId);
3121 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3122 sta_ds->staIndex);
3123 assoc_sta_tmp++;
3124 sta_cnt++;
3125 }
3126 }
3127lim_assoc_sta_end:
3128 /*
3129 * Call hdd callback with sap event to send the list of
3130 * associated stations from PE
3131 */
3132 if (sap_event_cb != NULL) {
3133 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3134 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303135 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3137 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3138 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3139 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3140 }
3141}
3142
3143/**
3144 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3145 *
3146 * @mac_ctx: Pointer to Global MAC structure
3147 * @msg_buf: pointer to WPS PBC overlap query message
3148 *
3149 * This function parses get WPS PBC overlap information
3150 * message and call callback to pass WPS PBC overlap
3151 * information back to hdd.
3152 *
3153 * Return: None
3154 */
3155void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3156 uint32_t *msg_buf)
3157{
3158 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3159 tpPESession session_entry = NULL;
3160 tSap_Event sap_event;
3161 tpWLAN_SAPEventCB sap_event_cb = NULL;
3162 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3164
3165 if (msg_buf == NULL) {
3166 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3167 return;
3168 }
3169
3170 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303171 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303173 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3175 /*
3176 * Get Associated stations from PE
3177 * Find PE session Entry
3178 */
3179 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003180 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 if (session_entry == NULL) {
3182 lim_log(mac_ctx, LOGE,
3183 FL("session does not exist for given bssId"));
3184 goto lim_get_wpspbc_sessions_end;
3185 }
3186
3187 if (!LIM_IS_AP_ROLE(session_entry)) {
3188 lim_log(mac_ctx, LOGE,
3189 FL("Received unexpected message in role %X"),
3190 GET_LIM_SYSTEM_ROLE(session_entry));
3191 goto lim_get_wpspbc_sessions_end;
3192 }
3193 /*
3194 * Call hdd callback with sap event to send the
3195 * WPS PBC overlap information
3196 */
3197 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303198 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199
Anurag Chouhanc5548422016-02-24 18:33:27 +05303200 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003202 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 sap_get_wpspbc_event->UUID_E,
3204 &sap_get_wpspbc_event->wpsPBCOverlap,
3205 session_entry);
3206 } else {
3207 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003208 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 session_entry);
3210 /* don't have to inform the HDD/Host */
3211 return;
3212 }
3213
3214 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3215 sap_get_wpspbc_event->wpsPBCOverlap);
3216 lim_print_mac_addr(mac_ctx,
3217 sap_get_wpspbc_event->addr.bytes, LOG4);
3218
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303219 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220
3221lim_get_wpspbc_sessions_end:
3222 sap_event_cb =
3223 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3224 if (NULL != sap_event_cb)
3225 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3226}
3227
3228/**
3229 * __lim_counter_measures()
3230 *
3231 * FUNCTION:
3232 * This function is called to "implement" MIC counter measure
3233 * and is *temporary* only
3234 *
3235 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3236 * we don't do the proper STA disassoc sequence since the
3237 * BSS will be stoped anyway
3238 *
3239 ***ASSUMPTIONS:
3240 *
3241 ***NOTE:
3242 *
3243 * @param pMac Pointer to Global MAC structure
3244 * @return None
3245 */
3246
3247static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3248{
3249 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3250 if (LIM_IS_AP_ROLE(psessionEntry) ||
3251 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3252 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3253 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3254 mac, psessionEntry, false);
3255};
3256
3257void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3258{
3259 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3260 tpPESession psessionEntry;
3261 uint8_t sessionId; /* PE sessionId */
3262
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303263 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 sizeof(struct sSirSmeTkipCntrMeasReq));
3265
3266 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003267 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 if (NULL == psessionEntry) {
3269 lim_log(pMac, LOGE,
3270 FL("session does not exist for given BSSID "));
3271 return;
3272 }
3273
3274 if (tkipCntrMeasReq.bEnable)
3275 __lim_counter_measures(pMac, psessionEntry);
3276
3277 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3278}
3279
3280static void
3281__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3282{
3283 tSirSmeStopBssReq stopBssReq;
3284 tSirRetStatus status;
3285 tLimSmeStates prevState;
3286 tpPESession psessionEntry;
3287 uint8_t smesessionId;
3288 uint8_t sessionId;
3289 uint16_t smetransactionId;
3290 uint8_t i = 0;
3291 tpDphHashNode pStaDs = NULL;
3292
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303293 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 smesessionId = stopBssReq.sessionId;
3295 smetransactionId = stopBssReq.transactionId;
3296
3297 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3298 PELOGW(lim_log(pMac, LOGW,
3299 FL("received invalid SME_STOP_BSS_REQ message"));)
3300 /* Send Stop BSS response to host */
3301 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3302 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3303 smetransactionId);
3304 return;
3305 }
3306
3307 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003308 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 &sessionId);
3310 if (psessionEntry == NULL) {
3311 lim_log(pMac, LOGW,
3312 FL("session does not exist for given BSSID "));
3313 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3314 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3315 smetransactionId);
3316 return;
3317 }
3318#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3319 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3320 0, 0);
3321#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3322
3323 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3324 LIM_IS_STA_ROLE(psessionEntry)) {
3325 /**
3326 * Should not have received STOP_BSS_REQ in states
3327 * other than 'normal' state or on STA in Infrastructure
3328 * mode. Log error and return response to host.
3329 */
3330 lim_log(pMac, LOGE,
3331 FL
3332 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3333 psessionEntry->limSmeState,
3334 GET_LIM_SYSTEM_ROLE(psessionEntry));
3335 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3336 /* / Send Stop BSS response to host */
3337 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3338 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3339 smetransactionId);
3340 return;
3341 }
3342
3343 if (LIM_IS_AP_ROLE(psessionEntry))
3344 lim_wpspbc_close(pMac, psessionEntry);
3345
3346 lim_log(pMac, LOGW,
3347 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3348 stopBssReq.reasonCode);
3349
3350 prevState = psessionEntry->limSmeState;
3351
3352 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3353 MTRACE(mac_trace
3354 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3355 psessionEntry->limSmeState));
3356
3357 /* Update SME session Id and Transaction Id */
3358 psessionEntry->smeSessionId = smesessionId;
3359 psessionEntry->transactionId = smetransactionId;
3360
3361 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3362 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3363 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3364 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3365 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3366 /* Send disassoc all stations associated thru TKIP */
3367 __lim_counter_measures(pMac, psessionEntry);
3368 else
3369 lim_send_disassoc_mgmt_frame(pMac,
3370 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3371 bcAddr, psessionEntry, false);
3372 }
3373
3374 /* Free the buffer allocated in START_BSS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303375 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 psessionEntry->addIeParams.probeRespDataLen = 0;
3377 psessionEntry->addIeParams.probeRespData_buff = NULL;
3378
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303379 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 psessionEntry->addIeParams.assocRespDataLen = 0;
3381 psessionEntry->addIeParams.assocRespData_buff = NULL;
3382
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303383 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3385 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3386
3387 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3388 pMac->lim.gLimIbssCoalescingHappened = false;
3389
3390 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3391 pStaDs =
3392 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3393 if (NULL == pStaDs)
3394 continue;
3395 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3396 if (eSIR_SUCCESS == status) {
3397 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3398 pStaDs->assocId, psessionEntry);
3399 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3400 } else {
3401 lim_log(pMac, LOGE,
3402 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303403 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 }
3405 }
3406 /* send a delBss to HAL and wait for a response */
3407 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3408
3409 if (status != eSIR_SUCCESS) {
3410 PELOGE(lim_log
3411 (pMac, LOGE, FL("delBss failed for bss %d"),
3412 psessionEntry->bssIdx);
3413 )
3414 psessionEntry->limSmeState = prevState;
3415
3416 MTRACE(mac_trace
3417 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3418 psessionEntry->limSmeState));
3419
3420 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3421 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3422 smetransactionId);
3423 }
3424}
3425
3426/**
3427 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3428 * @pMac: Global MAC context
3429 * @pMsg: Message from SME
3430 *
3431 * Wrapper for the function __lim_handle_sme_stop_bss_request
3432 * This message will be defered until softmac come out of
3433 * scan mode. Message should be handled even if we have
3434 * detected radar in the current operating channel.
3435 *
3436 * Return: true - If we consumed the buffer
3437 * false - If have defered the message.
3438 */
3439
3440static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3441{
3442 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3443 /**
3444 * If message defered, buffer is not consumed yet.
3445 * So return false
3446 */
3447 return false;
3448 }
3449 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3450 return true;
3451} /*** end __lim_process_sme_stop_bss_req() ***/
3452
3453void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3454 uint32_t body, tpPESession psessionEntry)
3455{
3456
3457 (void)body;
3458 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3459 lim_ibss_delete(pMac, psessionEntry);
3460 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3461 lim_delete_pre_auth_list(pMac);
3462 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3463 psessionEntry->smeSessionId,
3464 psessionEntry->transactionId);
3465 return;
3466}
3467
3468/**
3469 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3470 *
3471 * @mac_ctx: pointer to mac context
3472 * @msg_type: message type
3473 * @msg_buf: pointer to the SME message buffer
3474 *
3475 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3476 * in BTAMP AP.
3477 *
3478 * Return: None
3479 */
3480
3481void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3482 uint32_t *msg_buf)
3483{
3484 tSirSmeAssocCnf assoc_cnf;
3485 tpDphHashNode sta_ds = NULL;
3486 tpPESession session_entry = NULL;
3487 uint8_t session_id;
3488 tpSirAssocReq assoc_req;
3489
3490 if (msg_buf == NULL) {
3491 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3492 goto end;
3493 }
3494
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303495 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3497 lim_log(mac_ctx, LOGE,
3498 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3499 goto end;
3500 }
3501
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003502 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 &session_id);
3504 if (session_entry == NULL) {
3505 lim_log(mac_ctx, LOGE,
3506 FL("session does not exist for given bssId"));
3507 goto end;
3508 }
3509
3510 if ((!LIM_IS_AP_ROLE(session_entry) &&
3511 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3512 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3513 (session_entry->limSmeState !=
3514 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3515 lim_log(mac_ctx, LOGE, FL(
3516 "Rcvd unexpected msg %X in state %X, in role %X"),
3517 msg_type, session_entry->limSmeState,
3518 GET_LIM_SYSTEM_ROLE(session_entry));
3519 goto end;
3520 }
3521 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3522 &session_entry->dph.dphHashTable);
3523 if (sta_ds == NULL) {
3524 lim_log(mac_ctx, LOGE, FL(
3525 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3526 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003527 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528
3529 /*
3530 * send a DISASSOC_IND message to WSM to make sure
3531 * the state in WSM and LIM is the same
3532 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003533 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 eSIR_SME_STA_NOT_ASSOCIATED,
3535 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3536 session_entry->smeSessionId,
3537 session_entry->transactionId,
3538 session_entry);
3539 goto end;
3540 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303541 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003542 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303543 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 lim_log(mac_ctx, LOG1, FL(
3545 "peerMacAddr mismatched for aid %d, peer "),
3546 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003547 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 goto end;
3549 }
3550
3551 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3552 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3553 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3554 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3555 (msg_type != eWNI_SME_ASSOC_CNF))) {
3556 lim_log(mac_ctx, LOG1, FL(
3557 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3558 "StaD mlmState : %d"),
3559 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003560 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 goto end;
3562 }
3563 /*
3564 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3565 * has been received
3566 */
3567 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3568 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3569 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3570
3571 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3572 /*
3573 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3574 * when it had received Assoc Request frame. Now, PE just needs
3575 * to send association rsp frame to the requesting BTAMP-STA.
3576 */
3577 sta_ds->mlmStaContext.mlmState =
3578 eLIM_MLM_LINK_ESTABLISHED_STATE;
3579 lim_log(mac_ctx, LOG1,
3580 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3581 sta_ds->assocId);
3582 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3583 sta_ds->assocId, sta_ds->staAddr,
3584 sta_ds->mlmStaContext.subType, sta_ds,
3585 session_entry);
3586 goto end;
3587 } else {
3588 /*
3589 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3590 * to be associated since the HAL sta entry is created for
3591 * denied STA we need to remove this HAL entry.
3592 * So to do that set updateContext to 1
3593 */
3594 if (!sta_ds->mlmStaContext.updateContext)
3595 sta_ds->mlmStaContext.updateContext = 1;
3596 lim_log(mac_ctx, LOG1,
3597 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3598 assoc_cnf.statusCode, sta_ds->assocId);
3599 lim_reject_association(mac_ctx, sta_ds->staAddr,
3600 sta_ds->mlmStaContext.subType,
3601 true, sta_ds->mlmStaContext.authType,
3602 sta_ds->assocId, true,
3603 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3604 session_entry);
3605 }
3606end:
3607 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3608 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3609 assoc_req = (tpSirAssocReq)
3610 session_entry->parsedAssocReq[sta_ds->assocId];
3611 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303612 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 assoc_req->assocReqFrame = NULL;
3614 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303615 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3617 }
3618}
3619
3620static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3621{
3622 tpDphHashNode pStaDs;
3623 tSirMacAddr peerMac;
3624 tpSirAddtsReq pSirAddts;
3625 uint32_t timeout;
3626 tpPESession psessionEntry;
3627 uint8_t sessionId; /* PE sessionId */
3628 uint8_t smesessionId;
3629 uint16_t smetransactionId;
3630
3631 if (pMsgBuf == NULL) {
3632 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3633 return;
3634 }
3635
3636 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3637 &smetransactionId);
3638
3639 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3640
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003641 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3642 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 if (psessionEntry == NULL) {
3644 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3645 return;
3646 }
3647#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3648 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3649 0);
3650#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3651
3652 /* if sta
3653 * - verify assoc state
3654 * - send addts request to ap
3655 * - wait for addts response from ap
3656 * if ap, just ignore with error log
3657 */
3658 PELOG1(lim_log(pMac, LOG1,
3659 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3660 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3661 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3662 )
3663
3664 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3665 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3666 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3667 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3668 psessionEntry, pSirAddts->req.tspec,
3669 smesessionId, smetransactionId);
3670 return;
3671 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003672
3673 pStaDs =
3674 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3675 &psessionEntry->dph.dphHashTable);
3676
3677 if (pStaDs == NULL) {
3678 PELOGE(lim_log
3679 (pMac, LOGE, "Cannot find AP context for addts req");
3680 )
3681 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3682 psessionEntry, pSirAddts->req.tspec,
3683 smesessionId, smetransactionId);
3684 return;
3685 }
3686
3687 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3688 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3689 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3690 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3691 psessionEntry, pSirAddts->req.tspec,
3692 smesessionId, smetransactionId);
3693 return;
3694 }
3695
3696 pSirAddts->req.wsmTspecPresent = 0;
3697 pSirAddts->req.wmeTspecPresent = 0;
3698 pSirAddts->req.lleTspecPresent = 0;
3699
3700 if ((pStaDs->wsmEnabled) &&
3701 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3702 SIR_MAC_ACCESSPOLICY_EDCA))
3703 pSirAddts->req.wsmTspecPresent = 1;
3704 else if (pStaDs->wmeEnabled)
3705 pSirAddts->req.wmeTspecPresent = 1;
3706 else if (pStaDs->lleEnabled)
3707 pSirAddts->req.lleTspecPresent = 1;
3708 else {
3709 PELOGW(lim_log
3710 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3711 )
3712 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3713 psessionEntry, pSirAddts->req.tspec,
3714 smesessionId, smetransactionId);
3715 return;
3716 }
3717
3718 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3719 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3720 lim_log(pMac, LOGE,
3721 "AddTs received in invalid LIMsme state (%d)",
3722 psessionEntry->limSmeState);
3723 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3724 psessionEntry, pSirAddts->req.tspec,
3725 smesessionId, smetransactionId);
3726 return;
3727 }
3728
3729 if (pMac->lim.gLimAddtsSent) {
3730 lim_log(pMac, LOGE,
3731 "Addts (token %d, tsid %d, up %d) is still pending",
3732 pMac->lim.gLimAddtsReq.req.dialogToken,
3733 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3734 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3735 userPrio);
3736 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3737 psessionEntry, pSirAddts->req.tspec,
3738 smesessionId, smetransactionId);
3739 return;
3740 }
3741
3742 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3743
3744 /* save the addts request */
3745 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303746 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3748
3749 /* ship out the message now */
3750 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3751 psessionEntry);
3752 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3753 /* start a timer to wait for the response */
3754 if (pSirAddts->timeout)
3755 timeout = pSirAddts->timeout;
3756 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3757 eSIR_SUCCESS) {
3758 lim_log(pMac, LOGP,
3759 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3760 WNI_CFG_ADDTS_RSP_TIMEOUT);
3761 return;
3762 }
3763
3764 timeout = SYS_MS_TO_TICKS(timeout);
3765 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3766 != TX_SUCCESS) {
3767 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3768 return;
3769 }
3770 pMac->lim.gLimAddtsRspTimerCount++;
3771 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3772 pMac->lim.gLimAddtsRspTimerCount) !=
3773 TX_SUCCESS) {
3774 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3775 return;
3776 }
3777 MTRACE(mac_trace
3778 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3779 eLIM_ADDTS_RSP_TIMER));
3780
3781 /* add the sessionId to the timer object */
3782 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3783 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3784 TX_SUCCESS) {
3785 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3786 return;
3787 }
3788 return;
3789}
3790
3791static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3792{
3793 tSirMacAddr peerMacAddr;
3794 uint8_t ac;
3795 tSirMacTSInfo *pTsinfo;
3796 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3797 tpDphHashNode pStaDs = NULL;
3798 tpPESession psessionEntry;
3799 uint8_t sessionId;
3800 uint32_t status = eSIR_SUCCESS;
3801 uint8_t smesessionId;
3802 uint16_t smetransactionId;
3803
3804 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3805 &smetransactionId);
3806
3807 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003808 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 &sessionId);
3810 if (psessionEntry == NULL) {
3811 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3812 status = eSIR_FAILURE;
3813 goto end;
3814 }
3815#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3816 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3817 0);
3818#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3819
3820 if (eSIR_SUCCESS !=
3821 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3822 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3823 status = eSIR_FAILURE;
3824 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3825 smesessionId, smetransactionId);
3826 return;
3827 }
3828
3829 lim_log(pMac, LOG1,
3830 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3831 MAC_ADDRESS_STR),
3832 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3833
3834 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3835 pDeltsReq->req.wmeTspecPresent,
3836 &pDeltsReq->req.tsinfo,
3837 &pDeltsReq->req.tspec, psessionEntry);
3838
3839 pTsinfo =
3840 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3841 tsinfo : &pDeltsReq->req.tsinfo;
3842
3843 /* We've successfully send DELTS frame to AP. Update the
3844 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3845 * is no longer trigger enabled or delivery enabled
3846 */
3847 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3848 pTsinfo, CLEAR_UAPSD_MASK);
3849
3850 /* We're deleting the TSPEC, so this particular AC is no longer
3851 * admitted. PE needs to downgrade the EDCA
3852 * parameters(for the AC for which TS is being deleted) to the
3853 * next best AC for which ACM is not enabled, and send the
3854 * updated values to HAL.
3855 */
3856 ac = upToAc(pTsinfo->traffic.userPrio);
3857
3858 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3859 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3860 ~(1 << ac);
3861 } else if (pTsinfo->traffic.direction ==
3862 SIR_MAC_DIRECTION_DNLINK) {
3863 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3864 ~(1 << ac);
3865 } else if (pTsinfo->traffic.direction ==
3866 SIR_MAC_DIRECTION_BIDIR) {
3867 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3868 ~(1 << ac);
3869 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3870 ~(1 << ac);
3871 }
3872
3873 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3874 psessionEntry);
3875
3876 pStaDs =
3877 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3878 &psessionEntry->dph.dphHashTable);
3879 if (pStaDs != NULL) {
3880 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3881 pStaDs->bssId);
3882 status = eSIR_SUCCESS;
3883 } else {
3884 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3885 status = eSIR_FAILURE;
3886 }
3887#ifdef FEATURE_WLAN_ESE
3888#ifdef FEATURE_WLAN_ESE_UPLOAD
3889 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890#endif /* FEATURE_WLAN_ESE_UPLOAD */
3891#endif
3892
3893 /* send an sme response back */
3894end:
3895 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3896 smesessionId, smetransactionId);
3897}
3898
3899void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3900{
3901 /* fetch the sessionEntry based on the sessionId */
3902 tpPESession psessionEntry;
3903 psessionEntry = pe_find_session_by_session_id(pMac,
3904 pMac->lim.limTimers.gLimAddtsRspTimer.
3905 sessionId);
3906 if (psessionEntry == NULL) {
3907 lim_log(pMac, LOGP,
3908 FL("Session Does not exist for given sessionID"));
3909 return;
3910 }
3911
3912 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3913 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3914 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3915 GET_LIM_SYSTEM_ROLE(psessionEntry));
3916 pMac->lim.gLimAddtsSent = false;
3917 return;
3918 }
3919
3920 if (!pMac->lim.gLimAddtsSent) {
3921 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3922 return;
3923 }
3924
3925 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3926 lim_log(pMac, LOGE,
3927 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3928 pMac->lim.gLimAddtsRspTimerCount);
3929 return;
3930 }
3931 /* this a real response timeout */
3932 pMac->lim.gLimAddtsSent = false;
3933 pMac->lim.gLimAddtsRspTimerCount++;
3934
3935 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3936 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3937 psessionEntry->smeSessionId,
3938 psessionEntry->transactionId);
3939}
3940
3941/**
3942 * __lim_process_sme_get_statistics_request()
3943 *
3944 ***FUNCTION:
3945 *
3946 *
3947 ***NOTE:
3948 *
3949 * @param pMac Pointer to Global MAC structure
3950 * @param *pMsgBuf A pointer to the SME message buffer
3951 * @return None
3952 */
3953static void
3954__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3955{
3956 tpAniGetPEStatsReq pPEStatsReq;
3957 tSirMsgQ msgQ;
3958
3959 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3960
3961 msgQ.type = WMA_GET_STATISTICS_REQ;
3962
3963 msgQ.reserved = 0;
3964 msgQ.bodyptr = pMsgBuf;
3965 msgQ.bodyval = 0;
3966 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3967
3968 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303969 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970 pMsgBuf = NULL;
3971 lim_log(pMac, LOGP, "Unable to forward request");
3972 return;
3973 }
3974
3975 return;
3976}
3977
3978#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
3979/**
3980 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
3981 *
3982 ***NOTE:
3983 *
3984 * @param pMac Pointer to Global MAC structure
3985 * @param *pMsgBuf A pointer to the SME message buffer
3986 * @return None
3987 */
3988static void
3989__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3990{
3991 tSirMsgQ msgQ;
3992
3993 msgQ.type = WMA_TSM_STATS_REQ;
3994 msgQ.reserved = 0;
3995 msgQ.bodyptr = pMsgBuf;
3996 msgQ.bodyval = 0;
3997 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3998
3999 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304000 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 pMsgBuf = NULL;
4002 lim_log(pMac, LOGP, "Unable to forward request");
4003 return;
4004 }
4005}
4006#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4007
4008static void
4009__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4010{
4011 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4012 tpPESession psessionEntry;
4013 uint8_t sessionId; /* PE sessionID */
4014
4015 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4016
4017 if (pMsgBuf == NULL) {
4018 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4019 return;
4020 }
4021
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304022 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 if (NULL == pUpdateAPWPSIEsReq) {
4024 lim_log(pMac, LOGP,
4025 FL
4026 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4027 return;
4028 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304029 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 sizeof(struct sSirUpdateAPWPSIEsReq));
4031
4032 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004033 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 &sessionId);
4035 if (psessionEntry == NULL) {
4036 lim_log(pMac, LOGW,
4037 FL("Session does not exist for given BSSID"));
4038 goto end;
4039 }
4040
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304041 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 sizeof(tSirAPWPSIEs));
4043
4044 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4045 lim_send_beacon_ind(pMac, psessionEntry);
4046
4047end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304048 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 return;
4050}
4051
4052void
4053lim_send_vdev_restart(tpAniSirGlobal pMac,
4054 tpPESession psessionEntry, uint8_t sessionId)
4055{
4056 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4057 tSirMsgQ msgQ;
4058 tSirRetStatus retCode = eSIR_SUCCESS;
4059
4060 if (psessionEntry == NULL) {
4061 PELOGE(lim_log
4062 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4063 __LINE__);
4064 )
4065 return;
4066 }
4067
4068 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304069 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 if (NULL == pHalHiddenSsidVdevRestart) {
4071 PELOGE(lim_log
4072 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4073 __func__, __LINE__);
4074 )
4075 return;
4076 }
4077
4078 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4079 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4080
4081 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4082 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4083 msgQ.bodyval = 0;
4084
4085 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4086 if (eSIR_SUCCESS != retCode) {
4087 PELOGE(lim_log
4088 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4089 __LINE__);
4090 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 }
4093}
4094
4095static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4096{
4097 tpSirUpdateParams pUpdateParams;
4098 tpPESession psessionEntry;
4099
4100 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4101
4102 if (pMsgBuf == NULL) {
4103 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4104 return;
4105 }
4106
4107 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4108
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004109 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 pUpdateParams->sessionId);
4111 if (psessionEntry == NULL) {
4112 lim_log(pMac, LOGW,
4113 "Session does not exist for given sessionId %d",
4114 pUpdateParams->sessionId);
4115 return;
4116 }
4117
4118 /* Update the session entry */
4119 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4120
4121 /* Send vdev restart */
4122 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4123
4124 /* Update beacon */
4125 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4126 lim_send_beacon_ind(pMac, psessionEntry);
4127
4128 return;
4129} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4130
4131static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4132{
4133 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4134 tpPESession psessionEntry;
4135 uint8_t sessionId; /* PE sessionID */
4136
4137 if (pMsgBuf == NULL) {
4138 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4139 return;
4140 }
4141
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304142 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 if (NULL == pUpdateAPWPARSNIEsReq) {
4144 lim_log(pMac, LOGP,
4145 FL
4146 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4147 return;
4148 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304149 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4151
4152 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004153 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 &sessionId);
4155 if (psessionEntry == NULL) {
4156 lim_log(pMac, LOGW,
4157 FL("Session does not exist for given BSSID"));
4158 goto end;
4159 }
4160
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304161 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4163
4164 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4165 &psessionEntry->
4166 pLimStartBssReq->rsnIE,
4167 psessionEntry);
4168
4169 psessionEntry->pLimStartBssReq->privacy = 1;
4170 psessionEntry->privacy = 1;
4171
4172 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4173 lim_send_beacon_ind(pMac, psessionEntry);
4174
4175end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304176 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 return;
4178} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4179
4180/*
4181 Update the beacon Interval dynamically if beaconInterval is different in MCC
4182 */
4183static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4184{
4185 tpSirChangeBIParams pChangeBIParams;
4186 tpPESession psessionEntry;
4187 uint8_t sessionId = 0;
4188 tUpdateBeaconParams beaconParams;
4189
4190 PELOG1(lim_log(pMac, LOG1,
4191 FL("received Update Beacon Interval message"));
4192 );
4193
4194 if (pMsgBuf == NULL) {
4195 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4196 return;
4197 }
4198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304199 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4201
4202 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004203 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 &sessionId);
4205 if (psessionEntry == NULL) {
4206 lim_log(pMac, LOGE,
4207 FL("Session does not exist for given BSSID"));
4208 return;
4209 }
4210
4211 /*Update sessionEntry Beacon Interval */
4212 if (psessionEntry->beaconParams.beaconInterval !=
4213 pChangeBIParams->beaconInterval) {
4214 psessionEntry->beaconParams.beaconInterval =
4215 pChangeBIParams->beaconInterval;
4216 }
4217
4218 /*Update sch beaconInterval */
4219 if (pMac->sch.schObject.gSchBeaconInterval !=
4220 pChangeBIParams->beaconInterval) {
4221 pMac->sch.schObject.gSchBeaconInterval =
4222 pChangeBIParams->beaconInterval;
4223
4224 PELOG1(lim_log(pMac, LOG1,
4225 FL
4226 ("LIM send update BeaconInterval Indication : %d"),
4227 pChangeBIParams->beaconInterval);
4228 );
4229
4230 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4231 /* Update beacon */
4232 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4233
4234 beaconParams.bssIdx = psessionEntry->bssIdx;
4235 /* Set change in beacon Interval */
4236 beaconParams.beaconInterval =
4237 pChangeBIParams->beaconInterval;
4238 beaconParams.paramChangeBitmap =
4239 PARAM_BCN_INTERVAL_CHANGED;
4240 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4241 }
4242 }
4243
4244 return;
4245} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4246
4247#ifdef QCA_HT_2040_COEX
4248static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4249 uint32_t *pMsgBuf)
4250{
4251 tpSirSetHT2040Mode pSetHT2040Mode;
4252 tpPESession psessionEntry;
4253 uint8_t sessionId = 0;
4254 cds_msg_t msg;
4255 tUpdateVHTOpMode *pHtOpMode = NULL;
4256 uint16_t staId = 0;
4257 tpDphHashNode pStaDs = NULL;
4258
4259 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4260 if (pMsgBuf == NULL) {
4261 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4262 return;
4263 }
4264
4265 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4266
4267 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004268 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 &sessionId);
4270 if (psessionEntry == NULL) {
4271 lim_log(pMac, LOG1,
4272 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004273 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 return;
4275 }
4276
4277 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4278 pSetHT2040Mode->cbMode);
4279 /*Update sessionEntry HT related fields */
4280 switch (pSetHT2040Mode->cbMode) {
4281 case PHY_SINGLE_CHANNEL_CENTERED:
4282 psessionEntry->htSecondaryChannelOffset =
4283 PHY_SINGLE_CHANNEL_CENTERED;
4284 psessionEntry->htRecommendedTxWidthSet = 0;
4285 if (pSetHT2040Mode->obssEnabled)
4286 psessionEntry->htSupportedChannelWidthSet
4287 = eHT_CHANNEL_WIDTH_40MHZ;
4288 else
4289 psessionEntry->htSupportedChannelWidthSet
4290 = eHT_CHANNEL_WIDTH_20MHZ;
4291 break;
4292 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4293 psessionEntry->htSecondaryChannelOffset =
4294 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4295 psessionEntry->htRecommendedTxWidthSet = 1;
4296 break;
4297 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4298 psessionEntry->htSecondaryChannelOffset =
4299 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4300 psessionEntry->htRecommendedTxWidthSet = 1;
4301 break;
4302 default:
4303 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4304 return;
4305 }
4306
4307 /* Update beacon */
4308 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4309 lim_send_beacon_ind(pMac, psessionEntry);
4310
4311 /* update OP Mode for each associated peer */
4312 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4313 pStaDs = dph_get_hash_entry(pMac, staId,
4314 &psessionEntry->dph.dphHashTable);
4315 if (NULL == pStaDs)
4316 continue;
4317
4318 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304319 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 if (NULL == pHtOpMode) {
4321 lim_log(pMac, LOGE,
4322 FL
4323 ("%s: Not able to allocate memory for setting OP mode"),
4324 __func__);
4325 return;
4326 }
4327 pHtOpMode->opMode =
4328 (psessionEntry->htSecondaryChannelOffset ==
4329 PHY_SINGLE_CHANNEL_CENTERED) ?
4330 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4331 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304332 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 sizeof(tSirMacAddr));
4334 pHtOpMode->smesessionId = sessionId;
4335
4336 msg.type = WMA_UPDATE_OP_MODE;
4337 msg.reserved = 0;
4338 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304339 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304340 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341 lim_log(pMac, LOGE,
4342 FL
4343 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4344 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304345 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 return;
4347 }
4348 lim_log(pMac, LOG1,
4349 FL
4350 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4351 __func__, pHtOpMode->opMode, staId);
4352
4353 } else
4354 lim_log(pMac, LOG1,
4355 FL("%s: station %d does not support HT40\n"),
4356 __func__, staId);
4357 }
4358
4359 return;
4360}
4361#endif
4362
4363/* -------------------------------------------------------------------- */
4364/**
4365 * __lim_process_report_message
4366 *
4367 * FUNCTION: Processes the next received Radio Resource Management message
4368 *
4369 * LOGIC:
4370 *
4371 * ASSUMPTIONS:
4372 *
4373 * NOTE:
4374 *
4375 * @param None
4376 * @return None
4377 */
4378
4379void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4380{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 switch (pMsg->type) {
4382 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4383 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4384 break;
4385 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004387 break;
4388 default:
4389 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391}
4392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393/* -------------------------------------------------------------------- */
4394/**
4395 * lim_send_set_max_tx_power_req
4396 *
4397 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4398 *
4399 * LOGIC:
4400 *
4401 * ASSUMPTIONS:
4402 *
4403 * NOTE:
4404 *
4405 * @param txPower txPower to be set.
4406 * @param pSessionEntry session entry.
4407 * @return None
4408 */
4409tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004410lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 tpPESession pSessionEntry)
4412{
4413 tpMaxTxPowerParams pMaxTxParams = NULL;
4414 tSirRetStatus retCode = eSIR_SUCCESS;
4415 tSirMsgQ msgQ;
4416
4417 if (pSessionEntry == NULL) {
4418 PELOGE(lim_log
4419 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4420 __LINE__);
4421 )
4422 return eSIR_FAILURE;
4423 }
4424
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304425 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 if (NULL == pMaxTxParams) {
4427 lim_log(pMac, LOGP,
4428 FL("Unable to allocate memory for pMaxTxParams "));
4429 return eSIR_MEM_ALLOC_FAILED;
4430
4431 }
4432#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4433 lim_log(pMac, LOG1,
4434 FL("pMaxTxParams allocated...will be freed in other module"));
4435#endif
4436 if (pMaxTxParams == NULL) {
4437 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4438 return eSIR_FAILURE;
4439 }
4440 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304441 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304442 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304443 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004444 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304445 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446
4447 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4448 msgQ.bodyptr = pMaxTxParams;
4449 msgQ.bodyval = 0;
4450 PELOG1(lim_log
4451 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4452 )
4453 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4454 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4455 if (eSIR_SUCCESS != retCode) {
4456 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 }
4459 return retCode;
4460}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461
4462/**
4463 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4464 *
4465 * @mac_ctx: Pointer to Global MAC structure
4466 * @msg_buf: pointer to the SME message buffer
4467 *
4468 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4469 * from SME. It Register this information within PE.
4470 *
4471 * Return: None
4472 */
4473static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4474 uint32_t *msg_buf)
4475{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304476 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4478 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4479 struct mgmt_frm_reg_info *next = NULL;
4480 bool match = false;
4481
4482 lim_log(mac_ctx, LOG1, FL(
4483 "registerFrame %d, frameType %d, matchLen %d"),
4484 sme_req->registerFrame, sme_req->frameType,
4485 sme_req->matchLen);
4486 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304487 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304488 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4489 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304490 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491
4492 while (lim_mgmt_regn != NULL) {
4493 if (lim_mgmt_regn->frameType != sme_req->frameType)
4494 goto skip_match;
4495 if (sme_req->matchLen) {
4496 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304497 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 sme_req->matchData,
4499 lim_mgmt_regn->matchLen))) {
4500 /* found match! */
4501 match = true;
4502 break;
4503 }
4504 } else {
4505 /* found match! */
4506 match = true;
4507 break;
4508 }
4509skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304510 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304511 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304513 (qdf_list_node_t *)lim_mgmt_regn,
4514 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304515 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 lim_mgmt_regn = next;
4517 next = NULL;
4518 }
4519 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304520 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304521 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304523 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304524 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304525 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526 }
4527
4528 if (sme_req->registerFrame) {
4529 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304530 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 sme_req->matchLen);
4532 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304533 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 sizeof(struct mgmt_frm_reg_info) +
4535 sme_req->matchLen, 0);
4536 lim_mgmt_regn->frameType = sme_req->frameType;
4537 lim_mgmt_regn->matchLen = sme_req->matchLen;
4538 lim_mgmt_regn->sessionId = sme_req->sessionId;
4539 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304540 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541 sme_req->matchData,
4542 sme_req->matchLen);
4543 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304544 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304546 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 gLimMgmtFrameRegistratinQueue,
4548 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304549 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 &mac_ctx->lim.lim_frame_register_lock);
4551 }
4552 }
4553 return;
4554}
4555
4556static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4557{
4558 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4559 pMac->lim.gDeferMsgTypeForNOA);
4560 pMac->lim.gDeferMsgTypeForNOA = 0;
4561 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4562 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304563 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4565 }
4566}
4567
4568/**
4569 * lim_process_regd_defd_sme_req_after_noa_start()
4570 *
4571 * mac_ctx: Pointer to Global MAC structure
4572 *
4573 * This function is called to process deferred sme req message
4574 * after noa start.
4575 *
4576 * Return: None
4577 */
4578void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4579{
4580 bool buf_consumed = true;
4581
4582 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4583 mac_ctx->lim.gDeferMsgTypeForNOA);
4584
4585 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4586 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4587 lim_log(mac_ctx, LOGW,
4588 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4589 lim_log(mac_ctx, LOGW,
4590 FL("It may happen when NOA start ind and timeout happen at the same time"));
4591 return;
4592 }
4593 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4594 case eWNI_SME_SCAN_REQ:
4595 __lim_process_sme_scan_req(mac_ctx,
4596 mac_ctx->lim.gpDefdSmeMsgForNOA);
4597 break;
4598#ifdef FEATURE_OEM_DATA_SUPPORT
4599 case eWNI_SME_OEM_DATA_REQ:
4600 __lim_process_sme_oem_data_req(mac_ctx,
4601 mac_ctx->lim.gpDefdSmeMsgForNOA);
4602 break;
4603#endif
4604 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4605 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4606 mac_ctx->lim.gpDefdSmeMsgForNOA);
4607 /*
4608 * lim_process_remain_on_chnl_req doesnt want us to free
4609 * the buffer since it is freed in lim_remain_on_chn_rsp.
4610 * this change is to avoid "double free"
4611 */
4612 if (false == buf_consumed)
4613 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4614 break;
4615 case eWNI_SME_JOIN_REQ:
4616 __lim_process_sme_join_req(mac_ctx,
4617 mac_ctx->lim.gpDefdSmeMsgForNOA);
4618 break;
4619 default:
4620 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4621 mac_ctx->lim.gDeferMsgTypeForNOA);
4622 break;
4623 }
4624 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4625}
4626
4627static void
4628__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4629{
4630 tpSirResetAPCapsChange pResetCapsChange;
4631 tpPESession psessionEntry;
4632 uint8_t sessionId = 0;
4633 if (pMsgBuf == NULL) {
4634 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4635 return;
4636 }
4637
4638 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4639 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004640 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4641 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 if (psessionEntry == NULL) {
4643 lim_log(pMac, LOGE,
4644 FL("Session does not exist for given BSSID"));
4645 return;
4646 }
4647
4648 psessionEntry->limSentCapsChangeNtf = false;
4649 return;
4650}
4651
4652/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304653 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4654 * indication callback in PE.
4655 * @mac_ptr: Mac pointer
4656 * @msg_buf: Msg pointer containing the callback
4657 *
4658 * This function is used save the Management frame
4659 * indication callback in PE.
4660 *
4661 * Return: None
4662 */
4663static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4664 uint32_t *msg_buf)
4665{
4666 struct sir_sme_mgmt_frame_cb_req *sme_req =
4667 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4668
4669 if (NULL == msg_buf) {
4670 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4671 return;
4672 }
4673 if (sme_req->callback)
4674 mac_ctx->mgmt_frame_ind_cb =
4675 (sir_mgmt_frame_ind_callback)sme_req->callback;
4676 else
4677 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4678}
4679
4680/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 * lim_process_sme_req_messages()
4682 *
4683 ***FUNCTION:
4684 * This function is called by limProcessMessageQueue(). This
4685 * function processes SME request messages from HDD or upper layer
4686 * application.
4687 *
4688 ***LOGIC:
4689 *
4690 ***ASSUMPTIONS:
4691 *
4692 ***NOTE:
4693 *
4694 * @param pMac Pointer to Global MAC structure
4695 * @param msgType Indicates the SME message type
4696 * @param *pMsgBuf A pointer to the SME message buffer
4697 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4698 * false - if pMsgBuf is not to be freed.
4699 */
4700
4701bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4702{
4703 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4704 uint32_t *pMsgBuf = pMsg->bodyptr;
4705 tpSirSmeScanReq pScanReq;
4706 PELOG1(lim_log
4707 (pMac, LOG1,
4708 FL
4709 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4710 lim_msg_str(pMsg->type), pMsg->type,
4711 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4712 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4713 )
4714
4715 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4716 /* If no insert NOA required then execute the code below */
4717
4718 switch (pMsg->type) {
4719 case eWNI_SME_SYS_READY_IND:
4720 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4721 break;
4722
4723 case eWNI_SME_START_BSS_REQ:
4724 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4725 break;
4726
4727 case eWNI_SME_SCAN_REQ:
4728 __lim_process_sme_scan_req(pMac, pMsgBuf);
4729 break;
4730
4731#ifdef FEATURE_OEM_DATA_SUPPORT
4732 case eWNI_SME_OEM_DATA_REQ:
4733 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4734 break;
4735#endif
4736 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4737 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4738 break;
4739
4740 case eWNI_SME_UPDATE_NOA:
4741 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4742 break;
4743 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4744 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4745 break;
4746 case eWNI_SME_JOIN_REQ:
4747 __lim_process_sme_join_req(pMac, pMsgBuf);
4748 break;
4749
4750 case eWNI_SME_REASSOC_REQ:
4751 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4752 break;
4753
4754 case eWNI_SME_DISASSOC_REQ:
4755 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4756 break;
4757
4758 case eWNI_SME_DISASSOC_CNF:
4759 case eWNI_SME_DEAUTH_CNF:
4760 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4761 break;
4762
4763 case eWNI_SME_DEAUTH_REQ:
4764 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4765 break;
4766
4767 case eWNI_SME_SETCONTEXT_REQ:
4768 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4769 break;
4770
4771 case eWNI_SME_STOP_BSS_REQ:
4772 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4773 break;
4774
4775 case eWNI_SME_ASSOC_CNF:
4776 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4777 PELOG1(lim_log(pMac,
4778 LOG1, FL("Received ASSOC_CNF message"));)
4779 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4780 pMsgBuf);
4781 break;
4782
4783 case eWNI_SME_ADDTS_REQ:
4784 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4785 __lim_process_sme_addts_req(pMac, pMsgBuf);
4786 break;
4787
4788 case eWNI_SME_DELTS_REQ:
4789 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4790 __lim_process_sme_delts_req(pMac, pMsgBuf);
4791 break;
4792
4793 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4794 PELOG1(lim_log
4795 (pMac, LOG1,
4796 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4797 )
4798 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4799 break;
4800
4801 case eWNI_SME_GET_STATISTICS_REQ:
4802 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4803 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4804 bufConsumed = false;
4805 break;
4806#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4807 case eWNI_SME_GET_TSM_STATS_REQ:
4808 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4809 bufConsumed = false;
4810 break;
4811#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4812 case eWNI_SME_GET_ASSOC_STAS_REQ:
4813 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4814 break;
4815 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4816 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4817 break;
4818
4819 case eWNI_SME_HIDE_SSID_REQ:
4820 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4821 break;
4822 case eWNI_SME_UPDATE_APWPSIE_REQ:
4823 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4824 break;
4825 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4826 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4827 break;
4828
4829 case eWNI_SME_SET_APWPARSNIEs_REQ:
4830 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4831 break;
4832
4833 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4834 /* Update the beaconInterval */
4835 __lim_process_sme_change_bi(pMac, pMsgBuf);
4836 break;
4837
4838#ifdef QCA_HT_2040_COEX
4839 case eWNI_SME_SET_HT_2040_MODE:
4840 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4841 break;
4842#endif
4843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004844 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4845 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4846 __lim_process_report_message(pMac, pMsg);
4847 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849 case eWNI_SME_FT_PRE_AUTH_REQ:
4850 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4851 break;
4852 case eWNI_SME_FT_UPDATE_KEY:
4853 lim_process_ft_update_key(pMac, pMsgBuf);
4854 break;
4855
4856 case eWNI_SME_FT_AGGR_QOS_REQ:
4857 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4858 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859
4860 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4861 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4862 break;
4863#ifdef FEATURE_WLAN_TDLS
4864 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4865 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4866 break;
4867 case eWNI_SME_TDLS_ADD_STA_REQ:
4868 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4869 break;
4870 case eWNI_SME_TDLS_DEL_STA_REQ:
4871 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4872 break;
4873 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4874 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4875 break;
4876#endif
4877 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4878 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4879 break;
4880
4881 case eWNI_SME_CHANNEL_CHANGE_REQ:
4882 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4883 break;
4884
4885 case eWNI_SME_START_BEACON_REQ:
4886 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4887 break;
4888
4889 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4890 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4891 break;
4892
4893 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4894 lim_process_update_add_ies(pMac, pMsgBuf);
4895 break;
4896
4897 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4898 lim_process_modify_add_ies(pMac, pMsgBuf);
4899 break;
4900 case eWNI_SME_SET_HW_MODE_REQ:
4901 lim_process_set_hw_mode(pMac, pMsgBuf);
4902 break;
4903 case eWNI_SME_NSS_UPDATE_REQ:
4904 lim_process_nss_update_request(pMac, pMsgBuf);
4905 break;
4906 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4907 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4908 break;
4909 case eWNI_SME_SET_IE_REQ:
4910 lim_process_set_ie_req(pMac, pMsgBuf);
4911 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304912 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4913 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4914 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304915 case eWNI_SME_EXT_CHANGE_CHANNEL:
4916 lim_process_ext_change_channel(pMac, pMsgBuf);
4917 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304919 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 pMsg->bodyptr = NULL;
4921 break;
4922 } /* switch (msgType) */
4923
4924 return bufConsumed;
4925} /*** end lim_process_sme_req_messages() ***/
4926
4927/**
4928 * lim_process_sme_start_beacon_req()
4929 *
4930 ***FUNCTION:
4931 * This function is called by limProcessMessageQueue(). This
4932 * function processes SME request messages from HDD or upper layer
4933 * application.
4934 *
4935 ***LOGIC:
4936 *
4937 ***ASSUMPTIONS:
4938 *
4939 ***NOTE:
4940 *
4941 * @param pMac Pointer to Global MAC structure
4942 * @param msgType Indicates the SME message type
4943 * @param *pMsgBuf A pointer to the SME message buffer
4944 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4945 * false - if pMsgBuf is not to be freed.
4946 */
4947static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4948{
4949 tpSirStartBeaconIndication pBeaconStartInd;
4950 tpPESession psessionEntry;
4951 uint8_t sessionId; /* PE sessionID */
4952
4953 if (pMsg == NULL) {
4954 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4955 return;
4956 }
4957
4958 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4959 psessionEntry = pe_find_session_by_bssid(pMac,
4960 pBeaconStartInd->bssid,
4961 &sessionId);
4962 if (psessionEntry == NULL) {
4963 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
4964 lim_log(pMac, LOGE,
4965 FL("Session does not exist for given bssId"));
4966 return;
4967 }
4968
4969 if (pBeaconStartInd->beaconStartStatus == true) {
4970 /*
4971 * Currently this Indication comes from SAP
4972 * to start Beacon Tx on a DFS channel
4973 * since beaconing has to be done on DFS
4974 * channel only after CAC WAIT is completed.
4975 * On a DFS Channel LIM does not start beacon
4976 * Tx right after the WMA_ADD_BSS_RSP.
4977 */
4978 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304979 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 FL("Start Beacon with ssid %s Ch %d"),
4981 psessionEntry->ssId.ssId,
4982 psessionEntry->currentOperChannel);
4983 lim_send_beacon_ind(pMac, psessionEntry);
4984 } else {
4985 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
4986 return;
4987 }
4988}
4989
4990/**
4991 * lim_process_sme_channel_change_request() - process sme ch change req
4992 *
4993 * @mac_ctx: Pointer to Global MAC structure
4994 * @msg_buf: pointer to the SME message buffer
4995 *
4996 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4997 *
4998 * Return: None
4999 */
5000static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5001 uint32_t *msg_buf)
5002{
5003 tpSirChanChangeRequest ch_change_req;
5004 tpPESession session_entry;
5005 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005006 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 uint32_t val = 0;
5008
5009 if (msg_buf == NULL) {
5010 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5011 return;
5012 }
5013 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5014
5015 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5016 ch_change_req->targetChannel);
5017
5018 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5019 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5020 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5021 return;
5022 }
5023
5024 session_entry = pe_find_session_by_bssid(mac_ctx,
5025 ch_change_req->bssid, &session_id);
5026 if (session_entry == NULL) {
5027 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5028 lim_log(mac_ctx, LOGE, FL(
5029 "Session does not exist for given bssId"));
5030 return;
5031 }
5032
5033 if (session_entry->currentOperChannel ==
5034 ch_change_req->targetChannel) {
5035 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5036 return;
5037 }
5038
5039 if (LIM_IS_AP_ROLE(session_entry))
5040 session_entry->channelChangeReasonCode =
5041 LIM_SWITCH_CHANNEL_SAP_DFS;
5042 else
5043 session_entry->channelChangeReasonCode =
5044 LIM_SWITCH_CHANNEL_OPERATION;
5045
5046 lim_log(mac_ctx, LOGW, FL(
5047 "switch old chnl %d to new chnl %d, ch_bw %d"),
5048 session_entry->currentOperChannel,
5049 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005050 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051
5052 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005053 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054 session_entry->ch_center_freq_seg0 =
5055 ch_change_req->center_freq_seg_0;
5056 session_entry->ch_center_freq_seg1 =
5057 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005058 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005059 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005060 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 session_entry->htRecommendedTxWidthSet =
5062 session_entry->htSupportedChannelWidthSet;
5063 session_entry->currentOperChannel =
5064 ch_change_req->targetChannel;
5065 session_entry->limRFBand =
5066 lim_get_rf_band(session_entry->currentOperChannel);
5067 /* Initialize 11h Enable Flag */
5068 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5069 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5070 eSIR_SUCCESS)
5071 lim_log(mac_ctx, LOGP,
5072 FL("Fail to get WNI_CFG_11H_ENABLED"));
5073 }
5074
5075 session_entry->lim11hEnable = val;
5076 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305077 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078 &ch_change_req->operational_rateset,
5079 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305080 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 &ch_change_req->extended_rateset,
5082 sizeof(session_entry->extRateSet));
5083 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5084 session_entry->ch_center_freq_seg0,
5085 session_entry->ch_center_freq_seg1,
5086 session_entry->ch_width,
5087 max_tx_pwr, session_entry->peSessionId);
5088}
5089
5090/******************************************************************************
5091* lim_start_bss_update_add_ie_buffer()
5092*
5093***FUNCTION:
5094* This function checks the src buffer and its length and then malloc for
5095* dst buffer update the same
5096*
5097***LOGIC:
5098*
5099***ASSUMPTIONS:
5100*
5101***NOTE:
5102*
5103* @param pMac Pointer to Global MAC structure
5104* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5105* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5106* @param *pSrcData_buff A pointer of uint8_t src buffer
5107* @param srcDataLen src buffer length
5108******************************************************************************/
5109
5110static void
5111lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5112 uint8_t **pDstData_buff,
5113 uint16_t *pDstDataLen,
5114 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5115{
5116
5117 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5118 *pDstDataLen = srcDataLen;
5119
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305120 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121
5122 if (NULL == *pDstData_buff) {
5123 lim_log(pMac, LOGE,
5124 FL("AllocateMemory failed for pDstData_buff"));
5125 return;
5126 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305127 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 } else {
5129 *pDstData_buff = NULL;
5130 *pDstDataLen = 0;
5131 }
5132}
5133
5134/******************************************************************************
5135* lim_update_add_ie_buffer()
5136*
5137***FUNCTION:
5138* This function checks the src buffer and length if src buffer length more
5139* than dst buffer length then free the dst buffer and malloc for the new src
5140* length, and update the dst buffer and length. But if dst buffer is bigger
5141* than src buffer length then it just update the dst buffer and length
5142*
5143***LOGIC:
5144*
5145***ASSUMPTIONS:
5146*
5147***NOTE:
5148*
5149* @param pMac Pointer to Global MAC structure
5150* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5151* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5152* @param *pSrcData_buff A pointer of uint8_t src buffer
5153* @param srcDataLen src buffer length
5154******************************************************************************/
5155
5156static void
5157lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5158 uint8_t **pDstData_buff,
5159 uint16_t *pDstDataLen,
5160 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5161{
5162
5163 if (NULL == pSrcData_buff) {
5164 lim_log(pMac, LOGE, FL("src buffer is null."));
5165 return;
5166 }
5167
5168 if (srcDataLen > *pDstDataLen) {
5169 *pDstDataLen = srcDataLen;
5170 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305171 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305173 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005174
5175 if (NULL == *pDstData_buff) {
5176 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5177 *pDstDataLen = 0;
5178 return;
5179 }
5180 }
5181
5182 /* copy the content of buffer into dst buffer
5183 */
5184 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305185 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186
5187}
5188
5189/*
5190* lim_process_modify_add_ies() - process modify additional IE req.
5191*
5192* @mac_ctx: Pointer to Global MAC structure
5193* @msg_buf: pointer to the SME message buffer
5194*
5195* This function update the PE buffers for additional IEs.
5196*
5197* Return: None
5198*/
5199static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5200 uint32_t *msg_buf)
5201{
5202 tpSirModifyIEsInd modify_add_ies;
5203 tpPESession session_entry;
5204 uint8_t session_id;
5205 bool ret = false;
5206 tSirAddIeParams *add_ie_params;
5207
5208 if (msg_buf == NULL) {
5209 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5210 return;
5211 }
5212
5213 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5214 /* Incoming message has smeSession, use BSSID to find PE session */
5215 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005216 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217
5218 if (NULL == session_entry) {
5219 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5220 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005221 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 goto end;
5223 }
5224 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5225 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5226 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5227 lim_log(mac_ctx, LOGE,
5228 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5229 modify_add_ies->modifyIE.pIEBuffer,
5230 modify_add_ies->modifyIE.ieBufferlength,
5231 modify_add_ies->modifyIE.ieID,
5232 modify_add_ies->modifyIE.ieIDLen,
5233 modify_add_ies->updateType);
5234 goto end;
5235 }
5236 add_ie_params = &session_entry->addIeParams;
5237 switch (modify_add_ies->updateType) {
5238 case eUPDATE_IE_PROBE_RESP:
5239 /* Probe resp */
5240 break;
5241 case eUPDATE_IE_ASSOC_RESP:
5242 /* assoc resp IE */
5243 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305244 QDF_TRACE(QDF_MODULE_ID_PE,
5245 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 "assoc resp add ie not present %d"),
5247 add_ie_params->assocRespDataLen);
5248 }
5249 /* search through the buffer and modify the IE */
5250 break;
5251 case eUPDATE_IE_PROBE_BCN:
5252 /*probe beacon IE */
5253 if (ret == true && modify_add_ies->modifyIE.notify) {
5254 lim_handle_param_update(mac_ctx,
5255 modify_add_ies->updateType);
5256 }
5257 break;
5258 default:
5259 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5260 modify_add_ies->updateType);
5261 break;
5262 }
5263end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305264 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265 modify_add_ies->modifyIE.pIEBuffer = NULL;
5266}
5267
5268/*
5269* lim_process_update_add_ies() - process additional IE update req
5270*
5271* @mac_ctx: Pointer to Global MAC structure
5272* @msg_buf: pointer to the SME message buffer
5273*
5274* This function update the PE buffers for additional IEs.
5275*
5276* Return: None
5277*/
5278static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5279 uint32_t *msg_buf)
5280{
5281 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5282 uint8_t session_id;
5283 tpPESession session_entry;
5284 tSirAddIeParams *addn_ie;
5285 uint16_t new_length = 0;
5286 uint8_t *new_ptr = NULL;
5287 tSirUpdateIE *update_ie;
5288
5289 if (msg_buf == NULL) {
5290 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5291 return;
5292 }
5293 update_ie = &update_add_ies->updateIE;
5294 /* incoming message has smeSession, use BSSID to find PE session */
5295 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005296 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297
5298 if (NULL == session_entry) {
5299 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5300 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005301 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 goto end;
5303 }
5304 addn_ie = &session_entry->addIeParams;
5305 /* if len is 0, upper layer requested freeing of buffer */
5306 if (0 == update_ie->ieBufferlength) {
5307 switch (update_add_ies->updateType) {
5308 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305309 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 addn_ie->probeRespData_buff = NULL;
5311 addn_ie->probeRespDataLen = 0;
5312 break;
5313 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305314 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 addn_ie->assocRespData_buff = NULL;
5316 addn_ie->assocRespDataLen = 0;
5317 break;
5318 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305319 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 addn_ie->probeRespBCNData_buff = NULL;
5321 addn_ie->probeRespBCNDataLen = 0;
5322
5323 if (update_ie->notify)
5324 lim_handle_param_update(mac_ctx,
5325 update_add_ies->updateType);
5326 break;
5327 default:
5328 break;
5329 }
5330 return;
5331 }
5332 switch (update_add_ies->updateType) {
5333 case eUPDATE_IE_PROBE_RESP:
5334 if (update_ie->append) {
5335 /*
5336 * In case of append, allocate new memory
5337 * with combined length
5338 */
5339 new_length = update_ie->ieBufferlength +
5340 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305341 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342 if (NULL == new_ptr) {
5343 lim_log(mac_ctx, LOGE, FL(
5344 "Memory allocation failed."));
5345 goto end;
5346 }
5347 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305348 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305350 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 update_ie->pAdditionIEBuffer,
5352 update_ie->ieBufferlength);
5353 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305354 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005355 /* adjust length accordingly */
5356 addn_ie->probeRespDataLen = new_length;
5357 /* save refernece of local buffer in PE session */
5358 addn_ie->probeRespData_buff = new_ptr;
5359 goto end;
5360 }
5361 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5362 &addn_ie->probeRespDataLen,
5363 update_ie->pAdditionIEBuffer,
5364 update_ie->ieBufferlength);
5365 break;
5366 case eUPDATE_IE_ASSOC_RESP:
5367 /* assoc resp IE */
5368 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5369 &addn_ie->assocRespDataLen,
5370 update_ie->pAdditionIEBuffer,
5371 update_ie->ieBufferlength);
5372 break;
5373 case eUPDATE_IE_PROBE_BCN:
5374 /* probe resp Bcn IE */
5375 lim_update_add_ie_buffer(mac_ctx,
5376 &addn_ie->probeRespBCNData_buff,
5377 &addn_ie->probeRespBCNDataLen,
5378 update_ie->pAdditionIEBuffer,
5379 update_ie->ieBufferlength);
5380 if (update_ie->notify)
5381 lim_handle_param_update(mac_ctx,
5382 update_add_ies->updateType);
5383 break;
5384 default:
5385 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5386 update_add_ies->updateType);
5387 break;
5388 }
5389end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305390 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 update_ie->pAdditionIEBuffer = NULL;
5392}
5393
5394/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305395 * send_extended_chan_switch_action_frame()- function to send ECSA
5396 * action frame for each sta connected to SAP/GO and AP in case of
5397 * STA .
5398 * @mac_ctx: pointer to global mac structure
5399 * @new_channel: new channel to switch to.
5400 * @ch_bandwidth: BW of channel to calculate op_class
5401 * @session_entry: pe session
5402 *
5403 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5404 *
5405 * Return: void
5406 */
5407
5408static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5409 uint16_t new_channel, uint8_t ch_bandwidth,
5410 tpPESession session_entry)
5411{
5412 uint16_t op_class;
5413 uint8_t switch_mode = 0, i;
5414 tpDphHashNode psta;
5415
5416
5417 op_class = cds_regdm_get_opclass_from_channel(
5418 mac_ctx->scan.countryCodeCurrent,
5419 new_channel,
5420 ch_bandwidth);
5421
5422 if (LIM_IS_AP_ROLE(session_entry) &&
5423 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5424 switch_mode = 1;
5425
5426 if (LIM_IS_AP_ROLE(session_entry)) {
5427 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5428 psta =
5429 session_entry->dph.dphHashTable.pDphNodeArray + i;
5430 if (psta && psta->added)
5431 lim_send_extended_chan_switch_action_frame(
5432 mac_ctx,
5433 psta->staAddr,
5434 switch_mode, op_class, new_channel,
5435 LIM_MAX_CSA_IE_UPDATES, session_entry);
5436 }
5437 } else if (LIM_IS_STA_ROLE(session_entry)) {
5438 lim_send_extended_chan_switch_action_frame(mac_ctx,
5439 session_entry->bssId,
5440 switch_mode, op_class, new_channel,
5441 LIM_MAX_CSA_IE_UPDATES, session_entry);
5442 }
5443
5444}
5445
5446/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5448 *
5449 * @mac_ctx: Pointer to Global MAC structure
5450 * @msg_buf: pointer to the SME message buffer
5451 *
5452 * This function processes SME request messages from HDD or upper layer
5453 * application.
5454 *
5455 * Return: None
5456 */
5457static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5458 uint32_t *msg_buf)
5459{
5460 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5461 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 uint8_t session_id;
5463 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305464 offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465
5466 if (msg_buf == NULL) {
5467 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5468 return;
5469 }
5470
5471 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5472 session_entry = pe_find_session_by_bssid(mac_ctx,
5473 dfs_csa_ie_req->bssid, &session_id);
5474 if (session_entry == NULL) {
5475 lim_log(mac_ctx, LOGE, FL(
5476 "Session not found for given BSSID" MAC_ADDRESS_STR),
5477 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5478 return;
5479 }
5480
5481 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5482 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5483 GET_LIM_SYSTEM_ROLE(session_entry));
5484 return;
5485 }
5486
5487 /* target channel */
5488 session_entry->gLimChannelSwitch.primaryChannel =
5489 dfs_csa_ie_req->targetChannel;
5490
5491 /* Channel switch announcement needs to be included in beacon */
5492 session_entry->dfsIncludeChanSwIe = true;
5493 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5494 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005495 dfs_csa_ie_req->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5497 session_entry->gLimChannelSwitch.switchMode = 1;
5498
5499 /*
5500 * Validate if SAP is operating HT or VHT mode and set the Channel
5501 * Switch Wrapper element with the Wide Band Switch subelement.
5502 */
5503 if (true != session_entry->vhtCapability)
5504 goto skip_vht;
5505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 /* Now encode the Wider Ch BW element depending on the ch width */
5507 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005508 switch (dfs_csa_ie_req->ch_params.ch_width) {
5509 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510 /*
5511 * Wide channel BW sublement in channel wrapper element is not
5512 * required in case of 20 Mhz operation. Currently It is set
5513 * only set in case of 40/80 Mhz Operation.
5514 */
5515 session_entry->dfsIncludeChanWrapperIe = false;
5516 wider_bw_ch_switch->newChanWidth =
5517 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5518 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005519 case CH_WIDTH_40MHZ:
5520 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 wider_bw_ch_switch->newChanWidth =
5522 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5523 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005524 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525 session_entry->dfsIncludeChanWrapperIe = true;
5526 wider_bw_ch_switch->newChanWidth =
5527 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5528 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005529 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 session_entry->dfsIncludeChanWrapperIe = true;
5531 wider_bw_ch_switch->newChanWidth =
5532 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5533 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005534 case CH_WIDTH_80P80MHZ:
5535 session_entry->dfsIncludeChanWrapperIe = true;
5536 wider_bw_ch_switch->newChanWidth =
5537 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
5538 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 default:
5540 session_entry->dfsIncludeChanWrapperIe = false;
5541 /*
5542 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5543 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5544 */
5545 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5546 break;
5547 }
5548 /* Fetch the center channel based on the channel width */
5549 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005550 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551 /*
5552 * This is not applicable for 20/40/80 Mhz.Only used when we support
5553 * 80+80 Mhz operation. In case of 80+80 Mhz, this parameter indicates
5554 * center channel frequency index of 80 Mhz channel of
5555 * frequency segment 1.
5556 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005557 wider_bw_ch_switch->newCenterChanFreq1 =
5558 dfs_csa_ie_req->ch_params.center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559skip_vht:
5560 /* Send CSA IE request from here */
5561 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5562 eSIR_SUCCESS) {
5563 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5564 return;
5565 }
5566
5567 /*
5568 * First beacon update request is sent here, the remaining updates are
5569 * done when the FW responds back after sending the first beacon after
5570 * the template update
5571 */
5572 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305573
5574 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5575 ch_offset = BW80;
5576 else
5577 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5578
5579 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5580 session_entry->gLimChannelSwitch.switchCount,
5581 session_entry->gLimChannelSwitch.primaryChannel,
5582 session_entry->gLimChannelSwitch.ch_width,
5583 session_entry->dfsIncludeChanWrapperIe,
5584 ch_offset);
5585
Abhishek Singh518323d2015-10-19 17:42:01 +05305586 /* Send ECSA Action frame after updating the beacon */
5587 send_extended_chan_switch_action_frame(mac_ctx,
5588 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305589 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005590 session_entry->gLimChannelSwitch.switchCount--;
5591}
5592
5593/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305594 * lim_process_ext_change_channel()- function to send ECSA
5595 * action frame for STA/CLI .
5596 * @mac_ctx: pointer to global mac structure
5597 * @msg: params from sme for new channel.
5598 *
5599 * This function is called to send ECSA frame for STA/CLI.
5600 *
5601 * Return: void
5602 */
5603
5604static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5605 uint32_t *msg)
5606{
5607 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5608 (struct sir_sme_ext_cng_chan_req *) msg;
5609 tpPESession session_entry = NULL;
5610
5611 if (NULL == msg) {
5612 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5613 return;
5614 }
5615 session_entry =
5616 pe_find_session_by_sme_session_id(mac_ctx,
5617 ext_chng_channel->session_id);
5618 if (NULL == session_entry) {
5619 lim_log(mac_ctx, LOGE,
5620 FL("Session not found for given session %d"),
5621 ext_chng_channel->session_id);
5622 return;
5623 }
5624 if (LIM_IS_AP_ROLE(session_entry)) {
5625 lim_log(mac_ctx, LOGE,
5626 FL("not an STA/CLI session"));
5627 return;
5628 }
5629 send_extended_chan_switch_action_frame(mac_ctx,
5630 ext_chng_channel->new_channel,
5631 0, session_entry);
5632}
5633
5634/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 * lim_process_nss_update_request() - process sme nss update req
5636 *
5637 * @mac_ctx: Pointer to Global MAC structure
5638 * @msg_buf: pointer to the SME message buffer
5639 *
5640 * This function processes SME request messages from HDD or upper layer
5641 * application.
5642 *
5643 * Return: None
5644 */
5645static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5646 uint32_t *msg_buf)
5647{
5648 struct sir_nss_update_request *nss_update_req_ptr;
5649 tpPESession session_entry = NULL;
5650
5651 if (msg_buf == NULL) {
5652 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5653 return;
5654 }
5655
5656 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305657 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 nss_update_req_ptr->vdev_id);
5659 if (session_entry == NULL) {
5660 lim_log(mac_ctx, LOGE, FL(
5661 "Session not found for given session_id %d"),
5662 nss_update_req_ptr->vdev_id);
5663 return;
5664 }
5665
5666 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5667 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5668 GET_LIM_SYSTEM_ROLE(session_entry));
5669 return;
5670 }
5671
5672 /* populate nss field in the beacon */
5673 session_entry->gLimOperatingMode.present = 1;
5674 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5675 /* Send nss update request from here */
5676 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5677 eSIR_SUCCESS) {
5678 lim_log(mac_ctx, LOGE,
5679 FL("Unable to set op mode IE in beacon"));
5680 return;
5681 }
5682
5683 lim_send_beacon_ind(mac_ctx, session_entry);
5684}
5685
5686/**
5687 * lim_process_set_ie_req() - process sme set IE request
5688 *
5689 * @mac_ctx: Pointer to Global MAC structure
5690 * @msg_buf: pointer to the SME message buffer
5691 *
5692 * This function processes SME request messages from HDD or upper layer
5693 * application.
5694 *
5695 * Return: None
5696 */
5697static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5698{
5699 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305700 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701
5702 if (msg_buf == NULL) {
5703 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5704 return;
5705 }
5706
5707 msg = (struct send_extcap_ie *)msg_buf;
5708 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305709 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5711
5712}