blob: 26a93d27b0f1717106d0a098c629b74359e26d6f [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,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002606 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 &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,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002664 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 &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),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002670 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 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"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002680 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302681 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,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002692 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 }
2694
2695 return;
2696}
2697
2698/**
2699 * __lim_process_sme_deauth_req() - process sme deauth req
2700 * @mac_ctx: Pointer to Global MAC structure
2701 * @msg_buf: pointer to the SME message buffer
2702 *
2703 * This function is called to process SME_DEAUTH_REQ message
2704 * from HDD or upper layer application.
2705 *
2706 * Return: None
2707 */
2708
2709static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2710 uint32_t *msg_buf)
2711{
2712 uint16_t deauth_trigger, reason_code;
2713 tLimMlmDeauthReq *mlm_deauth_req;
2714 tSirSmeDeauthReq sme_deauth_req;
2715 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2716 tpPESession session_entry;
2717 uint8_t session_id; /* PE sessionId */
2718 uint8_t sme_session_id;
2719 uint16_t sme_transaction_id;
2720
2721 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2722
2723 cdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
2724 sme_session_id = sme_deauth_req.sessionId;
2725 sme_transaction_id = sme_deauth_req.transactionId;
2726
2727 /*
2728 * We need to get a session first but we don't even know
2729 * if the message is correct.
2730 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002731 session_entry = pe_find_session_by_bssid(mac_ctx,
2732 sme_deauth_req.bssid.bytes,
2733 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 if (session_entry == NULL) {
2735 lim_log(mac_ctx, LOGE,
2736 FL("session does not exist for given bssId"));
2737 ret_code = eSIR_SME_INVALID_PARAMETERS;
2738 deauth_trigger = eLIM_HOST_DEAUTH;
2739 goto send_deauth;
2740 }
2741
2742 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2743 session_entry)) {
2744 lim_log(mac_ctx, LOGE,
2745 FL("received invalid SME_DEAUTH_REQ message"));
2746 mac_ctx->lim.gLimRspReqd = false;
2747
2748 ret_code = eSIR_SME_INVALID_PARAMETERS;
2749 deauth_trigger = eLIM_HOST_DEAUTH;
2750 goto send_deauth;
2751 }
2752 lim_log(mac_ctx, LOG1,
2753 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2754 MAC_ADDRESS_STR), sme_session_id,
2755 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2756 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002757 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2759 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2760 session_entry, 0, sme_deauth_req.reasonCode);
2761#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2762
2763 /* Update SME session ID and Transaction ID */
2764 session_entry->smeSessionId = sme_session_id;
2765 session_entry->transactionId = sme_transaction_id;
2766
2767 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2768 case eLIM_STA_ROLE:
2769 case eLIM_BT_AMP_STA_ROLE:
2770
2771 switch (session_entry->limSmeState) {
2772 case eLIM_SME_ASSOCIATED_STATE:
2773 case eLIM_SME_LINK_EST_STATE:
2774 case eLIM_SME_WT_ASSOC_STATE:
2775 case eLIM_SME_JOIN_FAILURE_STATE:
2776 case eLIM_SME_IDLE_STATE:
2777 session_entry->limPrevSmeState =
2778 session_entry->limSmeState;
2779 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2780 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2781 session_entry->peSessionId,
2782 session_entry->limSmeState));
2783 /* Send Deauthentication request to MLM below */
2784 break;
2785 case eLIM_SME_WT_DEAUTH_STATE:
2786 case eLIM_SME_WT_DISASSOC_STATE:
2787 /*
2788 * PE Recieved a Deauth/Disassoc frame. Normally it get
2789 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2790 * Which means host is also trying to disconnect.
2791 * PE can continue processing DEAUTH_REQ and send
2792 * the response instead of failing the request.
2793 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2794 * was sent for deauth/disassoc frame.
2795 */
2796 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2797 lim_log(mac_ctx, LOG1, FL(
2798 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2799 break;
2800 default:
2801 /*
2802 * STA is not in a state to deauthenticate with
2803 * peer. Log error and send response to host.
2804 */
2805 lim_log(mac_ctx, LOGE, FL(
2806 "received unexp SME_DEAUTH_REQ in state %X"),
2807 session_entry->limSmeState);
2808 lim_print_sme_state(mac_ctx, LOGE,
2809 session_entry->limSmeState);
2810
2811 if (mac_ctx->lim.gLimRspReqd) {
2812 mac_ctx->lim.gLimRspReqd = false;
2813
2814 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2815 deauth_trigger = eLIM_HOST_DEAUTH;
2816
2817 /*
2818 * here we received deauth request from AP so sme state
2819 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2820 * delSta then mlm state should be
2821 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2822 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2823 * so the below condition captures the state where
2824 * delSta not done and firmware still in
2825 * connected state.
2826 */
2827 if (session_entry->limSmeState ==
2828 eLIM_SME_WT_DEAUTH_STATE &&
2829 session_entry->limMlmState !=
2830 eLIM_MLM_IDLE_STATE &&
2831 session_entry->limMlmState !=
2832 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2833 ret_code = eSIR_SME_DEAUTH_STATUS;
2834 goto send_deauth;
2835 }
2836 return;
2837 }
2838 break;
2839
2840 case eLIM_STA_IN_IBSS_ROLE:
2841 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2842 if (mac_ctx->lim.gLimRspReqd) {
2843 mac_ctx->lim.gLimRspReqd = false;
2844 ret_code = eSIR_SME_INVALID_PARAMETERS;
2845 deauth_trigger = eLIM_HOST_DEAUTH;
2846 goto send_deauth;
2847 }
2848 return;
2849 case eLIM_AP_ROLE:
2850 break;
2851 default:
2852 lim_log(mac_ctx, LOGE,
2853 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2854 GET_LIM_SYSTEM_ROLE(session_entry));
2855 if (mac_ctx->lim.gLimRspReqd) {
2856 mac_ctx->lim.gLimRspReqd = false;
2857 ret_code = eSIR_SME_INVALID_PARAMETERS;
2858 deauth_trigger = eLIM_HOST_DEAUTH;
2859 goto send_deauth;
2860 }
2861 return;
2862 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2863
2864 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2865 /* Deauthentication is triggered by Link Monitoring */
2866 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2867 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2868 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2869 } else {
2870 deauth_trigger = eLIM_HOST_DEAUTH;
2871 reason_code = sme_deauth_req.reasonCode;
2872 }
2873
2874 /* Trigger Deauthentication frame to peer MAC entity */
2875 mlm_deauth_req = cdf_mem_malloc(sizeof(tLimMlmDeauthReq));
2876 if (NULL == mlm_deauth_req) {
2877 lim_log(mac_ctx, LOGP,
2878 FL("call to AllocateMemory failed for mlmDeauthReq"));
2879 if (mac_ctx->lim.gLimRspReqd) {
2880 mac_ctx->lim.gLimRspReqd = false;
2881 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2882 deauth_trigger = eLIM_HOST_DEAUTH;
2883 goto send_deauth;
2884 }
2885 return;
2886 }
2887
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002888 cdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
2889 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890
2891 mlm_deauth_req->reasonCode = reason_code;
2892 mlm_deauth_req->deauthTrigger = deauth_trigger;
2893
2894 /* Update PE session Id */
2895 mlm_deauth_req->sessionId = session_id;
2896
2897 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2898 (uint32_t *)mlm_deauth_req);
2899 return;
2900
2901send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002902 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2903 ret_code, deauth_trigger, 1,
2904 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905}
2906
2907/**
2908 * __lim_process_sme_set_context_req()
2909 *
2910 * @mac_ctx: Pointer to Global MAC structure
2911 * @msg_buf: pointer to the SME message buffer
2912 *
2913 * This function is called to process SME_SETCONTEXT_REQ message
2914 * from HDD or upper layer application.
2915 *
2916 * Return: None
2917 */
2918
2919static void
2920__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2921{
2922 tpSirSmeSetContextReq set_context_req;
2923 tLimMlmSetKeysReq *mlm_set_key_req;
2924 tpPESession session_entry;
2925 uint8_t session_id; /* PE sessionID */
2926 uint8_t sme_session_id;
2927 uint16_t sme_transaction_id;
2928
2929 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2930
2931 if (msg_buf == NULL) {
2932 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2933 return;
2934 }
2935
2936 set_context_req = cdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
2937 if (NULL == set_context_req) {
2938 lim_log(mac_ctx, LOGP, FL(
2939 "call to AllocateMemory failed for set_context_req"));
2940 return;
2941 }
2942 cdf_mem_copy(set_context_req, msg_buf,
2943 sizeof(struct sSirSmeSetContextReq));
2944 sme_session_id = set_context_req->sessionId;
2945 sme_transaction_id = set_context_req->transactionId;
2946
2947 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2948 lim_log(mac_ctx, LOGW,
2949 FL("received invalid SME_SETCONTEXT_REQ message"));
2950 goto end;
2951 }
2952
2953 if (set_context_req->keyMaterial.numKeys >
2954 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2955 lim_log(mac_ctx, LOGE, FL(
2956 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2957 set_context_req->keyMaterial.numKeys);
2958 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002959 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 eSIR_SME_INVALID_PARAMETERS, NULL,
2961 sme_session_id, sme_transaction_id);
2962 goto end;
2963 }
2964
2965 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002966 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 if (session_entry == NULL) {
2968 lim_log(mac_ctx, LOGW,
2969 FL("Session does not exist for given BSSID"));
2970 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002971 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 eSIR_SME_INVALID_PARAMETERS, NULL,
2973 sme_session_id, sme_transaction_id);
2974 goto end;
2975 }
2976#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2977 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2978 session_entry, 0, 0);
2979#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2980
2981 if (((LIM_IS_STA_ROLE(session_entry) ||
2982 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
2983 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2984 ((LIM_IS_IBSS_ROLE(session_entry) ||
2985 LIM_IS_AP_ROLE(session_entry) ||
2986 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
2987 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2988 /* Trigger MLM_SETKEYS_REQ */
2989 mlm_set_key_req = cdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
2990 if (NULL == mlm_set_key_req) {
2991 lim_log(mac_ctx, LOGP, FL(
2992 "mem alloc failed for mlmSetKeysReq"));
2993 goto end;
2994 }
2995 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2996 mlm_set_key_req->numKeys =
2997 set_context_req->keyMaterial.numKeys;
2998 if (mlm_set_key_req->numKeys >
2999 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3000 lim_log(mac_ctx, LOGP, FL(
3001 "no.of keys exceeded max num of default keys limit"));
3002 goto end;
3003 }
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003004 cdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
3005 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006
3007 cdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
3008 (uint8_t *) &set_context_req->keyMaterial.key,
3009 sizeof(tSirKeys) *
3010 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3011 numKeys : 1));
3012
3013 mlm_set_key_req->sessionId = session_id;
3014 mlm_set_key_req->smesessionId = sme_session_id;
3015#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3016 lim_log(mac_ctx, LOG1, FL(
3017 "received SETCONTEXT_REQ message sessionId=%d"),
3018 mlm_set_key_req->sessionId);
3019#endif
3020
3021 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3022 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3023 LIM_IS_AP_ROLE(session_entry)) {
3024 if (set_context_req->keyMaterial.key[0].keyLength) {
3025 uint8_t key_id;
3026 key_id =
3027 set_context_req->keyMaterial.key[0].keyId;
3028 cdf_mem_copy((uint8_t *)
3029 &session_entry->WEPKeyMaterial[key_id],
3030 (uint8_t *) &set_context_req->keyMaterial,
3031 sizeof(tSirKeyMaterial));
3032 } else {
3033 uint32_t i;
3034 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3035 i++) {
3036 cdf_mem_copy((uint8_t *)
3037 &mlm_set_key_req->key[i],
3038 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3039 sizeof(tSirKeys));
3040 }
3041 }
3042 }
3043 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3044 (uint32_t *) mlm_set_key_req);
3045 } else {
3046 lim_log(mac_ctx, LOGE, FL(
3047 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3048 GET_LIM_SYSTEM_ROLE(session_entry),
3049 session_entry->limSmeState);
3050 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3051
3052 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003053 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3055 session_entry, sme_session_id,
3056 sme_transaction_id);
3057 }
3058end:
3059 cdf_mem_free(set_context_req);
3060 return;
3061}
3062
3063/**
3064 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3065 *
3066 * @mac_ctx: Pointer to Global MAC structure
3067 * @msg_buf: pointer to the SME message buffer
3068 *
3069 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3070 * from HDD or upper layer application.
3071 *
3072 * Return: None
3073 */
3074
3075void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3076 uint32_t *msg_buf)
3077{
3078 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3079 tpDphHashNode sta_ds = NULL;
3080 tpPESession session_entry = NULL;
3081 tSap_Event sap_event;
3082 tpWLAN_SAPEventCB sap_event_cb = NULL;
3083 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3084 uint8_t session_id = CSR_SESSION_ID_INVALID;
3085 uint8_t assoc_id = 0;
3086 uint8_t sta_cnt = 0;
3087
3088 if (msg_buf == NULL) {
3089 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3090 return;
3091 }
3092
3093 cdf_mem_copy(&get_assoc_stas_req, msg_buf,
3094 sizeof(struct sSirSmeGetAssocSTAsReq));
3095 /*
3096 * Get Associated stations from PE.
3097 * Find PE session Entry
3098 */
3099 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003100 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 &session_id);
3102 if (session_entry == NULL) {
3103 lim_log(mac_ctx, LOGE,
3104 FL("session does not exist for given bssId"));
3105 goto lim_assoc_sta_end;
3106 }
3107
3108 if (!LIM_IS_AP_ROLE(session_entry)) {
3109 lim_log(mac_ctx, LOGE, FL(
3110 "Received unexpected message in state %X, in role %X"),
3111 session_entry->limSmeState,
3112 GET_LIM_SYSTEM_ROLE(session_entry));
3113 goto lim_assoc_sta_end;
3114 }
3115 /* Retrieve values obtained in the request message */
3116 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3117 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3118
3119 if (NULL == assoc_sta_tmp)
3120 goto lim_assoc_sta_end;
3121 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3122 assoc_id++) {
3123 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3124 &session_entry->dph.dphHashTable);
3125 if (NULL == sta_ds)
3126 continue;
3127 if (sta_ds->valid) {
3128 cdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
3129 (uint8_t *) &sta_ds->staAddr,
3130 CDF_MAC_ADDR_SIZE);
3131 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3132 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3133
3134 cdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
3135 (uint8_t *)&sta_ds->supportedRates,
3136 sizeof(tSirSupportedRates));
3137 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3138 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3139 assoc_sta_tmp->Support40Mhz =
3140 sta_ds->htDsssCckRate40MHzSupport;
3141
3142 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3143 sta_cnt + 1);
3144 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3145 MAC_ADDR_ARRAY(sta_ds->staAddr));
3146 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3147 sta_ds->assocId);
3148 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3149 sta_ds->staIndex);
3150 assoc_sta_tmp++;
3151 sta_cnt++;
3152 }
3153 }
3154lim_assoc_sta_end:
3155 /*
3156 * Call hdd callback with sap event to send the list of
3157 * associated stations from PE
3158 */
3159 if (sap_event_cb != NULL) {
3160 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3161 sap_event.sapevt.sapAssocStaListEvent.module =
3162 CDF_MODULE_ID_PE;
3163 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3164 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3165 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3166 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3167 }
3168}
3169
3170/**
3171 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3172 *
3173 * @mac_ctx: Pointer to Global MAC structure
3174 * @msg_buf: pointer to WPS PBC overlap query message
3175 *
3176 * This function parses get WPS PBC overlap information
3177 * message and call callback to pass WPS PBC overlap
3178 * information back to hdd.
3179 *
3180 * Return: None
3181 */
3182void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3183 uint32_t *msg_buf)
3184{
3185 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3186 tpPESession session_entry = NULL;
3187 tSap_Event sap_event;
3188 tpWLAN_SAPEventCB sap_event_cb = NULL;
3189 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3191
3192 if (msg_buf == NULL) {
3193 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3194 return;
3195 }
3196
3197 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
3198 sap_get_wpspbc_event->status = CDF_STATUS_E_FAULT;
3199
3200 cdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
3201 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3202 /*
3203 * Get Associated stations from PE
3204 * Find PE session Entry
3205 */
3206 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003207 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 if (session_entry == NULL) {
3209 lim_log(mac_ctx, LOGE,
3210 FL("session does not exist for given bssId"));
3211 goto lim_get_wpspbc_sessions_end;
3212 }
3213
3214 if (!LIM_IS_AP_ROLE(session_entry)) {
3215 lim_log(mac_ctx, LOGE,
3216 FL("Received unexpected message in role %X"),
3217 GET_LIM_SYSTEM_ROLE(session_entry));
3218 goto lim_get_wpspbc_sessions_end;
3219 }
3220 /*
3221 * Call hdd callback with sap event to send the
3222 * WPS PBC overlap information
3223 */
3224 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3225 sap_get_wpspbc_event->module = CDF_MODULE_ID_PE;
3226
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003227 if (cdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003229 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 sap_get_wpspbc_event->UUID_E,
3231 &sap_get_wpspbc_event->wpsPBCOverlap,
3232 session_entry);
3233 } else {
3234 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003235 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 session_entry);
3237 /* don't have to inform the HDD/Host */
3238 return;
3239 }
3240
3241 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3242 sap_get_wpspbc_event->wpsPBCOverlap);
3243 lim_print_mac_addr(mac_ctx,
3244 sap_get_wpspbc_event->addr.bytes, LOG4);
3245
3246 sap_get_wpspbc_event->status = CDF_STATUS_SUCCESS;
3247
3248lim_get_wpspbc_sessions_end:
3249 sap_event_cb =
3250 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3251 if (NULL != sap_event_cb)
3252 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3253}
3254
3255/**
3256 * __lim_counter_measures()
3257 *
3258 * FUNCTION:
3259 * This function is called to "implement" MIC counter measure
3260 * and is *temporary* only
3261 *
3262 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3263 * we don't do the proper STA disassoc sequence since the
3264 * BSS will be stoped anyway
3265 *
3266 ***ASSUMPTIONS:
3267 *
3268 ***NOTE:
3269 *
3270 * @param pMac Pointer to Global MAC structure
3271 * @return None
3272 */
3273
3274static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3275{
3276 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3277 if (LIM_IS_AP_ROLE(psessionEntry) ||
3278 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3279 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3280 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3281 mac, psessionEntry, false);
3282};
3283
3284void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3285{
3286 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3287 tpPESession psessionEntry;
3288 uint8_t sessionId; /* PE sessionId */
3289
3290 cdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
3291 sizeof(struct sSirSmeTkipCntrMeasReq));
3292
3293 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003294 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 if (NULL == psessionEntry) {
3296 lim_log(pMac, LOGE,
3297 FL("session does not exist for given BSSID "));
3298 return;
3299 }
3300
3301 if (tkipCntrMeasReq.bEnable)
3302 __lim_counter_measures(pMac, psessionEntry);
3303
3304 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3305}
3306
3307static void
3308__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3309{
3310 tSirSmeStopBssReq stopBssReq;
3311 tSirRetStatus status;
3312 tLimSmeStates prevState;
3313 tpPESession psessionEntry;
3314 uint8_t smesessionId;
3315 uint8_t sessionId;
3316 uint16_t smetransactionId;
3317 uint8_t i = 0;
3318 tpDphHashNode pStaDs = NULL;
3319
3320 cdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
3321 smesessionId = stopBssReq.sessionId;
3322 smetransactionId = stopBssReq.transactionId;
3323
3324 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3325 PELOGW(lim_log(pMac, LOGW,
3326 FL("received invalid SME_STOP_BSS_REQ message"));)
3327 /* Send Stop BSS response to host */
3328 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3329 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3330 smetransactionId);
3331 return;
3332 }
3333
3334 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003335 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 &sessionId);
3337 if (psessionEntry == NULL) {
3338 lim_log(pMac, LOGW,
3339 FL("session does not exist for given BSSID "));
3340 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3341 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3342 smetransactionId);
3343 return;
3344 }
3345#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3346 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3347 0, 0);
3348#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3349
3350 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3351 LIM_IS_STA_ROLE(psessionEntry)) {
3352 /**
3353 * Should not have received STOP_BSS_REQ in states
3354 * other than 'normal' state or on STA in Infrastructure
3355 * mode. Log error and return response to host.
3356 */
3357 lim_log(pMac, LOGE,
3358 FL
3359 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3360 psessionEntry->limSmeState,
3361 GET_LIM_SYSTEM_ROLE(psessionEntry));
3362 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3363 /* / Send Stop BSS response to host */
3364 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3365 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3366 smetransactionId);
3367 return;
3368 }
3369
3370 if (LIM_IS_AP_ROLE(psessionEntry))
3371 lim_wpspbc_close(pMac, psessionEntry);
3372
3373 lim_log(pMac, LOGW,
3374 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3375 stopBssReq.reasonCode);
3376
3377 prevState = psessionEntry->limSmeState;
3378
3379 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3380 MTRACE(mac_trace
3381 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3382 psessionEntry->limSmeState));
3383
3384 /* Update SME session Id and Transaction Id */
3385 psessionEntry->smeSessionId = smesessionId;
3386 psessionEntry->transactionId = smetransactionId;
3387
3388 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3389 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3390 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3391 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3392 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3393 /* Send disassoc all stations associated thru TKIP */
3394 __lim_counter_measures(pMac, psessionEntry);
3395 else
3396 lim_send_disassoc_mgmt_frame(pMac,
3397 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3398 bcAddr, psessionEntry, false);
3399 }
3400
3401 /* Free the buffer allocated in START_BSS_REQ */
3402 cdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3403 psessionEntry->addIeParams.probeRespDataLen = 0;
3404 psessionEntry->addIeParams.probeRespData_buff = NULL;
3405
3406 cdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3407 psessionEntry->addIeParams.assocRespDataLen = 0;
3408 psessionEntry->addIeParams.assocRespData_buff = NULL;
3409
3410 cdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3411 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3412 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3413
3414 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3415 pMac->lim.gLimIbssCoalescingHappened = false;
3416
3417 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3418 pStaDs =
3419 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3420 if (NULL == pStaDs)
3421 continue;
3422 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3423 if (eSIR_SUCCESS == status) {
3424 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3425 pStaDs->assocId, psessionEntry);
3426 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3427 } else {
3428 lim_log(pMac, LOGE,
3429 FL("lim_del_sta failed with Status : %d"), status);
3430 CDF_ASSERT(0);
3431 }
3432 }
3433 /* send a delBss to HAL and wait for a response */
3434 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3435
3436 if (status != eSIR_SUCCESS) {
3437 PELOGE(lim_log
3438 (pMac, LOGE, FL("delBss failed for bss %d"),
3439 psessionEntry->bssIdx);
3440 )
3441 psessionEntry->limSmeState = prevState;
3442
3443 MTRACE(mac_trace
3444 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3445 psessionEntry->limSmeState));
3446
3447 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3448 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3449 smetransactionId);
3450 }
3451}
3452
3453/**
3454 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3455 * @pMac: Global MAC context
3456 * @pMsg: Message from SME
3457 *
3458 * Wrapper for the function __lim_handle_sme_stop_bss_request
3459 * This message will be defered until softmac come out of
3460 * scan mode. Message should be handled even if we have
3461 * detected radar in the current operating channel.
3462 *
3463 * Return: true - If we consumed the buffer
3464 * false - If have defered the message.
3465 */
3466
3467static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3468{
3469 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3470 /**
3471 * If message defered, buffer is not consumed yet.
3472 * So return false
3473 */
3474 return false;
3475 }
3476 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3477 return true;
3478} /*** end __lim_process_sme_stop_bss_req() ***/
3479
3480void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3481 uint32_t body, tpPESession psessionEntry)
3482{
3483
3484 (void)body;
3485 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3486 lim_ibss_delete(pMac, psessionEntry);
3487 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3488 lim_delete_pre_auth_list(pMac);
3489 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3490 psessionEntry->smeSessionId,
3491 psessionEntry->transactionId);
3492 return;
3493}
3494
3495/**
3496 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3497 *
3498 * @mac_ctx: pointer to mac context
3499 * @msg_type: message type
3500 * @msg_buf: pointer to the SME message buffer
3501 *
3502 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3503 * in BTAMP AP.
3504 *
3505 * Return: None
3506 */
3507
3508void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3509 uint32_t *msg_buf)
3510{
3511 tSirSmeAssocCnf assoc_cnf;
3512 tpDphHashNode sta_ds = NULL;
3513 tpPESession session_entry = NULL;
3514 uint8_t session_id;
3515 tpSirAssocReq assoc_req;
3516
3517 if (msg_buf == NULL) {
3518 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3519 goto end;
3520 }
3521
3522 cdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
3523 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3524 lim_log(mac_ctx, LOGE,
3525 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3526 goto end;
3527 }
3528
3529 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssId,
3530 &session_id);
3531 if (session_entry == NULL) {
3532 lim_log(mac_ctx, LOGE,
3533 FL("session does not exist for given bssId"));
3534 goto end;
3535 }
3536
3537 if ((!LIM_IS_AP_ROLE(session_entry) &&
3538 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3539 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3540 (session_entry->limSmeState !=
3541 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3542 lim_log(mac_ctx, LOGE, FL(
3543 "Rcvd unexpected msg %X in state %X, in role %X"),
3544 msg_type, session_entry->limSmeState,
3545 GET_LIM_SYSTEM_ROLE(session_entry));
3546 goto end;
3547 }
3548 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3549 &session_entry->dph.dphHashTable);
3550 if (sta_ds == NULL) {
3551 lim_log(mac_ctx, LOGE, FL(
3552 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3553 msg_type, assoc_cnf.aid);
3554 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3555
3556 /*
3557 * send a DISASSOC_IND message to WSM to make sure
3558 * the state in WSM and LIM is the same
3559 */
3560 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peerMacAddr,
3561 eSIR_SME_STA_NOT_ASSOCIATED,
3562 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3563 session_entry->smeSessionId,
3564 session_entry->transactionId,
3565 session_entry);
3566 goto end;
3567 }
3568 if (!cdf_mem_compare((uint8_t *)sta_ds->staAddr,
3569 (uint8_t *) assoc_cnf.peerMacAddr,
3570 sizeof(tSirMacAddr))) {
3571 lim_log(mac_ctx, LOG1, FL(
3572 "peerMacAddr mismatched for aid %d, peer "),
3573 assoc_cnf.aid);
3574 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3575 goto end;
3576 }
3577
3578 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3579 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3580 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3581 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3582 (msg_type != eWNI_SME_ASSOC_CNF))) {
3583 lim_log(mac_ctx, LOG1, FL(
3584 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3585 "StaD mlmState : %d"),
3586 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
3587 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3588 goto end;
3589 }
3590 /*
3591 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3592 * has been received
3593 */
3594 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3595 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3596 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3597
3598 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3599 /*
3600 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3601 * when it had received Assoc Request frame. Now, PE just needs
3602 * to send association rsp frame to the requesting BTAMP-STA.
3603 */
3604 sta_ds->mlmStaContext.mlmState =
3605 eLIM_MLM_LINK_ESTABLISHED_STATE;
3606 lim_log(mac_ctx, LOG1,
3607 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3608 sta_ds->assocId);
3609 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3610 sta_ds->assocId, sta_ds->staAddr,
3611 sta_ds->mlmStaContext.subType, sta_ds,
3612 session_entry);
3613 goto end;
3614 } else {
3615 /*
3616 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3617 * to be associated since the HAL sta entry is created for
3618 * denied STA we need to remove this HAL entry.
3619 * So to do that set updateContext to 1
3620 */
3621 if (!sta_ds->mlmStaContext.updateContext)
3622 sta_ds->mlmStaContext.updateContext = 1;
3623 lim_log(mac_ctx, LOG1,
3624 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3625 assoc_cnf.statusCode, sta_ds->assocId);
3626 lim_reject_association(mac_ctx, sta_ds->staAddr,
3627 sta_ds->mlmStaContext.subType,
3628 true, sta_ds->mlmStaContext.authType,
3629 sta_ds->assocId, true,
3630 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3631 session_entry);
3632 }
3633end:
3634 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3635 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3636 assoc_req = (tpSirAssocReq)
3637 session_entry->parsedAssocReq[sta_ds->assocId];
3638 if (assoc_req->assocReqFrame) {
3639 cdf_mem_free(assoc_req->assocReqFrame);
3640 assoc_req->assocReqFrame = NULL;
3641 }
3642 cdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
3643 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3644 }
3645}
3646
3647static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3648{
3649 tpDphHashNode pStaDs;
3650 tSirMacAddr peerMac;
3651 tpSirAddtsReq pSirAddts;
3652 uint32_t timeout;
3653 tpPESession psessionEntry;
3654 uint8_t sessionId; /* PE sessionId */
3655 uint8_t smesessionId;
3656 uint16_t smetransactionId;
3657
3658 if (pMsgBuf == NULL) {
3659 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3660 return;
3661 }
3662
3663 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3664 &smetransactionId);
3665
3666 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3667
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003668 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3669 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 if (psessionEntry == NULL) {
3671 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3672 return;
3673 }
3674#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3675 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3676 0);
3677#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3678
3679 /* if sta
3680 * - verify assoc state
3681 * - send addts request to ap
3682 * - wait for addts response from ap
3683 * if ap, just ignore with error log
3684 */
3685 PELOG1(lim_log(pMac, LOG1,
3686 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3687 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3688 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3689 )
3690
3691 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3692 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3693 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3694 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3695 psessionEntry, pSirAddts->req.tspec,
3696 smesessionId, smetransactionId);
3697 return;
3698 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699
3700 pStaDs =
3701 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3702 &psessionEntry->dph.dphHashTable);
3703
3704 if (pStaDs == NULL) {
3705 PELOGE(lim_log
3706 (pMac, LOGE, "Cannot find AP context for addts req");
3707 )
3708 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3709 psessionEntry, pSirAddts->req.tspec,
3710 smesessionId, smetransactionId);
3711 return;
3712 }
3713
3714 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3715 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3716 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3717 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3718 psessionEntry, pSirAddts->req.tspec,
3719 smesessionId, smetransactionId);
3720 return;
3721 }
3722
3723 pSirAddts->req.wsmTspecPresent = 0;
3724 pSirAddts->req.wmeTspecPresent = 0;
3725 pSirAddts->req.lleTspecPresent = 0;
3726
3727 if ((pStaDs->wsmEnabled) &&
3728 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3729 SIR_MAC_ACCESSPOLICY_EDCA))
3730 pSirAddts->req.wsmTspecPresent = 1;
3731 else if (pStaDs->wmeEnabled)
3732 pSirAddts->req.wmeTspecPresent = 1;
3733 else if (pStaDs->lleEnabled)
3734 pSirAddts->req.lleTspecPresent = 1;
3735 else {
3736 PELOGW(lim_log
3737 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3738 )
3739 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3740 psessionEntry, pSirAddts->req.tspec,
3741 smesessionId, smetransactionId);
3742 return;
3743 }
3744
3745 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3746 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3747 lim_log(pMac, LOGE,
3748 "AddTs received in invalid LIMsme state (%d)",
3749 psessionEntry->limSmeState);
3750 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3751 psessionEntry, pSirAddts->req.tspec,
3752 smesessionId, smetransactionId);
3753 return;
3754 }
3755
3756 if (pMac->lim.gLimAddtsSent) {
3757 lim_log(pMac, LOGE,
3758 "Addts (token %d, tsid %d, up %d) is still pending",
3759 pMac->lim.gLimAddtsReq.req.dialogToken,
3760 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3761 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3762 userPrio);
3763 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3764 psessionEntry, pSirAddts->req.tspec,
3765 smesessionId, smetransactionId);
3766 return;
3767 }
3768
3769 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3770
3771 /* save the addts request */
3772 pMac->lim.gLimAddtsSent = true;
3773 cdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
3774 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3775
3776 /* ship out the message now */
3777 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3778 psessionEntry);
3779 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3780 /* start a timer to wait for the response */
3781 if (pSirAddts->timeout)
3782 timeout = pSirAddts->timeout;
3783 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3784 eSIR_SUCCESS) {
3785 lim_log(pMac, LOGP,
3786 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3787 WNI_CFG_ADDTS_RSP_TIMEOUT);
3788 return;
3789 }
3790
3791 timeout = SYS_MS_TO_TICKS(timeout);
3792 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3793 != TX_SUCCESS) {
3794 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3795 return;
3796 }
3797 pMac->lim.gLimAddtsRspTimerCount++;
3798 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3799 pMac->lim.gLimAddtsRspTimerCount) !=
3800 TX_SUCCESS) {
3801 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3802 return;
3803 }
3804 MTRACE(mac_trace
3805 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3806 eLIM_ADDTS_RSP_TIMER));
3807
3808 /* add the sessionId to the timer object */
3809 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3810 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3811 TX_SUCCESS) {
3812 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3813 return;
3814 }
3815 return;
3816}
3817
3818static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3819{
3820 tSirMacAddr peerMacAddr;
3821 uint8_t ac;
3822 tSirMacTSInfo *pTsinfo;
3823 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3824 tpDphHashNode pStaDs = NULL;
3825 tpPESession psessionEntry;
3826 uint8_t sessionId;
3827 uint32_t status = eSIR_SUCCESS;
3828 uint8_t smesessionId;
3829 uint16_t smetransactionId;
3830
3831 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3832 &smetransactionId);
3833
3834 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003835 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 &sessionId);
3837 if (psessionEntry == NULL) {
3838 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3839 status = eSIR_FAILURE;
3840 goto end;
3841 }
3842#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3843 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3844 0);
3845#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3846
3847 if (eSIR_SUCCESS !=
3848 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3849 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3850 status = eSIR_FAILURE;
3851 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3852 smesessionId, smetransactionId);
3853 return;
3854 }
3855
3856 lim_log(pMac, LOG1,
3857 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3858 MAC_ADDRESS_STR),
3859 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3860
3861 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3862 pDeltsReq->req.wmeTspecPresent,
3863 &pDeltsReq->req.tsinfo,
3864 &pDeltsReq->req.tspec, psessionEntry);
3865
3866 pTsinfo =
3867 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3868 tsinfo : &pDeltsReq->req.tsinfo;
3869
3870 /* We've successfully send DELTS frame to AP. Update the
3871 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3872 * is no longer trigger enabled or delivery enabled
3873 */
3874 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3875 pTsinfo, CLEAR_UAPSD_MASK);
3876
3877 /* We're deleting the TSPEC, so this particular AC is no longer
3878 * admitted. PE needs to downgrade the EDCA
3879 * parameters(for the AC for which TS is being deleted) to the
3880 * next best AC for which ACM is not enabled, and send the
3881 * updated values to HAL.
3882 */
3883 ac = upToAc(pTsinfo->traffic.userPrio);
3884
3885 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3886 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3887 ~(1 << ac);
3888 } else if (pTsinfo->traffic.direction ==
3889 SIR_MAC_DIRECTION_DNLINK) {
3890 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3891 ~(1 << ac);
3892 } else if (pTsinfo->traffic.direction ==
3893 SIR_MAC_DIRECTION_BIDIR) {
3894 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3895 ~(1 << ac);
3896 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3897 ~(1 << ac);
3898 }
3899
3900 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3901 psessionEntry);
3902
3903 pStaDs =
3904 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3905 &psessionEntry->dph.dphHashTable);
3906 if (pStaDs != NULL) {
3907 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3908 pStaDs->bssId);
3909 status = eSIR_SUCCESS;
3910 } else {
3911 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3912 status = eSIR_FAILURE;
3913 }
3914#ifdef FEATURE_WLAN_ESE
3915#ifdef FEATURE_WLAN_ESE_UPLOAD
3916 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917#endif /* FEATURE_WLAN_ESE_UPLOAD */
3918#endif
3919
3920 /* send an sme response back */
3921end:
3922 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3923 smesessionId, smetransactionId);
3924}
3925
3926void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3927{
3928 /* fetch the sessionEntry based on the sessionId */
3929 tpPESession psessionEntry;
3930 psessionEntry = pe_find_session_by_session_id(pMac,
3931 pMac->lim.limTimers.gLimAddtsRspTimer.
3932 sessionId);
3933 if (psessionEntry == NULL) {
3934 lim_log(pMac, LOGP,
3935 FL("Session Does not exist for given sessionID"));
3936 return;
3937 }
3938
3939 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3940 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3941 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3942 GET_LIM_SYSTEM_ROLE(psessionEntry));
3943 pMac->lim.gLimAddtsSent = false;
3944 return;
3945 }
3946
3947 if (!pMac->lim.gLimAddtsSent) {
3948 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3949 return;
3950 }
3951
3952 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3953 lim_log(pMac, LOGE,
3954 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3955 pMac->lim.gLimAddtsRspTimerCount);
3956 return;
3957 }
3958 /* this a real response timeout */
3959 pMac->lim.gLimAddtsSent = false;
3960 pMac->lim.gLimAddtsRspTimerCount++;
3961
3962 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3963 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3964 psessionEntry->smeSessionId,
3965 psessionEntry->transactionId);
3966}
3967
3968/**
3969 * __lim_process_sme_get_statistics_request()
3970 *
3971 ***FUNCTION:
3972 *
3973 *
3974 ***NOTE:
3975 *
3976 * @param pMac Pointer to Global MAC structure
3977 * @param *pMsgBuf A pointer to the SME message buffer
3978 * @return None
3979 */
3980static void
3981__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3982{
3983 tpAniGetPEStatsReq pPEStatsReq;
3984 tSirMsgQ msgQ;
3985
3986 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3987
3988 msgQ.type = WMA_GET_STATISTICS_REQ;
3989
3990 msgQ.reserved = 0;
3991 msgQ.bodyptr = pMsgBuf;
3992 msgQ.bodyval = 0;
3993 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3994
3995 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
3996 cdf_mem_free(pMsgBuf);
3997 pMsgBuf = NULL;
3998 lim_log(pMac, LOGP, "Unable to forward request");
3999 return;
4000 }
4001
4002 return;
4003}
4004
4005#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4006/**
4007 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
4008 *
4009 ***NOTE:
4010 *
4011 * @param pMac Pointer to Global MAC structure
4012 * @param *pMsgBuf A pointer to the SME message buffer
4013 * @return None
4014 */
4015static void
4016__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4017{
4018 tSirMsgQ msgQ;
4019
4020 msgQ.type = WMA_TSM_STATS_REQ;
4021 msgQ.reserved = 0;
4022 msgQ.bodyptr = pMsgBuf;
4023 msgQ.bodyval = 0;
4024 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4025
4026 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
4027 cdf_mem_free(pMsgBuf);
4028 pMsgBuf = NULL;
4029 lim_log(pMac, LOGP, "Unable to forward request");
4030 return;
4031 }
4032}
4033#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4034
4035static void
4036__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4037{
4038 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4039 tpPESession psessionEntry;
4040 uint8_t sessionId; /* PE sessionID */
4041
4042 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4043
4044 if (pMsgBuf == NULL) {
4045 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4046 return;
4047 }
4048
4049 pUpdateAPWPSIEsReq = cdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4050 if (NULL == pUpdateAPWPSIEsReq) {
4051 lim_log(pMac, LOGP,
4052 FL
4053 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4054 return;
4055 }
4056 cdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
4057 sizeof(struct sSirUpdateAPWPSIEsReq));
4058
4059 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004060 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 &sessionId);
4062 if (psessionEntry == NULL) {
4063 lim_log(pMac, LOGW,
4064 FL("Session does not exist for given BSSID"));
4065 goto end;
4066 }
4067
4068 cdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
4069 sizeof(tSirAPWPSIEs));
4070
4071 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4072 lim_send_beacon_ind(pMac, psessionEntry);
4073
4074end:
4075 cdf_mem_free(pUpdateAPWPSIEsReq);
4076 return;
4077}
4078
4079void
4080lim_send_vdev_restart(tpAniSirGlobal pMac,
4081 tpPESession psessionEntry, uint8_t sessionId)
4082{
4083 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4084 tSirMsgQ msgQ;
4085 tSirRetStatus retCode = eSIR_SUCCESS;
4086
4087 if (psessionEntry == NULL) {
4088 PELOGE(lim_log
4089 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4090 __LINE__);
4091 )
4092 return;
4093 }
4094
4095 pHalHiddenSsidVdevRestart =
4096 cdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
4097 if (NULL == pHalHiddenSsidVdevRestart) {
4098 PELOGE(lim_log
4099 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4100 __func__, __LINE__);
4101 )
4102 return;
4103 }
4104
4105 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4106 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4107
4108 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4109 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4110 msgQ.bodyval = 0;
4111
4112 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4113 if (eSIR_SUCCESS != retCode) {
4114 PELOGE(lim_log
4115 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4116 __LINE__);
4117 )
4118 cdf_mem_free(pHalHiddenSsidVdevRestart);
4119 }
4120}
4121
4122static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4123{
4124 tpSirUpdateParams pUpdateParams;
4125 tpPESession psessionEntry;
4126
4127 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4128
4129 if (pMsgBuf == NULL) {
4130 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4131 return;
4132 }
4133
4134 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4135
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004136 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 pUpdateParams->sessionId);
4138 if (psessionEntry == NULL) {
4139 lim_log(pMac, LOGW,
4140 "Session does not exist for given sessionId %d",
4141 pUpdateParams->sessionId);
4142 return;
4143 }
4144
4145 /* Update the session entry */
4146 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4147
4148 /* Send vdev restart */
4149 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4150
4151 /* Update beacon */
4152 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4153 lim_send_beacon_ind(pMac, psessionEntry);
4154
4155 return;
4156} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4157
4158static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4159{
4160 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4161 tpPESession psessionEntry;
4162 uint8_t sessionId; /* PE sessionID */
4163
4164 if (pMsgBuf == NULL) {
4165 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4166 return;
4167 }
4168
4169 pUpdateAPWPARSNIEsReq = cdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4170 if (NULL == pUpdateAPWPARSNIEsReq) {
4171 lim_log(pMac, LOGP,
4172 FL
4173 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4174 return;
4175 }
4176 cdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
4177 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4178
4179 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004180 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 &sessionId);
4182 if (psessionEntry == NULL) {
4183 lim_log(pMac, LOGW,
4184 FL("Session does not exist for given BSSID"));
4185 goto end;
4186 }
4187
4188 cdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4189 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4190
4191 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4192 &psessionEntry->
4193 pLimStartBssReq->rsnIE,
4194 psessionEntry);
4195
4196 psessionEntry->pLimStartBssReq->privacy = 1;
4197 psessionEntry->privacy = 1;
4198
4199 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4200 lim_send_beacon_ind(pMac, psessionEntry);
4201
4202end:
4203 cdf_mem_free(pUpdateAPWPARSNIEsReq);
4204 return;
4205} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4206
4207/*
4208 Update the beacon Interval dynamically if beaconInterval is different in MCC
4209 */
4210static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4211{
4212 tpSirChangeBIParams pChangeBIParams;
4213 tpPESession psessionEntry;
4214 uint8_t sessionId = 0;
4215 tUpdateBeaconParams beaconParams;
4216
4217 PELOG1(lim_log(pMac, LOG1,
4218 FL("received Update Beacon Interval message"));
4219 );
4220
4221 if (pMsgBuf == NULL) {
4222 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4223 return;
4224 }
4225
4226 cdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
4227 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4228
4229 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004230 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 &sessionId);
4232 if (psessionEntry == NULL) {
4233 lim_log(pMac, LOGE,
4234 FL("Session does not exist for given BSSID"));
4235 return;
4236 }
4237
4238 /*Update sessionEntry Beacon Interval */
4239 if (psessionEntry->beaconParams.beaconInterval !=
4240 pChangeBIParams->beaconInterval) {
4241 psessionEntry->beaconParams.beaconInterval =
4242 pChangeBIParams->beaconInterval;
4243 }
4244
4245 /*Update sch beaconInterval */
4246 if (pMac->sch.schObject.gSchBeaconInterval !=
4247 pChangeBIParams->beaconInterval) {
4248 pMac->sch.schObject.gSchBeaconInterval =
4249 pChangeBIParams->beaconInterval;
4250
4251 PELOG1(lim_log(pMac, LOG1,
4252 FL
4253 ("LIM send update BeaconInterval Indication : %d"),
4254 pChangeBIParams->beaconInterval);
4255 );
4256
4257 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4258 /* Update beacon */
4259 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4260
4261 beaconParams.bssIdx = psessionEntry->bssIdx;
4262 /* Set change in beacon Interval */
4263 beaconParams.beaconInterval =
4264 pChangeBIParams->beaconInterval;
4265 beaconParams.paramChangeBitmap =
4266 PARAM_BCN_INTERVAL_CHANGED;
4267 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4268 }
4269 }
4270
4271 return;
4272} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4273
4274#ifdef QCA_HT_2040_COEX
4275static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4276 uint32_t *pMsgBuf)
4277{
4278 tpSirSetHT2040Mode pSetHT2040Mode;
4279 tpPESession psessionEntry;
4280 uint8_t sessionId = 0;
4281 cds_msg_t msg;
4282 tUpdateVHTOpMode *pHtOpMode = NULL;
4283 uint16_t staId = 0;
4284 tpDphHashNode pStaDs = NULL;
4285
4286 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4287 if (pMsgBuf == NULL) {
4288 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4289 return;
4290 }
4291
4292 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4293
4294 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004295 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 &sessionId);
4297 if (psessionEntry == NULL) {
4298 lim_log(pMac, LOG1,
4299 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004300 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 return;
4302 }
4303
4304 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4305 pSetHT2040Mode->cbMode);
4306 /*Update sessionEntry HT related fields */
4307 switch (pSetHT2040Mode->cbMode) {
4308 case PHY_SINGLE_CHANNEL_CENTERED:
4309 psessionEntry->htSecondaryChannelOffset =
4310 PHY_SINGLE_CHANNEL_CENTERED;
4311 psessionEntry->htRecommendedTxWidthSet = 0;
4312 if (pSetHT2040Mode->obssEnabled)
4313 psessionEntry->htSupportedChannelWidthSet
4314 = eHT_CHANNEL_WIDTH_40MHZ;
4315 else
4316 psessionEntry->htSupportedChannelWidthSet
4317 = eHT_CHANNEL_WIDTH_20MHZ;
4318 break;
4319 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4320 psessionEntry->htSecondaryChannelOffset =
4321 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4322 psessionEntry->htRecommendedTxWidthSet = 1;
4323 break;
4324 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4325 psessionEntry->htSecondaryChannelOffset =
4326 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4327 psessionEntry->htRecommendedTxWidthSet = 1;
4328 break;
4329 default:
4330 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4331 return;
4332 }
4333
4334 /* Update beacon */
4335 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4336 lim_send_beacon_ind(pMac, psessionEntry);
4337
4338 /* update OP Mode for each associated peer */
4339 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4340 pStaDs = dph_get_hash_entry(pMac, staId,
4341 &psessionEntry->dph.dphHashTable);
4342 if (NULL == pStaDs)
4343 continue;
4344
4345 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
4346 pHtOpMode = cdf_mem_malloc(sizeof(tUpdateVHTOpMode));
4347 if (NULL == pHtOpMode) {
4348 lim_log(pMac, LOGE,
4349 FL
4350 ("%s: Not able to allocate memory for setting OP mode"),
4351 __func__);
4352 return;
4353 }
4354 pHtOpMode->opMode =
4355 (psessionEntry->htSecondaryChannelOffset ==
4356 PHY_SINGLE_CHANNEL_CENTERED) ?
4357 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4358 pHtOpMode->staId = staId;
4359 cdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
4360 sizeof(tSirMacAddr));
4361 pHtOpMode->smesessionId = sessionId;
4362
4363 msg.type = WMA_UPDATE_OP_MODE;
4364 msg.reserved = 0;
4365 msg.bodyptr = pHtOpMode;
4366 if (!CDF_IS_STATUS_SUCCESS
4367 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
4368 lim_log(pMac, LOGE,
4369 FL
4370 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4371 __func__);
4372 cdf_mem_free(pHtOpMode);
4373 return;
4374 }
4375 lim_log(pMac, LOG1,
4376 FL
4377 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4378 __func__, pHtOpMode->opMode, staId);
4379
4380 } else
4381 lim_log(pMac, LOG1,
4382 FL("%s: station %d does not support HT40\n"),
4383 __func__, staId);
4384 }
4385
4386 return;
4387}
4388#endif
4389
4390/* -------------------------------------------------------------------- */
4391/**
4392 * __lim_process_report_message
4393 *
4394 * FUNCTION: Processes the next received Radio Resource Management message
4395 *
4396 * LOGIC:
4397 *
4398 * ASSUMPTIONS:
4399 *
4400 * NOTE:
4401 *
4402 * @param None
4403 * @return None
4404 */
4405
4406void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4407{
4408#ifdef WLAN_FEATURE_VOWIFI
4409 switch (pMsg->type) {
4410 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4411 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4412 break;
4413 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004415 break;
4416 default:
4417 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 }
4419#endif
4420}
4421
4422#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
4423/* -------------------------------------------------------------------- */
4424/**
4425 * lim_send_set_max_tx_power_req
4426 *
4427 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4428 *
4429 * LOGIC:
4430 *
4431 * ASSUMPTIONS:
4432 *
4433 * NOTE:
4434 *
4435 * @param txPower txPower to be set.
4436 * @param pSessionEntry session entry.
4437 * @return None
4438 */
4439tSirRetStatus
4440lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, tPowerdBm txPower,
4441 tpPESession pSessionEntry)
4442{
4443 tpMaxTxPowerParams pMaxTxParams = NULL;
4444 tSirRetStatus retCode = eSIR_SUCCESS;
4445 tSirMsgQ msgQ;
4446
4447 if (pSessionEntry == NULL) {
4448 PELOGE(lim_log
4449 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4450 __LINE__);
4451 )
4452 return eSIR_FAILURE;
4453 }
4454
4455 pMaxTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
4456 if (NULL == pMaxTxParams) {
4457 lim_log(pMac, LOGP,
4458 FL("Unable to allocate memory for pMaxTxParams "));
4459 return eSIR_MEM_ALLOC_FAILED;
4460
4461 }
4462#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4463 lim_log(pMac, LOG1,
4464 FL("pMaxTxParams allocated...will be freed in other module"));
4465#endif
4466 if (pMaxTxParams == NULL) {
4467 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4468 return eSIR_FAILURE;
4469 }
4470 pMaxTxParams->power = txPower;
Srinivas Girigowda97215232015-09-24 12:26:28 -07004471 cdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
4472 CDF_MAC_ADDR_SIZE);
4473 cdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
4474 pSessionEntry->selfMacAddr,
4475 CDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476
4477 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4478 msgQ.bodyptr = pMaxTxParams;
4479 msgQ.bodyval = 0;
4480 PELOG1(lim_log
4481 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4482 )
4483 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4484 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4485 if (eSIR_SUCCESS != retCode) {
4486 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
4487 cdf_mem_free(pMaxTxParams);
4488 }
4489 return retCode;
4490}
4491#endif
4492
4493/**
4494 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4495 *
4496 * @mac_ctx: Pointer to Global MAC structure
4497 * @msg_buf: pointer to the SME message buffer
4498 *
4499 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4500 * from SME. It Register this information within PE.
4501 *
4502 * Return: None
4503 */
4504static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4505 uint32_t *msg_buf)
4506{
4507 CDF_STATUS cdf_status;
4508 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4509 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4510 struct mgmt_frm_reg_info *next = NULL;
4511 bool match = false;
4512
4513 lim_log(mac_ctx, LOG1, FL(
4514 "registerFrame %d, frameType %d, matchLen %d"),
4515 sme_req->registerFrame, sme_req->frameType,
4516 sme_req->matchLen);
4517 /* First check whether entry exists already */
4518 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4519 cdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4520 (cdf_list_node_t **) &lim_mgmt_regn);
4521 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4522
4523 while (lim_mgmt_regn != NULL) {
4524 if (lim_mgmt_regn->frameType != sme_req->frameType)
4525 goto skip_match;
4526 if (sme_req->matchLen) {
4527 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
4528 (cdf_mem_compare(lim_mgmt_regn->matchData,
4529 sme_req->matchData,
4530 lim_mgmt_regn->matchLen))) {
4531 /* found match! */
4532 match = true;
4533 break;
4534 }
4535 } else {
4536 /* found match! */
4537 match = true;
4538 break;
4539 }
4540skip_match:
4541 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4542 cdf_status = cdf_list_peek_next(
4543 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4544 (cdf_list_node_t *)lim_mgmt_regn,
4545 (cdf_list_node_t **)&next);
4546 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4547 lim_mgmt_regn = next;
4548 next = NULL;
4549 }
4550 if (match) {
4551 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4552 cdf_list_remove_node(
4553 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4554 (cdf_list_node_t *)lim_mgmt_regn);
4555 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4556 cdf_mem_free(lim_mgmt_regn);
4557 }
4558
4559 if (sme_req->registerFrame) {
4560 lim_mgmt_regn =
4561 cdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
4562 sme_req->matchLen);
4563 if (lim_mgmt_regn != NULL) {
4564 cdf_mem_set((void *)lim_mgmt_regn,
4565 sizeof(struct mgmt_frm_reg_info) +
4566 sme_req->matchLen, 0);
4567 lim_mgmt_regn->frameType = sme_req->frameType;
4568 lim_mgmt_regn->matchLen = sme_req->matchLen;
4569 lim_mgmt_regn->sessionId = sme_req->sessionId;
4570 if (sme_req->matchLen) {
4571 cdf_mem_copy(lim_mgmt_regn->matchData,
4572 sme_req->matchData,
4573 sme_req->matchLen);
4574 }
4575 cdf_mutex_acquire(
4576 &mac_ctx->lim.lim_frame_register_lock);
4577 cdf_list_insert_front(&mac_ctx->lim.
4578 gLimMgmtFrameRegistratinQueue,
4579 &lim_mgmt_regn->node);
4580 cdf_mutex_release(
4581 &mac_ctx->lim.lim_frame_register_lock);
4582 }
4583 }
4584 return;
4585}
4586
4587static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4588{
4589 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4590 pMac->lim.gDeferMsgTypeForNOA);
4591 pMac->lim.gDeferMsgTypeForNOA = 0;
4592 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4593 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
4594 cdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
4595 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4596 }
4597}
4598
4599/**
4600 * lim_process_regd_defd_sme_req_after_noa_start()
4601 *
4602 * mac_ctx: Pointer to Global MAC structure
4603 *
4604 * This function is called to process deferred sme req message
4605 * after noa start.
4606 *
4607 * Return: None
4608 */
4609void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4610{
4611 bool buf_consumed = true;
4612
4613 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4614 mac_ctx->lim.gDeferMsgTypeForNOA);
4615
4616 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4617 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4618 lim_log(mac_ctx, LOGW,
4619 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4620 lim_log(mac_ctx, LOGW,
4621 FL("It may happen when NOA start ind and timeout happen at the same time"));
4622 return;
4623 }
4624 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4625 case eWNI_SME_SCAN_REQ:
4626 __lim_process_sme_scan_req(mac_ctx,
4627 mac_ctx->lim.gpDefdSmeMsgForNOA);
4628 break;
4629#ifdef FEATURE_OEM_DATA_SUPPORT
4630 case eWNI_SME_OEM_DATA_REQ:
4631 __lim_process_sme_oem_data_req(mac_ctx,
4632 mac_ctx->lim.gpDefdSmeMsgForNOA);
4633 break;
4634#endif
4635 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4636 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4637 mac_ctx->lim.gpDefdSmeMsgForNOA);
4638 /*
4639 * lim_process_remain_on_chnl_req doesnt want us to free
4640 * the buffer since it is freed in lim_remain_on_chn_rsp.
4641 * this change is to avoid "double free"
4642 */
4643 if (false == buf_consumed)
4644 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4645 break;
4646 case eWNI_SME_JOIN_REQ:
4647 __lim_process_sme_join_req(mac_ctx,
4648 mac_ctx->lim.gpDefdSmeMsgForNOA);
4649 break;
4650 default:
4651 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4652 mac_ctx->lim.gDeferMsgTypeForNOA);
4653 break;
4654 }
4655 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4656}
4657
4658static void
4659__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4660{
4661 tpSirResetAPCapsChange pResetCapsChange;
4662 tpPESession psessionEntry;
4663 uint8_t sessionId = 0;
4664 if (pMsgBuf == NULL) {
4665 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4666 return;
4667 }
4668
4669 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4670 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004671 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4672 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 if (psessionEntry == NULL) {
4674 lim_log(pMac, LOGE,
4675 FL("Session does not exist for given BSSID"));
4676 return;
4677 }
4678
4679 psessionEntry->limSentCapsChangeNtf = false;
4680 return;
4681}
4682
4683/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304684 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4685 * indication callback in PE.
4686 * @mac_ptr: Mac pointer
4687 * @msg_buf: Msg pointer containing the callback
4688 *
4689 * This function is used save the Management frame
4690 * indication callback in PE.
4691 *
4692 * Return: None
4693 */
4694static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4695 uint32_t *msg_buf)
4696{
4697 struct sir_sme_mgmt_frame_cb_req *sme_req =
4698 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4699
4700 if (NULL == msg_buf) {
4701 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4702 return;
4703 }
4704 if (sme_req->callback)
4705 mac_ctx->mgmt_frame_ind_cb =
4706 (sir_mgmt_frame_ind_callback)sme_req->callback;
4707 else
4708 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4709}
4710
4711/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 * lim_process_sme_req_messages()
4713 *
4714 ***FUNCTION:
4715 * This function is called by limProcessMessageQueue(). This
4716 * function processes SME request messages from HDD or upper layer
4717 * application.
4718 *
4719 ***LOGIC:
4720 *
4721 ***ASSUMPTIONS:
4722 *
4723 ***NOTE:
4724 *
4725 * @param pMac Pointer to Global MAC structure
4726 * @param msgType Indicates the SME message type
4727 * @param *pMsgBuf A pointer to the SME message buffer
4728 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4729 * false - if pMsgBuf is not to be freed.
4730 */
4731
4732bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4733{
4734 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4735 uint32_t *pMsgBuf = pMsg->bodyptr;
4736 tpSirSmeScanReq pScanReq;
4737 PELOG1(lim_log
4738 (pMac, LOG1,
4739 FL
4740 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4741 lim_msg_str(pMsg->type), pMsg->type,
4742 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4743 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4744 )
4745
4746 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4747 /* If no insert NOA required then execute the code below */
4748
4749 switch (pMsg->type) {
4750 case eWNI_SME_SYS_READY_IND:
4751 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4752 break;
4753
4754 case eWNI_SME_START_BSS_REQ:
4755 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4756 break;
4757
4758 case eWNI_SME_SCAN_REQ:
4759 __lim_process_sme_scan_req(pMac, pMsgBuf);
4760 break;
4761
4762#ifdef FEATURE_OEM_DATA_SUPPORT
4763 case eWNI_SME_OEM_DATA_REQ:
4764 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4765 break;
4766#endif
4767 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4768 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4769 break;
4770
4771 case eWNI_SME_UPDATE_NOA:
4772 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4773 break;
4774 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4775 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4776 break;
4777 case eWNI_SME_JOIN_REQ:
4778 __lim_process_sme_join_req(pMac, pMsgBuf);
4779 break;
4780
4781 case eWNI_SME_REASSOC_REQ:
4782 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4783 break;
4784
4785 case eWNI_SME_DISASSOC_REQ:
4786 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4787 break;
4788
4789 case eWNI_SME_DISASSOC_CNF:
4790 case eWNI_SME_DEAUTH_CNF:
4791 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4792 break;
4793
4794 case eWNI_SME_DEAUTH_REQ:
4795 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4796 break;
4797
4798 case eWNI_SME_SETCONTEXT_REQ:
4799 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4800 break;
4801
4802 case eWNI_SME_STOP_BSS_REQ:
4803 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4804 break;
4805
4806 case eWNI_SME_ASSOC_CNF:
4807 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4808 PELOG1(lim_log(pMac,
4809 LOG1, FL("Received ASSOC_CNF message"));)
4810 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4811 pMsgBuf);
4812 break;
4813
4814 case eWNI_SME_ADDTS_REQ:
4815 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4816 __lim_process_sme_addts_req(pMac, pMsgBuf);
4817 break;
4818
4819 case eWNI_SME_DELTS_REQ:
4820 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4821 __lim_process_sme_delts_req(pMac, pMsgBuf);
4822 break;
4823
4824 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4825 PELOG1(lim_log
4826 (pMac, LOG1,
4827 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4828 )
4829 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4830 break;
4831
4832 case eWNI_SME_GET_STATISTICS_REQ:
4833 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4834 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4835 bufConsumed = false;
4836 break;
4837#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4838 case eWNI_SME_GET_TSM_STATS_REQ:
4839 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4840 bufConsumed = false;
4841 break;
4842#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4843 case eWNI_SME_GET_ASSOC_STAS_REQ:
4844 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4845 break;
4846 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4847 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4848 break;
4849
4850 case eWNI_SME_HIDE_SSID_REQ:
4851 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4852 break;
4853 case eWNI_SME_UPDATE_APWPSIE_REQ:
4854 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4855 break;
4856 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4857 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4858 break;
4859
4860 case eWNI_SME_SET_APWPARSNIEs_REQ:
4861 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4862 break;
4863
4864 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4865 /* Update the beaconInterval */
4866 __lim_process_sme_change_bi(pMac, pMsgBuf);
4867 break;
4868
4869#ifdef QCA_HT_2040_COEX
4870 case eWNI_SME_SET_HT_2040_MODE:
4871 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4872 break;
4873#endif
4874
4875#if defined WLAN_FEATURE_VOWIFI
4876 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4877 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4878 __lim_process_report_message(pMac, pMsg);
4879 break;
4880#endif
4881
4882#if defined WLAN_FEATURE_VOWIFI_11R
4883 case eWNI_SME_FT_PRE_AUTH_REQ:
4884 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4885 break;
4886 case eWNI_SME_FT_UPDATE_KEY:
4887 lim_process_ft_update_key(pMac, pMsgBuf);
4888 break;
4889
4890 case eWNI_SME_FT_AGGR_QOS_REQ:
4891 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4892 break;
4893#endif
4894
4895 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4896 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4897 break;
4898#ifdef FEATURE_WLAN_TDLS
4899 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4900 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4901 break;
4902 case eWNI_SME_TDLS_ADD_STA_REQ:
4903 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4904 break;
4905 case eWNI_SME_TDLS_DEL_STA_REQ:
4906 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4907 break;
4908 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4909 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4910 break;
4911#endif
4912 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4913 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4914 break;
4915
4916 case eWNI_SME_CHANNEL_CHANGE_REQ:
4917 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4918 break;
4919
4920 case eWNI_SME_START_BEACON_REQ:
4921 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4922 break;
4923
4924 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4925 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4926 break;
4927
4928 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4929 lim_process_update_add_ies(pMac, pMsgBuf);
4930 break;
4931
4932 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4933 lim_process_modify_add_ies(pMac, pMsgBuf);
4934 break;
4935 case eWNI_SME_SET_HW_MODE_REQ:
4936 lim_process_set_hw_mode(pMac, pMsgBuf);
4937 break;
4938 case eWNI_SME_NSS_UPDATE_REQ:
4939 lim_process_nss_update_request(pMac, pMsgBuf);
4940 break;
4941 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4942 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4943 break;
4944 case eWNI_SME_SET_IE_REQ:
4945 lim_process_set_ie_req(pMac, pMsgBuf);
4946 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304947 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4948 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4949 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304950 case eWNI_SME_EXT_CHANGE_CHANNEL:
4951 lim_process_ext_change_channel(pMac, pMsgBuf);
4952 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 default:
4954 cdf_mem_free((void *)pMsg->bodyptr);
4955 pMsg->bodyptr = NULL;
4956 break;
4957 } /* switch (msgType) */
4958
4959 return bufConsumed;
4960} /*** end lim_process_sme_req_messages() ***/
4961
4962/**
4963 * lim_process_sme_start_beacon_req()
4964 *
4965 ***FUNCTION:
4966 * This function is called by limProcessMessageQueue(). This
4967 * function processes SME request messages from HDD or upper layer
4968 * application.
4969 *
4970 ***LOGIC:
4971 *
4972 ***ASSUMPTIONS:
4973 *
4974 ***NOTE:
4975 *
4976 * @param pMac Pointer to Global MAC structure
4977 * @param msgType Indicates the SME message type
4978 * @param *pMsgBuf A pointer to the SME message buffer
4979 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4980 * false - if pMsgBuf is not to be freed.
4981 */
4982static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4983{
4984 tpSirStartBeaconIndication pBeaconStartInd;
4985 tpPESession psessionEntry;
4986 uint8_t sessionId; /* PE sessionID */
4987
4988 if (pMsg == NULL) {
4989 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4990 return;
4991 }
4992
4993 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4994 psessionEntry = pe_find_session_by_bssid(pMac,
4995 pBeaconStartInd->bssid,
4996 &sessionId);
4997 if (psessionEntry == NULL) {
4998 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
4999 lim_log(pMac, LOGE,
5000 FL("Session does not exist for given bssId"));
5001 return;
5002 }
5003
5004 if (pBeaconStartInd->beaconStartStatus == true) {
5005 /*
5006 * Currently this Indication comes from SAP
5007 * to start Beacon Tx on a DFS channel
5008 * since beaconing has to be done on DFS
5009 * channel only after CAC WAIT is completed.
5010 * On a DFS Channel LIM does not start beacon
5011 * Tx right after the WMA_ADD_BSS_RSP.
5012 */
5013 lim_apply_configuration(pMac, psessionEntry);
5014 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
5015 FL("Start Beacon with ssid %s Ch %d"),
5016 psessionEntry->ssId.ssId,
5017 psessionEntry->currentOperChannel);
5018 lim_send_beacon_ind(pMac, psessionEntry);
5019 } else {
5020 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5021 return;
5022 }
5023}
5024
5025/**
5026 * lim_process_sme_channel_change_request() - process sme ch change req
5027 *
5028 * @mac_ctx: Pointer to Global MAC structure
5029 * @msg_buf: pointer to the SME message buffer
5030 *
5031 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5032 *
5033 * Return: None
5034 */
5035static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5036 uint32_t *msg_buf)
5037{
5038 tpSirChanChangeRequest ch_change_req;
5039 tpPESession session_entry;
5040 uint8_t session_id; /* PE session_id */
5041 tPowerdBm max_tx_pwr;
5042 uint32_t val = 0;
5043
5044 if (msg_buf == NULL) {
5045 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5046 return;
5047 }
5048 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5049
5050 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5051 ch_change_req->targetChannel);
5052
5053 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5054 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5055 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5056 return;
5057 }
5058
5059 session_entry = pe_find_session_by_bssid(mac_ctx,
5060 ch_change_req->bssid, &session_id);
5061 if (session_entry == NULL) {
5062 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5063 lim_log(mac_ctx, LOGE, FL(
5064 "Session does not exist for given bssId"));
5065 return;
5066 }
5067
5068 if (session_entry->currentOperChannel ==
5069 ch_change_req->targetChannel) {
5070 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5071 return;
5072 }
5073
5074 if (LIM_IS_AP_ROLE(session_entry))
5075 session_entry->channelChangeReasonCode =
5076 LIM_SWITCH_CHANNEL_SAP_DFS;
5077 else
5078 session_entry->channelChangeReasonCode =
5079 LIM_SWITCH_CHANNEL_OPERATION;
5080
5081 lim_log(mac_ctx, LOGW, FL(
5082 "switch old chnl %d to new chnl %d, ch_bw %d"),
5083 session_entry->currentOperChannel,
5084 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005085 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086
5087 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005088 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089 session_entry->ch_center_freq_seg0 =
5090 ch_change_req->center_freq_seg_0;
5091 session_entry->ch_center_freq_seg1 =
5092 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005093 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005095 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 session_entry->htRecommendedTxWidthSet =
5097 session_entry->htSupportedChannelWidthSet;
5098 session_entry->currentOperChannel =
5099 ch_change_req->targetChannel;
5100 session_entry->limRFBand =
5101 lim_get_rf_band(session_entry->currentOperChannel);
5102 /* Initialize 11h Enable Flag */
5103 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5104 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5105 eSIR_SUCCESS)
5106 lim_log(mac_ctx, LOGP,
5107 FL("Fail to get WNI_CFG_11H_ENABLED"));
5108 }
5109
5110 session_entry->lim11hEnable = val;
5111 session_entry->dot11mode = ch_change_req->dot11mode;
5112 cdf_mem_copy(&session_entry->rateSet,
5113 &ch_change_req->operational_rateset,
5114 sizeof(session_entry->rateSet));
5115 cdf_mem_copy(&session_entry->extRateSet,
5116 &ch_change_req->extended_rateset,
5117 sizeof(session_entry->extRateSet));
5118 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5119 session_entry->ch_center_freq_seg0,
5120 session_entry->ch_center_freq_seg1,
5121 session_entry->ch_width,
5122 max_tx_pwr, session_entry->peSessionId);
5123}
5124
5125/******************************************************************************
5126* lim_start_bss_update_add_ie_buffer()
5127*
5128***FUNCTION:
5129* This function checks the src buffer and its length and then malloc for
5130* dst buffer update the same
5131*
5132***LOGIC:
5133*
5134***ASSUMPTIONS:
5135*
5136***NOTE:
5137*
5138* @param pMac Pointer to Global MAC structure
5139* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5140* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5141* @param *pSrcData_buff A pointer of uint8_t src buffer
5142* @param srcDataLen src buffer length
5143******************************************************************************/
5144
5145static void
5146lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5147 uint8_t **pDstData_buff,
5148 uint16_t *pDstDataLen,
5149 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5150{
5151
5152 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5153 *pDstDataLen = srcDataLen;
5154
5155 *pDstData_buff = cdf_mem_malloc(*pDstDataLen);
5156
5157 if (NULL == *pDstData_buff) {
5158 lim_log(pMac, LOGE,
5159 FL("AllocateMemory failed for pDstData_buff"));
5160 return;
5161 }
5162 cdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
5163 } else {
5164 *pDstData_buff = NULL;
5165 *pDstDataLen = 0;
5166 }
5167}
5168
5169/******************************************************************************
5170* lim_update_add_ie_buffer()
5171*
5172***FUNCTION:
5173* This function checks the src buffer and length if src buffer length more
5174* than dst buffer length then free the dst buffer and malloc for the new src
5175* length, and update the dst buffer and length. But if dst buffer is bigger
5176* than src buffer length then it just update the dst buffer and length
5177*
5178***LOGIC:
5179*
5180***ASSUMPTIONS:
5181*
5182***NOTE:
5183*
5184* @param pMac Pointer to Global MAC structure
5185* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5186* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5187* @param *pSrcData_buff A pointer of uint8_t src buffer
5188* @param srcDataLen src buffer length
5189******************************************************************************/
5190
5191static void
5192lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5193 uint8_t **pDstData_buff,
5194 uint16_t *pDstDataLen,
5195 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5196{
5197
5198 if (NULL == pSrcData_buff) {
5199 lim_log(pMac, LOGE, FL("src buffer is null."));
5200 return;
5201 }
5202
5203 if (srcDataLen > *pDstDataLen) {
5204 *pDstDataLen = srcDataLen;
5205 /* free old buffer */
5206 cdf_mem_free(*pDstData_buff);
5207 /* allocate a new */
5208 *pDstData_buff = cdf_mem_malloc(*pDstDataLen);
5209
5210 if (NULL == *pDstData_buff) {
5211 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5212 *pDstDataLen = 0;
5213 return;
5214 }
5215 }
5216
5217 /* copy the content of buffer into dst buffer
5218 */
5219 *pDstDataLen = srcDataLen;
5220 cdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
5221
5222}
5223
5224/*
5225* lim_process_modify_add_ies() - process modify additional IE req.
5226*
5227* @mac_ctx: Pointer to Global MAC structure
5228* @msg_buf: pointer to the SME message buffer
5229*
5230* This function update the PE buffers for additional IEs.
5231*
5232* Return: None
5233*/
5234static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5235 uint32_t *msg_buf)
5236{
5237 tpSirModifyIEsInd modify_add_ies;
5238 tpPESession session_entry;
5239 uint8_t session_id;
5240 bool ret = false;
5241 tSirAddIeParams *add_ie_params;
5242
5243 if (msg_buf == NULL) {
5244 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5245 return;
5246 }
5247
5248 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5249 /* Incoming message has smeSession, use BSSID to find PE session */
5250 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005251 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252
5253 if (NULL == session_entry) {
5254 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5255 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005256 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 goto end;
5258 }
5259 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5260 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5261 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5262 lim_log(mac_ctx, LOGE,
5263 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5264 modify_add_ies->modifyIE.pIEBuffer,
5265 modify_add_ies->modifyIE.ieBufferlength,
5266 modify_add_ies->modifyIE.ieID,
5267 modify_add_ies->modifyIE.ieIDLen,
5268 modify_add_ies->updateType);
5269 goto end;
5270 }
5271 add_ie_params = &session_entry->addIeParams;
5272 switch (modify_add_ies->updateType) {
5273 case eUPDATE_IE_PROBE_RESP:
5274 /* Probe resp */
5275 break;
5276 case eUPDATE_IE_ASSOC_RESP:
5277 /* assoc resp IE */
5278 if (add_ie_params->assocRespDataLen == 0) {
5279 CDF_TRACE(CDF_MODULE_ID_PE,
5280 CDF_TRACE_LEVEL_ERROR, FL(
5281 "assoc resp add ie not present %d"),
5282 add_ie_params->assocRespDataLen);
5283 }
5284 /* search through the buffer and modify the IE */
5285 break;
5286 case eUPDATE_IE_PROBE_BCN:
5287 /*probe beacon IE */
5288 if (ret == true && modify_add_ies->modifyIE.notify) {
5289 lim_handle_param_update(mac_ctx,
5290 modify_add_ies->updateType);
5291 }
5292 break;
5293 default:
5294 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5295 modify_add_ies->updateType);
5296 break;
5297 }
5298end:
5299 cdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
5300 modify_add_ies->modifyIE.pIEBuffer = NULL;
5301}
5302
5303/*
5304* lim_process_update_add_ies() - process additional IE update req
5305*
5306* @mac_ctx: Pointer to Global MAC structure
5307* @msg_buf: pointer to the SME message buffer
5308*
5309* This function update the PE buffers for additional IEs.
5310*
5311* Return: None
5312*/
5313static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5314 uint32_t *msg_buf)
5315{
5316 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5317 uint8_t session_id;
5318 tpPESession session_entry;
5319 tSirAddIeParams *addn_ie;
5320 uint16_t new_length = 0;
5321 uint8_t *new_ptr = NULL;
5322 tSirUpdateIE *update_ie;
5323
5324 if (msg_buf == NULL) {
5325 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5326 return;
5327 }
5328 update_ie = &update_add_ies->updateIE;
5329 /* incoming message has smeSession, use BSSID to find PE session */
5330 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005331 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332
5333 if (NULL == session_entry) {
5334 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5335 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005336 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 goto end;
5338 }
5339 addn_ie = &session_entry->addIeParams;
5340 /* if len is 0, upper layer requested freeing of buffer */
5341 if (0 == update_ie->ieBufferlength) {
5342 switch (update_add_ies->updateType) {
5343 case eUPDATE_IE_PROBE_RESP:
5344 cdf_mem_free(addn_ie->probeRespData_buff);
5345 addn_ie->probeRespData_buff = NULL;
5346 addn_ie->probeRespDataLen = 0;
5347 break;
5348 case eUPDATE_IE_ASSOC_RESP:
5349 cdf_mem_free(addn_ie->assocRespData_buff);
5350 addn_ie->assocRespData_buff = NULL;
5351 addn_ie->assocRespDataLen = 0;
5352 break;
5353 case eUPDATE_IE_PROBE_BCN:
5354 cdf_mem_free(addn_ie->probeRespBCNData_buff);
5355 addn_ie->probeRespBCNData_buff = NULL;
5356 addn_ie->probeRespBCNDataLen = 0;
5357
5358 if (update_ie->notify)
5359 lim_handle_param_update(mac_ctx,
5360 update_add_ies->updateType);
5361 break;
5362 default:
5363 break;
5364 }
5365 return;
5366 }
5367 switch (update_add_ies->updateType) {
5368 case eUPDATE_IE_PROBE_RESP:
5369 if (update_ie->append) {
5370 /*
5371 * In case of append, allocate new memory
5372 * with combined length
5373 */
5374 new_length = update_ie->ieBufferlength +
5375 addn_ie->probeRespDataLen;
5376 new_ptr = cdf_mem_malloc(new_length);
5377 if (NULL == new_ptr) {
5378 lim_log(mac_ctx, LOGE, FL(
5379 "Memory allocation failed."));
5380 goto end;
5381 }
5382 /* append buffer to end of local buffers */
5383 cdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
5384 addn_ie->probeRespDataLen);
5385 cdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
5386 update_ie->pAdditionIEBuffer,
5387 update_ie->ieBufferlength);
5388 /* free old memory */
5389 cdf_mem_free(addn_ie->probeRespData_buff);
5390 /* adjust length accordingly */
5391 addn_ie->probeRespDataLen = new_length;
5392 /* save refernece of local buffer in PE session */
5393 addn_ie->probeRespData_buff = new_ptr;
5394 goto end;
5395 }
5396 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5397 &addn_ie->probeRespDataLen,
5398 update_ie->pAdditionIEBuffer,
5399 update_ie->ieBufferlength);
5400 break;
5401 case eUPDATE_IE_ASSOC_RESP:
5402 /* assoc resp IE */
5403 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5404 &addn_ie->assocRespDataLen,
5405 update_ie->pAdditionIEBuffer,
5406 update_ie->ieBufferlength);
5407 break;
5408 case eUPDATE_IE_PROBE_BCN:
5409 /* probe resp Bcn IE */
5410 lim_update_add_ie_buffer(mac_ctx,
5411 &addn_ie->probeRespBCNData_buff,
5412 &addn_ie->probeRespBCNDataLen,
5413 update_ie->pAdditionIEBuffer,
5414 update_ie->ieBufferlength);
5415 if (update_ie->notify)
5416 lim_handle_param_update(mac_ctx,
5417 update_add_ies->updateType);
5418 break;
5419 default:
5420 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5421 update_add_ies->updateType);
5422 break;
5423 }
5424end:
5425 cdf_mem_free(update_ie->pAdditionIEBuffer);
5426 update_ie->pAdditionIEBuffer = NULL;
5427}
5428
5429/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305430 * send_extended_chan_switch_action_frame()- function to send ECSA
5431 * action frame for each sta connected to SAP/GO and AP in case of
5432 * STA .
5433 * @mac_ctx: pointer to global mac structure
5434 * @new_channel: new channel to switch to.
5435 * @ch_bandwidth: BW of channel to calculate op_class
5436 * @session_entry: pe session
5437 *
5438 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5439 *
5440 * Return: void
5441 */
5442
5443static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5444 uint16_t new_channel, uint8_t ch_bandwidth,
5445 tpPESession session_entry)
5446{
5447 uint16_t op_class;
5448 uint8_t switch_mode = 0, i;
5449 tpDphHashNode psta;
5450
5451
5452 op_class = cds_regdm_get_opclass_from_channel(
5453 mac_ctx->scan.countryCodeCurrent,
5454 new_channel,
5455 ch_bandwidth);
5456
5457 if (LIM_IS_AP_ROLE(session_entry) &&
5458 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5459 switch_mode = 1;
5460
5461 if (LIM_IS_AP_ROLE(session_entry)) {
5462 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5463 psta =
5464 session_entry->dph.dphHashTable.pDphNodeArray + i;
5465 if (psta && psta->added)
5466 lim_send_extended_chan_switch_action_frame(
5467 mac_ctx,
5468 psta->staAddr,
5469 switch_mode, op_class, new_channel,
5470 LIM_MAX_CSA_IE_UPDATES, session_entry);
5471 }
5472 } else if (LIM_IS_STA_ROLE(session_entry)) {
5473 lim_send_extended_chan_switch_action_frame(mac_ctx,
5474 session_entry->bssId,
5475 switch_mode, op_class, new_channel,
5476 LIM_MAX_CSA_IE_UPDATES, session_entry);
5477 }
5478
5479}
5480
5481/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5483 *
5484 * @mac_ctx: Pointer to Global MAC structure
5485 * @msg_buf: pointer to the SME message buffer
5486 *
5487 * This function processes SME request messages from HDD or upper layer
5488 * application.
5489 *
5490 * Return: None
5491 */
5492static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5493 uint32_t *msg_buf)
5494{
5495 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5496 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 uint8_t session_id;
5498 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305499 offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500
5501 if (msg_buf == NULL) {
5502 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5503 return;
5504 }
5505
5506 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5507 session_entry = pe_find_session_by_bssid(mac_ctx,
5508 dfs_csa_ie_req->bssid, &session_id);
5509 if (session_entry == NULL) {
5510 lim_log(mac_ctx, LOGE, FL(
5511 "Session not found for given BSSID" MAC_ADDRESS_STR),
5512 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5513 return;
5514 }
5515
5516 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5517 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5518 GET_LIM_SYSTEM_ROLE(session_entry));
5519 return;
5520 }
5521
5522 /* target channel */
5523 session_entry->gLimChannelSwitch.primaryChannel =
5524 dfs_csa_ie_req->targetChannel;
5525
5526 /* Channel switch announcement needs to be included in beacon */
5527 session_entry->dfsIncludeChanSwIe = true;
5528 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5529 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005530 dfs_csa_ie_req->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5532 session_entry->gLimChannelSwitch.switchMode = 1;
5533
5534 /*
5535 * Validate if SAP is operating HT or VHT mode and set the Channel
5536 * Switch Wrapper element with the Wide Band Switch subelement.
5537 */
5538 if (true != session_entry->vhtCapability)
5539 goto skip_vht;
5540
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 /* Now encode the Wider Ch BW element depending on the ch width */
5542 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005543 switch (dfs_csa_ie_req->ch_params.ch_width) {
5544 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 /*
5546 * Wide channel BW sublement in channel wrapper element is not
5547 * required in case of 20 Mhz operation. Currently It is set
5548 * only set in case of 40/80 Mhz Operation.
5549 */
5550 session_entry->dfsIncludeChanWrapperIe = false;
5551 wider_bw_ch_switch->newChanWidth =
5552 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5553 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005554 case CH_WIDTH_40MHZ:
5555 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 wider_bw_ch_switch->newChanWidth =
5557 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5558 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005559 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 session_entry->dfsIncludeChanWrapperIe = true;
5561 wider_bw_ch_switch->newChanWidth =
5562 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5563 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005564 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 session_entry->dfsIncludeChanWrapperIe = true;
5566 wider_bw_ch_switch->newChanWidth =
5567 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5568 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005569 case CH_WIDTH_80P80MHZ:
5570 session_entry->dfsIncludeChanWrapperIe = true;
5571 wider_bw_ch_switch->newChanWidth =
5572 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
5573 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 default:
5575 session_entry->dfsIncludeChanWrapperIe = false;
5576 /*
5577 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5578 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5579 */
5580 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5581 break;
5582 }
5583 /* Fetch the center channel based on the channel width */
5584 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005585 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586 /*
5587 * This is not applicable for 20/40/80 Mhz.Only used when we support
5588 * 80+80 Mhz operation. In case of 80+80 Mhz, this parameter indicates
5589 * center channel frequency index of 80 Mhz channel of
5590 * frequency segment 1.
5591 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005592 wider_bw_ch_switch->newCenterChanFreq1 =
5593 dfs_csa_ie_req->ch_params.center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594skip_vht:
5595 /* Send CSA IE request from here */
5596 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5597 eSIR_SUCCESS) {
5598 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5599 return;
5600 }
5601
5602 /*
5603 * First beacon update request is sent here, the remaining updates are
5604 * done when the FW responds back after sending the first beacon after
5605 * the template update
5606 */
5607 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305608
5609 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5610 ch_offset = BW80;
5611 else
5612 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5613
5614 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5615 session_entry->gLimChannelSwitch.switchCount,
5616 session_entry->gLimChannelSwitch.primaryChannel,
5617 session_entry->gLimChannelSwitch.ch_width,
5618 session_entry->dfsIncludeChanWrapperIe,
5619 ch_offset);
5620
Abhishek Singh518323d2015-10-19 17:42:01 +05305621 /* Send ECSA Action frame after updating the beacon */
5622 send_extended_chan_switch_action_frame(mac_ctx,
5623 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305624 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 session_entry->gLimChannelSwitch.switchCount--;
5626}
5627
5628/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305629 * lim_process_ext_change_channel()- function to send ECSA
5630 * action frame for STA/CLI .
5631 * @mac_ctx: pointer to global mac structure
5632 * @msg: params from sme for new channel.
5633 *
5634 * This function is called to send ECSA frame for STA/CLI.
5635 *
5636 * Return: void
5637 */
5638
5639static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5640 uint32_t *msg)
5641{
5642 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5643 (struct sir_sme_ext_cng_chan_req *) msg;
5644 tpPESession session_entry = NULL;
5645
5646 if (NULL == msg) {
5647 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5648 return;
5649 }
5650 session_entry =
5651 pe_find_session_by_sme_session_id(mac_ctx,
5652 ext_chng_channel->session_id);
5653 if (NULL == session_entry) {
5654 lim_log(mac_ctx, LOGE,
5655 FL("Session not found for given session %d"),
5656 ext_chng_channel->session_id);
5657 return;
5658 }
5659 if (LIM_IS_AP_ROLE(session_entry)) {
5660 lim_log(mac_ctx, LOGE,
5661 FL("not an STA/CLI session"));
5662 return;
5663 }
5664 send_extended_chan_switch_action_frame(mac_ctx,
5665 ext_chng_channel->new_channel,
5666 0, session_entry);
5667}
5668
5669/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 * lim_process_nss_update_request() - process sme nss update req
5671 *
5672 * @mac_ctx: Pointer to Global MAC structure
5673 * @msg_buf: pointer to the SME message buffer
5674 *
5675 * This function processes SME request messages from HDD or upper layer
5676 * application.
5677 *
5678 * Return: None
5679 */
5680static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5681 uint32_t *msg_buf)
5682{
5683 struct sir_nss_update_request *nss_update_req_ptr;
5684 tpPESession session_entry = NULL;
5685
5686 if (msg_buf == NULL) {
5687 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5688 return;
5689 }
5690
5691 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
5692 session_entry = pe_find_session_by_session_id(mac_ctx,
5693 nss_update_req_ptr->vdev_id);
5694 if (session_entry == NULL) {
5695 lim_log(mac_ctx, LOGE, FL(
5696 "Session not found for given session_id %d"),
5697 nss_update_req_ptr->vdev_id);
5698 return;
5699 }
5700
5701 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5702 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5703 GET_LIM_SYSTEM_ROLE(session_entry));
5704 return;
5705 }
5706
5707 /* populate nss field in the beacon */
5708 session_entry->gLimOperatingMode.present = 1;
5709 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5710 /* Send nss update request from here */
5711 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5712 eSIR_SUCCESS) {
5713 lim_log(mac_ctx, LOGE,
5714 FL("Unable to set op mode IE in beacon"));
5715 return;
5716 }
5717
5718 lim_send_beacon_ind(mac_ctx, session_entry);
5719}
5720
5721/**
5722 * lim_process_set_ie_req() - process sme set IE request
5723 *
5724 * @mac_ctx: Pointer to Global MAC structure
5725 * @msg_buf: pointer to the SME message buffer
5726 *
5727 * This function processes SME request messages from HDD or upper layer
5728 * application.
5729 *
5730 * Return: None
5731 */
5732static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5733{
5734 struct send_extcap_ie *msg;
5735 CDF_STATUS status;
5736
5737 if (msg_buf == NULL) {
5738 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5739 return;
5740 }
5741
5742 msg = (struct send_extcap_ie *)msg_buf;
5743 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
5744 if (CDF_STATUS_SUCCESS != status)
5745 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5746
5747}