blob: 44374ba1c3dbb86d1580cd676039ea89db8e9393 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302 * Copyright (c) 2012-2017 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#include "wni_api.h"
29#include "wni_cfg.h"
30#include "cfg_api.h"
31#include "sir_api.h"
32#include "sch_api.h"
33#include "utils_api.h"
34#include "lim_utils.h"
35#include "lim_assoc_utils.h"
36#include "lim_security_utils.h"
37#include "lim_ser_des_utils.h"
38#include "lim_timer_utils.h"
39#include "lim_send_messages.h"
40#include "lim_admit_control.h"
41#include "lim_send_messages.h"
42#include "lim_ibss_peer_mgmt.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include "lim_ft.h"
44#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_session.h"
46#include "lim_session_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "wma_types.h"
49#include "cds_utils.h"
50#include "lim_types.h"
Chandrasekaran, Manishekarce7ab082016-02-02 10:24:15 +053051#include "cds_concurrency.h"
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070052#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053
54#define MAX_SUPPORTED_PEERS_WEP 16
55
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056void lim_process_mlm_join_cnf(tpAniSirGlobal, uint32_t *);
57void lim_process_mlm_auth_cnf(tpAniSirGlobal, uint32_t *);
58void lim_process_mlm_start_cnf(tpAniSirGlobal, uint32_t *);
59void lim_process_mlm_assoc_ind(tpAniSirGlobal, uint32_t *);
60void lim_process_mlm_assoc_cnf(tpAniSirGlobal, uint32_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061void lim_process_mlm_reassoc_ind(tpAniSirGlobal, uint32_t *);
62void lim_process_mlm_set_keys_cnf(tpAniSirGlobal, uint32_t *);
63void lim_process_mlm_disassoc_ind(tpAniSirGlobal, uint32_t *);
64void lim_process_mlm_disassoc_cnf(tpAniSirGlobal, uint32_t *);
65void lim_process_mlm_deauth_ind(tpAniSirGlobal, uint32_t *);
66void lim_process_mlm_deauth_cnf(tpAniSirGlobal, uint32_t *);
67void lim_process_mlm_purge_sta_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumaraa262c42016-04-15 15:41:08 -070068void lim_get_session_info(tpAniSirGlobal pMac, uint8_t *, uint8_t *,
69 uint16_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070/**
71 * lim_process_mlm_rsp_messages()
72 *
73 ***FUNCTION:
74 * This function is called to processes various MLM response (CNF/IND
75 * messages from MLM State machine.
76 *
77 ***LOGIC:
78 *
79 ***ASSUMPTIONS:
80 *
81 ***NOTE:
82 *
83 * @param pMac Pointer to Global MAC structure
84 * @param msgType Indicates the MLM message type
85 * @param *pMsgBuf A pointer to the MLM message buffer
86 *
87 * @return None
88 */
89void
90lim_process_mlm_rsp_messages(tpAniSirGlobal pMac, uint32_t msgType,
91 uint32_t *pMsgBuf)
92{
93
94 if (pMsgBuf == NULL) {
95 PELOGE(lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));)
96 return;
97 }
98 MTRACE(mac_trace(pMac, TRACE_CODE_TX_LIM_MSG, 0, msgType));
99 switch (msgType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100 case LIM_MLM_AUTH_CNF:
101 lim_process_mlm_auth_cnf(pMac, pMsgBuf);
102 break;
103 case LIM_MLM_ASSOC_CNF:
104 lim_process_mlm_assoc_cnf(pMac, pMsgBuf);
105 break;
106 case LIM_MLM_START_CNF:
107 lim_process_mlm_start_cnf(pMac, pMsgBuf);
108 break;
109 case LIM_MLM_JOIN_CNF:
110 lim_process_mlm_join_cnf(pMac, pMsgBuf);
111 break;
112 case LIM_MLM_ASSOC_IND:
113 lim_process_mlm_assoc_ind(pMac, pMsgBuf);
114 break;
115 case LIM_MLM_REASSOC_CNF:
116 lim_process_mlm_reassoc_cnf(pMac, pMsgBuf);
117 break;
118 case LIM_MLM_DISASSOC_CNF:
119 lim_process_mlm_disassoc_cnf(pMac, pMsgBuf);
120 break;
121 case LIM_MLM_DISASSOC_IND:
122 lim_process_mlm_disassoc_ind(pMac, pMsgBuf);
123 break;
124 case LIM_MLM_PURGE_STA_IND:
125 lim_process_mlm_purge_sta_ind(pMac, pMsgBuf);
126 break;
127 case LIM_MLM_DEAUTH_CNF:
128 lim_process_mlm_deauth_cnf(pMac, pMsgBuf);
129 break;
130 case LIM_MLM_DEAUTH_IND:
131 lim_process_mlm_deauth_ind(pMac, pMsgBuf);
132 break;
133 case LIM_MLM_SETKEYS_CNF:
134 lim_process_mlm_set_keys_cnf(pMac, pMsgBuf);
135 break;
136 case LIM_MLM_TSPEC_CNF:
137 break;
138 default:
139 break;
140 } /* switch (msgType) */
141 return;
142} /*** end lim_process_mlm_rsp_messages() ***/
143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144/**
145 * lim_process_mlm_start_cnf()
146 *
147 ***FUNCTION:
148 * This function is called to processes MLM_START_CNF
149 * message from MLM State machine.
150 *
151 ***LOGIC:
152 *
153 ***ASSUMPTIONS:
154 *
155 ***NOTE:
156 *
157 * @param pMac Pointer to Global MAC structure
158 * @param pMsgBuf A pointer to the MLM message buffer
159 *
160 * @return None
161 */
162void lim_process_mlm_start_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
163{
164 tpPESession psessionEntry = NULL;
165 tLimMlmStartCnf *pLimMlmStartCnf;
166 uint8_t smesessionId;
167 uint16_t smetransactionId;
168 uint8_t channelId;
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800169 uint8_t send_bcon_ind = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170
171 if (pMsgBuf == NULL) {
172 PELOGE(lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));)
173 return;
174 }
175 pLimMlmStartCnf = (tLimMlmStartCnf *) pMsgBuf;
176 psessionEntry = pe_find_session_by_session_id(pMac,
177 pLimMlmStartCnf->sessionId);
178 if (psessionEntry == NULL) {
179 PELOGE(lim_log(pMac, LOGE, FL(
180 "Session does Not exist with given sessionId "));)
181 return;
182 }
183 smesessionId = psessionEntry->smeSessionId;
184 smetransactionId = psessionEntry->transactionId;
185
186 if (psessionEntry->limSmeState != eLIM_SME_WT_START_BSS_STATE) {
187 /*
188 * Should not have received Start confirm from MLM
189 * in other states. Log error.
190 */
191 PELOGE(lim_log(pMac, LOGE, FL
192 ("received unexpected MLM_START_CNF in state %X"),
193 psessionEntry->limSmeState);)
194 return;
195 }
196 if (((tLimMlmStartCnf *) pMsgBuf)->resultCode == eSIR_SME_SUCCESS) {
197
198 /*
199 * Update global SME state so that Beacon Generation
200 * module starts writing Beacon frames into TFP's
201 * Beacon file register.
202 */
203 psessionEntry->limSmeState = eLIM_SME_NORMAL_STATE;
204 MTRACE(mac_trace
205 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
206 psessionEntry->limSmeState));
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700207 if (psessionEntry->bssType == eSIR_INFRA_AP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 lim_log(pMac, LOG1,
209 FL("*** Started BSS in INFRA AP SIDE***"));
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700210 else if (psessionEntry->bssType == eSIR_NDI_MODE)
211 lim_log(pMac, LOG1,
212 FL("*** Started BSS in NDI mode ***"));
213 else
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700214 lim_log(pMac, LOG1, FL("*** Started BSS ***"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215 } else {
216 /* Start BSS is a failure */
217 pe_delete_session(pMac, psessionEntry);
218 psessionEntry = NULL;
219 PELOGE(lim_log(pMac, LOGE, FL("Start BSS Failed "));)
220 }
221 /* Send response to Host */
222 lim_send_sme_start_bss_rsp(pMac, eWNI_SME_START_BSS_RSP,
223 ((tLimMlmStartCnf *)pMsgBuf)->resultCode,
224 psessionEntry, smesessionId, smetransactionId);
225 if ((psessionEntry != NULL) &&
226 (((tLimMlmStartCnf *) pMsgBuf)->resultCode ==
227 eSIR_SME_SUCCESS)) {
228 channelId = psessionEntry->pLimStartBssReq->channelId;
229
230 /* We should start beacon transmission only if the channel
231 * on which we are operating is non-DFS until the channel
232 * availability check is done. The PE will receive an explicit
233 * request from upper layers to start the beacon transmission
234 */
235
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800236 if (!(LIM_IS_IBSS_ROLE(psessionEntry) ||
237 (LIM_IS_AP_ROLE(psessionEntry))))
238 return;
239 if (psessionEntry->ch_width == CH_WIDTH_160MHZ) {
240 send_bcon_ind = false;
241 } else if (psessionEntry->ch_width == CH_WIDTH_80P80MHZ) {
242 if ((cds_get_channel_state(channelId) !=
243 CHANNEL_STATE_DFS) &&
244 (cds_get_channel_state(psessionEntry->
245 ch_center_freq_seg1 -
246 SIR_80MHZ_START_CENTER_CH_DIFF) !=
247 CHANNEL_STATE_DFS))
248 send_bcon_ind = true;
249 } else {
250 if (cds_get_channel_state(channelId) !=
251 CHANNEL_STATE_DFS)
252 send_bcon_ind = true;
253 }
254 if (send_bcon_ind) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 /* Configure beacon and send beacons to HAL */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530256 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 FL("Start Beacon with ssid %s Ch %d"),
258 psessionEntry->ssId.ssId,
259 psessionEntry->currentOperChannel);
260 lim_send_beacon_ind(pMac, psessionEntry);
261 }
262 }
263}
264
265/*** end lim_process_mlm_start_cnf() ***/
266
267/**
268 * lim_process_mlm_join_cnf() - Processes join confirmation
269 * @mac_ctx: Pointer to Global MAC structure
270 * @msg: A pointer to the MLM message buffer
271 *
272 * This Function handles the join confirmation message
273 * LIM_MLM_JOIN_CNF.
274 *
275 * Return: None
276 */
277void lim_process_mlm_join_cnf(tpAniSirGlobal mac_ctx,
278 uint32_t *msg)
279{
280 tSirResultCodes result_code;
281 tLimMlmJoinCnf *join_cnf;
282 tpPESession session_entry;
283
284 join_cnf = (tLimMlmJoinCnf *) msg;
285 session_entry = pe_find_session_by_session_id(mac_ctx,
286 join_cnf->sessionId);
287 if (session_entry == NULL) {
288 lim_log(mac_ctx, LOGE, FL("SessionId:%d does not exist"),
289 join_cnf->sessionId);
290 return;
291 }
292
293 if (session_entry->limSmeState != eLIM_SME_WT_JOIN_STATE) {
294 lim_log(mac_ctx, LOGE,
295 FL("received unexpected MLM_JOIN_CNF in state %X"),
296 session_entry->limSmeState);
297 return;
298 }
299
300 result_code = ((tLimMlmJoinCnf *) msg)->resultCode;
301 /* Process Join confirm from MLM */
302 if (result_code == eSIR_SME_SUCCESS) {
303 lim_log(mac_ctx, LOG1, FL("***SessionId:%d Joined ESS ***"),
304 join_cnf->sessionId);
305 /* Setup hardware upfront */
306 if (lim_sta_send_add_bss_pre_assoc(mac_ctx, false,
307 session_entry) == eSIR_SUCCESS)
308 return;
309 else
310 result_code = eSIR_SME_REFUSED;
311 }
312
313 /* Join failure */
314 session_entry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
315 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
316 session_entry->peSessionId,
317 session_entry->limSmeState));
318 /* Send Join response to Host */
319 lim_handle_sme_join_result(mac_ctx, result_code,
320 ((tLimMlmJoinCnf *) msg)->protStatusCode, session_entry);
321 return;
322}
323
324/**
325 * lim_send_mlm_assoc_req() - Association request will be processed
326 * mac_ctx: Pointer to Global MAC structure
327 * session_entry: Pointer to session etnry
328 *
329 * This function is sends ASSOC request MLM message to MLM State machine.
330 * ASSOC request packet would be by picking parameters from psessionEntry
331 * automatically based on the current state of MLM state machine.
332 * ASSUMPTIONS:
333 * this function is called in middle of connection state machine and is
334 * expected to be called after auth cnf has been received or after ASSOC rsp
335 * with TRY_AGAIN_LATER was received and required time has elapsed after that.
336 *
337 * Return: None
338 */
339
Jeff Johnsona0495a62016-10-07 07:25:58 -0700340static void lim_send_mlm_assoc_req(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 tpPESession session_entry)
342{
343 tLimMlmAssocReq *assoc_req;
344 uint32_t val;
345 uint16_t caps;
346 uint32_t tele_bcn = 0;
347 tpSirMacCapabilityInfo cap_info;
348
349 /* Successful MAC based authentication. Trigger Association with BSS */
350 lim_log(mac_ctx, LOG1, FL("SessionId:%d Authenticated with BSS"),
351 session_entry->peSessionId);
352
353 if (NULL == session_entry->pLimJoinReq) {
354 lim_log(mac_ctx, LOGE, FL("Join Request is NULL."));
355 /* No need to Assert. JOIN timeout will handle this error */
356 return;
357 }
358
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530359 assoc_req = qdf_mem_malloc(sizeof(tLimMlmAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 if (NULL == assoc_req) {
361 lim_log(mac_ctx, LOGP,
362 FL("call to AllocateMemory failed for mlmAssocReq"));
363 return;
364 }
365 val = sizeof(tSirMacAddr);
366 sir_copy_mac_addr(assoc_req->peerMacAddr, session_entry->bssId);
367 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT,
368 (uint32_t *) &assoc_req->assocFailureTimeout)
369 != eSIR_SUCCESS) {
370 /* Could not get AssocFailureTimeout value from CFG.*/
371 lim_log(mac_ctx, LOGP,
372 FL("could not retrieve AssocFailureTimeout value"));
373 }
374
375 if (cfg_get_capability_info(mac_ctx, &caps, session_entry)
376 != eSIR_SUCCESS)
377 /* Could not get Capabilities value from CFG.*/
378 lim_log(mac_ctx, LOGP,
379 FL("could not retrieve Capabilities value"));
380
381 /* Clear spectrum management bit if AP doesn't support it */
382 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
383 LIM_SPECTRUM_MANAGEMENT_BIT_MASK))
384 /*
385 * AP doesn't support spectrum management
386 * clear spectrum management bit
387 */
388 caps &= (~LIM_SPECTRUM_MANAGEMENT_BIT_MASK);
389
Krishna Kumaar Natarajand26e9e72015-11-03 11:49:03 -0800390 /*
391 * RM capability should be independent of AP's capabilities
392 * Refer 8.4.1.4 Capability Information field in 802.11-2012
393 * Do not modify it.
394 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395
396 /* Clear short preamble bit if AP does not support it */
397 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
398 (LIM_SHORT_PREAMBLE_BIT_MASK))) {
399 caps &= (~LIM_SHORT_PREAMBLE_BIT_MASK);
400 lim_log(mac_ctx, LOG1,
401 FL("Clearing short preamble:no AP support"));
402 }
403
404 /* Clear immediate block ack bit if AP does not support it */
405 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
406 (LIM_IMMEDIATE_BLOCK_ACK_MASK))) {
407 caps &= (~LIM_IMMEDIATE_BLOCK_ACK_MASK);
408 lim_log(mac_ctx, LOG1,
409 FL("Clearing Immed Blk Ack:no AP support"));
410 }
411
412 assoc_req->capabilityInfo = caps;
413 cap_info = ((tpSirMacCapabilityInfo) &assoc_req->capabilityInfo);
414 lim_log(mac_ctx, LOG3, FL("Capabilities to be used in AssocReq=0x%X,"
415 "privacy bit=%x shortSlotTime %x"), caps,
416 cap_info->privacy,
417 cap_info->shortSlotTime);
418
419 /*
420 * If telescopic beaconing is enabled, set listen interval to
421 * WNI_CFG_TELE_BCN_MAX_LI
422 */
423 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN, &tele_bcn)
424 != eSIR_SUCCESS)
425 lim_log(mac_ctx, LOGP,
426 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
427
428 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
429 if (tele_bcn) {
430 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
431 eSIR_SUCCESS)
432 /*
433 * Could not get ListenInterval value
434 * from CFG. Log error.
435 */
436 lim_log(mac_ctx, LOGP,
437 FL("could not retrieve ListenInterval"));
438 } else {
439 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL,
440 &val) != eSIR_SUCCESS)
441 /*
442 * Could not get ListenInterval value
443 * from CFG. Log error.
444 */
445 lim_log(mac_ctx, LOGP,
446 FL("could not retrieve ListenInterval"));
447 }
448#ifdef FEATURE_WLAN_DIAG_SUPPORT
449 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_REQ_EVENT,
450 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
451#endif
452 assoc_req->listenInterval = (uint16_t) val;
453 /* Update PE session ID */
454 assoc_req->sessionId = session_entry->peSessionId;
455 session_entry->limPrevSmeState = session_entry->limSmeState;
456 session_entry->limSmeState = eLIM_SME_WT_ASSOC_STATE;
457 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
458 session_entry->peSessionId, session_entry->limSmeState));
459 lim_post_mlm_message(mac_ctx, LIM_MLM_ASSOC_REQ,
460 (uint32_t *) assoc_req);
461}
462
463#ifdef WLAN_FEATURE_11W
464/**
465 * lim_pmf_comeback_timer_callback() -PMF callback handler
466 * @context: Timer context
467 *
468 * This function is called to processes the PMF comeback
469 * callback
470 *
471 * Return: None
472 */
473void lim_pmf_comeback_timer_callback(void *context)
474{
475 tComebackTimerInfo *info = (tComebackTimerInfo *) context;
476 tpAniSirGlobal mac_ctx = info->pMac;
477 tpPESession psessionEntry = &mac_ctx->lim.gpSession[info->sessionID];
478
479 lim_log(mac_ctx, LOGE,
480 FL("comeback later timer expired. sending MLM ASSOC req"));
481 /* set MLM state such that ASSOC REQ packet will be sent out */
482 psessionEntry->limPrevMlmState = info->limPrevMlmState;
483 psessionEntry->limMlmState = info->limMlmState;
484 lim_send_mlm_assoc_req(mac_ctx, psessionEntry);
485}
486#endif /* WLAN_FEATURE_11W */
487
488/**
489 * lim_process_mlm_auth_cnf()-Process Auth confirmation
490 * @mac_ctx: Pointer to Global MAC structure
491 * @msg: A pointer to the MLM message buffer
492 *
493 * This function is called to processes MLM_AUTH_CNF
494 * message from MLM State machine.
495 *
496 * Return: None
497 */
498void lim_process_mlm_auth_cnf(tpAniSirGlobal mac_ctx, uint32_t *msg)
499{
500 tAniAuthType auth_type, auth_mode;
501 tLimMlmAuthReq *auth_req;
502 tLimMlmAuthCnf *auth_cnf;
503 tpPESession session_entry;
504
505 if (msg == NULL) {
506 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
507 return;
508 }
509 auth_cnf = (tLimMlmAuthCnf *) msg;
510 session_entry = pe_find_session_by_session_id(mac_ctx,
511 auth_cnf->sessionId);
512 if (session_entry == NULL) {
513 lim_log(mac_ctx, LOGE, FL("SessionId:%d session doesn't exist"),
514 auth_cnf->sessionId);
515 return;
516 }
517
518 if ((session_entry->limSmeState != eLIM_SME_WT_AUTH_STATE &&
519 session_entry->limSmeState != eLIM_SME_WT_PRE_AUTH_STATE) ||
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700520 LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 /**
522 * Should not have received AUTH confirm
523 * from MLM in other states or on AP.
524 * Log error
525 */
526 lim_log(mac_ctx, LOGE,
527 FL("SessionId:%d received MLM_AUTH_CNF in state %X"),
528 session_entry->peSessionId, session_entry->limSmeState);
529 return;
530 }
531
Selvaraj, Sridhar9cee77f2016-06-22 21:47:52 +0530532 if (auth_cnf->resultCode == eSIR_SME_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 if (session_entry->limSmeState == eLIM_SME_WT_AUTH_STATE) {
534 lim_send_mlm_assoc_req(mac_ctx, session_entry);
535 } else {
536 /*
537 * Successful Pre-authentication. Send
538 * Pre-auth response to host
539 */
540 session_entry->limSmeState =
541 session_entry->limPrevSmeState;
542 MTRACE(mac_trace
543 (mac_ctx, TRACE_CODE_SME_STATE,
544 session_entry->peSessionId,
545 session_entry->limSmeState));
546 }
547 /* Return for success case */
548 return;
549 }
550 /*
551 * Failure case handle:
552 * Process AUTH confirm from MLM
553 */
554 if (session_entry->limSmeState == eLIM_SME_WT_AUTH_STATE) {
555 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_AUTHENTICATION_TYPE,
556 (uint32_t *) &auth_type) != eSIR_SUCCESS) {
557 /*
558 * Could not get AuthType value from CFG.
559 * Log error.
560 */
561 lim_log(mac_ctx, LOGP,
562 FL("Fail to retrieve AuthType value"));
563 }
564 } else {
565 auth_type = mac_ctx->lim.gLimPreAuthType;
566 }
567
568 if ((auth_type == eSIR_AUTO_SWITCH) &&
Selvaraj, Sridhar9cee77f2016-06-22 21:47:52 +0530569 (auth_cnf->authType == eSIR_SHARED_KEY) &&
570 ((eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS ==
571 auth_cnf->protStatusCode) ||
572 (auth_cnf->resultCode == eSIR_SME_AUTH_TIMEOUT_RESULT_CODE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 /*
Rajeev Kumar437c9212016-04-14 15:26:59 -0700574 * When shared authentication fails with reason
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 * code "13" and authType set to 'auto switch',
Rajeev Kumar437c9212016-04-14 15:26:59 -0700576 * Try with open Authentication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 */
Rajeev Kumar437c9212016-04-14 15:26:59 -0700578 auth_mode = eSIR_OPEN_SYSTEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 /* Trigger MAC based Authentication */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530580 auth_req = qdf_mem_malloc(sizeof(tLimMlmAuthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 if (NULL == auth_req) {
582 /* Log error */
583 lim_log(mac_ctx, LOGP,
584 FL("mlmAuthReq :Memory alloc failed "));
585 return;
586 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587 if (session_entry->limSmeState ==
588 eLIM_SME_WT_AUTH_STATE) {
589 sir_copy_mac_addr(auth_req->peerMacAddr,
590 session_entry->bssId);
591 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530592 qdf_mem_copy((uint8_t *)&auth_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 (uint8_t *)&mac_ctx->lim.gLimPreAuthPeerAddr,
594 sizeof(tSirMacAddr));
595 }
596 auth_req->authType = auth_mode;
597 /* Update PE session Id */
598 auth_req->sessionId = auth_cnf->sessionId;
599 if (wlan_cfg_get_int(mac_ctx,
600 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
601 (uint32_t *) &auth_req->authFailureTimeout)
602 != eSIR_SUCCESS) {
603 /*
604 * Could not get AuthFailureTimeout value from CFG.
605 * Log error.
606 */
607 lim_log(mac_ctx, LOGP,
608 FL("Fail:retrieve AuthFailureTimeout "));
609 }
610 lim_post_mlm_message(mac_ctx, LIM_MLM_AUTH_REQ,
611 (uint32_t *) auth_req);
612 return;
613 } else {
614 /* MAC based authentication failure */
615 if (session_entry->limSmeState ==
616 eLIM_SME_WT_AUTH_STATE) {
617 lim_log(mac_ctx, LOGE,
618 FL("Auth Failure occurred."));
619 session_entry->limSmeState =
620 eLIM_SME_JOIN_FAILURE_STATE;
621 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
622 session_entry->peSessionId,
623 session_entry->limSmeState));
624 session_entry->limMlmState =
625 eLIM_MLM_IDLE_STATE;
626 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
627 session_entry->peSessionId,
628 session_entry->limMlmState));
629 /*
630 * Need to send Join response with
631 * auth failure to Host.
632 */
633 lim_handle_sme_join_result(mac_ctx,
Selvaraj, Sridhar9cee77f2016-06-22 21:47:52 +0530634 auth_cnf->resultCode,
635 auth_cnf->protStatusCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 session_entry);
637 } else {
638 /*
639 * Pre-authentication failure.
640 * Send Pre-auth failure response to host
641 */
642 session_entry->limSmeState =
643 session_entry->limPrevSmeState;
644 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
645 session_entry->peSessionId,
646 session_entry->limSmeState));
647 }
648 }
649}
650
651/**
652 * lim_process_mlm_assoc_cnf() - Process association confirmation
653 * @mac_ctx: Pointer to Global MAC structure
654 * @msg: A pointer to the MLM message buffer
655 *
656 * This function is called to processes MLM_ASSOC_CNF
657 * message from MLM State machine.
658 *
659 * Return: None
660 */
661void lim_process_mlm_assoc_cnf(tpAniSirGlobal mac_ctx,
662 uint32_t *msg)
663{
664 tpPESession session_entry;
665 tLimMlmAssocCnf *assoc_cnf;
666
667 if (msg == NULL) {
668 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
669 return;
670 }
671 assoc_cnf = (tLimMlmAssocCnf *) msg;
672 session_entry = pe_find_session_by_session_id(mac_ctx,
673 assoc_cnf->sessionId);
674 if (session_entry == NULL) {
675 lim_log(mac_ctx, LOGE,
676 FL("SessionId:%d Session does not exist"),
677 assoc_cnf->sessionId);
678 return;
679 }
680 if (session_entry->limSmeState != eLIM_SME_WT_ASSOC_STATE ||
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700681 LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 /*
683 * Should not have received Assocication confirm
684 * from MLM in other states OR on AP.
685 * Log error
686 */
687 lim_log(mac_ctx, LOGE,
688 FL("SessionId:%d Received MLM_ASSOC_CNF in state %X"),
689 session_entry->peSessionId, session_entry->limSmeState);
690 return;
691 }
692 if (((tLimMlmAssocCnf *) msg)->resultCode != eSIR_SME_SUCCESS) {
693 /* Association failure */
Hanumantha Reddy Pothula6677a332016-09-12 14:35:03 +0530694 lim_log(mac_ctx, LOG1, FL("SessionId:%d Association failure resultCode: %d limSmeState:%d"),
695 session_entry->peSessionId,
696 ((tLimMlmAssocCnf *) msg)->resultCode,
697 session_entry->limSmeState);
698
699 /* If driver gets deauth when its waiting for ADD_STA_RSP then
700 * we need to do DEL_STA followed by DEL_BSS. So based on below
701 * reason-code here we decide whether to do only DEL_BSS or
702 * DEL_STA + DEL_BSS.
703 */
704 if (((tLimMlmAssocCnf *) msg)->resultCode !=
705 eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA)
706 session_entry->limSmeState =
707 eLIM_SME_JOIN_FAILURE_STATE;
708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
710 session_entry->peSessionId, mac_ctx->lim.gLimSmeState));
711 /*
712 * Need to send Join response with
713 * Association failure to Host.
714 */
715 lim_handle_sme_join_result(mac_ctx,
716 ((tLimMlmAssocCnf *) msg)->resultCode,
717 ((tLimMlmAssocCnf *) msg)->protStatusCode,
718 session_entry);
719 } else {
720 /* Successful Association */
721 lim_log(mac_ctx, LOG1, FL("SessionId:%d Associated with BSS"),
722 session_entry->peSessionId);
723 session_entry->limSmeState = eLIM_SME_LINK_EST_STATE;
724 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
725 session_entry->peSessionId,
726 session_entry->limSmeState));
727 /**
728 * Need to send Join response with
729 * Association success to Host.
730 */
731 lim_handle_sme_join_result(mac_ctx,
732 ((tLimMlmAssocCnf *) msg)->resultCode,
733 ((tLimMlmAssocCnf *) msg)->protStatusCode,
734 session_entry);
735 }
736}
737
738/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 * lim_fill_assoc_ind_params() - Initialize association indication
740 * mac_ctx: Pointer to Global MAC structure
741 * assoc_ind: PE association indication structure
742 * sme_assoc_ind: SME association indication
743 * session_entry: PE session entry
744 *
745 * This function is called to initialzie the association
746 * indication strucutre to process association indication.
747 *
748 * Return: None
749 */
750
Jeff Johnsona0495a62016-10-07 07:25:58 -0700751static void
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752lim_fill_assoc_ind_params(tpAniSirGlobal mac_ctx,
753 tpLimMlmAssocInd assoc_ind, tSirSmeAssocInd *sme_assoc_ind,
754 tpPESession session_entry)
755{
756 sme_assoc_ind->length = sizeof(tSirSmeAssocInd);
757 sme_assoc_ind->sessionId = session_entry->smeSessionId;
758
759 /* Required for indicating the frames to upper layer */
760 sme_assoc_ind->assocReqLength = assoc_ind->assocReqLength;
761 sme_assoc_ind->assocReqPtr = assoc_ind->assocReqPtr;
762
763 sme_assoc_ind->beaconPtr = session_entry->beacon;
764 sme_assoc_ind->beaconLength = session_entry->bcnLen;
765
766 /* Fill in peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530767 qdf_mem_copy(sme_assoc_ind->peerMacAddr, assoc_ind->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 sizeof(tSirMacAddr));
769
770 /* Fill in aid */
771 sme_assoc_ind->aid = assoc_ind->aid;
772 /* Fill in bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530773 qdf_mem_copy(sme_assoc_ind->bssId, session_entry->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 sizeof(tSirMacAddr));
775 /* Fill in authType */
776 sme_assoc_ind->authType = assoc_ind->authType;
777 /* Fill in ssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530778 qdf_mem_copy((uint8_t *) &sme_assoc_ind->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 (uint8_t *) &(assoc_ind->ssId), assoc_ind->ssId.length + 1);
780 sme_assoc_ind->rsnIE.length = assoc_ind->rsnIE.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530781 qdf_mem_copy((uint8_t *) &sme_assoc_ind->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 (uint8_t *) &(assoc_ind->rsnIE.rsnIEdata),
783 assoc_ind->rsnIE.length);
784
785#ifdef FEATURE_WLAN_WAPI
786 sme_assoc_ind->wapiIE.length = assoc_ind->wapiIE.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530787 qdf_mem_copy((uint8_t *) &sme_assoc_ind->wapiIE.wapiIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 (uint8_t *) &(assoc_ind->wapiIE.wapiIEdata),
789 assoc_ind->wapiIE.length);
790#endif
791 sme_assoc_ind->addIE.length = assoc_ind->addIE.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530792 qdf_mem_copy((uint8_t *) &sme_assoc_ind->addIE.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 (uint8_t *) &(assoc_ind->addIE.addIEdata),
794 assoc_ind->addIE.length);
795
796 /* Copy the new TITAN capabilities */
797 sme_assoc_ind->spectrumMgtIndicator = assoc_ind->spectrumMgtIndicator;
798 if (assoc_ind->spectrumMgtIndicator == eSIR_TRUE) {
799 sme_assoc_ind->powerCap.minTxPower =
800 assoc_ind->powerCap.minTxPower;
801 sme_assoc_ind->powerCap.maxTxPower =
802 assoc_ind->powerCap.maxTxPower;
803 sme_assoc_ind->supportedChannels.numChnl =
804 assoc_ind->supportedChannels.numChnl;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_copy((uint8_t *) &sme_assoc_ind->supportedChannels.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 channelList,
807 (uint8_t *) &(assoc_ind->supportedChannels.channelList),
808 assoc_ind->supportedChannels.numChnl);
809 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530810 qdf_mem_copy(&sme_assoc_ind->chan_info, &assoc_ind->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 sizeof(tSirSmeChanInfo));
812 /* Fill in WmmInfo */
813 sme_assoc_ind->wmmEnabledSta = assoc_ind->WmmStaInfoPresent;
814}
815
816/**
817 * lim_process_mlm_assoc_ind()
818 *
819 ***FUNCTION:
820 * This function is called to processes MLM_ASSOC_IND
821 * message from MLM State machine.
822 *
823 ***LOGIC:
824 *
825 ***ASSUMPTIONS:
826 *
827 ***NOTE:
828 *
829 * @param pMac Pointer to Global MAC structure
830 * @param pMsgBuf A pointer to the MLM message buffer
831 *
832 * @return None
833 */
834void lim_process_mlm_assoc_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
835{
836 uint32_t len;
837 tSirMsgQ msgQ;
838 tSirSmeAssocInd *pSirSmeAssocInd;
839 tpDphHashNode pStaDs = 0;
840 tpPESession psessionEntry;
841 if (pMsgBuf == NULL) {
842 PELOGE(lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));)
843 return;
844 }
845 psessionEntry = pe_find_session_by_session_id(pMac,
846 ((tpLimMlmAssocInd) pMsgBuf)->
847 sessionId);
848 if (psessionEntry == NULL) {
849 lim_log(pMac, LOGE,
850 FL("Session Does not exist for given sessionId"));
851 return;
852 }
853 /* / Inform Host of STA association */
854 len = sizeof(tSirSmeAssocInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530855 pSirSmeAssocInd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 if (NULL == pSirSmeAssocInd) {
857 /* Log error */
858 lim_log(pMac, LOGP,
859 FL
860 ("call to AllocateMemory failed for eWNI_SME_ASSOC_IND"));
861 return;
862 }
863
864 pSirSmeAssocInd->messageType = eWNI_SME_ASSOC_IND;
865 lim_fill_assoc_ind_params(pMac, (tpLimMlmAssocInd) pMsgBuf, pSirSmeAssocInd,
866 psessionEntry);
867 msgQ.type = eWNI_SME_ASSOC_IND;
868 msgQ.bodyptr = pSirSmeAssocInd;
869 msgQ.bodyval = 0;
870 pStaDs = dph_get_hash_entry(pMac,
871 ((tpLimMlmAssocInd) pMsgBuf)->aid,
872 &psessionEntry->dph.dphHashTable);
873 if (!pStaDs) { /* good time to panic... */
874 lim_log(pMac, LOGE,
875 FL
876 ("MLM AssocInd: Station context no longer valid (aid %d)"),
877 ((tpLimMlmAssocInd) pMsgBuf)->aid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530878 qdf_mem_free(pSirSmeAssocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879
880 return;
881 }
882 pSirSmeAssocInd->staId = pStaDs->staIndex;
883 pSirSmeAssocInd->reassocReq = pStaDs->mlmStaContext.subType;
884 pSirSmeAssocInd->timingMeasCap = pStaDs->timingMeasCap;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530885 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
886 psessionEntry->peSessionId, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
888 lim_diag_event_report(pMac, WLAN_PE_DIAG_ASSOC_IND_EVENT, psessionEntry, 0,
889 0);
890#endif /* FEATURE_WLAN_DIAG_SUPPORT */
891 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
892
893 PELOG1(lim_log(pMac, LOG1,
894 FL
895 ("Create CNF_WAIT_TIMER after received LIM_MLM_ASSOC_IND"));
896 )
897 /*
898 ** turn on a timer to detect the loss of ASSOC CNF
899 **/
900 lim_activate_cnf_timer(pMac,
901 (uint16_t) ((tpLimMlmAssocInd) pMsgBuf)->aid,
902 psessionEntry);
903
904} /*** end lim_process_mlm_assoc_ind() ***/
905
906/**
907 * lim_process_mlm_disassoc_ind()
908 *
909 ***FUNCTION:
910 * This function is called to processes MLM_DISASSOC_IND
911 * message from MLM State machine.
912 *
913 ***LOGIC:
914 *
915 ***ASSUMPTIONS:
916 *
917 ***NOTE:
918 *
919 * @param pMac Pointer to Global MAC structure
920 * @param pMsgBuf A pointer to the MLM message buffer
921 *
922 * @return None
923 */
924void lim_process_mlm_disassoc_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
925{
926 tLimMlmDisassocInd *pMlmDisassocInd;
927 tpPESession psessionEntry;
928 pMlmDisassocInd = (tLimMlmDisassocInd *) pMsgBuf;
929 psessionEntry = pe_find_session_by_session_id(pMac,
930 pMlmDisassocInd->sessionId);
931 if (psessionEntry == NULL) {
932 lim_log(pMac, LOGP,
933 FL("Session Does not exist for given sessionID"));
934 return;
935 }
936 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
937 case eLIM_STA_IN_IBSS_ROLE:
938 break;
939 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
941 MTRACE(mac_trace
942 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
943 psessionEntry->limSmeState));
944 break;
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700945 default: /* eLIM_AP_ROLE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 PELOG1(lim_log(pMac, LOG1,
947 FL("*** Peer staId=%d Disassociated ***"),
948 pMlmDisassocInd->aid);
949 )
950 /* Send SME_DISASOC_IND after Polaris cleanup */
951 /* (after receiving LIM_MLM_PURGE_STA_IND) */
952 break;
953 } /* end switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) */
954} /*** end lim_process_mlm_disassoc_ind() ***/
955
956/**
957 * lim_process_mlm_disassoc_cnf() - Processes disassociation
958 * @mac_ctx: Pointer to Global MAC structure
959 * @msg: A pointer to the MLM message buffer
960 *
961 * This function is called to processes MLM_DISASSOC_CNF
962 * message from MLM State machine.
963 *
964 * Return: None
965 */
966void lim_process_mlm_disassoc_cnf(tpAniSirGlobal mac_ctx,
967 uint32_t *msg)
968{
969 tSirResultCodes result_code;
970 tLimMlmDisassocCnf *disassoc_cnf;
971 tpPESession session_entry;
972 disassoc_cnf = (tLimMlmDisassocCnf *) msg;
973
974 session_entry =
975 pe_find_session_by_session_id(mac_ctx, disassoc_cnf->sessionId);
976 if (session_entry == NULL) {
977 lim_log(mac_ctx, LOGE,
978 FL("session Does not exist for given session Id"));
979 return;
980 }
981 result_code = (tSirResultCodes)(disassoc_cnf->disassocTrigger ==
982 eLIM_LINK_MONITORING_DISASSOC) ?
983 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
984 disassoc_cnf->resultCode;
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700985 if (LIM_IS_STA_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 /* Disassociate Confirm from MLM */
987 if ((session_entry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
988 && (session_entry->limSmeState !=
989 eLIM_SME_WT_DEAUTH_STATE)) {
990 /*
991 * Should not have received
992 * Disassocate confirm
993 * from MLM in other states.Log error
994 */
995 lim_log(mac_ctx, LOGE,
996 FL("received MLM_DISASSOC_CNF in state %X"),
997 session_entry->limSmeState);
998 return;
999 }
1000 if (mac_ctx->lim.gLimRspReqd)
1001 mac_ctx->lim.gLimRspReqd = false;
1002 if (disassoc_cnf->disassocTrigger ==
1003 eLIM_PROMISCUOUS_MODE_DISASSOC) {
1004 if (disassoc_cnf->resultCode != eSIR_SME_SUCCESS)
1005 session_entry->limSmeState =
1006 session_entry->limPrevSmeState;
1007 else
1008 session_entry->limSmeState =
1009 eLIM_SME_OFFLINE_STATE;
1010 MTRACE(mac_trace
1011 (mac_ctx, TRACE_CODE_SME_STATE,
1012 session_entry->peSessionId,
1013 session_entry->limSmeState));
1014 } else {
1015 if (disassoc_cnf->resultCode != eSIR_SME_SUCCESS)
1016 session_entry->limSmeState =
1017 session_entry->limPrevSmeState;
1018 else
1019 session_entry->limSmeState =
1020 eLIM_SME_IDLE_STATE;
1021 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1022 session_entry->peSessionId,
1023 session_entry->limSmeState));
1024 lim_send_sme_disassoc_ntf(mac_ctx,
1025 disassoc_cnf->peerMacAddr, result_code,
1026 disassoc_cnf->disassocTrigger,
1027 disassoc_cnf->aid, session_entry->smeSessionId,
1028 session_entry->transactionId, session_entry);
1029 }
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001030 } else if (LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 lim_send_sme_disassoc_ntf(mac_ctx, disassoc_cnf->peerMacAddr,
1032 result_code, disassoc_cnf->disassocTrigger,
1033 disassoc_cnf->aid, session_entry->smeSessionId,
1034 session_entry->transactionId, session_entry);
1035 }
1036}
1037
1038/**
1039 * lim_process_mlm_deauth_ind()
1040 *
1041 ***FUNCTION:
1042 * This function is called to processes MLM_DEAUTH_IND
1043 * message from MLM State machine.
1044 *
1045 ***LOGIC:
1046 *
1047 ***ASSUMPTIONS:
1048 *
1049 ***NOTE:
1050 *
1051 * @param pMac Pointer to Global MAC structure
1052 * @param pMsgBuf A pointer to the MLM message buffer
1053 *
1054 * @return None
1055 */
1056void lim_process_mlm_deauth_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1057{
1058 tLimMlmDeauthInd *pMlmDeauthInd;
1059 tpPESession psessionEntry;
1060 uint8_t sessionId;
1061 pMlmDeauthInd = (tLimMlmDeauthInd *) pMsgBuf;
1062 psessionEntry = pe_find_session_by_bssid(pMac,
1063 pMlmDeauthInd->peerMacAddr, &sessionId);
1064 if (psessionEntry == NULL) {
1065 lim_log(pMac, LOGE,
1066 FL("session does not exist for Addr:" MAC_ADDRESS_STR),
1067 MAC_ADDR_ARRAY(pMlmDeauthInd->peerMacAddr));
1068 return;
1069 }
1070 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
1071 case eLIM_STA_IN_IBSS_ROLE:
1072 break;
1073 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
1075 MTRACE(mac_trace
1076 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
1077 psessionEntry->limSmeState));
1078
1079 default: /* eLIM_AP_ROLE */
1080 {
1081 PELOG1(lim_log(pMac, LOG1,
1082 FL
1083 ("*** Received Deauthentication from staId=%d ***"),
1084 pMlmDeauthInd->aid);
1085 )
1086 }
1087 /* Send SME_DEAUTH_IND after Polaris cleanup */
1088 /* (after receiving LIM_MLM_PURGE_STA_IND) */
1089 break;
1090 } /* end switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) */
1091} /*** end lim_process_mlm_deauth_ind() ***/
1092
1093/**
1094 * lim_process_mlm_deauth_cnf()
1095 *
1096 ***FUNCTION:
1097 * This function is called to processes MLM_DEAUTH_CNF
1098 * message from MLM State machine.
1099 *
1100 ***LOGIC:
1101 *
1102 ***ASSUMPTIONS:
1103 *
1104 ***NOTE:
1105 *
1106 * @param pMac Pointer to Global MAC structure
1107 * @param pMsgBuf A pointer to the MLM message buffer
1108 *
1109 * @return None
1110 */
1111void lim_process_mlm_deauth_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1112{
1113 uint16_t aid;
1114 tSirResultCodes resultCode;
1115 tLimMlmDeauthCnf *pMlmDeauthCnf;
1116 tpPESession psessionEntry;
1117
1118 if (pMsgBuf == NULL) {
1119 PELOGE(lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));)
1120 return;
1121 }
1122 pMlmDeauthCnf = (tLimMlmDeauthCnf *) pMsgBuf;
1123 psessionEntry = pe_find_session_by_session_id(pMac,
1124 pMlmDeauthCnf->sessionId);
1125 if (psessionEntry == NULL) {
1126 PELOGE(lim_log
1127 (pMac, LOGE,
1128 FL("session does not exist for given session Id "));
1129 )
1130 return;
1131 }
1132
1133 resultCode = (tSirResultCodes)
1134 (pMlmDeauthCnf->deauthTrigger ==
1135 eLIM_LINK_MONITORING_DEAUTH) ?
1136 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
1137 pMlmDeauthCnf->resultCode;
1138 aid = LIM_IS_AP_ROLE(psessionEntry) ? pMlmDeauthCnf->aid : 1;
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001139 if (LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 /* Deauth Confirm from MLM */
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301141 if ((psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
1142 && psessionEntry->limSmeState !=
1143 eLIM_SME_WT_DEAUTH_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 /**
1145 * Should not have received Deauth confirm
1146 * from MLM in other states.
1147 * Log error
1148 */
1149 PELOGE(lim_log(pMac, LOGE,
1150 FL
1151 ("received unexpected MLM_DEAUTH_CNF in state %X"),
1152 psessionEntry->limSmeState);)
1153 return;
1154 }
1155 if (pMlmDeauthCnf->resultCode == eSIR_SME_SUCCESS) {
1156 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
1157 PELOG1(lim_log(pMac, LOG1,
1158 FL("*** Deauthenticated with BSS ***"));)
1159 } else
1160 psessionEntry->limSmeState =
1161 psessionEntry->limPrevSmeState;
1162 MTRACE(mac_trace
1163 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
1164 psessionEntry->limSmeState));
1165
1166 if (pMac->lim.gLimRspReqd)
1167 pMac->lim.gLimRspReqd = false;
1168 }
1169 /* On STA or on BASIC AP, send SME_DEAUTH_RSP to host */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001170 lim_send_sme_deauth_ntf(pMac, pMlmDeauthCnf->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 resultCode,
1172 pMlmDeauthCnf->deauthTrigger,
1173 aid, psessionEntry->smeSessionId,
1174 psessionEntry->transactionId);
1175} /*** end lim_process_mlm_deauth_cnf() ***/
1176
1177/**
1178 * lim_process_mlm_purge_sta_ind()
1179 *
1180 ***FUNCTION:
1181 * This function is called to processes MLM_PURGE_STA_IND
1182 * message from MLM State machine.
1183 *
1184 ***LOGIC:
1185 *
1186 ***ASSUMPTIONS:
1187 *
1188 ***NOTE:
1189 *
1190 * @param pMac Pointer to Global MAC structure
1191 * @param pMsgBuf A pointer to the MLM message buffer
1192 *
1193 * @return None
1194 */
1195void lim_process_mlm_purge_sta_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1196{
1197 tSirResultCodes resultCode;
1198 tpLimMlmPurgeStaInd pMlmPurgeStaInd;
1199 tpPESession psessionEntry;
1200 if (pMsgBuf == NULL) {
1201 PELOGE(lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));)
1202 return;
1203 }
1204 pMlmPurgeStaInd = (tpLimMlmPurgeStaInd) pMsgBuf;
1205 psessionEntry = pe_find_session_by_session_id(pMac,
1206 pMlmPurgeStaInd->sessionId);
1207 if (psessionEntry == NULL) {
1208 PELOGE(lim_log
1209 (pMac, LOGE,
1210 FL("session does not exist for given bssId"));
1211 )
1212 return;
1213 }
1214 /* Purge STA indication from MLM */
1215 resultCode = (tSirResultCodes) pMlmPurgeStaInd->reasonCode;
1216 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
1217 case eLIM_STA_IN_IBSS_ROLE:
1218 break;
1219 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220 default: /* eLIM_AP_ROLE */
1221 if (LIM_IS_STA_ROLE(psessionEntry) &&
1222 (psessionEntry->limSmeState !=
1223 eLIM_SME_WT_DISASSOC_STATE) &&
1224 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE)) {
1225 /**
1226 * Should not have received
1227 * Purge STA indication
1228 * from MLM in other states.
1229 * Log error
1230 */
1231 PELOGE(lim_log(pMac, LOGE,
1232 FL
1233 ("received unexpected MLM_PURGE_STA_IND in state %X"),
1234 psessionEntry->limSmeState);
1235 )
1236 break;
1237 }
1238 PELOG1(lim_log(pMac, LOG1,
1239 FL("*** Cleanup completed for staId=%d ***"),
1240 pMlmPurgeStaInd->aid);
1241 )
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001242 if (LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
1244 MTRACE(mac_trace
1245 (pMac, TRACE_CODE_SME_STATE,
1246 psessionEntry->peSessionId,
1247 psessionEntry->limSmeState));
1248
1249 }
1250 if (pMlmPurgeStaInd->purgeTrigger == eLIM_PEER_ENTITY_DEAUTH) {
1251 lim_send_sme_deauth_ntf(pMac,
1252 pMlmPurgeStaInd->peerMacAddr,
1253 resultCode,
1254 pMlmPurgeStaInd->purgeTrigger,
1255 pMlmPurgeStaInd->aid,
1256 psessionEntry->smeSessionId,
1257 psessionEntry->transactionId);
1258 } else
1259 lim_send_sme_disassoc_ntf(pMac,
1260 pMlmPurgeStaInd->peerMacAddr,
1261 resultCode,
1262 pMlmPurgeStaInd->purgeTrigger,
1263 pMlmPurgeStaInd->aid,
1264 psessionEntry->smeSessionId,
1265 psessionEntry->transactionId,
1266 psessionEntry);
1267 } /* end switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) */
1268} /*** end lim_process_mlm_purge_sta_ind() ***/
1269
1270/**
1271 * lim_process_mlm_set_keys_cnf()
1272 *
1273 ***FUNCTION:
1274 * This function is called to processes MLM_SETKEYS_CNF
1275 * message from MLM State machine.
1276 *
1277 ***LOGIC:
1278 *
1279 ***ASSUMPTIONS:
1280 *
1281 ***NOTE:
1282 *
1283 * @param pMac Pointer to Global MAC structure
1284 * @param pMsgBuf A pointer to the MLM message buffer
1285 *
1286 * @return None
1287 */
1288void lim_process_mlm_set_keys_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1289{
1290 /* Prepare and send SME_SETCONTEXT_RSP message */
1291 tLimMlmSetKeysCnf *pMlmSetKeysCnf;
1292 tpPESession psessionEntry;
1293 uint16_t aid;
1294 tpDphHashNode sta_ds;
1295
1296 if (pMsgBuf == NULL) {
1297 PELOGE(lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));)
1298 return;
1299 }
1300 pMlmSetKeysCnf = (tLimMlmSetKeysCnf *) pMsgBuf;
1301 psessionEntry = pe_find_session_by_session_id(pMac,
1302 pMlmSetKeysCnf->sessionId);
1303 if (psessionEntry == NULL) {
1304 PELOGE(lim_log
1305 (pMac, LOGE,
1306 FL("session does not exist for given sessionId "));
1307 )
1308 return;
1309 }
1310 psessionEntry->is_key_installed = 0;
1311 lim_log(pMac, LOG1,
1312 FL("Received MLM_SETKEYS_CNF with resultCode = %d"),
1313 pMlmSetKeysCnf->resultCode);
1314 /* if the status is success keys are installed in the
1315 * Firmware so we can set the protection bit
1316 */
1317 if (eSIR_SME_SUCCESS == pMlmSetKeysCnf->resultCode) {
Deepak Dhamdhere07168162016-10-19 20:45:20 -07001318 if (pMlmSetKeysCnf->key_len_nonzero)
1319 psessionEntry->is_key_installed = 1;
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001320 if (LIM_IS_AP_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 sta_ds = dph_lookup_hash_entry(pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001322 pMlmSetKeysCnf->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 &aid, &psessionEntry->dph.dphHashTable);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07001324 if (sta_ds != NULL && pMlmSetKeysCnf->key_len_nonzero)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 sta_ds->is_key_installed = 1;
1326 }
1327 }
Deepak Dhamdhere07168162016-10-19 20:45:20 -07001328 lim_log(pMac, LOG1,
1329 FL("is_key_installed = %d"),
1330 psessionEntry->is_key_installed);
1331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 lim_send_sme_set_context_rsp(pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001333 pMlmSetKeysCnf->peer_macaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 1,
1335 (tSirResultCodes) pMlmSetKeysCnf->resultCode,
1336 psessionEntry, psessionEntry->smeSessionId,
1337 psessionEntry->transactionId);
1338} /*** end lim_process_mlm_set_keys_cnf() ***/
1339
1340/**
1341 * lim_handle_sme_join_result() - Handles sme join result
1342 * @mac_ctx: Pointer to Global MAC structure
1343 * @result_code: Failure code to be sent
1344 * @prot_status_code : Protocol status code
1345 * @session_entry: PE session handle
1346 *
1347 * This function is called to process join/auth/assoc failures
1348 * upon receiving MLM_JOIN/AUTH/ASSOC_CNF with a failure code or
1349 * MLM_ASSOC_CNF with a success code in case of STA role and
1350 * MLM_JOIN_CNF with success in case of STA in IBSS role.
1351 *
1352 * Return: None
1353 */
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001354void lim_handle_sme_join_result(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 tSirResultCodes result_code, uint16_t prot_status_code,
1356 tpPESession session_entry)
1357{
1358 tpDphHashNode sta_ds = NULL;
1359 uint8_t sme_session_id;
1360 uint16_t sme_trans_id;
1361
1362 if (session_entry == NULL) {
1363 lim_log(mac_ctx, LOGE, FL("psessionEntry is NULL "));
1364 return;
1365 }
1366 sme_session_id = session_entry->smeSessionId;
1367 sme_trans_id = session_entry->transactionId;
1368 /*
1369 * When associations is failed , delete the session created
1370 * and pass NULL to limsendsmeJoinReassocRsp()
1371 */
1372 if (result_code != eSIR_SME_SUCCESS) {
1373 sta_ds =
1374 dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1375 &session_entry->dph.dphHashTable);
1376 if (sta_ds != NULL) {
1377 sta_ds->mlmStaContext.disassocReason =
1378 eSIR_MAC_UNSPEC_FAILURE_REASON;
1379 sta_ds->mlmStaContext.cleanupTrigger =
1380 eLIM_JOIN_FAILURE;
1381 sta_ds->mlmStaContext.resultCode = result_code;
1382 sta_ds->mlmStaContext.protStatusCode = prot_status_code;
1383 /*
1384 * FIX_ME: at the end of lim_cleanup_rx_path,
1385 * make sure PE is sending eWNI_SME_JOIN_RSP
1386 * to SME
1387 */
1388 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
Naveen Rawat2d57a0d2016-10-21 15:59:54 -07001389 qdf_mem_free(session_entry->pLimJoinReq);
1390 session_entry->pLimJoinReq = NULL;
Abhishek Singh96bda8e2015-12-03 16:45:35 +05301391 /* Cleanup if add bss failed */
1392 if (session_entry->add_bss_failed) {
1393 dph_delete_hash_entry(mac_ctx,
1394 sta_ds->staAddr, sta_ds->assocId,
1395 &session_entry->dph.dphHashTable);
1396 goto error;
1397 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 return;
1399 }
Naveen Rawat2d57a0d2016-10-21 15:59:54 -07001400 qdf_mem_free(session_entry->pLimJoinReq);
1401 session_entry->pLimJoinReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 }
Abhishek Singh96bda8e2015-12-03 16:45:35 +05301403error:
Naveen Rawat2d57a0d2016-10-21 15:59:54 -07001404 /* Delete the session if JOIN failure occurred. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 if (result_code != eSIR_SME_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 if (lim_set_link_state
Kiran Kumar Lokere92b1fca2016-05-23 15:28:15 -07001407 (mac_ctx, eSIR_LINK_DOWN_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 session_entry->bssId,
1409 session_entry->selfMacAddr, NULL,
1410 NULL) != eSIR_SUCCESS)
1411 lim_log(mac_ctx, LOGE,
1412 FL("Failed to set the LinkState."));
1413 pe_delete_session(mac_ctx, session_entry);
1414 session_entry = NULL;
1415 }
1416
1417 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, result_code,
1418 prot_status_code, session_entry, sme_session_id, sme_trans_id);
1419}
1420
1421/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 * lim_process_mlm_add_sta_rsp()
1423 *
1424 ***FUNCTION:
1425 * This function is called to process a WMA_ADD_STA_RSP from HAL.
1426 * Upon receipt of this message from HAL, MLME -
1427 * > Determines the "state" in which this message was received
1428 * > Forwards it to the appropriate callback
1429 *
1430 ***ASSUMPTIONS:
1431 *
1432 ***NOTE:
1433 *
1434 * @param pMac Pointer to Global MAC structure
1435 * @param tSirMsgQ The MsgQ header, which contains the response buffer
1436 *
1437 * @return None
1438 */
1439void lim_process_mlm_add_sta_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
1440 tpPESession psessionEntry)
1441{
1442 /* we need to process the deferred message since the initiating req. there might be nested request. */
1443 /* in the case of nested request the new request initiated from the response will take care of resetting */
1444 /* the deffered flag. */
1445 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001446 if (LIM_IS_AP_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 lim_process_ap_mlm_add_sta_rsp(pMac, limMsgQ, psessionEntry);
1448 return;
1449 }
1450 lim_process_sta_mlm_add_sta_rsp(pMac, limMsgQ, psessionEntry);
1451}
1452
1453/**
1454 * lim_process_sta_mlm_add_sta_rsp () - Process add sta response
1455 * @mac_ctx: Pointer to mac context
1456 * @msg: tpSirMsgQan Message structure
1457 * @session_entry: PE session entry
1458 *
1459 * Process ADD STA response sent from WMA and posts results
1460 * to SME.
1461 *
1462 * Return: Null
1463 */
1464
1465void lim_process_sta_mlm_add_sta_rsp(tpAniSirGlobal mac_ctx,
1466 tpSirMsgQ msg, tpPESession session_entry)
1467{
1468 tLimMlmAssocCnf mlm_assoc_cnf;
1469 tpDphHashNode sta_ds;
1470 uint32_t msg_type = LIM_MLM_ASSOC_CNF;
1471 tpAddStaParams add_sta_params = (tpAddStaParams) msg->bodyptr;
1472 tpPESession ft_session = NULL;
1473 uint8_t ft_session_id;
1474
1475 if (NULL == add_sta_params) {
1476 lim_log(mac_ctx, LOGE, FL("Encountered NULL Pointer"));
1477 return;
1478 }
1479
1480 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
1481 msg_type = LIM_MLM_REASSOC_CNF;
1482
1483 if (true == session_entry->fDeauthReceived) {
1484 lim_log(mac_ctx, LOGE,
1485 FL("Received Deauth frame in ADD_STA_RESP state"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301486 if (QDF_STATUS_SUCCESS == add_sta_params->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 lim_log(mac_ctx, LOGE,
1488 FL("ADD_STA success, send update result code with eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA staIdx: %d limMlmState: %d"),
1489 add_sta_params->staIdx,
1490 session_entry->limMlmState);
1491
1492 if (session_entry->limSmeState ==
1493 eLIM_SME_WT_REASSOC_STATE)
1494 msg_type = LIM_MLM_REASSOC_CNF;
1495 /*
1496 * We are sending result code
1497 * eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA which
1498 * will trigger proper cleanup (DEL_STA/DEL_BSS both
1499 * required) in either assoc cnf or reassoc cnf handler.
1500 */
1501 mlm_assoc_cnf.resultCode =
1502 eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA;
Abhishek Singhac2be142015-12-03 16:16:25 +05301503 mlm_assoc_cnf.protStatusCode =
1504 eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 session_entry->staId = add_sta_params->staIdx;
1506 goto end;
1507 }
1508 }
1509
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301510 if (QDF_STATUS_SUCCESS == add_sta_params->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 if (eLIM_MLM_WT_ADD_STA_RSP_STATE !=
1512 session_entry->limMlmState) {
1513 lim_log(mac_ctx, LOGE,
1514 FL("Received WMA_ADD_STA_RSP in state %X"),
1515 session_entry->limMlmState);
1516 mlm_assoc_cnf.resultCode =
1517 (tSirResultCodes) eSIR_SME_REFUSED;
1518 goto end;
1519 }
1520 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 /* check if we have keys(PTK)to install in case of 11r */
1522 tpftPEContext ft_ctx = &session_entry->ftPEContext;
1523 ft_session = pe_find_session_by_bssid(mac_ctx,
1524 session_entry->limReAssocbssId, &ft_session_id);
1525 if (ft_session != NULL &&
1526 ft_ctx->PreAuthKeyInfo.extSetStaKeyParamValid
1527 == true) {
1528 tpLimMlmSetKeysReq pMlmStaKeys =
1529 &ft_ctx->PreAuthKeyInfo.extSetStaKeyParam;
1530 lim_send_set_sta_key_req(mac_ctx, pMlmStaKeys,
1531 0, 0, ft_session, false);
1532 ft_ctx->PreAuthKeyInfo.extSetStaKeyParamValid =
1533 false;
1534 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 }
1536 /*
1537 * Update the DPH Hash Entry for this STA
1538 * with proper state info
1539 */
1540 sta_ds =
1541 dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1542 &session_entry->dph.dphHashTable);
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301543 if (NULL != sta_ds) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 sta_ds->mlmStaContext.mlmState =
1545 eLIM_MLM_LINK_ESTABLISHED_STATE;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301546 sta_ds->nss = add_sta_params->nss;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301547 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 lim_log(mac_ctx, LOGW,
1549 FL("Fail to get DPH Hash Entry for AID - %d"),
1550 DPH_STA_HASH_INDEX_PEER);
1551 session_entry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1552 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1553 session_entry->peSessionId,
1554 session_entry->limMlmState));
1555 /*
1556 * Storing the self StaIndex(Generated by HAL) in
1557 * session context, instead of storing it in DPH Hash
1558 * entry for Self STA.
1559 * DPH entry for the self STA stores the sta index for
1560 * the BSS entry to which the STA is associated
1561 */
1562 session_entry->staId = add_sta_params->staIdx;
1563
1564#ifdef WLAN_DEBUG
1565 mac_ctx->lim.gLimNumLinkEsts++;
1566#endif
1567#ifdef FEATURE_WLAN_TDLS
1568 /* initialize TDLS peer related data */
1569 lim_init_tdls_data(mac_ctx, session_entry);
1570#endif
1571 /*
1572 * Return Assoc confirm to SME with success
1573 * FIXME - Need the correct ASSOC RSP code to
1574 * be passed in here
1575 */
1576 mlm_assoc_cnf.resultCode = (tSirResultCodes) eSIR_SME_SUCCESS;
1577 } else {
1578 lim_log(mac_ctx, LOGE, FL("ADD_STA failed!"));
1579 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
1580 mlm_assoc_cnf.resultCode =
1581 (tSirResultCodes) eSIR_SME_FT_REASSOC_FAILURE;
1582 else
1583 mlm_assoc_cnf.resultCode =
1584 (tSirResultCodes) eSIR_SME_REFUSED;
Abhishek Singhac2be142015-12-03 16:16:25 +05301585 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 }
1587end:
1588 if (NULL != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301589 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 msg->bodyptr = NULL;
1591 }
1592 /* Updating PE session Id */
1593 mlm_assoc_cnf.sessionId = session_entry->peSessionId;
1594 lim_post_sme_message(mac_ctx, msg_type, (uint32_t *) &mlm_assoc_cnf);
1595 if (true == session_entry->fDeauthReceived)
1596 session_entry->fDeauthReceived = false;
1597 return;
1598}
1599
1600void lim_process_mlm_del_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
1601 tpPESession psessionEntry)
1602{
1603 /* we need to process the deferred message since the initiating req. there might be nested request. */
1604 /* in the case of nested request the new request initiated from the response will take care of resetting */
1605 /* the deffered flag. */
1606 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1607 pMac->sys.gSysFrameCount[SIR_MAC_MGMT_FRAME][SIR_MAC_MGMT_DEAUTH] = 0;
1608
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001609 if (LIM_IS_AP_ROLE(psessionEntry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 (psessionEntry->statypeForBss == STA_ENTRY_SELF)) {
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001611 lim_process_ap_mlm_del_bss_rsp(pMac, limMsgQ, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 return;
1613 }
1614 lim_process_sta_mlm_del_bss_rsp(pMac, limMsgQ, psessionEntry);
1615
1616#ifdef WLAN_FEATURE_11W
1617 if (psessionEntry->limRmfEnabled) {
1618 if (eSIR_SUCCESS !=
1619 lim_send_exclude_unencrypt_ind(pMac, true, psessionEntry)) {
1620 lim_log(pMac, LOGE,
1621 FL
1622 ("Could not send down Exclude Unencrypted Indication!"));
1623 }
1624 }
1625#endif
1626}
1627
1628void lim_process_sta_mlm_del_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
1629 tpPESession psessionEntry)
1630{
1631 tpDeleteBssParams pDelBssParams = (tpDeleteBssParams) limMsgQ->bodyptr;
1632 tpDphHashNode pStaDs =
1633 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
1634 &psessionEntry->dph.dphHashTable);
1635 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
1636
1637 if (NULL == pDelBssParams) {
1638 lim_log(pMac, LOGE, FL("Invalid body pointer in message"));
1639 goto end;
1640 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301641 if (QDF_STATUS_SUCCESS == pDelBssParams->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 PELOGW(lim_log(pMac, LOGW,
1643 FL("STA received the DEL_BSS_RSP for BSSID: %X."),
1644 pDelBssParams->bssIdx);
1645 )
1646 if (lim_set_link_state
1647 (pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
1648 psessionEntry->selfMacAddr, NULL,
1649 NULL) != eSIR_SUCCESS) {
1650 PELOGE(lim_log
1651 (pMac, LOGE,
1652 FL("Failure in setting link state to IDLE"));
1653 )
1654 statusCode = eSIR_SME_REFUSED;
1655 goto end;
1656 }
1657 if (pStaDs == NULL) {
1658 lim_log(pMac, LOGE, FL("DPH Entry for STA 1 missing."));
1659 statusCode = eSIR_SME_REFUSED;
1660 goto end;
1661 }
1662 if (eLIM_MLM_WT_DEL_BSS_RSP_STATE !=
1663 pStaDs->mlmStaContext.mlmState) {
1664 PELOGE(lim_log
1665 (pMac, LOGE,
1666 FL
1667 ("Received unexpected WMA_DEL_BSS_RSP in state %X"),
1668 pStaDs->mlmStaContext.mlmState);
1669 )
1670 statusCode = eSIR_SME_REFUSED;
1671 goto end;
1672 }
1673 PELOG1(lim_log
1674 (pMac, LOG1, FL("STA AssocID %d MAC "), pStaDs->assocId);
1675 lim_print_mac_addr(pMac, pStaDs->staAddr, LOG1);
1676 )
1677 } else {
1678 lim_log(pMac, LOGE, FL("DEL BSS failed!"));
1679 statusCode = eSIR_SME_STOP_BSS_FAILURE;
1680 }
1681end:
1682 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301683 qdf_mem_free(pDelBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 limMsgQ->bodyptr = NULL;
1685 }
1686 if (pStaDs == NULL)
1687 return;
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001688 if ((LIM_IS_STA_ROLE(psessionEntry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 (psessionEntry->limSmeState !=
1690 eLIM_SME_WT_DISASSOC_STATE &&
1691 psessionEntry->limSmeState !=
1692 eLIM_SME_WT_DEAUTH_STATE) &&
1693 pStaDs->mlmStaContext.cleanupTrigger !=
1694 eLIM_JOIN_FAILURE) {
1695 /** The Case where the DelBss is invoked from
1696 * context of other than normal DisAssoc / Deauth OR
1697 * as part of Join Failure.
1698 */
1699 lim_handle_del_bss_in_re_assoc_context(pMac, pStaDs, psessionEntry);
1700 return;
1701 }
1702 lim_prepare_and_send_del_sta_cnf(pMac, pStaDs, statusCode, psessionEntry);
1703 return;
1704}
1705
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001706void lim_process_ap_mlm_del_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 tpPESession psessionEntry)
1708{
1709 tSirResultCodes rc = eSIR_SME_SUCCESS;
1710 tSirRetStatus status;
1711 tpDeleteBssParams pDelBss = (tpDeleteBssParams) limMsgQ->bodyptr;
1712 tSirMacAddr nullBssid = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1713
1714 if (psessionEntry == NULL) {
1715 lim_log(pMac, LOGE, FL("Session entry passed is NULL"));
1716 if (pDelBss != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301717 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 limMsgQ->bodyptr = NULL;
1719 }
1720 return;
1721 }
1722
1723 if (pDelBss == NULL) {
1724 PELOGE(lim_log(pMac, LOGE, FL("BSS: DEL_BSS_RSP with no body!"));)
1725 rc = eSIR_SME_REFUSED;
1726 goto end;
1727 }
1728 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
1729 MTRACE(mac_trace
1730 (pMac, TRACE_CODE_MLM_STATE, NO_SESSION,
1731 pMac->lim.gLimMlmState));
1732
1733 if (eLIM_MLM_WT_DEL_BSS_RSP_STATE != psessionEntry->limMlmState) {
1734 lim_log(pMac, LOGE,
1735 FL("Received unexpected WMA_DEL_BSS_RSP in state %X"),
1736 psessionEntry->limMlmState);
1737 rc = eSIR_SME_REFUSED;
1738 goto end;
1739 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301740 if (pDelBss->status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 lim_log(pMac, LOGE, FL("BSS: DEL_BSS_RSP error (%x) Bss %d "),
1742 pDelBss->status, pDelBss->bssIdx);
1743 rc = eSIR_SME_STOP_BSS_FAILURE;
1744 goto end;
1745 }
1746 status = lim_set_link_state(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
1747 psessionEntry->selfMacAddr, NULL, NULL);
1748 if (status != eSIR_SUCCESS) {
1749 rc = eSIR_SME_REFUSED;
1750 goto end;
1751 }
1752 /** Softmac may send all the buffered packets right after resuming the transmission hence
1753 * to occupy the medium during non channel occupancy period. So resume the transmission after
1754 * HAL gives back the response.
1755 */
1756 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
1757 lim_delete_pre_auth_list(pMac);
1758 /* Initialize number of associated stations during cleanup */
1759 psessionEntry->gLimNumOfCurrentSTAs = 0;
1760end:
1761 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, rc,
1762 psessionEntry->smeSessionId,
1763 psessionEntry->transactionId);
1764 pe_delete_session(pMac, psessionEntry);
1765
1766 if (pDelBss != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301767 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 limMsgQ->bodyptr = NULL;
1769 }
1770}
1771
1772/**
1773 * lim_process_mlm_del_sta_rsp() - Process DEL STA response
1774 * @mac_ctx: Pointer to Global MAC structure
1775 * @msg: The MsgQ header, which contains the response buffer
1776 *
1777 * This function is called to process a WMA_DEL_STA_RSP from
1778 * WMA Upon receipt of this message from FW.
1779 *
1780 * Return: None
1781 */
1782void lim_process_mlm_del_sta_rsp(tpAniSirGlobal mac_ctx,
1783 tpSirMsgQ msg)
1784{
1785 /*
1786 * we need to process the deferred message since the
1787 * initiating req. there might be nested request
1788 * in the case of nested request the new request
1789 * initiated from the response will take care of resetting
1790 * the deffered flag.
1791 */
1792 tpPESession session_entry;
1793 tpDeleteStaParams del_sta_params;
1794 del_sta_params = (tpDeleteStaParams) msg->bodyptr;
1795 if (NULL == del_sta_params) {
1796 lim_log(mac_ctx, LOGE,
1797 FL("null pointer del_sta_params msg"));
1798 return;
1799 }
1800 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
1801
1802 session_entry = pe_find_session_by_session_id(mac_ctx,
1803 del_sta_params->sessionId);
1804 if (NULL == session_entry) {
Peng Xu66162de2016-02-11 17:01:20 -08001805 lim_log(mac_ctx, LOGP, FL("Session Doesn't exist: %d"),
1806 del_sta_params->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301807 qdf_mem_free(del_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 msg->bodyptr = NULL;
1809 return;
1810 }
1811
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001812 if (LIM_IS_AP_ROLE(session_entry)) {
1813 lim_process_ap_mlm_del_sta_rsp(mac_ctx, msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 session_entry);
1815 return;
1816 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001817 if (LIM_IS_NDI_ROLE(session_entry)) {
1818 lim_process_ndi_del_sta_rsp(mac_ctx, msg, session_entry);
1819 return;
1820 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 lim_process_sta_mlm_del_sta_rsp(mac_ctx, msg, session_entry);
1822}
1823
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301824/**
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001825 * lim_process_ap_mlm_del_sta_rsp() - Process WMA_DEL_STA_RSP
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301826 * @mac_ctx: Global pointer to MAC context
1827 * @msg: Received message
1828 * @session_entry: Session entry
1829 *
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001830 * Process WMA_DEL_STA_RSP for AP role
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301831 *
1832 * Retunrn: None
1833 */
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001834void lim_process_ap_mlm_del_sta_rsp(tpAniSirGlobal mac_ctx,
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301835 tpSirMsgQ msg,
1836 tpPESession session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837{
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301838 tpDeleteStaParams del_sta_params = (tpDeleteStaParams) msg->bodyptr;
1839 tpDphHashNode sta_ds;
1840 tSirResultCodes status_code = eSIR_SME_SUCCESS;
1841
1842 if (msg->bodyptr == NULL) {
1843 lim_log(mac_ctx, LOGE, FL("msg->bodyptr NULL"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 return;
1845 }
1846
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301847 sta_ds = dph_get_hash_entry(mac_ctx, del_sta_params->assocId,
1848 &session_entry->dph.dphHashTable);
1849 if (sta_ds == NULL) {
1850 lim_log(mac_ctx, LOGE, FL("DPH Entry for STA %X missing."),
1851 del_sta_params->assocId);
1852 status_code = eSIR_SME_REFUSED;
1853 qdf_mem_free(del_sta_params);
1854 msg->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 return;
1856 }
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301857 lim_log(mac_ctx, LOG1, FL("Received del Sta Rsp in StaD MlmState : %d"),
1858 sta_ds->mlmStaContext.mlmState);
1859 if (QDF_STATUS_SUCCESS != del_sta_params->status) {
1860 lim_log(mac_ctx, LOGW, FL("DEL STA failed!"));
1861 status_code = eSIR_SME_REFUSED;
1862 goto end;
1863 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301865 lim_log(mac_ctx, LOGW,
1866 FL("AP received the DEL_STA_RSP for assocID: %X."),
1867 del_sta_params->assocId);
1868 if ((eLIM_MLM_WT_DEL_STA_RSP_STATE != sta_ds->mlmStaContext.mlmState) &&
1869 (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
1870 sta_ds->mlmStaContext.mlmState)) {
1871 lim_log(mac_ctx, LOGE,
1872 FL("Received unexpected WMA_DEL_STA_RSP in state %s for staId %d assocId %d "),
1873 lim_mlm_state_str(sta_ds->mlmStaContext.mlmState),
1874 sta_ds->staIndex, sta_ds->assocId);
1875 status_code = eSIR_SME_REFUSED;
1876 goto end;
1877 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301879 lim_log(mac_ctx, LOG1, FL("Deleted STA AssocID %d staId %d MAC "),
1880 sta_ds->assocId, sta_ds->staIndex);
1881 lim_print_mac_addr(mac_ctx, sta_ds->staAddr, LOG1);
1882 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE ==
1883 sta_ds->mlmStaContext.mlmState) {
1884 qdf_mem_free(del_sta_params);
1885 msg->bodyptr = NULL;
1886 if (lim_add_sta(mac_ctx, sta_ds, false, session_entry) !=
1887 eSIR_SUCCESS) {
1888 lim_log(mac_ctx, LOGE, FL("could not Add STA with assocId=%d"),
1889 sta_ds->assocId);
1890 /*
1891 * delete the TS if it has already been added.
1892 * send the response with error status.
1893 */
1894 if (sta_ds->qos.addtsPresent) {
1895 tpLimTspecInfo pTspecInfo;
1896 if (eSIR_SUCCESS ==
1897 lim_tspec_find_by_assoc_id(mac_ctx,
1898 sta_ds->assocId,
1899 &sta_ds->qos.addts.tspec,
1900 &mac_ctx->lim.tspecInfo[0],
1901 &pTspecInfo)) {
1902 lim_admit_control_delete_ts(mac_ctx,
1903 sta_ds->assocId,
1904 &sta_ds->qos.addts.tspec.tsinfo,
1905 NULL,
1906 &pTspecInfo->idx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 }
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301909 lim_reject_association(mac_ctx, sta_ds->staAddr,
1910 sta_ds->mlmStaContext.subType, true,
1911 sta_ds->mlmStaContext.authType, sta_ds->assocId,
1912 true,
1913 (tSirResultCodes)eSIR_MAC_UNSPEC_FAILURE_STATUS,
1914 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 }
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301916 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 }
1918end:
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301919 qdf_mem_free(del_sta_params);
1920 msg->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301922 sta_ds->mlmStaContext.mlmState) {
1923 lim_prepare_and_send_del_sta_cnf(mac_ctx, sta_ds, status_code,
1924 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 }
1926 return;
1927}
1928
1929void lim_process_sta_mlm_del_sta_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
1930 tpPESession psessionEntry)
1931{
1932 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
1933 tpDeleteStaParams pDelStaParams = (tpDeleteStaParams) limMsgQ->bodyptr;
1934 tpDphHashNode pStaDs = NULL;
1935 if (NULL == pDelStaParams) {
1936 lim_log(pMac, LOGE, FL("Encountered NULL Pointer"));
1937 goto end;
1938 }
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07001939 lim_log(pMac, LOG1, FL("Del STA RSP received. Status:%d AssocID:%d"),
1940 pDelStaParams->status, pDelStaParams->assocId);
1941
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301942 if (QDF_STATUS_SUCCESS != pDelStaParams->status)
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07001943 lim_log(pMac, LOGE, FL(
1944 "Del STA failed! Status:%d, proceeding with Del BSS"),
1945 pDelStaParams->status);
1946
1947 pStaDs = dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
1948 &psessionEntry->dph.dphHashTable);
1949 if (pStaDs == NULL) {
1950 lim_log(pMac, LOGE, FL("DPH Entry for STA %X missing."),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 pDelStaParams->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 statusCode = eSIR_SME_REFUSED;
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07001953 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 }
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07001955 if (eLIM_MLM_WT_DEL_STA_RSP_STATE != psessionEntry->limMlmState) {
1956 lim_log(pMac, LOGE, FL(
1957 "Received unexpected WDA_DELETE_STA_RSP in state %s"),
1958 lim_mlm_state_str(psessionEntry->limMlmState));
1959 statusCode = eSIR_SME_REFUSED;
1960 goto end;
1961 }
1962 lim_log(pMac, LOG1, FL("STA AssocID %d MAC "), pStaDs->assocId);
1963 lim_print_mac_addr(pMac, pStaDs->staAddr, LOG1);
1964 /*
1965 * we must complete all cleanup related to delSta before
1966 * calling limDelBSS.
1967 */
1968 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301969 qdf_mem_free(pDelStaParams);
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07001970 limMsgQ->bodyptr = NULL;
1971 }
1972 /* Proceed to do DelBSS even if DelSta resulted in failure */
1973 statusCode = (tSirResultCodes)lim_del_bss(pMac, pStaDs, 0,
1974 psessionEntry);
1975 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976end:
1977 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301978 qdf_mem_free(pDelStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 limMsgQ->bodyptr = NULL;
1980 }
1981 return;
1982}
1983
1984void lim_process_ap_mlm_add_sta_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
1985 tpPESession psessionEntry)
1986{
1987 tpAddStaParams pAddStaParams = (tpAddStaParams) limMsgQ->bodyptr;
1988 tpDphHashNode pStaDs = NULL;
1989
1990 if (NULL == pAddStaParams) {
1991 lim_log(pMac, LOGE, FL("Invalid body pointer in message"));
1992 goto end;
1993 }
1994
1995 pStaDs =
1996 dph_get_hash_entry(pMac, pAddStaParams->assocId,
1997 &psessionEntry->dph.dphHashTable);
1998 if (pStaDs == NULL) {
1999 /* TODO: any response to be sent out here ? */
2000 lim_log(pMac, LOGE, FL("DPH Entry for STA %X missing."),
2001 pAddStaParams->assocId);
2002 goto end;
2003 }
2004 /* */
2005 /* TODO & FIXME_GEN4 */
2006 /* Need to inspect tSirMsgQ.reserved for a valid Dialog token! */
2007 /* */
2008 /* TODO: any check for pMac->lim.gLimMlmState ? */
2009 if (eLIM_MLM_WT_ADD_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState) {
2010 /* TODO: any response to be sent out here ? */
2011 lim_log(pMac, LOGE,
2012 FL("Received unexpected WMA_ADD_STA_RSP in state %X"),
2013 pStaDs->mlmStaContext.mlmState);
2014 goto end;
2015 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302016 if (QDF_STATUS_SUCCESS != pAddStaParams->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 PELOGE(lim_log
2018 (pMac, LOGE,
2019 FL("Error! rcvd delSta rsp from HAL with status %d"),
2020 pAddStaParams->status);
2021 )
2022 lim_reject_association(pMac, pStaDs->staAddr,
2023 pStaDs->mlmStaContext.subType,
2024 true, pStaDs->mlmStaContext.authType,
2025 pStaDs->assocId, true,
2026 (tSirResultCodes)
2027 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2028 psessionEntry);
2029 goto end;
2030 }
2031 pStaDs->bssId = pAddStaParams->bssIdx;
2032 pStaDs->staIndex = pAddStaParams->staIdx;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05302033 pStaDs->nss = pAddStaParams->nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 /* if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state */
2035 pStaDs->valid = 1;
2036 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ASSOC_CNF_STATE;
2037 lim_log(pMac, LOG1,
2038 FL("AddStaRsp Success.STA AssocID %d staId %d MAC "),
2039 pStaDs->assocId, pStaDs->staIndex);
2040 lim_print_mac_addr(pMac, pStaDs->staAddr, LOG1);
2041
2042 /* For BTAMP-AP, the flow sequence shall be:
2043 * 1) PE sends eWNI_SME_ASSOC_IND to SME
2044 * 2) PE receives eWNI_SME_ASSOC_CNF from SME
2045 * 3) BTAMP-AP sends Re/Association Response to BTAMP-STA
2046 */
2047 lim_send_mlm_assoc_ind(pMac, pStaDs, psessionEntry);
2048 /* fall though to reclaim the original Add STA Response message */
2049end:
2050 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302051 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 limMsgQ->bodyptr = NULL;
2053 }
2054 return;
2055}
2056
2057/**
2058 * lim_process_ap_mlm_add_bss_rsp()
2059 *
2060 ***FUNCTION:
2061 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2062 * Upon receipt of this message from HAL, MLME -
2063 * > Validates the result of WMA_ADD_BSS_REQ
2064 * > Init other remaining LIM variables
2065 * > Init the AID pool, for that BSSID
2066 * > Init the Pre-AUTH list, for that BSSID
2067 * > Create LIM timers, specific to that BSSID
2068 * > Init DPH related parameters that are specific to that BSSID
2069 * > TODO - When do we do the actual change channel?
2070 *
2071 ***LOGIC:
2072 * SME sends eWNI_SME_START_BSS_REQ to LIM
2073 * LIM sends LIM_MLM_START_REQ to MLME
2074 * MLME sends WMA_ADD_BSS_REQ to HAL
2075 * HAL responds with WMA_ADD_BSS_RSP to MLME
2076 * MLME responds with LIM_MLM_START_CNF to LIM
2077 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2078 *
2079 ***ASSUMPTIONS:
2080 * tSirMsgQ.body is allocated by MLME during lim_process_mlm_start_req
2081 * tSirMsgQ.body will now be freed by this routine
2082 *
2083 ***NOTE:
2084 *
2085 * @param pMac Pointer to Global MAC structure
2086 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2087 *
2088 * @return None
2089 */
2090static void lim_process_ap_mlm_add_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ)
2091{
2092 tLimMlmStartCnf mlmStartCnf;
2093 tpPESession psessionEntry;
2094 uint8_t isWepEnabled = false;
2095 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2096 if (NULL == pAddBssParams) {
2097 lim_log(pMac, LOGE, FL("Encountered NULL Pointer"));
2098 goto end;
2099 }
2100 /* TBD: free the memory before returning, do it for all places where lookup fails. */
2101 psessionEntry = pe_find_session_by_session_id(pMac,
2102 pAddBssParams->sessionId);
2103 if (psessionEntry == NULL) {
2104 PELOGE(lim_log
2105 (pMac, LOGE,
2106 FL("session does not exist for given sessionId"));
2107 )
2108 if (NULL != pAddBssParams) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302109 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 limMsgQ->bodyptr = NULL;
2111 }
2112 return;
2113 }
2114 /* Update PE session Id */
2115 mlmStartCnf.sessionId = pAddBssParams->sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302116 if (QDF_STATUS_SUCCESS == pAddBssParams->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 PELOG2(lim_log
2118 (pMac, LOG2,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302119 FL("WMA_ADD_BSS_RSP returned with QDF_STATUS_SUCCESS"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 )
2121 if (lim_set_link_state
2122 (pMac, eSIR_LINK_AP_STATE, psessionEntry->bssId,
2123 psessionEntry->selfMacAddr, NULL,
2124 NULL) != eSIR_SUCCESS)
2125 goto end;
2126 /* Set MLME state */
2127 psessionEntry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
2128 psessionEntry->chainMask = pAddBssParams->chainMask;
2129 psessionEntry->smpsMode = pAddBssParams->smpsMode;
2130 MTRACE(mac_trace
2131 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
2132 psessionEntry->limMlmState));
2133 if (eSIR_IBSS_MODE == pAddBssParams->bssType) {
2134 /** IBSS is 'active' when we receive
2135 * Beacon frames from other STAs that are part of same IBSS.
2136 * Mark internal state as inactive until then.
2137 */
2138 psessionEntry->limIbssActive = false;
2139 psessionEntry->statypeForBss = STA_ENTRY_PEER; /* to know session created for self/peer */
2140 limResetHBPktCount(psessionEntry);
2141 }
2142 psessionEntry->bssIdx = (uint8_t) pAddBssParams->bssIdx;
2143
2144 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2145
2146 if (eSIR_INFRA_AP_MODE == pAddBssParams->bssType)
2147 psessionEntry->limSystemRole = eLIM_AP_ROLE;
2148 else
2149 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2150 sch_edca_profile_update(pMac, psessionEntry);
2151 lim_init_pre_auth_list(pMac);
2152 /* Check the SAP security configuration.If configured to
2153 * WEP then max clients supported is 16
2154 */
2155 if (psessionEntry->privacy) {
2156 if ((psessionEntry->gStartBssRSNIe.present)
2157 || (psessionEntry->gStartBssWPAIe.present))
2158 lim_log(pMac, LOG1,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +05302159 FL("WPA/WPA2 SAP configuration"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 else {
2161 if (pMac->lim.gLimAssocStaLimit >
2162 MAX_SUPPORTED_PEERS_WEP) {
2163 lim_log(pMac, LOG1,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +05302164 FL("WEP SAP Configuration"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 pMac->lim.gLimAssocStaLimit =
2166 MAX_SUPPORTED_PEERS_WEP;
2167 isWepEnabled = true;
2168 }
2169 }
2170 }
2171 lim_init_peer_idxpool(pMac, psessionEntry);
2172
2173 /* Start OLBC timer */
2174 if (tx_timer_activate
2175 (&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer) !=
2176 TX_SUCCESS) {
2177 lim_log(pMac, LOGE, FL("tx_timer_activate failed"));
2178 }
2179
2180 /* Apply previously set configuration at HW */
2181 lim_apply_configuration(pMac, psessionEntry);
2182
2183 /* In lim_apply_configuration gLimAssocStaLimit is assigned from cfg.
2184 * So update the value to 16 in case SoftAP is configured in WEP.
2185 */
2186 if ((pMac->lim.gLimAssocStaLimit > MAX_SUPPORTED_PEERS_WEP)
2187 && (isWepEnabled))
2188 pMac->lim.gLimAssocStaLimit = MAX_SUPPORTED_PEERS_WEP;
2189 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2190 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2191 } else {
2192 lim_log(pMac, LOGE, FL("WMA_ADD_BSS_REQ failed with status %d"),
2193 pAddBssParams->status);
2194 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2195 }
2196 lim_post_sme_message(pMac, LIM_MLM_START_CNF, (uint32_t *) &mlmStartCnf);
2197end:
2198 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 limMsgQ->bodyptr = NULL;
2201 }
2202}
2203
2204/**
2205 * lim_process_ibss_mlm_add_bss_rsp()
2206 *
2207 ***FUNCTION:
2208 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2209 * Upon receipt of this message from HAL, MLME -
2210 * > Validates the result of WMA_ADD_BSS_REQ
2211 * > Init other remaining LIM variables
2212 * > Init the AID pool, for that BSSID
2213 * > Init the Pre-AUTH list, for that BSSID
2214 * > Create LIM timers, specific to that BSSID
2215 * > Init DPH related parameters that are specific to that BSSID
2216 * > TODO - When do we do the actual change channel?
2217 *
2218 ***LOGIC:
2219 * SME sends eWNI_SME_START_BSS_REQ to LIM
2220 * LIM sends LIM_MLM_START_REQ to MLME
2221 * MLME sends WMA_ADD_BSS_REQ to HAL
2222 * HAL responds with WMA_ADD_BSS_RSP to MLME
2223 * MLME responds with LIM_MLM_START_CNF to LIM
2224 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2225 *
2226 ***ASSUMPTIONS:
2227 * tSirMsgQ.body is allocated by MLME during lim_process_mlm_start_req
2228 * tSirMsgQ.body will now be freed by this routine
2229 *
2230 ***NOTE:
2231 *
2232 * @param pMac Pointer to Global MAC structure
2233 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2234 *
2235 * @return None
2236 */
2237static void
2238lim_process_ibss_mlm_add_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,
2239 tpPESession psessionEntry)
2240{
2241 tLimMlmStartCnf mlmStartCnf;
2242 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2243
2244 if (NULL == pAddBssParams) {
2245 lim_log(pMac, LOGE, FL("Invalid body pointer in message"));
2246 goto end;
2247 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302248 if (QDF_STATUS_SUCCESS == pAddBssParams->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 PELOG1(lim_log
2250 (pMac, LOG1,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302251 FL("WMA_ADD_BSS_RSP returned with QDF_STATUS_SUCCESS"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252 )
2253 if (lim_set_link_state
2254 (pMac, eSIR_LINK_IBSS_STATE, psessionEntry->bssId,
2255 psessionEntry->selfMacAddr, NULL,
2256 NULL) != eSIR_SUCCESS)
2257 goto end;
2258 /* Set MLME state */
2259 psessionEntry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
2260 MTRACE(mac_trace
2261 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
2262 psessionEntry->limMlmState));
2263 /** IBSS is 'active' when we receive
2264 * Beacon frames from other STAs that are part of same IBSS.
2265 * Mark internal state as inactive until then.
2266 */
2267 psessionEntry->limIbssActive = false;
2268 limResetHBPktCount(psessionEntry);
2269 psessionEntry->bssIdx = (uint8_t) pAddBssParams->bssIdx;
2270 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2271 psessionEntry->statypeForBss = STA_ENTRY_SELF;
2272 sch_edca_profile_update(pMac, psessionEntry);
2273 if (0 == psessionEntry->freePeerIdxHead)
2274 lim_init_peer_idxpool(pMac, psessionEntry);
2275
2276 /* Apply previously set configuration at HW */
2277 lim_apply_configuration(pMac, psessionEntry);
2278 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2279 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2280 /* If ADD BSS was issued as part of IBSS coalescing, don't send the message to SME, as that is internal to LIM */
2281 if (true == pMac->lim.gLimIbssCoalescingHappened) {
2282 lim_ibss_add_bss_rsp_when_coalescing(pMac, limMsgQ->bodyptr,
2283 psessionEntry);
2284 goto end;
2285 }
2286 } else {
2287 lim_log(pMac, LOGE, FL("WMA_ADD_BSS_REQ failed with status %d"),
2288 pAddBssParams->status);
2289 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2290 }
2291 /* Send this message to SME, when ADD_BSS is initiated by SME */
2292 /* If ADD_BSS is done as part of coalescing, this won't happen. */
2293 /* Update PE session Id */
2294 mlmStartCnf.sessionId = psessionEntry->peSessionId;
2295 lim_post_sme_message(pMac, LIM_MLM_START_CNF, (uint32_t *) &mlmStartCnf);
2296end:
2297 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302298 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 limMsgQ->bodyptr = NULL;
2300 }
2301}
2302
2303/**
2304 * csr_neighbor_roam_handoff_req_hdlr - Processes handoff request
2305 * @mac_ctx: Pointer to mac context
2306 * @msg: message sent to HDD
2307 * @session_entry: PE session handle
2308 *
2309 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2310 * Upon receipt of this message from HAL if the state is pre assoc.
2311 *
2312 * Return: Null
2313 */
2314static void
2315lim_process_sta_add_bss_rsp_pre_assoc(tpAniSirGlobal mac_ctx,
2316 tpSirMsgQ msg, tpPESession session_entry)
2317{
2318 tpAddBssParams pAddBssParams = (tpAddBssParams) msg->bodyptr;
2319 tAniAuthType cfgAuthType, authMode;
2320 tLimMlmAuthReq *pMlmAuthReq;
2321 tpDphHashNode pStaDs = NULL;
2322
2323 if (NULL == pAddBssParams) {
2324 lim_log(mac_ctx, LOGE, FL("Invalid body pointer in message"));
2325 goto joinFailure;
2326 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302327 if (QDF_STATUS_SUCCESS == pAddBssParams->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 pStaDs = dph_add_hash_entry(mac_ctx,
2329 pAddBssParams->staContext.staMac,
2330 DPH_STA_HASH_INDEX_PEER,
2331 &session_entry->dph.dphHashTable);
2332 if (pStaDs == NULL) {
2333 /* Could not add hash table entry */
2334 lim_log(mac_ctx, LOGE,
2335 FL("could not add hash entry at DPH for "));
2336 lim_print_mac_addr(mac_ctx,
2337 pAddBssParams->staContext.staMac, LOGE);
2338 goto joinFailure;
2339 }
2340 session_entry->bssIdx = (uint8_t) pAddBssParams->bssIdx;
2341 /* Success, handle below */
2342 pStaDs->bssId = pAddBssParams->bssIdx;
2343 /* STA Index(genr by HAL) for the BSS entry is stored here */
2344 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
2345 /* Trigger Authentication with AP */
2346 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_AUTHENTICATION_TYPE,
2347 (uint32_t *) &cfgAuthType) != eSIR_SUCCESS) {
2348 /*
2349 * Could not get AuthType from CFG.
2350 * Log error.
2351 */
2352 lim_log(mac_ctx, LOGP,
2353 FL("could not retrieve AuthType"));
2354 }
Rajeev Kumar437c9212016-04-14 15:26:59 -07002355 /* Try shared Authentication first */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 if (cfgAuthType == eSIR_AUTO_SWITCH)
Rajeev Kumar437c9212016-04-14 15:26:59 -07002357 authMode = eSIR_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358 else
2359 authMode = cfgAuthType;
2360
2361 /* Trigger MAC based Authentication */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302362 pMlmAuthReq = qdf_mem_malloc(sizeof(tLimMlmAuthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 if (NULL == pMlmAuthReq) {
2364 lim_log(mac_ctx, LOGP,
2365 FL("Allocate Memory failed for mlmAuthReq"));
2366 return;
2367 }
2368 sir_copy_mac_addr(pMlmAuthReq->peerMacAddr,
2369 session_entry->bssId);
2370
2371 pMlmAuthReq->authType = authMode;
2372 if (wlan_cfg_get_int(mac_ctx,
2373 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
2374 (uint32_t *) &pMlmAuthReq->authFailureTimeout)
2375 != eSIR_SUCCESS) {
2376 /*
2377 * Could not get AuthFailureTimeout
2378 * value from CFG. Log error.
2379 */
2380 lim_log(mac_ctx, LOGP,
2381 FL("Fail: retrieve AuthFailureTimeout value"));
2382 }
2383 session_entry->limMlmState = eLIM_MLM_JOINED_STATE;
2384 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2385 session_entry->peSessionId, eLIM_MLM_JOINED_STATE));
2386 pMlmAuthReq->sessionId = session_entry->peSessionId;
2387 session_entry->limPrevSmeState = session_entry->limSmeState;
2388 session_entry->limSmeState = eLIM_SME_WT_AUTH_STATE;
2389 /* remember staId in case of assoc timeout/failure handling */
2390 session_entry->staId = pAddBssParams->staContext.staIdx;
2391
2392 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2393 session_entry->peSessionId,
2394 session_entry->limSmeState));
2395 lim_log(mac_ctx, LOG1,
2396 FL("SessionId:%d lim_post_mlm_message "
2397 "LIM_MLM_AUTH_REQ with limSmeState:%d"),
2398 session_entry->peSessionId, session_entry->limSmeState);
2399 lim_post_mlm_message(mac_ctx, LIM_MLM_AUTH_REQ,
2400 (uint32_t *) pMlmAuthReq);
2401 return;
2402 }
2403
2404joinFailure:
2405 {
2406 session_entry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
2407 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2408 session_entry->peSessionId,
2409 session_entry->limSmeState));
2410
2411 /* Send Join response to Host */
2412 lim_handle_sme_join_result(mac_ctx, eSIR_SME_REFUSED,
2413 eSIR_MAC_UNSPEC_FAILURE_STATUS, session_entry);
2414 }
2415
2416}
2417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418/**
2419 * lim_process_sta_mlm_add_bss_rsp() - Process ADD BSS response
2420 * @mac_ctx: Pointer to Global MAC structure
2421 * @msg: The MsgQ header, which contains the response buffer
2422 *
2423 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2424 * Upon receipt of this message from HAL, MLME -
2425 * > Validates the result of WMA_ADD_BSS_REQ
2426 * > Now, send an ADD_STA to HAL and ADD the "local" STA itself
2427 *
2428 * MLME had sent WMA_ADD_BSS_REQ to HAL
2429 * HAL responded with WMA_ADD_BSS_RSP to MLME
2430 * MLME now sends WMA_ADD_STA_REQ to HAL
2431 * ASSUMPTIONS:
2432 * tSirMsgQ.body is allocated by MLME during lim_process_mlm_join_req
2433 * tSirMsgQ.body will now be freed by this routine
2434 *
2435 * Return: None
2436 */
2437static void
2438lim_process_sta_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx,
2439 tpSirMsgQ msg, tpPESession session_entry)
2440{
2441 tpAddBssParams add_bss_params = (tpAddBssParams) msg->bodyptr;
2442 tLimMlmAssocCnf mlm_assoc_cnf;
2443 uint32_t msg_type = LIM_MLM_ASSOC_CNF;
2444 uint32_t sub_type = LIM_ASSOC;
2445 tpDphHashNode sta_ds = NULL;
2446 uint16_t sta_idx = STA_INVALID_IDX;
2447 uint8_t update_sta = false;
2448 mlm_assoc_cnf.resultCode = eSIR_SME_SUCCESS;
2449
2450 if (eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE ==
2451 session_entry->limMlmState) {
2452 lim_log(mac_ctx, LOG1,
2453 "SessionId:%d lim_process_sta_add_bss_rsp_pre_assoc",
2454 session_entry->peSessionId);
2455 lim_process_sta_add_bss_rsp_pre_assoc(mac_ctx, msg,
2456 session_entry);
2457 goto end;
2458 }
2459 if (eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE == session_entry->limMlmState
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 || (eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE ==
Deepak Dhamdhere9a7110c2015-11-08 19:44:07 -08002461 session_entry->limMlmState)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 msg_type = LIM_MLM_REASSOC_CNF;
2463 sub_type = LIM_REASSOC;
2464 /*
2465 * If Reassoc is happening for the same BSS, then
2466 * use the existing StaId and indicate to HAL to update
2467 * the existing STA entry.
2468 * If Reassoc is happening for the new BSS, then
2469 * old BSS and STA entry would have been already deleted
2470 * before PE tries to add BSS for the new BSS, so set the
2471 * updateSta to false and pass INVALID STA Index.
2472 */
2473 if (sir_compare_mac_addr(session_entry->bssId,
2474 session_entry->limReAssocbssId)) {
2475 sta_idx = session_entry->staId;
2476 update_sta = true;
2477 }
2478 }
2479
2480 if (add_bss_params == 0)
2481 goto end;
2482#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2483 if (session_entry->bRoamSynchInProgress)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302484 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 "LFR3:lim_process_sta_mlm_add_bss_rsp");
2486#endif
2487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302488 if (QDF_STATUS_SUCCESS == add_bss_params->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 if (eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE ==
2490 session_entry->limMlmState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 lim_log(mac_ctx, LOG1, FL("Mlm=%d %d"),
2492 session_entry->limMlmState,
2493 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 lim_process_sta_mlm_add_bss_rsp_ft(mac_ctx, msg,
2495 session_entry);
2496 goto end;
2497 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498
2499 /* Set MLME state */
2500 session_entry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2501 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2502 session_entry->peSessionId,
2503 session_entry->limMlmState));
2504 /* to know the session started for self or for peer */
2505 session_entry->statypeForBss = STA_ENTRY_PEER;
2506 /* Now, send WMA_ADD_STA_REQ */
2507 lim_log(mac_ctx, LOGW,
2508 FL("SessionId:%d On STA: ADD_BSS was successful"),
2509 session_entry->peSessionId);
2510 sta_ds =
2511 dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2512 &session_entry->dph.dphHashTable);
2513 if (sta_ds == NULL) {
2514 lim_log(mac_ctx, LOGE,
2515 FL("Session:%d Fail to add Self Entry for STA"),
2516 session_entry->peSessionId);
2517 mlm_assoc_cnf.resultCode =
2518 (tSirResultCodes) eSIR_SME_REFUSED;
2519 } else {
2520 session_entry->bssIdx =
2521 (uint8_t) add_bss_params->bssIdx;
2522 /* Success, handle below */
2523 sta_ds->bssId = add_bss_params->bssIdx;
2524 /*
2525 * STA Index(genr by HAL) for the BSS
2526 * entry is stored here
2527 */
2528 sta_ds->staIndex = add_bss_params->staContext.staIdx;
2529 sta_ds->ucUcastSig =
2530 add_bss_params->staContext.ucUcastSig;
2531 sta_ds->ucBcastSig =
2532 add_bss_params->staContext.ucBcastSig;
2533 /* Downgrade the EDCA parameters if needed */
2534 lim_set_active_edca_params(mac_ctx,
2535 session_entry->gLimEdcaParams, session_entry);
2536 lim_send_edca_params(mac_ctx,
2537 session_entry->gLimEdcaParamsActive,
2538 sta_ds->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 rrm_cache_mgmt_tx_power(mac_ctx,
2540 add_bss_params->txMgmtPower, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541 if (lim_add_sta_self(mac_ctx, sta_idx, update_sta,
2542 session_entry) != eSIR_SUCCESS) {
2543 /* Add STA context at HW */
2544 lim_log(mac_ctx, LOGE,
2545 FL("Session:%d could not Add Self"
2546 "Entry for the station"),
2547 session_entry->peSessionId);
2548 mlm_assoc_cnf.resultCode =
2549 (tSirResultCodes) eSIR_SME_REFUSED;
2550 }
2551 }
2552 } else {
2553 lim_log(mac_ctx, LOGP, FL("SessionId:%d ADD_BSS failed!"),
2554 session_entry->peSessionId);
Abhishek Singhac2be142015-12-03 16:16:25 +05302555 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 /* Return Assoc confirm to SME with failure */
2557 if (eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE ==
2558 session_entry->limMlmState)
2559 mlm_assoc_cnf.resultCode =
2560 (tSirResultCodes) eSIR_SME_FT_REASSOC_FAILURE;
2561 else
2562 mlm_assoc_cnf.resultCode =
2563 (tSirResultCodes) eSIR_SME_REFUSED;
Abhishek Singh96bda8e2015-12-03 16:45:35 +05302564 session_entry->add_bss_failed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 }
2566
2567 if (mlm_assoc_cnf.resultCode != eSIR_SME_SUCCESS) {
2568 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
2569 if (lim_set_link_state(mac_ctx, eSIR_LINK_IDLE_STATE,
2570 session_entry->bssId,
2571 session_entry->selfMacAddr,
2572 NULL, NULL) != eSIR_SUCCESS)
2573 lim_log(mac_ctx, LOGE, FL("Failed to set the LinkState"));
2574 /* Update PE session Id */
2575 mlm_assoc_cnf.sessionId = session_entry->peSessionId;
2576 lim_post_sme_message(mac_ctx, msg_type,
2577 (uint32_t *) &mlm_assoc_cnf);
2578 }
2579end:
2580 if (0 != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302581 qdf_mem_free(add_bss_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 msg->bodyptr = NULL;
2583 }
2584}
2585
2586/**
2587 * lim_process_mlm_add_bss_rsp() - Processes ADD BSS Response
2588 *
2589 * @mac_ctx - Pointer to Global MAC structure
2590 * @msg - The MsgQ header, which contains the response buffer
2591 *
2592 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2593 * Upon receipt of this message from HAL, MLME -
2594 * Determines the "state" in which this message was received
2595 * Forwards it to the appropriate callback
2596 *
2597 *LOGIC:
2598 * WMA_ADD_BSS_RSP can be received by MLME while the LIM is
2599 * in the following two states:
2600 * 1) As AP, LIM state = eLIM_SME_WT_START_BSS_STATE
2601 * 2) As STA, LIM state = eLIM_SME_WT_JOIN_STATE
2602 * Based on these two states, this API will determine where to
2603 * route the message to
2604 *
2605 * Return None
2606 */
2607void lim_process_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx,
2608 tpSirMsgQ msg)
2609{
2610 tLimMlmStartCnf mlm_start_cnf;
2611 tpPESession session_entry;
2612 tpAddBssParams add_bss_param = (tpAddBssParams) (msg->bodyptr);
2613 tSirBssType bss_type;
2614
2615 if (NULL == add_bss_param) {
2616 lim_log(mac_ctx, LOGE, FL("Encountered NULL Pointer"));
2617 return;
2618 }
2619
2620 /*
2621 * we need to process the deferred message since the
2622 * initiating req.there might be nested request.
2623 * in the case of nested request the new request initiated
2624 * from the response will take care of resetting the deffered
2625 * flag.
2626 */
2627 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
2628 /* Validate SME/LIM/MLME state */
2629 session_entry = pe_find_session_by_session_id(mac_ctx,
2630 add_bss_param->sessionId);
2631 if (session_entry == NULL) {
2632 lim_log(mac_ctx, LOGE, FL("SessionId:%d Session Doesn't exist"),
2633 add_bss_param->sessionId);
2634 if (NULL != add_bss_param) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302635 qdf_mem_free(add_bss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 msg->bodyptr = NULL;
2637 }
2638 return;
2639 }
2640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 bss_type = session_entry->bssType;
2642 /* update PE session Id */
2643 mlm_start_cnf.sessionId = session_entry->peSessionId;
2644 if (eSIR_IBSS_MODE == bss_type) {
2645 lim_process_ibss_mlm_add_bss_rsp(mac_ctx, msg, session_entry);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07002646 } else if (eSIR_NDI_MODE == session_entry->bssType) {
2647 lim_process_ndi_mlm_add_bss_rsp(mac_ctx, msg, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 } else {
2649 if (eLIM_SME_WT_START_BSS_STATE == session_entry->limSmeState) {
2650 if (eLIM_MLM_WT_ADD_BSS_RSP_STATE !=
2651 session_entry->limMlmState) {
2652 /* Mesg received from HAL in Invalid state! */
2653 lim_log(mac_ctx, LOGE,
2654 FL("SessionId:%d Received "
2655 " WMA_ADD_BSS_RSP in state %X"),
2656 session_entry->peSessionId,
2657 session_entry->limMlmState);
2658 mlm_start_cnf.resultCode =
2659 eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
2660 if (0 != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302661 qdf_mem_free(add_bss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 msg->bodyptr = NULL;
2663 }
2664 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
2665 (uint32_t *) &mlm_start_cnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 } else
2667 lim_process_ap_mlm_add_bss_rsp(mac_ctx, msg);
2668 } else {
2669 /* Called while processing assoc response */
2670 lim_process_sta_mlm_add_bss_rsp(mac_ctx, msg,
2671 session_entry);
2672 }
2673 }
2674
2675#ifdef WLAN_FEATURE_11W
2676 if (session_entry->limRmfEnabled) {
2677 if (eSIR_SUCCESS !=
2678 lim_send_exclude_unencrypt_ind(mac_ctx, false,
2679 session_entry)) {
2680 lim_log(mac_ctx, LOGE,
2681 FL("Failed to send Exclude Unencrypted Ind."));
2682 }
2683 }
2684#endif
2685}
2686
2687/**
2688 * lim_process_mlm_set_sta_key_rsp() - Process STA key response
2689 *
2690 * @mac_ctx: Pointer to Global MAC structure
2691 * @msg: The MsgQ header, which contains the response buffer
2692 *
2693 * This function is called to process the following two
2694 * messages from HAL:
2695 * 1) WMA_SET_BSSKEY_RSP
2696 * 2) WMA_SET_STAKEY_RSP
2697 * 3) WMA_SET_STA_BCASTKEY_RSP
2698 * Upon receipt of this message from HAL,
2699 * MLME -
2700 * > Determines the "state" in which this message was received
2701 * > Forwards it to the appropriate callback
2702 * LOGIC:
2703 * WMA_SET_BSSKEY_RSP/WMA_SET_STAKEY_RSP can be
2704 * received by MLME while in the following state:
2705 * MLME state = eLIM_MLM_WT_SET_BSS_KEY_STATE --OR--
2706 * MLME state = eLIM_MLM_WT_SET_STA_KEY_STATE --OR--
2707 * MLME state = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE
2708 * Based on this state, this API will determine where to
2709 * route the message to
2710 * Assumption:
2711 * ONLY the MLME state is being taken into account for now.
2712 * This is because, it appears that the handling of the
2713 * SETKEYS REQ is handled symmetrically on both the AP & STA
2714 *
2715 * Return: None
2716 */
2717void lim_process_mlm_set_sta_key_rsp(tpAniSirGlobal mac_ctx,
2718 tpSirMsgQ msg)
2719{
2720 uint8_t resp_reqd = 1;
2721 tLimMlmSetKeysCnf mlm_set_key_cnf;
2722 uint8_t session_id = 0;
2723 tpPESession session_entry;
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002724 uint16_t key_len;
2725 uint16_t result_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726
2727 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302728 qdf_mem_set((void *)&mlm_set_key_cnf, sizeof(tLimMlmSetKeysCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 if (NULL == msg->bodyptr) {
2730 PELOGE(lim_log(mac_ctx, LOGE, FL("msg bodyptr is NULL"));)
2731 return;
2732 }
2733 session_id = ((tpSetStaKeyParams) msg->bodyptr)->sessionId;
2734 session_entry = pe_find_session_by_session_id(mac_ctx, session_id);
2735 if (session_entry == NULL) {
2736 PELOGE(lim_log(mac_ctx, LOGE,
2737 FL("session does not exist for given session_id"));)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302738 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 msg->bodyptr = NULL;
2740 return;
2741 }
2742 if (eLIM_MLM_WT_SET_STA_KEY_STATE != session_entry->limMlmState) {
2743 /* Mesg received from HAL in Invalid state! */
2744 lim_log(mac_ctx, LOGE,
2745 FL("Received unexpected [Mesg Id - %d] in state %X"),
2746 msg->type, session_entry->limMlmState);
2747 /* There's not much that MLME can do at this stage... */
2748 resp_reqd = 0;
2749 } else {
2750 mlm_set_key_cnf.resultCode =
2751 (uint16_t)(((tpSetStaKeyParams) msg->bodyptr)->status);
2752 }
2753
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002754 result_status = (uint16_t)(((tpSetStaKeyParams) msg->bodyptr)->status);
2755 key_len = ((tpSetStaKeyParams)msg->bodyptr)->key[0].keyLength;
2756
2757 if (result_status == eSIR_SME_SUCCESS && key_len)
2758 mlm_set_key_cnf.key_len_nonzero = true;
2759 else
2760 mlm_set_key_cnf.key_len_nonzero = false;
2761
2762
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302763 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 msg->bodyptr = NULL;
2765 /* Restore MLME state */
2766 session_entry->limMlmState = session_entry->limPrevMlmState;
2767 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2768 session_entry->peSessionId, session_entry->limMlmState));
2769 if (resp_reqd) {
2770 tpLimMlmSetKeysReq lpLimMlmSetKeysReq =
2771 (tpLimMlmSetKeysReq) mac_ctx->lim.gpLimMlmSetKeysReq;
2772 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2773 if (NULL != lpLimMlmSetKeysReq) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05302774 qdf_copy_macaddr(&mlm_set_key_cnf.peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002775 &lpLimMlmSetKeysReq->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 /*
2777 * Free the buffer cached for the global
2778 * mac_ctx->lim.gpLimMlmSetKeysReq
2779 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302780 qdf_mem_free(mac_ctx->lim.gpLimMlmSetKeysReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 mac_ctx->lim.gpLimMlmSetKeysReq = NULL;
2782 }
2783 mlm_set_key_cnf.sessionId = session_id;
2784 lim_post_sme_message(mac_ctx, LIM_MLM_SETKEYS_CNF,
2785 (uint32_t *) &mlm_set_key_cnf);
2786 }
2787}
2788
2789/**
2790 * lim_process_mlm_set_bss_key_rsp() - handles BSS key
2791 *
2792 * @mac_ctx: A pointer to Global MAC structure
2793 * @msg: Message from SME
2794 *
2795 * This function processes BSS key response and updates
2796 * PE status accordingly.
2797 *
2798 * Return: NULL
2799 */
2800void lim_process_mlm_set_bss_key_rsp(tpAniSirGlobal mac_ctx,
2801 tpSirMsgQ msg)
2802{
2803 tLimMlmSetKeysCnf set_key_cnf;
2804 uint16_t result_status;
2805 uint8_t session_id = 0;
2806 tpPESession session_entry;
2807 tpLimMlmSetKeysReq set_key_req;
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002808 uint16_t key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809
2810 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302811 qdf_mem_set((void *)&set_key_cnf, sizeof(tLimMlmSetKeysCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 if (NULL == msg->bodyptr) {
2813 PELOGE(lim_log(mac_ctx, LOGE, FL("msg bodyptr is null"));)
2814 return;
2815 }
2816 session_id = ((tpSetBssKeyParams) msg->bodyptr)->sessionId;
2817 session_entry = pe_find_session_by_session_id(mac_ctx, session_id);
2818 if (session_entry == NULL) {
2819 PELOGE(lim_log(mac_ctx, LOGE,
2820 FL("session does not exist for given sessionId [%d]"),
2821 session_id);)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302822 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 msg->bodyptr = NULL;
2824 return;
2825 }
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002826 if (eLIM_MLM_WT_SET_BSS_KEY_STATE == session_entry->limMlmState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 result_status =
2828 (uint16_t)(((tpSetBssKeyParams)msg->bodyptr)->status);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002829 key_len = ((tpSetBssKeyParams)msg->bodyptr)->key[0].keyLength;
2830 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 /*
2832 * BCAST key also uses tpSetStaKeyParams.
2833 * Done this way for readabilty.
2834 */
2835 result_status =
2836 (uint16_t)(((tpSetStaKeyParams)msg->bodyptr)->status);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002837 key_len = ((tpSetStaKeyParams)msg->bodyptr)->key[0].keyLength;
2838 }
2839
2840 if (result_status == eSIR_SME_SUCCESS && key_len)
2841 set_key_cnf.key_len_nonzero = true;
2842 else
2843 set_key_cnf.key_len_nonzero = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844
2845 /* Validate MLME state */
2846 if (eLIM_MLM_WT_SET_BSS_KEY_STATE != session_entry->limMlmState &&
2847 eLIM_MLM_WT_SET_STA_BCASTKEY_STATE !=
2848 session_entry->limMlmState) {
2849 /* Msg received from HAL in Invalid state! */
2850 lim_log(mac_ctx, LOGE,
2851 FL("Received unexpected [Mesg Id - %d] in state %X"),
2852 msg->type, session_entry->limMlmState);
2853 } else {
2854 set_key_cnf.resultCode = result_status;
2855 }
2856
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302857 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 msg->bodyptr = NULL;
2859 /* Restore MLME state */
2860 session_entry->limMlmState = session_entry->limPrevMlmState;
2861
2862 MTRACE(mac_trace
2863 (mac_ctx, TRACE_CODE_MLM_STATE, session_entry->peSessionId,
2864 session_entry->limMlmState));
2865 set_key_req =
2866 (tpLimMlmSetKeysReq) mac_ctx->lim.gpLimMlmSetKeysReq;
2867 set_key_cnf.sessionId = session_id;
2868
2869 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2870 if (NULL != set_key_req) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05302871 qdf_copy_macaddr(&set_key_cnf.peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002872 &set_key_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 /*
2874 * Free the buffer cached for the
2875 * global mac_ctx->lim.gpLimMlmSetKeysReq
2876 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302877 qdf_mem_free(mac_ctx->lim.gpLimMlmSetKeysReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 mac_ctx->lim.gpLimMlmSetKeysReq = NULL;
2879 }
2880 lim_post_sme_message(mac_ctx, LIM_MLM_SETKEYS_CNF,
2881 (uint32_t *) &set_key_cnf);
2882}
2883
2884/**
2885 * lim_process_switch_channel_re_assoc_req()
2886 *
2887 ***FUNCTION:
2888 * This function is called to send the reassoc req mgmt frame after the
2889 * switchChannelRsp message is received from HAL.
2890 *
2891 ***LOGIC:
2892 *
2893 ***ASSUMPTIONS:
2894 * NA
2895 *
2896 ***NOTE:
2897 * NA
2898 *
2899 * @param pMac - Pointer to Global MAC structure.
2900 * @param psessionEntry - session related information.
2901 * @param status - channel switch success/failure.
2902 *
2903 * @return None
2904 */
2905static void lim_process_switch_channel_re_assoc_req(tpAniSirGlobal pMac,
2906 tpPESession psessionEntry,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302907 QDF_STATUS status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908{
2909 tLimMlmReassocCnf mlmReassocCnf;
2910 tLimMlmReassocReq *pMlmReassocReq;
2911 pMlmReassocReq =
2912 (tLimMlmReassocReq *) (psessionEntry->pLimMlmReassocReq);
2913 if (pMlmReassocReq == NULL) {
2914 lim_log(pMac, LOGP,
2915 FL
2916 ("pLimMlmReassocReq does not exist for given switchChanSession"));
2917 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2918 goto end;
2919 }
2920
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302921 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 PELOGE(lim_log(pMac, LOGE, FL("Change channel failed!!"));)
2923 mlmReassocCnf.resultCode = eSIR_SME_CHANNEL_SWITCH_FAIL;
2924 goto end;
2925 }
2926 /* / Start reassociation failure timer */
2927 MTRACE(mac_trace
2928 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
2929 eLIM_REASSOC_FAIL_TIMER));
2930 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2931 != TX_SUCCESS) {
2932 /* / Could not start reassoc failure timer. */
2933 /* Log error */
2934 lim_log(pMac, LOGP,
2935 FL("could not start Reassociation failure timer"));
2936 /* Return Reassoc confirm with */
2937 /* Resources Unavailable */
2938 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2939 goto end;
2940 }
2941 /* / Prepare and send Reassociation request frame */
2942 lim_send_reassoc_req_mgmt_frame(pMac, pMlmReassocReq, psessionEntry);
2943 return;
2944end:
2945 /* Free up buffer allocated for reassocReq */
2946 if (pMlmReassocReq != NULL) {
2947 /* Update PE session Id */
2948 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302949 qdf_mem_free(pMlmReassocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 psessionEntry->pLimMlmReassocReq = NULL;
2951 } else {
2952 mlmReassocCnf.sessionId = 0;
2953 }
2954
2955 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2956 /* Update PE sessio Id */
2957 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2958
2959 lim_post_sme_message(pMac, LIM_MLM_REASSOC_CNF,
2960 (uint32_t *) &mlmReassocCnf);
2961}
2962
2963
2964/**
2965 * lim_process_switch_channel_join_req() -Initiates probe request
2966 *
2967 * @mac_ctx - A pointer to Global MAC structure
2968 * @sessionEntry - session related information.
2969 * @status - channel switch success/failure
2970 *
2971 * This function is called to send the probe req mgmt frame
2972 * after the switchChannelRsp message is received from HAL.
2973 *
2974 * Return None
2975 */
2976static void lim_process_switch_channel_join_req(
2977 tpAniSirGlobal mac_ctx, tpPESession session_entry,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 QDF_STATUS status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979{
2980 tSirMacSSid ssId;
2981 tLimMlmJoinCnf join_cnf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 PELOGE(lim_log(mac_ctx, LOGE, FL("Change channel failed!!"));)
2984 goto error;
2985 }
2986
2987 if ((NULL == session_entry) || (NULL == session_entry->pLimMlmJoinReq)
2988 || (NULL == session_entry->pLimJoinReq)) {
2989 PELOGE(lim_log(mac_ctx, LOGE, FL("invalid pointer!!"));)
2990 goto error;
2991 }
2992
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 session_entry->limPrevMlmState = session_entry->limMlmState;
2994 session_entry->limMlmState = eLIM_MLM_WT_JOIN_BEACON_STATE;
2995 lim_log(mac_ctx, LOG1,
2996 FL("Sessionid %d prev lim state %d new lim state %d "
2997 "systemrole = %d"), session_entry->peSessionId,
2998 session_entry->limPrevMlmState,
2999 session_entry->limMlmState, GET_LIM_SYSTEM_ROLE(session_entry));
3000
3001 /* Apply previously set configuration at HW */
3002 lim_apply_configuration(mac_ctx, session_entry);
3003
3004 /*
3005 * If sendDeauthBeforeCon is enabled, Send Deauth first to AP if last
3006 * disconnection was caused by HB failure.
3007 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303008 if (mac_ctx->roam.configParam.sendDeauthBeforeCon) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009 int apCount;
3010
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303011 for (apCount = 0; apCount < 2; apCount++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303013 if (!qdf_mem_cmp(session_entry->pLimMlmJoinReq->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 mac_ctx->lim.gLimHeartBeatApMac[apCount], sizeof(tSirMacAddr))) {
3015
3016 lim_log(mac_ctx, LOGE, FL("Index %d Sessionid: %d Send deauth on "
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303017 "channel %d to BSSID: "MAC_ADDRESS_STR), apCount,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 session_entry->peSessionId, session_entry->currentOperChannel,
3019 MAC_ADDR_ARRAY(session_entry->pLimMlmJoinReq->bssDescription.
3020 bssId));
3021
3022 lim_send_deauth_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_REASON,
3023 session_entry->pLimMlmJoinReq->bssDescription.bssId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303024 session_entry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303026 qdf_mem_zero(mac_ctx->lim.gLimHeartBeatApMac[apCount],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 sizeof(tSirMacAddr));
3028 break;
3029 }
3030 }
3031 }
3032
3033 /* Wait for Beacon to announce join success */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303034 qdf_mem_copy(ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 session_entry->ssId.ssId, session_entry->ssId.length);
3036 ssId.length = session_entry->ssId.length;
3037
3038 lim_deactivate_and_change_timer(mac_ctx,
3039 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3040
3041 /* assign appropriate sessionId to the timer object */
3042 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId =
3043 session_entry->peSessionId;
3044 lim_log(mac_ctx, LOG1,
3045 FL("Sessionid: %d Send Probe req on channel %d ssid:%.*s "
3046 "BSSID: " MAC_ADDRESS_STR), session_entry->peSessionId,
3047 session_entry->currentOperChannel, ssId.length, ssId.ssId,
3048 MAC_ADDR_ARRAY(
3049 session_entry->pLimMlmJoinReq->bssDescription.bssId));
3050
3051 /*
3052 * We need to wait for probe response, so start join
3053 * timeout timer.This timer will be deactivated once
3054 * we receive probe response.
3055 */
3056 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
3057 session_entry->peSessionId, eLIM_JOIN_FAIL_TIMER));
3058 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimJoinFailureTimer) !=
3059 TX_SUCCESS) {
3060 lim_log(mac_ctx, LOGP,
3061 FL("couldn't activate Join failure timer"));
3062 session_entry->limMlmState = session_entry->limPrevMlmState;
3063 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
3064 session_entry->peSessionId,
3065 mac_ctx->lim.gLimMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 goto error;
3067 }
3068 /* include additional IE if there is */
3069 lim_send_probe_req_mgmt_frame(mac_ctx, &ssId,
3070 session_entry->pLimMlmJoinReq->bssDescription.bssId,
3071 session_entry->currentOperChannel, session_entry->selfMacAddr,
3072 session_entry->dot11mode,
3073 session_entry->pLimJoinReq->addIEScan.length,
3074 session_entry->pLimJoinReq->addIEScan.addIEdata);
3075
Anurag Chouhan6d760662016-02-20 16:05:43 +05303076 if (session_entry->pePersona == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 /* Activate Join Periodic Probe Req timer */
3078 if (tx_timer_activate
3079 (&mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer)
3080 != TX_SUCCESS) {
3081 lim_log(mac_ctx, LOGP,
3082 FL("Periodic JoinReq timer activate failed"));
3083 goto error;
3084 }
3085 }
3086 return;
3087error:
3088 if (NULL != session_entry) {
3089 if (session_entry->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303090 qdf_mem_free(session_entry->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 session_entry->pLimMlmJoinReq = NULL;
3092 }
3093 if (session_entry->pLimJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303094 qdf_mem_free(session_entry->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 session_entry->pLimJoinReq = NULL;
3096 }
3097 join_cnf.sessionId = session_entry->peSessionId;
3098 } else {
3099 join_cnf.sessionId = 0;
3100 }
3101 join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3102 join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3103 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF, (uint32_t *)&join_cnf);
3104}
3105
3106/**
3107 * lim_process_switch_channel_rsp()
3108 *
3109 ***FUNCTION:
3110 * This function is called to process switchChannelRsp message from HAL.
3111 *
3112 ***LOGIC:
3113 *
3114 ***ASSUMPTIONS:
3115 * NA
3116 *
3117 ***NOTE:
3118 * NA
3119 *
3120 * @param pMac - Pointer to Global MAC structure
3121 * @param body - message body.
3122 *
3123 * @return None
3124 */
3125void lim_process_switch_channel_rsp(tpAniSirGlobal pMac, void *body)
3126{
3127 tpSwitchChannelParams pChnlParams = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303128 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 uint16_t channelChangeReasonCode;
3130 uint8_t peSessionId;
3131 tpPESession psessionEntry;
3132 /* we need to process the deferred message since the initiating req. there might be nested request. */
3133 /* in the case of nested request the new request initiated from the response will take care of resetting */
3134 /* the deffered flag. */
3135 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3136 pChnlParams = (tpSwitchChannelParams) body;
3137 status = pChnlParams->status;
3138 peSessionId = pChnlParams->peSessionId;
3139
3140 psessionEntry = pe_find_session_by_session_id(pMac, peSessionId);
3141 if (psessionEntry == NULL) {
3142 lim_log(pMac, LOGP,
3143 FL("session does not exist for given sessionId"));
3144 return;
3145 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 /* HAL fills in the tx power used for mgmt frames in this field. */
3147 /* Store this value to use in TPC report IE. */
3148 rrm_cache_mgmt_tx_power(pMac, pChnlParams->txMgmtPower, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 channelChangeReasonCode = psessionEntry->channelChangeReasonCode;
3150 /* initialize it back to invalid id */
3151 psessionEntry->chainMask = pChnlParams->chainMask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 psessionEntry->smpsMode = pChnlParams->smpsMode;
3153 psessionEntry->channelChangeReasonCode = 0xBAD;
3154 lim_log(pMac, LOG1, FL("channelChangeReasonCode %d"),
3155 channelChangeReasonCode);
3156 switch (channelChangeReasonCode) {
3157 case LIM_SWITCH_CHANNEL_REASSOC:
3158 lim_process_switch_channel_re_assoc_req(pMac, psessionEntry, status);
3159 break;
3160 case LIM_SWITCH_CHANNEL_JOIN:
3161 lim_process_switch_channel_join_req(pMac, psessionEntry, status);
3162 break;
3163
3164 case LIM_SWITCH_CHANNEL_OPERATION:
3165 /*
3166 * The above code should also use the callback.
3167 * mechanism below, there is scope for cleanup here.
3168 * THat way all this response handler does is call the call back
3169 * We can get rid of the reason code here.
3170 */
3171 if (pMac->lim.gpchangeChannelCallback) {
3172 PELOG1(lim_log
3173 (pMac, LOG1,
3174 "Channel changed hence invoke registered call back");
3175 )
3176 pMac->lim.gpchangeChannelCallback(pMac, status,
3177 pMac->lim.
3178 gpchangeChannelData,
3179 psessionEntry);
3180 }
Chandrasekaran, Manishekarce7ab082016-02-02 10:24:15 +05303181 /* If MCC upgrade/DBS downgrade happended during channel switch,
3182 * the policy manager connection table needs to be updated.
3183 */
3184 cds_update_connection_info(psessionEntry->smeSessionId);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303185 if (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) {
3186 lim_log(pMac, LOG1,
3187 FL("Send p2p operating channel change conf action frame once first beacon is received on new channel"));
3188 psessionEntry->send_p2p_conf_frame = true;
3189 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 break;
3191 case LIM_SWITCH_CHANNEL_SAP_DFS:
3192 {
3193 /* Note: This event code specific to SAP mode
3194 * When SAP session issues channel change as performing
3195 * DFS, we will come here. Other sessions, for e.g. P2P
3196 * will have to define their own event code and channel
3197 * switch handler. This is required since the SME may
3198 * require completely different information for P2P unlike
3199 * SAP.
3200 */
3201 lim_send_sme_ap_channel_switch_resp(pMac, psessionEntry,
3202 pChnlParams);
Chandrasekaran, Manishekarce7ab082016-02-02 10:24:15 +05303203 /* If MCC upgrade/DBS downgrade happended during channel switch,
3204 * the policy manager connection table needs to be updated.
3205 */
3206 cds_update_connection_info(psessionEntry->smeSessionId);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05303207 cds_set_do_hw_mode_change_flag(true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 }
3209 break;
3210 default:
3211 break;
3212 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303213 qdf_mem_free(body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214}
3215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216void lim_send_beacon_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
3217{
3218 tBeaconGenParams *pBeaconGenParams = NULL;
3219 tSirMsgQ limMsg;
3220 /** Allocate the Memory for Beacon Pre Message and for Stations in PoweSave*/
3221 if (psessionEntry == NULL) {
3222 PELOGE(lim_log(pMac, LOGE,
3223 FL("Error:Unable to get the PESessionEntry"));
3224 )
3225 return;
3226 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303227 pBeaconGenParams = qdf_mem_malloc(sizeof(*pBeaconGenParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 if (NULL == pBeaconGenParams) {
3229 PELOGE(lim_log(pMac, LOGP,
3230 FL
3231 ("Unable to allocate memory during sending beaconPreMessage"));
3232 )
3233 return;
3234 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303235 qdf_mem_copy((void *)pBeaconGenParams->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303236 (void *)psessionEntry->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 limMsg.bodyptr = pBeaconGenParams;
3238 sch_process_pre_beacon_ind(pMac, &limMsg);
3239 return;
3240}
3241
3242#ifdef FEATURE_WLAN_SCAN_PNO
3243/**
3244 * lim_send_sme_scan_cache_updated_ind()
3245 *
3246 ***FUNCTION:
3247 * This function is used to post WMA_SME_SCAN_CACHE_UPDATED message to WMA.
3248 * This message is the indication to WMA that all scan cache results
3249 * are updated from LIM to SME. Mainly used only in PNO offload case.
3250 *
3251 ***LOGIC:
3252 *
3253 ***ASSUMPTIONS:
3254 * This function should be called after posting scan cache results to SME.
3255 *
3256 ***NOTE:
3257 * NA
3258 *
3259 * @return None
3260 */
Jeff Johnsona0495a62016-10-07 07:25:58 -07003261static void lim_send_sme_scan_cache_updated_ind(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262{
3263 cds_msg_t msg;
3264
3265 msg.type = WMA_SME_SCAN_CACHE_UPDATED;
3266 msg.reserved = 0;
3267 msg.bodyptr = NULL;
3268 msg.bodyval = sessionId;
3269
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303270 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05303271 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)))
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303272 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 "%s: Not able to post WMA_SME_SCAN_CACHE_UPDATED message to WMA",
3274 __func__);
3275}
3276#endif
3277
Jeff Johnsona0495a62016-10-07 07:25:58 -07003278static void lim_send_scan_offload_complete(tpAniSirGlobal pMac,
3279 tSirScanOffloadEvent *pScanEvent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280{
3281
3282 pMac->lim.gLimRspReqd = false;
3283 lim_send_sme_scan_rsp(pMac, pScanEvent->reasonCode,
3284 pScanEvent->sessionId, 0, pScanEvent->scanId);
3285#ifdef FEATURE_WLAN_SCAN_PNO
3286 lim_send_sme_scan_cache_updated_ind(pScanEvent->sessionId);
3287#endif
3288}
3289
3290void lim_process_rx_scan_event(tpAniSirGlobal pMac, void *buf)
3291{
3292 tSirScanOffloadEvent *pScanEvent = (tSirScanOffloadEvent *) buf;
3293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 switch (pScanEvent->event) {
Krishna Kumaar Natarajan3eed86b2016-03-25 16:55:21 -07003295 case SIR_SCAN_EVENT_STARTED:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 break;
Krishna Kumaar Natarajan3eed86b2016-03-25 16:55:21 -07003297 case SIR_SCAN_EVENT_START_FAILED:
3298 case SIR_SCAN_EVENT_COMPLETED:
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07003299 if (ROC_SCAN_REQUESTOR_ID == pScanEvent->requestor) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 lim_send_sme_roc_rsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303301 QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 pScanEvent->sessionId,
3303 pScanEvent->scanId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303304 qdf_mem_free(pMac->lim.gpLimRemainOnChanReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 pMac->lim.gpLimRemainOnChanReq = NULL;
3306 /*
3307 * If remain on channel timer expired and action frame
3308 * is pending then indicate confirmation with status
3309 * failure.
3310 */
3311 if (pMac->lim.mgmtFrameSessionId != 0xff) {
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303312 lim_p2p_action_cnf(pMac, NULL, false, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 pMac->lim.mgmtFrameSessionId = 0xff;
3314 }
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07003315 } else if (PREAUTH_REQUESTOR_ID == pScanEvent->requestor) {
3316 lim_preauth_scan_event_handler(pMac, pScanEvent->event,
3317 pScanEvent->sessionId,
3318 pScanEvent->scanId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 } else {
3320 lim_send_scan_offload_complete(pMac, pScanEvent);
3321 }
3322 break;
Krishna Kumaar Natarajan3eed86b2016-03-25 16:55:21 -07003323 case SIR_SCAN_EVENT_FOREIGN_CHANNEL:
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07003324 if (ROC_SCAN_REQUESTOR_ID == pScanEvent->requestor) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 /*Send Ready on channel indication to SME */
3326 if (pMac->lim.gpLimRemainOnChanReq) {
3327 lim_send_sme_roc_rsp(pMac,
3328 eWNI_SME_REMAIN_ON_CHN_RDY_IND,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303329 QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 pScanEvent->sessionId,
3331 pScanEvent->scanId);
3332 } else {
3333 lim_log(pMac, LOGE,
3334 FL("gpLimRemainOnChanReq is NULL"));
3335 }
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07003336 } else if (PREAUTH_REQUESTOR_ID == pScanEvent->requestor) {
3337 lim_preauth_scan_event_handler(pMac, pScanEvent->event,
3338 pScanEvent->sessionId,
3339 pScanEvent->scanId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 }
3341 break;
Krishna Kumaar Natarajan3eed86b2016-03-25 16:55:21 -07003342 case SIR_SCAN_EVENT_BSS_CHANNEL:
3343 case SIR_SCAN_EVENT_DEQUEUED:
3344 case SIR_SCAN_EVENT_PREEMPTED:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303346 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 "Received unhandled scan event %u",
3348 pScanEvent->event);
3349 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303350 qdf_mem_free(buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351}