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