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