blob: 7f484723eb21b6566b37b21170778cd7eb4fce3a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*
43 * Airgo Networks, Inc proprietary. All rights reserved.
44 * This file limProcessMlmRspMessages.cc contains the code
45 * for processing response messages from MLM state machine.
46 * Author: Chandra Modumudi
47 * Date: 02/11/02
48 * History:-
49 * Date Modified by Modification Information
50 * --------------------------------------------------------------------
51 *
52 */
53#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include "cfgApi.h"
56#include "sirApi.h"
57#include "schApi.h"
58#include "utilsApi.h"
59#include "limUtils.h"
60#include "limAssocUtils.h"
61#include "limSecurityUtils.h"
62#include "limSerDesUtils.h"
63#include "limTimerUtils.h"
64#include "limSendMessages.h"
65#include "limAdmitControl.h"
66#include "limSendMessages.h"
67#include "limIbssPeerMgmt.h"
68#include "limSession.h"
Jeff Johnsone7245742012-09-05 17:12:55 -070069#include "limSessionUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070070#if defined WLAN_FEATURE_VOWIFI
71#include "rrmApi.h"
72#endif
73#if defined WLAN_FEATURE_VOWIFI_11R
74#include <limFT.h>
75#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070076#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070077
78static void limHandleSmeJoinResult(tpAniSirGlobal, tSirResultCodes, tANI_U16,tpPESession);
Jeff Johnsone7245742012-09-05 17:12:55 -070079static void limHandleSmeReaasocResult(tpAniSirGlobal, tSirResultCodes, tANI_U16, tpPESession);
Jeff Johnson295189b2012-06-20 16:38:30 -070080void limProcessMlmScanCnf(tpAniSirGlobal, tANI_U32 *);
Jeff Johnsone7245742012-09-05 17:12:55 -070081#ifdef FEATURE_OEM_DATA_SUPPORT
82void limProcessMlmOemDataReqCnf(tpAniSirGlobal, tANI_U32 *);
83#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070084void limProcessMlmJoinCnf(tpAniSirGlobal, tANI_U32 *);
85void limProcessMlmAuthCnf(tpAniSirGlobal, tANI_U32 *);
86void limProcessMlmStartCnf(tpAniSirGlobal, tANI_U32 *);
87void limProcessMlmAuthInd(tpAniSirGlobal, tANI_U32 *);
88void limProcessMlmAssocInd(tpAniSirGlobal, tANI_U32 *);
89void limProcessMlmAssocCnf(tpAniSirGlobal, tANI_U32 *);
90void limProcessMlmReassocCnf(tpAniSirGlobal, tANI_U32 *);
91void limProcessMlmReassocInd(tpAniSirGlobal, tANI_U32 *);
92void limProcessMlmSetKeysCnf(tpAniSirGlobal, tANI_U32 *);
93void limProcessMlmDisassocInd(tpAniSirGlobal, tANI_U32 *);
94void limProcessMlmDisassocCnf(tpAniSirGlobal, tANI_U32 *);
95void limProcessMlmDeauthInd(tpAniSirGlobal, tANI_U32 *);
96void limProcessMlmDeauthCnf(tpAniSirGlobal, tANI_U32 *);
97void limProcessMlmPurgeStaInd(tpAniSirGlobal, tANI_U32 *);
98void limProcessMlmAddBACnf(tpAniSirGlobal, tANI_U32 *);
99void limProcessMlmDelBACnf(tpAniSirGlobal, tANI_U32 *);
100void limProcessMlmRemoveKeyCnf(tpAniSirGlobal pMac, tANI_U32 * pMsgBuf);
101static void limHandleDelBssInReAssocContext(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry);
102void limGetSessionInfo(tpAniSirGlobal pMac, tANI_U8 *, tANI_U8 *, tANI_U16 *);
103static void
104limProcessBtampAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry);
105/**
106 * limProcessMlmRspMessages()
107 *
108 *FUNCTION:
109 * This function is called to processes various MLM response (CNF/IND
110 * messages from MLM State machine.
111 *
112 *LOGIC:
113 *
114 *ASSUMPTIONS:
115 *
116 *NOTE:
117 *
118 * @param pMac Pointer to Global MAC structure
119 * @param msgType Indicates the MLM message type
120 * @param *pMsgBuf A pointer to the MLM message buffer
121 *
122 * @return None
123 */
124void
125limProcessMlmRspMessages(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
126{
127
128 if(pMsgBuf == NULL)
129 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700130 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 return;
132 }
133 switch (msgType)
134 {
135 case LIM_MLM_SCAN_CNF:
136 limProcessMlmScanCnf(pMac, pMsgBuf);
137 break;
138
Jeff Johnsone7245742012-09-05 17:12:55 -0700139#ifdef FEATURE_OEM_DATA_SUPPORT
140 case LIM_MLM_OEM_DATA_CNF:
141 limProcessMlmOemDataReqCnf(pMac, pMsgBuf);
142 break;
143#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145 case LIM_MLM_AUTH_CNF:
146 limProcessMlmAuthCnf(pMac, pMsgBuf);
147 break;
148 case LIM_MLM_AUTH_IND:
149 limProcessMlmAuthInd(pMac, pMsgBuf);
150 break;
151 case LIM_MLM_ASSOC_CNF:
152 limProcessMlmAssocCnf(pMac, pMsgBuf);
153 break;
154 case LIM_MLM_START_CNF:
155 limProcessMlmStartCnf(pMac, pMsgBuf);
156 break;
157 case LIM_MLM_JOIN_CNF:
158 limProcessMlmJoinCnf(pMac, pMsgBuf);
159 break;
160 case LIM_MLM_ASSOC_IND:
161 limProcessMlmAssocInd(pMac, pMsgBuf);
162 break;
163 case LIM_MLM_REASSOC_CNF:
164 limProcessMlmReassocCnf(pMac, pMsgBuf);
165 break;
166 case LIM_MLM_REASSOC_IND:
167 limProcessMlmReassocInd(pMac, pMsgBuf);
168 break;
169 case LIM_MLM_DISASSOC_CNF:
170 limProcessMlmDisassocCnf(pMac, pMsgBuf);
171 break;
172 case LIM_MLM_DISASSOC_IND:
173 limProcessMlmDisassocInd(pMac, pMsgBuf);
174 break;
175 case LIM_MLM_PURGE_STA_IND:
176 limProcessMlmPurgeStaInd(pMac, pMsgBuf);
177 break;
178 case LIM_MLM_DEAUTH_CNF:
179 limProcessMlmDeauthCnf(pMac, pMsgBuf);
180 break;
181 case LIM_MLM_DEAUTH_IND:
182 limProcessMlmDeauthInd(pMac, pMsgBuf);
183 break;
184 case LIM_MLM_SETKEYS_CNF:
185 limProcessMlmSetKeysCnf(pMac, pMsgBuf);
186 break;
187 case LIM_MLM_REMOVEKEY_CNF:
188 limProcessMlmRemoveKeyCnf(pMac, pMsgBuf);
189 break;
190 case LIM_MLM_TSPEC_CNF:
191 break;
192 case LIM_MLM_ADDBA_CNF:
193 limProcessMlmAddBACnf( pMac, pMsgBuf );
194 break;
195 case LIM_MLM_DELBA_CNF:
196 limProcessMlmDelBACnf( pMac, pMsgBuf );
197 break;
198 default:
199 break;
200 } // switch (msgType)
201 return;
202} /*** end limProcessMlmRspMessages() ***/
203
204/**
205 * limProcessMlmScanCnf()
206 *
207 *FUNCTION:
208 * This function is called to processes MLM_SCAN_CNF
209 * message from MLM State machine.
210 *
211 *LOGIC:
212 *
213 *ASSUMPTIONS:
214 *
215 *NOTE:
216 *
217 * @param pMac Pointer to Global MAC structure
218 * @param pMsgBuf A pointer to the MLM message buffer
219 *
220 * @return None
221 */
222void
223limProcessMlmScanCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
224{
225 switch(pMac->lim.gLimSmeState)
226 {
227 case eLIM_SME_WT_SCAN_STATE:
228 //case eLIM_SME_LINK_EST_WT_SCAN_STATE: //TO SUPPORT BT-AMP
229 //case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE: //TO SUPPORT BT-AMP
230 pMac->lim.gLimSmeState = pMac->lim.gLimPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700231 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 pMac->lim.gLimSystemInScanLearnMode = 0;
233 break;
234 default:
235 /**
236 * Should not have received scan confirm
237 * from MLM in other states.
238 * Log error
239 */
240 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700241 FL("received unexpected MLM_SCAN_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 pMac->lim.gLimSmeState);)
243 return;
244 }
245
246 /// Process received scan confirm
247 /// Increment length of cached scan results
248 pMac->lim.gLimSmeScanResultLength +=
249 ((tLimMlmScanCnf *) pMsgBuf)->scanResultLength;
250 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
251 {
252 tANI_U16 scanRspLen = 0;
253 /// Need to send response to Host
254 pMac->lim.gLimRspReqd = false;
255 if ((((tLimMlmScanCnf *) pMsgBuf)->resultCode ==
256 eSIR_SME_SUCCESS) ||
257 pMac->lim.gLimSmeScanResultLength)
258 {
259 scanRspLen = sizeof(tSirSmeScanRsp) +
260 pMac->lim.gLimSmeScanResultLength -
261 sizeof(tSirBssDescription);
262 }
263 else
264 {
265 scanRspLen = sizeof(tSirSmeScanRsp);
266 }
267 if(pMac->lim.gLimReportBackgroundScanResults)
268 {
269 pMac->lim.gLimBackgroundScanTerminate = TRUE;
270 }
271 if (pMac->lim.gLimSmeScanResultLength == 0)
272 {
273 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
274 }
275 else
276 {
277 limSendSmeScanRsp(pMac, scanRspLen,
278 eSIR_SME_SUCCESS,pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
279 }
280 } // if (pMac->lim.gLimRspReqd)
281 //check to see whether we need to run bgScan timer
282 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
283 {
284 if (tx_timer_activate(
285 &pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
286 {
287 /// Could not activate background scan timer.
288 // Log error
289 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700290 FL("could not activate background scan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 pMac->lim.gLimBackgroundScanStarted = FALSE;
292 }
293 else
294 {
295 pMac->lim.gLimBackgroundScanStarted = TRUE;
296 }
297 }
298} /*** end limProcessMlmScanCnf() ***/
299
Jeff Johnsone7245742012-09-05 17:12:55 -0700300#ifdef FEATURE_OEM_DATA_SUPPORT
301
302/**
303 * limProcessMlmOemDataReqCnf()
304 *
305 *FUNCTION:
306 * This function is called to processes LIM_MLM_OEM_DATA_REQ_CNF
307 * message from MLM State machine.
308 *
309 *LOGIC:
310 *
311 *ASSUMPTIONS:
312 *
313 *NOTE:
314 *
315 * @param pMac Pointer to Global MAC structure
316 * @param pMsgBuf A pointer to the MLM message buffer
317 *
318 * @return None
319 */
320
321void limProcessMlmOemDataReqCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
322{
323 tLimMlmOemDataRsp* measRsp;
324
325 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
326
327 measRsp = (tLimMlmOemDataRsp*)(pMsgBuf);
328
329 //Now send the meas confirm message to the sme
330 limSendSmeOemDataRsp(pMac, (tANI_U32*)measRsp, resultCode);
331
332 //Dont free the memory here. It will be freed up by the callee
333
334 return;
335}
336#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700337
338/**
339 * limProcessMlmStartCnf()
340 *
341 *FUNCTION:
342 * This function is called to processes MLM_START_CNF
343 * message from MLM State machine.
344 *
345 *LOGIC:
346 *
347 *ASSUMPTIONS:
348 *
349 *NOTE:
350 *
351 * @param pMac Pointer to Global MAC structure
352 * @param pMsgBuf A pointer to the MLM message buffer
353 *
354 * @return None
355 */
356void
357limProcessMlmStartCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
358{
359 tpPESession psessionEntry = NULL;
360 tLimMlmStartCnf *pLimMlmStartCnf;
361 tANI_U8 smesessionId;
362 tANI_U16 smetransactionId;
363
364 if(pMsgBuf == NULL)
365 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700366 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 return;
368 }
369 pLimMlmStartCnf = (tLimMlmStartCnf*)pMsgBuf;
370 if((psessionEntry = peFindSessionBySessionId(pMac,pLimMlmStartCnf->sessionId))==NULL)
371 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700372 PELOGE(limLog(pMac, LOGE,FL("Session does Not exist with given sessionId "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 return;
374 }
375 smesessionId = psessionEntry->smeSessionId;
376 smetransactionId = psessionEntry->transactionId;
377
378 if (psessionEntry->limSmeState != eLIM_SME_WT_START_BSS_STATE)
379 {
380 /**
381 * Should not have received Start confirm from MLM
382 * in other states.
383 * Log error
384 */
385 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700386 FL("received unexpected MLM_START_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 psessionEntry->limSmeState);)
388 return;
389 }
390 if (((tLimMlmStartCnf *) pMsgBuf)->resultCode ==
391 eSIR_SME_SUCCESS)
392 {
393
394 /**
395 * Update global SME state so that Beacon Generation
396 * module starts writing Beacon frames into TFP's
397 * Beacon file register.
398 */
399 psessionEntry->limSmeState = eLIM_SME_NORMAL_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700400 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 if(psessionEntry->bssType == eSIR_BTAMP_STA_MODE)
402 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700403 limLog(pMac, LOG1, FL("*** Started BSS in BT_AMP STA SIDE***"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 }
405 else if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
406 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700407 limLog(pMac, LOG1, FL("*** Started BSS in BT_AMP AP SIDE***"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 else if(psessionEntry->bssType == eSIR_INFRA_AP_MODE)
410 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700411 limLog(pMac, LOG1, FL("*** Started BSS in INFRA AP SIDE***"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 else
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700414 PELOG1(limLog(pMac, LOG1, FL("*** Started BSS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 }
416 else
417 {
418 /// Start BSS is a failure
419 peDeleteSession(pMac,psessionEntry);
420 psessionEntry = NULL;
421 }
422 /// Send response to Host
423 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP,
424 ((tLimMlmStartCnf *) pMsgBuf)->resultCode,psessionEntry,
425 smesessionId,smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 if (((tLimMlmStartCnf *) pMsgBuf)->resultCode == eSIR_SME_SUCCESS)
427 {
428 //Configure beacon and send beacons to HAL
429 limSendBeaconInd(pMac, psessionEntry);
430 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700431}
432
433 /*** end limProcessMlmStartCnf() ***/
434
435/**
436 * limProcessMlmJoinCnf()
437 *
438 *FUNCTION:
439 * This function is called to processes MLM_JOIN_CNF
440 * message from MLM State machine.
441 *
442 *LOGIC:
443 *
444 *ASSUMPTIONS:
445 *
446 *NOTE:
447 *
448 * @param pMac Pointer to Global MAC structure
449 * @param pMsgBuf A pointer to the MLM message buffer
450 *
451 * @return None
452 */
453void
454limProcessMlmJoinCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
455{
456 tSirResultCodes resultCode;
457 tLimMlmJoinCnf *pLimMlmJoinCnf;
458 tpPESession psessionEntry;
459 pLimMlmJoinCnf = (tLimMlmJoinCnf*)pMsgBuf;
460 if( (psessionEntry = peFindSessionBySessionId(pMac,pLimMlmJoinCnf->sessionId))== NULL)
461 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700462 PELOGE(limLog(pMac, LOGE,FL("Session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 return;
464 }
465
466 if (psessionEntry->limSmeState!= eLIM_SME_WT_JOIN_STATE)
467 {
468 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700469 FL("received unexpected MLM_JOIN_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 psessionEntry->limSmeState);)
471 return;
472 }
473
474 resultCode = ((tLimMlmJoinCnf *) pMsgBuf)->resultCode ;
475 /// Process Join confirm from MLM
476 if (resultCode == eSIR_SME_SUCCESS)
477 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700478 PELOG1(limLog(pMac, LOG1, FL("*** Joined ESS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 //Setup hardware upfront
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 //Done: 7-27-2009. JIM_FIX_ME sessionize the following function
481 if(limStaSendAddBssPreAssoc( pMac, false, psessionEntry) == eSIR_SUCCESS)
482 return;
483 else
484 resultCode = eSIR_SME_REFUSED;
485 }
486 {
487 /// Join failure
488 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700489 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 /// Send Join response to Host
491 limHandleSmeJoinResult(pMac, resultCode, ((tLimMlmJoinCnf *) pMsgBuf)->protStatusCode, psessionEntry );
492 }
493} /*** end limProcessMlmJoinCnf() ***/
494
495/**
496 * limProcessMlmAuthCnf()
497 *
498 *FUNCTION:
499 * This function is called to processes MLM_AUTH_CNF
500 * message from MLM State machine.
501 *
502 *LOGIC:
503 *
504 *ASSUMPTIONS:
505 *
506 *NOTE:
507 *
508 * @param pMac Pointer to Global MAC structure
509 * @param pMsgBuf A pointer to the MLM message buffer
510 *
511 * @return None
512 */
513void
514limProcessMlmAuthCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
515{
516 tANI_U16 caps;
517 tANI_U32 val;
518 tAniAuthType cfgAuthType, authMode;
519 tLimMlmAuthReq *pMlmAuthReq;
520 tLimMlmAssocReq *pMlmAssocReq;
521 tLimMlmAuthCnf *pMlmAuthCnf;
522 tpPESession psessionEntry;
523 tANI_U32 teleBcnEn = 0;
524// tANI_U8 sessionId;
525
526 if(pMsgBuf == NULL)
527 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700528 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 return;
530 }
531 pMlmAuthCnf = (tLimMlmAuthCnf*)pMsgBuf;
532 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAuthCnf->sessionId))== NULL)
533 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700534 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 return;
536 }
537
538 if (((psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
539 (psessionEntry->limSmeState != eLIM_SME_WT_PRE_AUTH_STATE)) ||
540 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
541 {
542 /**
543 * Should not have received AUTH confirm
544 * from MLM in other states or on AP.
545 * Log error
546 */
547 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700548 FL("received unexpected MLM_AUTH_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 psessionEntry->limSmeState);)
550 return;
551 }
552 /// Process AUTH confirm from MLM
553 if (((tLimMlmAuthCnf *) pMsgBuf)->resultCode != eSIR_SME_SUCCESS)
554 {
555 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
556 {
557 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE,
558 (tANI_U32 *) &cfgAuthType) != eSIR_SUCCESS)
559 {
560 /**
561 * Could not get AuthType value from CFG.
562 * Log error.
563 */
564 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700565 FL("could not retrieve AuthType value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 }
567 }
568 else
569 cfgAuthType = pMac->lim.gLimPreAuthType;
570
571 if ((cfgAuthType == eSIR_AUTO_SWITCH) &&
572 (((tLimMlmAuthCnf *) pMsgBuf)->authType == eSIR_OPEN_SYSTEM)
573 && (eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS == ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode))
574 {
575 /**
576 * When Open authentication fails with reason code "13" and
577 * authType set to 'auto switch', Try with Shared Authentication
578 */
579 authMode = eSIR_SHARED_KEY;
580 // Trigger MAC based Authentication
581 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmAuthReq, sizeof(tLimMlmAuthReq)))
582 {
583 // Log error
584 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700585 FL("call to palAllocateMemory failed for mlmAuthReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 return;
587 }
588 palZeroMemory( pMac->hHdd, (tANI_U8 *) pMlmAuthReq, sizeof(tLimMlmAuthReq));
589 val = sizeof(tSirMacAddr);
590 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
591 {
592 sirCopyMacAddr(pMlmAuthReq->peerMacAddr,psessionEntry->bssId);
593 }
594 else
595 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmAuthReq->peerMacAddr,
596 (tANI_U8 *) &pMac->lim.gLimPreAuthPeerAddr,
597 sizeof(tSirMacAddr));
598 pMlmAuthReq->authType = authMode;
599 /* Update PE session Id*/
600 pMlmAuthReq->sessionId = pMlmAuthCnf->sessionId;
601 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
602 (tANI_U32 *) &pMlmAuthReq->authFailureTimeout)
603 != eSIR_SUCCESS)
604 {
605 /**
606 * Could not get AuthFailureTimeout value from CFG.
607 * Log error.
608 */
609 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700610 FL("could not retrieve AuthFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 }
612 limPostMlmMessage(pMac,
613 LIM_MLM_AUTH_REQ,
614 (tANI_U32 *) pMlmAuthReq);
615 return;
616 }
617 else
618 {
619 // MAC based authentication failure
620 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
621 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700622 PELOGE(limLog(pMac, LOGE, FL("Auth Failure occurred."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700624 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700626 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
627
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 /**
629 * Need to send Join response with
630 * auth failure to Host.
631 */
632 limHandleSmeJoinResult(pMac,
633 ((tLimMlmAuthCnf *) pMsgBuf)->resultCode, ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode,psessionEntry);
634 }
635 else
636 {
637 /**
638 * Pre-authentication failure.
639 * Send Pre-auth failure response to host
640 */
641 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700642 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700643 limSendSmeAuthRsp(
644 pMac,
645 ((tLimMlmAuthCnf *) pMsgBuf)->resultCode,
646 ((tLimMlmAuthCnf *) pMsgBuf)->peerMacAddr,
647 ((tLimMlmAuthCnf *) pMsgBuf)->authType,
648 ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode,psessionEntry,psessionEntry->smeSessionId,psessionEntry->transactionId);
649 }
650 } // end if (cfgAuthType == eAUTO_SWITCH)
651 } // if (((tLimMlmAuthCnf *) pMsgBuf)->resultCode != ...
652 else
653 {
654 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
655 {
656 /**
657 * Successful MAC based authentication
658 * Trigger Association with BSS
659 */
660 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700661 FL("*** Authenticated with BSS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmAssocReq, sizeof(tLimMlmAssocReq)))
663 {
664 // Log error
665 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700666 FL("call to palAllocateMemory failed for mlmAssocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 return;
668 }
669 val = sizeof(tSirMacAddr);
670 #if 0
671 if (cfgGetStr(pMac, WNI_CFG_BSSID,
672 pMlmAssocReq->peerMacAddr,
673 &val) != eSIR_SUCCESS)
674 {
675 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700676 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678 #endif //SUPPORT BT-AMP
679 sirCopyMacAddr(pMlmAssocReq->peerMacAddr,psessionEntry->bssId);
680 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT,
681 (tANI_U32 *) &pMlmAssocReq->assocFailureTimeout)
682 != eSIR_SUCCESS)
683 {
684 /**
685 * Could not get AssocFailureTimeout value
686 * from CFG. Log error.
687 */
688 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700689 FL("could not retrieve AssocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 }
691 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
692 {
693 /**
694 * Could not get Capabilities value
695 * from CFG. Log error.
696 */
697 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700698 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 }
700 /*Clear spectrum management bit if AP doesn't support it*/
701 if(!(psessionEntry->pLimJoinReq->bssDescription.capabilityInfo & LIM_SPECTRUM_MANAGEMENT_BIT_MASK))
702 {
703 /*AP doesn't support spectrum management clear spectrum management bit*/
704 caps &= (~LIM_SPECTRUM_MANAGEMENT_BIT_MASK);
705 }
706
707 pMlmAssocReq->capabilityInfo = caps;
708 PELOG3(limLog(pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700709 FL("Capabilities to be used in AssocReq=0x%X, privacy bit=%x shortSlotTime %x"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 caps,
Jeff Johnsone7245742012-09-05 17:12:55 -0700711 ((tpSirMacCapabilityInfo) &pMlmAssocReq->capabilityInfo)->privacy,
712 ((tpSirMacCapabilityInfo) &pMlmAssocReq->capabilityInfo)->shortSlotTime);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713
714 /* If telescopic beaconing is enabled, set listen interval to
715 WNI_CFG_TELE_BCN_MAX_LI */
716 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
717 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700718 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700719
720 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
721
722 if(teleBcnEn)
723 {
724 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
725 eSIR_SUCCESS)
726 {
727 /**
728 * Could not get ListenInterval value
729 * from CFG. Log error.
730 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700731 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 }
733 }
734 else
735 {
736 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
737 {
738 /**
739 * Could not get ListenInterval value
740 * from CFG. Log error.
741 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700742 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 }
744 }
745
746 pMlmAssocReq->listenInterval = (tANI_U16)val;
747 /* Update PE session ID*/
748 pMlmAssocReq->sessionId = psessionEntry->peSessionId;
749 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
750 psessionEntry->limSmeState = eLIM_SME_WT_ASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700751 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 limPostMlmMessage(pMac,
753 LIM_MLM_ASSOC_REQ,
754 (tANI_U32 *) pMlmAssocReq);
755 }
756 else
757 {
758 /**
759 * Successful Pre-authentication.
760 * Send Pre-auth response to host
761 */
762 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700763 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 limSendSmeAuthRsp(
765 pMac,
766 ((tLimMlmAuthCnf *) pMsgBuf)->resultCode,
767 ((tLimMlmAuthCnf *) pMsgBuf)->peerMacAddr,
768 ((tLimMlmAuthCnf *) pMsgBuf)->authType,
769 ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode,psessionEntry,psessionEntry->smeSessionId,psessionEntry->transactionId);
770 }
771 } // end if (((tLimMlmAuthCnf *) pMsgBuf)->resultCode != ...
772} /*** end limProcessMlmAuthCnf() ***/
773
774/**
775 * limProcessMlmAssocCnf()
776 *
777 *FUNCTION:
778 * This function is called to processes MLM_ASSOC_CNF
779 * message from MLM State machine.
780 *
781 *LOGIC:
782 *
783 *ASSUMPTIONS:
784 *
785 *NOTE:
786 *
787 * @param pMac Pointer to Global MAC structure
788 * @param pMsgBuf A pointer to the MLM message buffer
789 *
790 * @return None
791 */
792void
793limProcessMlmAssocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
794{
795 tpPESession psessionEntry;
796 tLimMlmAssocCnf *pLimMlmAssocCnf;
797
798 if(pMsgBuf == NULL)
799 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700800 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 return;
802 }
803 pLimMlmAssocCnf = (tLimMlmAssocCnf*)pMsgBuf;
804 if((psessionEntry = peFindSessionBySessionId(pMac,pLimMlmAssocCnf->sessionId)) == NULL)
805 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700806 PELOGE(limLog(pMac, LOGE,FL("Session does not exist for given sessionId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 return;
808 }
809 if (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE ||
810 psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry ->limSystemRole == eLIM_BT_AMP_AP_ROLE)
811 {
812 /**
813 * Should not have received Assocication confirm
814 * from MLM in other states OR on AP.
815 * Log error
816 */
817 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700818 FL("received unexpected MLM_ASSOC_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 psessionEntry->limSmeState);)
820 return;
821 }
822 if (((tLimMlmAssocCnf *) pMsgBuf)->resultCode != eSIR_SME_SUCCESS)
823 {
824 // Association failure
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700825 PELOG1(limLog(pMac, LOG1, FL("*** Association failure ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700827 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 /**
829 * Need to send Join response with
830 * Association failure to Host.
831 */
832 limHandleSmeJoinResult(pMac,
833 ((tLimMlmAssocCnf *) pMsgBuf)->resultCode,
834 ((tLimMlmAssocCnf *) pMsgBuf)->protStatusCode,psessionEntry);
835 } // if (((tLimMlmAssocCnf *) pMsgBuf)->resultCode != ...
836 else
837 {
838 // Successful Association
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700839 PELOG1(limLog(pMac, LOG1, FL("*** Associated with BSS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 psessionEntry->limSmeState = eLIM_SME_LINK_EST_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700841 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 /**
843 * Need to send Join response with
844 * Association success to Host.
845 */
846 limHandleSmeJoinResult(pMac,
847 ((tLimMlmAssocCnf *) pMsgBuf)->resultCode,
848 ((tLimMlmAssocCnf *) pMsgBuf)->protStatusCode,psessionEntry);
849 } // end if (((tLimMlmAssocCnf *) pMsgBuf)->resultCode != ....
850} /*** end limProcessMlmAssocCnf() ***/
851
852/**
853 * limProcessMlmReassocCnf()
854 *
855 *FUNCTION:
856 * This function is called to processes MLM_REASSOC_CNF
857 * message from MLM State machine.
858 *
859 *LOGIC:
860 *
861 *ASSUMPTIONS:
862 *
863 *NOTE:
864 *
865 * @param pMac Pointer to Global MAC structure
866 * @param pMsgBuf A pointer to the MLM message buffer
867 *
868 * @return None
869 */
870void
871limProcessMlmReassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
872{
873 tpPESession psessionEntry;
874 tLimMlmReassocCnf *pLimMlmReassocCnf;
875
876 if(pMsgBuf == NULL)
877 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700878 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 return;
880 }
881 pLimMlmReassocCnf = (tLimMlmReassocCnf*) pMsgBuf;
882 if((psessionEntry = peFindSessionBySessionId(pMac,pLimMlmReassocCnf->sessionId))==NULL)
883 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700884 PELOGE(limLog(pMac, LOGE, FL("session Does not exist for given session Id"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 return;
886 }
887 if ((psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ||
888 (psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
889 {
890 /**
891 * Should not have received Reassocication confirm
892 * from MLM in other states OR on AP.
893 * Log error
894 */
895 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700896 FL("Rcv unexpected MLM_REASSOC_CNF in role %d, sme state 0x%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 psessionEntry->limSystemRole, psessionEntry->limSmeState);)
898 return;
899 }
900 if (psessionEntry->pLimReAssocReq) {
901 palFreeMemory( pMac->hHdd, psessionEntry->pLimReAssocReq);
902 psessionEntry->pLimReAssocReq = NULL;
903 }
904
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700905 PELOGE(limLog(pMac, LOGE, FL("Rcv MLM_REASSOC_CNF with result code %d"), pLimMlmReassocCnf->resultCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 if (pLimMlmReassocCnf->resultCode == eSIR_SME_SUCCESS) {
907 // Successful Reassociation
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700908 PELOG1(limLog(pMac, LOG1, FL("*** Reassociated with new BSS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700909
910 psessionEntry->limSmeState = eLIM_SME_LINK_EST_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700911 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913 /**
914 * Need to send Reassoc response with
915 * Reassociation success to Host.
916 */
917 limSendSmeJoinReassocRsp(
918 pMac, eWNI_SME_REASSOC_RSP,
919 pLimMlmReassocCnf->resultCode, pLimMlmReassocCnf->protStatusCode,psessionEntry,
920 psessionEntry->smeSessionId,psessionEntry->transactionId);
921 }else if (pLimMlmReassocCnf->resultCode == eSIR_SME_REASSOC_REFUSED) {
922 /** Reassociation failure With the New AP
923 * but we still have the link with the Older AP
924 */
925 psessionEntry->limSmeState = eLIM_SME_LINK_EST_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700926 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700927
928 /**
929 * Need to send Reassoc response with
930 * Association failure to Host.
931 */
932 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
933 pLimMlmReassocCnf->resultCode, pLimMlmReassocCnf->protStatusCode,psessionEntry,
934 psessionEntry->smeSessionId,psessionEntry->transactionId);
935 }else {
936 // Reassociation failure
937 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700938 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 /**
940 * Need to send Reassoc response with
941 * Association failure to Host.
942 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700943 limHandleSmeReaasocResult(pMac, pLimMlmReassocCnf->resultCode, pLimMlmReassocCnf->protStatusCode, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 }
945} /*** end limProcessMlmReassocCnf() ***/
946
947/**
948 * limProcessMlmReassocInd()
949 *
950 *FUNCTION:
951 * This function is called to processes MLM_REASSOC_IND
952 * message from MLM State machine.
953 *
954 *LOGIC:
955 *
956 *ASSUMPTIONS:
957 *
958 *NOTE:
959 *
960 * @param pMac Pointer to Global MAC structure
961 * @param pMsgBuf A pointer to the MLM message buffer
962 *
963 * @return None
964 */
965void
966limProcessMlmReassocInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
967{
968 tANI_U32 len;
969 tSirMsgQ msgQ;
970 tSirSmeReassocInd *pSirSmeReassocInd;
971 tpDphHashNode pStaDs=0;
972 tpPESession psessionEntry;
973 tANI_U8 sessionId;
974 if(pMsgBuf == NULL)
975 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700976 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 return;
978 }
979 if((psessionEntry = peFindSessionByBssid(pMac,((tpLimMlmReassocInd)pMsgBuf)->peerMacAddr, &sessionId))== NULL)
980 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700981 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 return;
983 }
984 /// Inform Host of STA reassociation
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 len = sizeof(tSirSmeReassocInd);
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeReassocInd, len))
987 {
988 // Log error
989 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700990 FL("call to palAllocateMemory failed for eWNI_SME_REASSOC_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 return;
992
993 }
994 sirStoreU16N((tANI_U8 *) &pSirSmeReassocInd->messageType,
995 eWNI_SME_REASSOC_IND);
996 limReassocIndSerDes(pMac, (tpLimMlmReassocInd) pMsgBuf,
997 (tANI_U8 *) &(pSirSmeReassocInd->length), psessionEntry);
998
999 // Required for indicating the frames to upper layer
1000 pSirSmeReassocInd->assocReqLength = ((tpLimMlmReassocInd) pMsgBuf)->assocReqLength;
1001 pSirSmeReassocInd->assocReqPtr = ((tpLimMlmReassocInd) pMsgBuf)->assocReqPtr;
1002 pSirSmeReassocInd->beaconPtr = psessionEntry->beacon;
1003 pSirSmeReassocInd->beaconLength = psessionEntry->bcnLen;
1004
1005 msgQ.type = eWNI_SME_REASSOC_IND;
1006 msgQ.bodyptr = pSirSmeReassocInd;
1007 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001008 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001009#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1010 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_IND_EVENT, psessionEntry, 0, 0);
1011#endif //FEATURE_WLAN_DIAG_SUPPORT
1012 pStaDs = dphGetHashEntry(pMac, ((tpLimMlmReassocInd) pMsgBuf)->aid, &psessionEntry->dph.dphHashTable);
1013 if (! pStaDs)
1014 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001015 limLog( pMac, LOGP, FL("MLM ReAssocInd: Station context no longer valid (aid %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 ((tpLimMlmReassocInd) pMsgBuf)->aid);
1017 palFreeMemory(pMac->hHdd, pSirSmeReassocInd);
1018 return;
1019 }
1020
1021 limSysProcessMmhMsgApi(pMac, &msgQ, ePROT);
1022 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001023 FL("Create CNF_WAIT_TIMER after received LIM_MLM_REASSOC_IND"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 /*
1025 ** turn on a timer to detect the loss of REASSOC CNF
1026 **/
1027 limActivateCnfTimer(pMac,
1028 (tANI_U16) ((tpLimMlmReassocInd) pMsgBuf)->aid, psessionEntry);
1029} /*** end limProcessMlmReassocInd() ***/
1030
1031/**
1032 * limProcessMlmAuthInd()
1033 *
1034 *FUNCTION:
1035 * This function is called to processes MLM_AUTH_IND
1036 * message from MLM State machine.
1037 *
1038 *LOGIC:
1039 *
1040 *ASSUMPTIONS:
1041 *
1042 *NOTE:
1043 *
1044 * @param pMac Pointer to Global MAC structure
1045 * @param pMsgBuf A pointer to the MLM message buffer
1046 *
1047 * @return None
1048 */
1049void
1050limProcessMlmAuthInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1051{
1052 tSirMsgQ msgQ;
1053 tSirSmeAuthInd *pSirSmeAuthInd;
1054
1055 if(pMsgBuf == NULL)
1056 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001057 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 return;
1059 }
1060 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeAuthInd, sizeof(tSirSmeAuthInd)))
1061 {
1062 // Log error
1063 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001064 FL("call to palAllocateMemory failed for eWNI_SME_AUTH_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 }
1066 limCopyU16((tANI_U8 *) &pSirSmeAuthInd->messageType, eWNI_SME_AUTH_IND);
1067 limAuthIndSerDes(pMac, (tpLimMlmAuthInd) pMsgBuf,
1068 (tANI_U8 *) &(pSirSmeAuthInd->length));
1069 msgQ.type = eWNI_SME_AUTH_IND;
1070 msgQ.bodyptr = pSirSmeAuthInd;
1071 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001072 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001073#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1074 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_IND_EVENT, NULL, 0, 0);
1075#endif //FEATURE_WLAN_DIAG_SUPPORT
1076 limSysProcessMmhMsgApi(pMac, &msgQ, ePROT);
1077} /*** end limProcessMlmAuthInd() ***/
1078
1079
1080
1081
1082void
1083limFillAssocIndParams(tpAniSirGlobal pMac, tpLimMlmAssocInd pAssocInd,
1084 tSirSmeAssocInd *pSirSmeAssocInd,
1085 tpPESession psessionEntry)
1086{
1087 pSirSmeAssocInd->length = sizeof(tSirSmeAssocInd);
1088 pSirSmeAssocInd->sessionId = psessionEntry->smeSessionId;
1089
1090 // Required for indicating the frames to upper layer
1091 pSirSmeAssocInd->assocReqLength = pAssocInd->assocReqLength;
1092 pSirSmeAssocInd->assocReqPtr = pAssocInd->assocReqPtr;
1093
1094 pSirSmeAssocInd->beaconPtr = psessionEntry->beacon;
1095 pSirSmeAssocInd->beaconLength = psessionEntry->bcnLen;
1096
1097 // Fill in peerMacAddr
1098 palCopyMemory( pMac->hHdd, pSirSmeAssocInd->peerMacAddr, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
1099 // Fill in aid
1100 pSirSmeAssocInd->aid = pAssocInd->aid;
1101 // Fill in bssId
1102 palCopyMemory( pMac->hHdd, pSirSmeAssocInd->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
1103 // Fill in staId
1104 //pSirSmeAssocInd->staId = psessionEntry->staId;
1105 // Fill in authType
1106 pSirSmeAssocInd->authType = pAssocInd->authType;
1107 // Fill in ssId
1108 palCopyMemory( pMac->hHdd, (tANI_U8*)&pSirSmeAssocInd->ssId,
1109 (tANI_U8 *) &(pAssocInd->ssId), pAssocInd->ssId.length + 1);
1110 pSirSmeAssocInd->rsnIE.length = pAssocInd->rsnIE.length;
1111 palCopyMemory( pMac->hHdd, (tANI_U8*) &pSirSmeAssocInd->rsnIE.rsnIEdata,
1112 (tANI_U8 *) &(pAssocInd->rsnIE.rsnIEdata),
1113 pAssocInd->rsnIE.length);
1114
1115 pSirSmeAssocInd->addIE.length = pAssocInd->addIE.length;
1116 palCopyMemory( pMac->hHdd, (tANI_U8*) &pSirSmeAssocInd->addIE.addIEdata,
1117 (tANI_U8 *) &(pAssocInd->addIE.addIEdata),
1118 pAssocInd->addIE.length);
1119
1120 // Copy the new TITAN capabilities
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 pSirSmeAssocInd->spectrumMgtIndicator = pAssocInd->spectrumMgtIndicator;
1122 if (pAssocInd->spectrumMgtIndicator == eSIR_TRUE)
1123 {
1124 pSirSmeAssocInd->powerCap.minTxPower = pAssocInd->powerCap.minTxPower;
1125 pSirSmeAssocInd->powerCap.maxTxPower = pAssocInd->powerCap.maxTxPower;
1126 pSirSmeAssocInd->supportedChannels.numChnl = pAssocInd->supportedChannels.numChnl;
1127 palCopyMemory( pMac->hHdd, (tANI_U8*) &pSirSmeAssocInd->supportedChannels.channelList,
1128 (tANI_U8 *) &(pAssocInd->supportedChannels.channelList),
1129 pAssocInd->supportedChannels.numChnl);
1130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 // Fill in WmmInfo
1132 pSirSmeAssocInd->wmmEnabledSta = pAssocInd->WmmStaInfoPresent;
Jeff Johnson295189b2012-06-20 16:38:30 -07001133} /*** end limAssocIndSerDes() ***/
1134
1135
1136
1137/**
1138 * limProcessMlmAssocInd()
1139 *
1140 *FUNCTION:
1141 * This function is called to processes MLM_ASSOC_IND
1142 * message from MLM State machine.
1143 *
1144 *LOGIC:
1145 *
1146 *ASSUMPTIONS:
1147 *
1148 *NOTE:
1149 *
1150 * @param pMac Pointer to Global MAC structure
1151 * @param pMsgBuf A pointer to the MLM message buffer
1152 *
1153 * @return None
1154 */
1155void
1156limProcessMlmAssocInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1157{
1158 tANI_U32 len;
1159 tSirMsgQ msgQ;
1160 tSirSmeAssocInd *pSirSmeAssocInd;
1161 tpDphHashNode pStaDs=0;
1162 tpPESession psessionEntry;
1163 if(pMsgBuf == NULL)
1164 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001165 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 return;
1167 }
1168 if((psessionEntry = peFindSessionBySessionId(pMac,((tpLimMlmAssocInd) pMsgBuf)->sessionId))== NULL)
1169 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001170 limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 return;
1172 }
1173 /// Inform Host of STA association
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 len = sizeof(tSirSmeAssocInd);
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeAssocInd, len))
1176 {
1177 // Log error
1178 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001179 FL("call to palAllocateMemory failed for eWNI_SME_ASSOC_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 return;
1181 }
1182
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 pSirSmeAssocInd->messageType = eWNI_SME_ASSOC_IND;
1184 limFillAssocIndParams(pMac, (tpLimMlmAssocInd) pMsgBuf, pSirSmeAssocInd, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 msgQ.type = eWNI_SME_ASSOC_IND;
1186 msgQ.bodyptr = pSirSmeAssocInd;
1187 msgQ.bodyval = 0;
1188 pStaDs = dphGetHashEntry(pMac,
1189 ((tpLimMlmAssocInd) pMsgBuf)->aid, &psessionEntry->dph.dphHashTable);
1190 if (! pStaDs)
1191 { // good time to panic...
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001192 limLog(pMac, LOGE, FL("MLM AssocInd: Station context no longer valid (aid %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 ((tpLimMlmAssocInd) pMsgBuf)->aid);
1194 palFreeMemory(pMac->hHdd, pSirSmeAssocInd);
1195
1196 return;
1197 }
1198 pSirSmeAssocInd->staId = pStaDs->staIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 pSirSmeAssocInd->reassocReq = pStaDs->mlmStaContext.subType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001200 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001201#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1202 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_IND_EVENT, psessionEntry, 0, 0);
1203#endif //FEATURE_WLAN_DIAG_SUPPORT
1204 limSysProcessMmhMsgApi(pMac, &msgQ, ePROT);
1205
1206 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001207 FL("Create CNF_WAIT_TIMER after received LIM_MLM_ASSOC_IND"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 /*
1209 ** turn on a timer to detect the loss of ASSOC CNF
1210 **/
1211 limActivateCnfTimer(pMac, (tANI_U16) ((tpLimMlmAssocInd) pMsgBuf)->aid, psessionEntry);
1212
1213// Enable this Compile flag to test the BT-AMP -AP assoc sequence
1214#ifdef TEST_BTAMP_AP
1215//tANI_U32 *pMsgBuf;
1216{
1217 tpSirSmeAssocCnf pSmeAssoccnf;
1218 if(!palAllocateMemory(pMac->hHdd,(void **)&pSmeAssoccnf,sizeof(tSirSmeAssocCnf)))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001219 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory failed for pSmeAssoccnf "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 pSmeAssoccnf->messageType = eWNI_SME_ASSOC_CNF;
1221 pSmeAssoccnf->length = sizeof(tSirSmeAssocCnf);
1222 palCopyMemory( pMac->hHdd,pSmeAssoccnf->peerMacAddr,((tpLimMlmAssocInd)pMsgBuf)->peerMacAddr,6);
1223 pSmeAssoccnf->statusCode = eSIR_SME_SUCCESS;
1224 pSmeAssoccnf->aid = ((tpLimMlmAssocInd)pMsgBuf)->aid;
1225 palCopyMemory( pMac->hHdd, pSmeAssoccnf->alternateBssId,pSmeAssoccnf->peerMacAddr,sizeof(tSirMacAddr));
1226 pSmeAssoccnf->alternateChannelId = 6;
1227 palCopyMemory( pMac->hHdd,pSmeAssoccnf->bssId,psessionEntry->selfMacAddr,6);
1228 pMsgBuf = (tANI_U32)pSmeAssoccnf;
1229 __limProcessSmeAssocCnfNew(pMac, eWNI_SME_ASSOC_CNF, pMsgBuf);
1230 palFreeMemory(pMac->hHdd,pSmeAssoccnf);
1231}
1232#endif
1233
1234
1235} /*** end limProcessMlmAssocInd() ***/
1236
1237
1238
1239
1240/**
1241 * limProcessMlmDisassocInd()
1242 *
1243 *FUNCTION:
1244 * This function is called to processes MLM_DISASSOC_IND
1245 * message from MLM State machine.
1246 *
1247 *LOGIC:
1248 *
1249 *ASSUMPTIONS:
1250 *
1251 *NOTE:
1252 *
1253 * @param pMac Pointer to Global MAC structure
1254 * @param pMsgBuf A pointer to the MLM message buffer
1255 *
1256 * @return None
1257 */
1258void
1259limProcessMlmDisassocInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1260{
1261 tLimMlmDisassocInd *pMlmDisassocInd;
1262 tpPESession psessionEntry;
1263 pMlmDisassocInd = (tLimMlmDisassocInd *) pMsgBuf;
1264 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocInd->sessionId) )== NULL)
1265 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001266 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 return;
1268 }
1269 switch (psessionEntry->limSystemRole)
1270 {
1271 case eLIM_STA_IN_IBSS_ROLE:
1272 break;
1273 case eLIM_STA_ROLE:
1274 case eLIM_BT_AMP_STA_ROLE:
1275 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001276 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 break;
1278 default: // eLIM_AP_ROLE //eLIM_BT_AMP_AP_ROLE
1279 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001280 FL("*** Peer staId=%d Disassociated ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 pMlmDisassocInd->aid);)
1282 // Send SME_DISASOC_IND after Polaris cleanup
1283 // (after receiving LIM_MLM_PURGE_STA_IND)
1284 break;
1285 } // end switch (psessionEntry->limSystemRole)
1286} /*** end limProcessMlmDisassocInd() ***/
1287
1288/**
1289 * limProcessMlmDisassocCnf()
1290 *
1291 *FUNCTION:
1292 * This function is called to processes MLM_DISASSOC_CNF
1293 * message from MLM State machine.
1294 *
1295 *LOGIC:
1296 *
1297 *ASSUMPTIONS:
1298 *
1299 *NOTE:
1300 *
1301 * @param pMac Pointer to Global MAC structure
1302 * @param pMsgBuf A pointer to the MLM message buffer
1303 *
1304 * @return None
1305 */
1306void
1307limProcessMlmDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1308{
1309 tSirResultCodes resultCode;
1310 tLimMlmDisassocCnf *pMlmDisassocCnf;
1311 tpPESession psessionEntry;
1312 pMlmDisassocCnf = (tLimMlmDisassocCnf *) pMsgBuf;
1313 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocCnf->sessionId))== NULL)
1314 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001315 PELOGE(limLog(pMac, LOGE,FL("session Does not exist for given session Id"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 return;
1317 }
1318 resultCode = (tSirResultCodes)
1319 (pMlmDisassocCnf->disassocTrigger ==
1320 eLIM_LINK_MONITORING_DISASSOC) ?
1321 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
1322 pMlmDisassocCnf->resultCode;
1323 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
1324 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 // Disassociate Confirm from MLM
1326 if ( (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
1327 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE) )
1328 {
1329 /**
1330 * Should not have received
1331 * Disassocate confirm
1332 * from MLM in other states.
1333 * Log error
1334 */
1335 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001336 FL("received unexpected MLM_DISASSOC_CNF in state %X"),psessionEntry->limSmeState);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 return;
1338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 if (pMac->lim.gLimRspReqd)
1340 pMac->lim.gLimRspReqd = false;
1341 if (pMlmDisassocCnf->disassocTrigger ==
1342 eLIM_PROMISCUOUS_MODE_DISASSOC)
1343 {
1344 if (pMlmDisassocCnf->resultCode != eSIR_SME_SUCCESS)
1345 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
1346 else
1347 psessionEntry->limSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001348 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 // Send Promiscuous mode response to host
1350 limSendSmePromiscuousModeRsp(pMac);
1351 }
1352 else
1353 {
1354 if (pMlmDisassocCnf->resultCode != eSIR_SME_SUCCESS)
1355 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
1356 else
1357 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001358 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 limSendSmeDisassocNtf(pMac, pMlmDisassocCnf->peerMacAddr,
1360 resultCode,
1361 pMlmDisassocCnf->disassocTrigger,
1362 pMlmDisassocCnf->aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
1363 }
1364 }
1365 else if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
1366 {
1367 limSendSmeDisassocNtf(pMac, pMlmDisassocCnf->peerMacAddr,
1368 resultCode,
1369 pMlmDisassocCnf->disassocTrigger,
1370 pMlmDisassocCnf->aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
1371 }
1372} /*** end limProcessMlmDisassocCnf() ***/
1373
1374/**
1375 * limProcessMlmDeauthInd()
1376 *
1377 *FUNCTION:
1378 * This function is called to processes MLM_DEAUTH_IND
1379 * message from MLM State machine.
1380 *
1381 *LOGIC:
1382 *
1383 *ASSUMPTIONS:
1384 *
1385 *NOTE:
1386 *
1387 * @param pMac Pointer to Global MAC structure
1388 * @param pMsgBuf A pointer to the MLM message buffer
1389 *
1390 * @return None
1391 */
1392void
1393limProcessMlmDeauthInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1394{
1395 tLimMlmDeauthInd *pMlmDeauthInd;
1396 tpPESession psessionEntry;
1397 tANI_U8 sessionId;
1398 pMlmDeauthInd = (tLimMlmDeauthInd *) pMsgBuf;
1399 if((psessionEntry = peFindSessionByBssid(pMac,pMlmDeauthInd->peerMacAddr,&sessionId))== NULL)
1400 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001401 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 return;
1403 }
1404 switch (psessionEntry->limSystemRole)
1405 {
1406 case eLIM_STA_IN_IBSS_ROLE:
1407 break;
1408 case eLIM_STA_ROLE:
1409 case eLIM_BT_AMP_STA_ROLE:
1410 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001411 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001412
1413 default: // eLIM_AP_ROLE
1414 {
1415 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001416 FL("*** Received Deauthentication from staId=%d ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 pMlmDeauthInd->aid);)
1418 }
1419 // Send SME_DEAUTH_IND after Polaris cleanup
1420 // (after receiving LIM_MLM_PURGE_STA_IND)
1421 break;
1422 } // end switch (psessionEntry->limSystemRole)
1423} /*** end limProcessMlmDeauthInd() ***/
1424
1425/**
1426 * limProcessMlmDeauthCnf()
1427 *
1428 *FUNCTION:
1429 * This function is called to processes MLM_DEAUTH_CNF
1430 * message from MLM State machine.
1431 *
1432 *LOGIC:
1433 *
1434 *ASSUMPTIONS:
1435 *
1436 *NOTE:
1437 *
1438 * @param pMac Pointer to Global MAC structure
1439 * @param pMsgBuf A pointer to the MLM message buffer
1440 *
1441 * @return None
1442 */
1443void
1444limProcessMlmDeauthCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1445{
1446 tANI_U16 aid;
1447 tSirResultCodes resultCode;
1448 tLimMlmDeauthCnf *pMlmDeauthCnf;
1449 tpPESession psessionEntry;
1450
1451 if(pMsgBuf == NULL)
1452 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001453 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 return;
1455 }
1456 pMlmDeauthCnf = (tLimMlmDeauthCnf *) pMsgBuf;
1457 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthCnf->sessionId))==NULL)
1458 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001459 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given session Id "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 return;
1461 }
1462
1463 resultCode = (tSirResultCodes)
1464 (pMlmDeauthCnf->deauthTrigger ==
1465 eLIM_LINK_MONITORING_DEAUTH) ?
1466 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
1467 pMlmDeauthCnf->resultCode;
1468 aid = (psessionEntry->limSystemRole == eLIM_AP_ROLE) ?
1469 pMlmDeauthCnf->aid : 1;
1470 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
1471 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 // Deauth Confirm from MLM
1473 if (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE)
1474 {
1475 /**
1476 * Should not have received Deauth confirm
1477 * from MLM in other states.
1478 * Log error
1479 */
1480 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001481 FL("received unexpected MLM_DEAUTH_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 psessionEntry->limSmeState);)
1483 return;
1484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 if (pMlmDeauthCnf->resultCode == eSIR_SME_SUCCESS)
1486 {
1487 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
1488 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001489 FL("*** Deauthenticated with BSS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 }
1491 else
1492 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -07001493 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001494
1495 if (pMac->lim.gLimRspReqd)
1496 pMac->lim.gLimRspReqd = false;
1497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 // On STA or on BASIC AP, send SME_DEAUTH_RSP to host
1499 limSendSmeDeauthNtf(pMac, pMlmDeauthCnf->peerMacAddr,
1500 resultCode,
1501 pMlmDeauthCnf->deauthTrigger,
1502 aid,psessionEntry->smeSessionId,psessionEntry->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001503} /*** end limProcessMlmDeauthCnf() ***/
1504
1505/**
1506 * limProcessMlmPurgeStaInd()
1507 *
1508 *FUNCTION:
1509 * This function is called to processes MLM_PURGE_STA_IND
1510 * message from MLM State machine.
1511 *
1512 *LOGIC:
1513 *
1514 *ASSUMPTIONS:
1515 *
1516 *NOTE:
1517 *
1518 * @param pMac Pointer to Global MAC structure
1519 * @param pMsgBuf A pointer to the MLM message buffer
1520 *
1521 * @return None
1522 */
1523void
1524limProcessMlmPurgeStaInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1525{
1526 tSirResultCodes resultCode;
1527 tpLimMlmPurgeStaInd pMlmPurgeStaInd;
1528 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 if(pMsgBuf == NULL)
1530 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001531 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 return;
1533 }
1534 pMlmPurgeStaInd = (tpLimMlmPurgeStaInd) pMsgBuf;
1535 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmPurgeStaInd->sessionId))==NULL)
1536 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001537 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 return;
1539 }
1540 // Purge STA indication from MLM
1541 resultCode = (tSirResultCodes) pMlmPurgeStaInd->reasonCode;
1542 switch (psessionEntry->limSystemRole)
1543 {
1544 case eLIM_STA_IN_IBSS_ROLE:
1545 break;
1546 case eLIM_STA_ROLE:
1547 case eLIM_BT_AMP_STA_ROLE:
1548 default: // eLIM_AP_ROLE
1549 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
1550 (psessionEntry->limSmeState !=
1551 eLIM_SME_WT_DISASSOC_STATE) &&
1552 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
1553 {
1554 /**
1555 * Should not have received
1556 * Purge STA indication
1557 * from MLM in other states.
1558 * Log error
1559 */
1560 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001561 FL("received unexpected MLM_PURGE_STA_IND in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 psessionEntry->limSmeState);)
1563 break;
1564 }
1565 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001566 FL("*** Polaris cleanup completed for staId=%d ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 pMlmPurgeStaInd->aid);)
1568 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
1569 {
1570 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001571 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001572
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 }
1574 if (pMlmPurgeStaInd->purgeTrigger == eLIM_PEER_ENTITY_DEAUTH)
1575 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 limSendSmeDeauthNtf(pMac,
1577 pMlmPurgeStaInd->peerMacAddr,
1578 resultCode,
1579 pMlmPurgeStaInd->purgeTrigger,
1580 pMlmPurgeStaInd->aid,psessionEntry->smeSessionId,psessionEntry->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 }
1582 else
1583 limSendSmeDisassocNtf(pMac,
1584 pMlmPurgeStaInd->peerMacAddr,
1585 resultCode,
1586 pMlmPurgeStaInd->purgeTrigger,
1587 pMlmPurgeStaInd->aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
1588 } // end switch (psessionEntry->limSystemRole)
1589} /*** end limProcessMlmPurgeStaInd() ***/
1590
1591/**
1592 * limProcessMlmSetKeysCnf()
1593 *
1594 *FUNCTION:
1595 * This function is called to processes MLM_SETKEYS_CNF
1596 * message from MLM State machine.
1597 *
1598 *LOGIC:
1599 *
1600 *ASSUMPTIONS:
1601 *
1602 *NOTE:
1603 *
1604 * @param pMac Pointer to Global MAC structure
1605 * @param pMsgBuf A pointer to the MLM message buffer
1606 *
1607 * @return None
1608 */
1609void
1610limProcessMlmSetKeysCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1611{
1612 // Prepare and send SME_SETCONTEXT_RSP message
Jeff Johnsone7245742012-09-05 17:12:55 -07001613 tLimMlmSetKeysCnf *pMlmSetKeysCnf;
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 tpPESession psessionEntry;
1615
1616 if(pMsgBuf == NULL)
1617 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001618 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001619 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 }
1621 pMlmSetKeysCnf = (tLimMlmSetKeysCnf *) pMsgBuf;
1622 if ((psessionEntry = peFindSessionBySessionId(pMac, pMlmSetKeysCnf->sessionId))== NULL)
1623 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001624 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 return;
1626 }
1627 limLog( pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001628 FL("Received MLM_SETKEYS_CNF with resultCode = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 pMlmSetKeysCnf->resultCode );
1630 limSendSmeSetContextRsp(pMac,
1631 pMlmSetKeysCnf->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 (tSirResultCodes) pMlmSetKeysCnf->resultCode,psessionEntry,psessionEntry->smeSessionId,
1634 psessionEntry->transactionId);
1635} /*** end limProcessMlmSetKeysCnf() ***/
1636/**
1637 * limProcessMlmRemoveKeyCnf()
1638 *
1639 *FUNCTION:
1640 * This function is called to processes MLM_REMOVEKEY_CNF
1641 * message from MLM State machine.
1642 *
1643 *LOGIC:
1644 *
1645 *ASSUMPTIONS:
1646 *
1647 *NOTE:
1648 *
1649 * @param pMac Pointer to Global MAC structure
1650 * @param pMsgBuf A pointer to the MLM message buffer
1651 *
1652 * @return None
1653 */
1654void
1655limProcessMlmRemoveKeyCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1656{
1657 // Prepare and send SME_REMOVECONTEXT_RSP message
Jeff Johnsone7245742012-09-05 17:12:55 -07001658 tLimMlmRemoveKeyCnf *pMlmRemoveKeyCnf;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 tpPESession psessionEntry;
1660
1661 if(pMsgBuf == NULL)
1662 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001663 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001664 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 }
1666 pMlmRemoveKeyCnf = (tLimMlmRemoveKeyCnf *) pMsgBuf;
1667 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyCnf->sessionId))== NULL)
1668 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001669 PELOGE(limLog(pMac, LOGE,FL("session Does not exist for given session Id"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 return;
1671 }
1672 limLog( pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001673 FL("Received MLM_REMOVEKEYS_CNF with resultCode = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 pMlmRemoveKeyCnf->resultCode );
1675 limSendSmeRemoveKeyRsp(pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001676 pMlmRemoveKeyCnf->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 (tSirResultCodes) pMlmRemoveKeyCnf->resultCode,psessionEntry,
1678 psessionEntry->smeSessionId,psessionEntry->transactionId);
1679} /*** end limProcessMlmRemoveKeyCnf() ***/
1680
1681
1682/**
1683 * limHandleSmeJoinResult()
1684 *
1685 *FUNCTION:
1686 * This function is called to process join/auth/assoc failures
1687 * upon receiving MLM_JOIN/AUTH/ASSOC_CNF with a failure code or
1688 * MLM_ASSOC_CNF with a success code in case of STA role and
1689 * MLM_JOIN_CNF with success in case of STA in IBSS role.
1690 *
1691 *LOGIC:
1692 *
1693 *ASSUMPTIONS:
1694 *
1695 *NOTE:
1696 *
1697 * @param pMac Pointer to Global MAC structure
1698 * @param resultCode Failure code to be sent
1699 *
1700 *
1701 * @return None
1702 */
1703static void
1704limHandleSmeJoinResult(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode, tpPESession psessionEntry)
1705{
1706 tpDphHashNode pStaDs = NULL;
1707 tANI_U8 smesessionId;
1708 tANI_U16 smetransactionId;
1709
1710 /* Newly Added on oct 11 th*/
1711 if(psessionEntry == NULL)
1712 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001713 PELOGE(limLog(pMac, LOGE,FL("psessionEntry is NULL "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 return;
1715 }
1716 smesessionId = psessionEntry->smeSessionId;
1717 smetransactionId = psessionEntry->transactionId;
1718 /* When associations is failed , delete the session created and pass NULL to limsendsmeJoinReassocRsp() */
1719 if(resultCode != eSIR_SME_SUCCESS)
1720 {
1721 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
1722 if (pStaDs != NULL)
1723 {
1724 pStaDs->mlmStaContext.disassocReason = eSIR_MAC_UNSPEC_FAILURE_REASON;
1725 pStaDs->mlmStaContext.cleanupTrigger = eLIM_JOIN_FAILURE;
1726 pStaDs->mlmStaContext.resultCode = resultCode;
1727 pStaDs->mlmStaContext.protStatusCode = protStatusCode;
1728 //Done: 7-27-2009. JIM_FIX_ME: at the end of limCleanupRxPath, make sure PE is sending eWNI_SME_JOIN_RSP to SME
1729 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001730 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq);
1731 psessionEntry->pLimJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 return;
1733 }
1734 }
1735
1736 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq);
1737 psessionEntry->pLimJoinReq = NULL;
1738 //Delete teh session if JOIN failure occurred.
1739 if(resultCode != eSIR_SME_SUCCESS)
1740 {
1741 if(NULL != psessionEntry)
1742 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001743 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE,psessionEntry->bssId,
1744 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001745 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 peDeleteSession(pMac,psessionEntry);
1747 psessionEntry = NULL;
1748 }
1749 }
1750 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, resultCode, protStatusCode,psessionEntry,
1751 smesessionId, smetransactionId);
1752} /*** end limHandleSmeJoinResult() ***/
1753
1754/**
Jeff Johnsone7245742012-09-05 17:12:55 -07001755 * limHandleSmeReaasocResult()
1756 *
1757 *FUNCTION:
1758 * This function is called to process reassoc failures
1759 * upon receiving REASSOC_CNF with a failure code or
1760 * MLM_REASSOC_CNF with a success code in case of STA role
1761 *
1762 *LOGIC:
1763 *
1764 *ASSUMPTIONS:
1765 *
1766 *NOTE:
1767 *
1768 * @param pMac Pointer to Global MAC structure
1769 * @param resultCode Failure code to be sent
1770 *
1771 *
1772 * @return None
1773 */
1774static void
1775limHandleSmeReaasocResult(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode, tpPESession psessionEntry)
1776{
1777 tpDphHashNode pStaDs = NULL;
1778 tANI_U8 smesessionId;
1779 tANI_U16 smetransactionId;
1780
1781 if(psessionEntry == NULL)
1782 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001783 PELOGE(limLog(pMac, LOGE,FL("psessionEntry is NULL "));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001784 return;
1785 }
1786 smesessionId = psessionEntry->smeSessionId;
1787 smetransactionId = psessionEntry->transactionId;
1788 /* When associations is failed , delete the session created and pass NULL to limsendsmeJoinReassocRsp() */
1789 if(resultCode != eSIR_SME_SUCCESS)
1790 {
1791 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
1792 if (pStaDs != NULL)
1793 {
1794 pStaDs->mlmStaContext.disassocReason = eSIR_MAC_UNSPEC_FAILURE_REASON;
1795 pStaDs->mlmStaContext.cleanupTrigger = eLIM_JOIN_FAILURE;
1796 pStaDs->mlmStaContext.resultCode = resultCode;
1797 pStaDs->mlmStaContext.protStatusCode = protStatusCode;
1798 limCleanupRxPath(pMac, pStaDs, psessionEntry);
1799 return;
1800 }
1801 }
1802
1803 //Delete teh session if REASSOC failure occurred.
1804 if(resultCode != eSIR_SME_SUCCESS)
1805 {
1806 if(NULL != psessionEntry)
1807 {
1808 peDeleteSession(pMac,psessionEntry);
1809 psessionEntry = NULL;
1810 }
1811 }
1812 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP, resultCode, protStatusCode,psessionEntry,
1813 smesessionId, smetransactionId);
1814} /*** end limHandleSmeReassocResult() ***/
1815
1816/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 * limProcessMlmAddStaRsp()
1818 *
1819 *FUNCTION:
1820 * This function is called to process a WDA_ADD_STA_RSP from HAL.
1821 * Upon receipt of this message from HAL, MLME -
1822 * > Determines the "state" in which this message was received
1823 * > Forwards it to the appropriate callback
1824 *
1825 *ASSUMPTIONS:
1826 *
1827 *NOTE:
1828 *
1829 * @param pMac Pointer to Global MAC structure
1830 * @param tSirMsgQ The MsgQ header, which contains the response buffer
1831 *
1832 * @return None
1833 */
1834void limProcessMlmAddStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry )
1835{
1836 //we need to process the deferred message since the initiating req. there might be nested request.
1837 //in the case of nested request the new request initiated from the response will take care of resetting
1838 //the deffered flag.
1839 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 || (psessionEntry->limSystemRole == eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 )
1843 {
1844 limProcessBtAmpApMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
1845 return;
1846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 limProcessStaMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001848}
1849void limProcessStaMlmAddStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry)
1850{
1851 tLimMlmAssocCnf mlmAssocCnf;
1852 tpDphHashNode pStaDs;
1853 tANI_U32 mesgType = LIM_MLM_ASSOC_CNF;
1854 tpAddStaParams pAddStaParams = (tpAddStaParams) limMsgQ->bodyptr;
1855
1856 if(NULL == pAddStaParams )
1857 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001858 limLog( pMac, LOGE, FL( "Encountered NULL Pointer" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 return;
1860 }
1861 if( eHAL_STATUS_SUCCESS == pAddStaParams->status )
1862 {
1863 if( eLIM_MLM_WT_ADD_STA_RSP_STATE != psessionEntry->limMlmState)
1864 {
1865 //TODO: any response to be sent out here ?
1866 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001867 FL( "Received unexpected WDA_ADD_STA_RSP in state %X" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 psessionEntry->limMlmState);
1869 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
1870 goto end;
1871 }
1872 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
1873 mesgType = LIM_MLM_REASSOC_CNF;
1874 //
1875 // Update the DPH Hash Entry for this STA
1876 // with proper state info
1877 //
1878 pStaDs = dphGetHashEntry( pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
1879 if( NULL != pStaDs)
1880 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1881 else
1882 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001883 FL( "Unable to get the DPH Hash Entry for AID - %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 DPH_STA_HASH_INDEX_PEER);
1885 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001886 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 /*
1888 * Storing the self StaIndex(Generated by HAL) in session context,
1889 * instead of storing it in DPH Hash entry for Self STA.
1890 * DPH entry for the self STA stores the sta index for the BSS entry
1891 * to which the STA is associated.
1892 */
1893 psessionEntry->staId = pAddStaParams->staIdx;
1894 //if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state
Yathish9f22e662012-12-10 14:21:35 -08001895#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
1896 if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
1897#endif
1898 {
1899 limReactivateHeartBeatTimer(pMac, psessionEntry);
1900 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001901 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_KEEPALIVE_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001902
1903 //assign the sessionId to the timer Object
1904 pMac->lim.limTimers.gLimKeepaliveTimer.sessionId = psessionEntry->peSessionId;
1905 if (tx_timer_activate(&pMac->lim.limTimers.gLimKeepaliveTimer) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001906 limLog(pMac, LOGP, FL("Cannot activate keepalive timer."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001907#ifdef WLAN_DEBUG
1908 pMac->lim.gLimNumLinkEsts++;
1909#endif
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07001910#ifdef FEATURE_WLAN_TDLS
1911 /* initialize TDLS peer related data */
1912 limInitTdlsData(pMac,psessionEntry);
1913#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 // Return Assoc confirm to SME with success
1915 // FIXME_GEN4 - Need the correct ASSOC RSP code to
1916 // be passed in here....
1917 //mlmAssocCnf.resultCode = (tSirResultCodes) assoc.statusCode;
1918 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_SUCCESS;
1919 }
1920 else
1921 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301922 limLog( pMac, LOGE, FL( "ADD_STA failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
1924 }
1925end:
1926 if( 0 != limMsgQ->bodyptr )
1927 {
1928 palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
1929 }
1930 /* Updating PE session Id*/
1931 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
1932 limPostSmeMessage( pMac, mesgType, (tANI_U32 *) &mlmAssocCnf );
1933 return;
1934}
1935void limProcessMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
1936{
1937 //we need to process the deferred message since the initiating req. there might be nested request.
1938 //in the case of nested request the new request initiated from the response will take care of resetting
1939 //the deffered flag.
1940 // tpPESession psessionEntry;
1941 // tpDeleteBssParams pDeleteBssParams =( tpDeleteBssParams)limMsgQ->bodyptr;
1942 // if((psessionEntry = peFindSessionBySessionId(pMac,pDeleteBssParams->sessionId)) == NULL)
1943 // {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001944 // limLog( pMac, LOGE, FL( "Session deos not exist with given sessionId" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 // return;
1946 // }
1947 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07001948
1949 if (((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
1950 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 || (psessionEntry->limSystemRole == eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 ) &&
1953 (psessionEntry->statypeForBss == STA_ENTRY_SELF))
1954 {
1955 limProcessBtAmpApMlmDelBssRsp(pMac, limMsgQ,psessionEntry);
1956 return;
1957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 limProcessStaMlmDelBssRsp(pMac, limMsgQ,psessionEntry);
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08001959
1960 if(!limIsInMCC(pMac))
1961 {
1962 WDA_TrafficStatsTimerActivate(FALSE);
1963 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001964
1965#ifdef WLAN_FEATURE_11W
1966 if (psessionEntry->limRmfEnabled)
1967 {
1968 if ( eSIR_SUCCESS != limSendExcludeUnencryptInd(pMac, TRUE, psessionEntry) )
1969 {
1970 limLog( pMac, LOGE,
1971 FL( "Could not send down Exclude Unencrypted Indication!" ),
1972 psessionEntry->limMlmState );
1973 }
1974 }
1975#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001976}
1977
1978void limProcessStaMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
1979{
1980 tpDeleteBssParams pDelBssParams = (tpDeleteBssParams) limMsgQ->bodyptr;
1981 tpDphHashNode pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
1982 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05301983
1984 if (NULL == pDelBssParams)
1985 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001986 limLog( pMac, LOGE, FL( "Invalid body pointer in message"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05301987 goto end;
1988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 if( eHAL_STATUS_SUCCESS == pDelBssParams->status )
1990 {
1991 PELOGW(limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001992 FL( "STA received the DEL_BSS_RSP for BSSID: %X."),pDelBssParams->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
1994 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1995
1996 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001997 PELOGE(limLog( pMac, LOGE, FL( "Failure in setting link state to IDLE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 statusCode = eSIR_SME_REFUSED;
1999 goto end;
2000 }
2001 if(pStaDs == NULL)
2002 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002003 limLog( pMac, LOGE, FL( "DPH Entry for STA 1 missing."));
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 statusCode = eSIR_SME_REFUSED;
2005 goto end;
2006 }
2007 if( eLIM_MLM_WT_DEL_BSS_RSP_STATE != pStaDs->mlmStaContext.mlmState)
2008 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002009 PELOGE(limLog( pMac, LOGE, FL( "Received unexpected WDA_DEL_BSS_RSP in state %X" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 pStaDs->mlmStaContext.mlmState);)
2011 statusCode = eSIR_SME_REFUSED;
2012 goto end;
2013 }
2014 PELOG1(limLog( pMac, LOG1, FL("STA AssocID %d MAC "), pStaDs->assocId );
2015 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
2016 }
2017 else
2018 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05302019 limLog( pMac, LOGE, FL( "DEL BSS failed!" ) );
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302020 palFreeMemory( pMac->hHdd, (void *) pDelBssParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 return;
2022 }
2023 end:
2024 if( 0 != limMsgQ->bodyptr )
2025 {
2026 palFreeMemory( pMac->hHdd, (void *) pDelBssParams );
2027 }
2028 if(pStaDs == NULL)
2029 return;
2030 if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2031 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE &&
2032 psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE) &&
2033 pStaDs->mlmStaContext.cleanupTrigger != eLIM_JOIN_FAILURE)
2034 {
2035 /** The Case where the DelBss is invoked from
2036 * context of other than normal DisAssoc / Deauth OR
2037 * as part of Join Failure.
2038 */
2039 limHandleDelBssInReAssocContext(pMac, pStaDs,psessionEntry);
2040 return;
2041 }
2042 limPrepareAndSendDelStaCnf(pMac, pStaDs, statusCode,psessionEntry);
2043 return;
2044}
2045
Jeff Johnson295189b2012-06-20 16:38:30 -07002046void limProcessBtAmpApMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2047{
2048 tSirResultCodes rc = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002049 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 tpDeleteBssParams pDelBss = (tpDeleteBssParams) limMsgQ->bodyptr;
2051 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
2052
2053 if(psessionEntry == NULL)
2054 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002055 limLog(pMac, LOGE,FL("Session entry passed is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002056 if(pDelBss != NULL)
2057 palFreeMemory( pMac->hHdd, (void *) pDelBss );
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 return;
2059 }
2060
2061 if (pDelBss == NULL)
2062 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002063 PELOGE(limLog(pMac, LOGE, FL("BSS: DEL_BSS_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 rc = eSIR_SME_REFUSED;
2065 goto end;
2066 }
2067 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002068 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
2069
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 if( eLIM_MLM_WT_DEL_BSS_RSP_STATE != psessionEntry->limMlmState)
2071 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002072 limLog( pMac, LOGE,
Jeff Johnson43971f52012-07-17 12:26:56 -07002073 FL( "Received unexpected WDA_DEL_BSS_RSP in state %X" ),
2074 psessionEntry->limMlmState);
Jeff Johnsone7245742012-09-05 17:12:55 -07002075 rc = eSIR_SME_REFUSED;
2076 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 }
2078 if (pDelBss->status != eHAL_STATUS_SUCCESS)
2079 {
2080 limLog(pMac, LOGE, FL("BSS: DEL_BSS_RSP error (%x) Bss %d "),
2081 pDelBss->status, pDelBss->bssIdx);
2082 rc = eSIR_SME_STOP_BSS_FAILURE;
2083 goto end;
2084 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002085 status = limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 psessionEntry->selfMacAddr, NULL, NULL);
Jeff Johnson43971f52012-07-17 12:26:56 -07002087 if (status != eSIR_SUCCESS)
2088 {
2089 rc = eSIR_SME_REFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 goto end;
Jeff Johnson43971f52012-07-17 12:26:56 -07002091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 /** Softmac may send all the buffered packets right after resuming the transmission hence
2093 * to occupy the medium during non channel occupancy period. So resume the transmission after
2094 * HAL gives back the response.
2095 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002096#if 0 //TODO: How to handle this per session
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 if (LIM_IS_RADAR_DETECTED(pMac))
2098 {
2099 limFrameTransmissionControl(pMac, eLIM_TX_BSS_BUT_BEACON, eLIM_RESUME_TX);
2100 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
2101 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);//TBD-RAJESH is it needed ?
2104 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 //Initialize number of associated stations during cleanup
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002106 psessionEntry->gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 end:
2108 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, rc, psessionEntry->smeSessionId, psessionEntry->transactionId);
2109 peDeleteSession(pMac, psessionEntry);
2110
2111 if(pDelBss != NULL)
2112 palFreeMemory( pMac->hHdd, (void *) pDelBss );
2113}
2114
2115void limProcessMlmDelStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
2116{
2117 //we need to process the deferred message since the initiating req. there might be nested request.
2118 //in the case of nested request the new request initiated from the response will take care of resetting
2119 //the deffered flag.
2120
2121 tpPESession psessionEntry;
2122 tpDeleteStaParams pDeleteStaParams;
2123 pDeleteStaParams = (tpDeleteStaParams)limMsgQ->bodyptr;
2124 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302125
2126 if(NULL == pDeleteStaParams ||
2127 NULL == (psessionEntry = peFindSessionBySessionId(pMac, pDeleteStaParams->sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002129 limLog(pMac, LOGP,FL("Session Does not exist or invalid body pointer in message"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002130 if(pDeleteStaParams != NULL)
2131 palFreeMemory( pMac->hHdd, (void *) pDeleteStaParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 return;
2133 }
2134
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 || (psessionEntry->limSystemRole == eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 )
2138 {
2139 limProcessBtAmpApMlmDelStaRsp(pMac,limMsgQ,psessionEntry);
2140 return;
2141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 limProcessStaMlmDelStaRsp(pMac, limMsgQ,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002143}
2144
Jeff Johnson295189b2012-06-20 16:38:30 -07002145void limProcessBtAmpApMlmDelStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2146{
2147 tpDeleteStaParams pDelStaParams = (tpDeleteStaParams) limMsgQ->bodyptr;
2148 tpDphHashNode pStaDs;
2149 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
2150 if(limMsgQ->bodyptr == NULL)
2151 {
2152 return;
2153 }
2154
2155 pStaDs = dphGetHashEntry(pMac, pDelStaParams->assocId, &psessionEntry->dph.dphHashTable);
2156 if(pStaDs == NULL)
2157 {
2158 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002159 FL( "DPH Entry for STA %X missing."), pDelStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 statusCode = eSIR_SME_REFUSED;
2161 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2162
2163 return;
2164 }
2165 if( eHAL_STATUS_SUCCESS == pDelStaParams->status )
2166 {
2167 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002168 FL( "AP received the DEL_STA_RSP for assocID: %X."), pDelStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002169
2170 if(( eLIM_MLM_WT_DEL_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState) &&
2171 ( eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState))
2172 {
2173 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002174 FL( "Received unexpected WDA_DEL_STA_RSP in state %s for staId %d assocId %d " ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 limMlmStateStr(pStaDs->mlmStaContext.mlmState), pStaDs->staIndex, pStaDs->assocId);
2176 statusCode = eSIR_SME_REFUSED;
2177 goto end;
2178 }
2179
2180 limLog( pMac, LOG1,
2181 FL("Deleted STA AssocID %d staId %d MAC "),
2182 pStaDs->assocId, pStaDs->staIndex);
2183 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);
2184 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE == pStaDs->mlmStaContext.mlmState)
2185 {
2186 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002187 if (limAddSta(pMac, pStaDs, false, psessionEntry) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 {
2189 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002190 FL("could not Add STA with assocId=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 pStaDs->assocId);)
2192 // delete the TS if it has already been added.
2193 // send the response with error status.
2194 if(pStaDs->qos.addtsPresent)
2195 {
2196 tpLimTspecInfo pTspecInfo;
2197 if(eSIR_SUCCESS == limTspecFindByAssocId(pMac, pStaDs->assocId,
2198 &pStaDs->qos.addts.tspec, &pMac->lim.tspecInfo[0], &pTspecInfo))
2199 {
2200 limAdmitControlDeleteTS(pMac, pStaDs->assocId, &pStaDs->qos.addts.tspec.tsinfo,
2201 NULL, &pTspecInfo->idx);
2202 }
2203 }
2204 limRejectAssociation(pMac,
2205 pStaDs->staAddr,
2206 pStaDs->mlmStaContext.subType,
2207 true, pStaDs->mlmStaContext.authType,
2208 pStaDs->assocId, true,
2209 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
2210 psessionEntry);
2211 }
2212 return;
2213 }
2214 }
2215 else
2216 {
2217 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002218 FL( "DEL STA failed!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 statusCode = eSIR_SME_REFUSED;
2220 }
2221 end:
2222 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2223 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState)
2224 {
2225 limPrepareAndSendDelStaCnf(pMac, pStaDs, statusCode,psessionEntry);
2226 }
2227 return;
2228}
2229
2230void limProcessStaMlmDelStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2231{
2232 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
2233 tpDeleteStaParams pDelStaParams = (tpDeleteStaParams) limMsgQ->bodyptr;
2234 tpDphHashNode pStaDs = NULL;
2235 if(NULL == pDelStaParams )
2236 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002237 limLog( pMac, LOGE, FL( "Encountered NULL Pointer" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 goto end;
2239 }
2240 if( eHAL_STATUS_SUCCESS == pDelStaParams->status )
2241 {
2242 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
2243 if (pStaDs == NULL)
2244 {
2245 //TODO: any response to be sent out here ?
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002246 limLog( pMac, LOGE, FL( "DPH Entry for STA %X missing."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 pDelStaParams->assocId);
2248 statusCode = eSIR_SME_REFUSED;
2249 goto end;
2250 }
2251 if( eLIM_MLM_WT_DEL_STA_RSP_STATE != psessionEntry->limMlmState)
2252 {
2253 //TODO: any response to be sent out here ?
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002254 limLog( pMac, LOGE, FL( "Received unexpected WDA_DELETE_STA_RSP in state %s" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 limMlmStateStr(psessionEntry->limMlmState));
2256 statusCode = eSIR_SME_REFUSED;
2257 goto end;
2258 }
2259 PELOG1(limLog( pMac, LOG1, FL("STA AssocID %d MAC "), pStaDs->assocId );
2260 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002261 limLog( pMac, LOGW, FL( "DEL_STA_RSP received for assocID: %X"), pDelStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 //we must complete all cleanup related to delSta before calling limDelBSS.
2263 if( 0 != limMsgQ->bodyptr )
2264 {
2265 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2266 }
2267 statusCode = (tSirResultCodes) limDelBss(pMac, pStaDs, 0,psessionEntry);
2268 return;
2269 }
2270 else
2271 {
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -07002272 limLog( pMac, LOGE, FL( "DEL_STA failed for sta Id %d" ), pDelStaParams->staIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 statusCode = eSIR_SME_REFUSED;
2274 }
2275end:
2276 if( 0 != limMsgQ->bodyptr )
2277 {
2278 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2279 }
2280 return;
2281}
2282
Jeff Johnson295189b2012-06-20 16:38:30 -07002283void limProcessBtAmpApMlmAddStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2284{
2285 tpAddStaParams pAddStaParams = (tpAddStaParams) limMsgQ->bodyptr;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302286 tpDphHashNode pStaDs = NULL;
2287
2288 if (NULL == pAddStaParams)
2289 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002290 limLog( pMac, LOGE, FL( "Invalid body pointer in message"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302291 goto end;
2292 }
2293
2294 pStaDs = dphGetHashEntry(pMac, pAddStaParams->assocId, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 if(pStaDs == NULL)
2296 {
2297 //TODO: any response to be sent out here ?
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002298 limLog( pMac, LOGE, FL( "DPH Entry for STA %X missing."), pAddStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 goto end;
2300 }
2301 //
2302 // TODO & FIXME_GEN4
2303 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
2304 //
2305 //TODO: any check for pMac->lim.gLimMlmState ?
2306 if( eLIM_MLM_WT_ADD_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState)
2307 {
2308 //TODO: any response to be sent out here ?
2309 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002310 FL( "Received unexpected WDA_ADD_STA_RSP in state %X" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 pStaDs->mlmStaContext.mlmState);
2312 goto end;
2313 }
2314 if(eHAL_STATUS_SUCCESS != pAddStaParams->status)
2315 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002316 PELOGE(limLog(pMac, LOGE, FL("Error! rcvd delSta rsp from HAL with status %d"),pAddStaParams->status);)
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 limRejectAssociation(pMac, pStaDs->staAddr,
2318 pStaDs->mlmStaContext.subType,
2319 true, pStaDs->mlmStaContext.authType,
2320 pStaDs->assocId, true,
2321 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
2322 psessionEntry);
2323 goto end;
2324 }
2325 pStaDs->bssId = pAddStaParams->bssIdx;
2326 pStaDs->staIndex = pAddStaParams->staIdx;
2327 //if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state
2328 pStaDs->valid = 1;
2329 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ASSOC_CNF_STATE;
2330 limLog( pMac, LOG1,
2331 FL("STA AssocID %d staId %d MAC "),
2332 pStaDs->assocId,
2333 pStaDs->staIndex);
2334 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);
2335
2336 /* For BTAMP-AP, the flow sequence shall be:
2337 * 1) PE sends eWNI_SME_ASSOC_IND to SME
2338 * 2) PE receives eWNI_SME_ASSOC_CNF from SME
2339 * 3) BTAMP-AP sends Re/Association Response to BTAMP-STA
2340 */
2341 limSendMlmAssocInd(pMac, pStaDs, psessionEntry);
2342 // fall though to reclaim the original Add STA Response message
2343end:
2344 if( 0 != limMsgQ->bodyptr )
2345 {
2346 palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
2347 }
2348 return;
2349}
2350
2351/**
2352 * limProcessApMlmAddBssRsp()
2353 *
2354 *FUNCTION:
2355 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
2356 * Upon receipt of this message from HAL, MLME -
2357 * > Validates the result of WDA_ADD_BSS_REQ
2358 * > Init other remaining LIM variables
2359 * > Init the AID pool, for that BSSID
2360 * > Init the Pre-AUTH list, for that BSSID
2361 * > Create LIM timers, specific to that BSSID
2362 * > Init DPH related parameters that are specific to that BSSID
2363 * > TODO - When do we do the actual change channel?
2364 *
2365 *LOGIC:
2366 * SME sends eWNI_SME_START_BSS_REQ to LIM
2367 * LIM sends LIM_MLM_START_REQ to MLME
2368 * MLME sends WDA_ADD_BSS_REQ to HAL
2369 * HAL responds with WDA_ADD_BSS_RSP to MLME
2370 * MLME responds with LIM_MLM_START_CNF to LIM
2371 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2372 *
2373 *ASSUMPTIONS:
2374 * tSirMsgQ.body is allocated by MLME during limProcessMlmStartReq
2375 * tSirMsgQ.body will now be freed by this routine
2376 *
2377 *NOTE:
2378 *
2379 * @param pMac Pointer to Global MAC structure
2380 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2381 *
2382 * @return None
2383 */
2384static void
2385limProcessApMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ)
2386{
2387 tLimMlmStartCnf mlmStartCnf;
2388 tANI_U32 val;
2389 tpPESession psessionEntry;
2390// tANI_U8 sessionId;
2391 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2392 if(NULL == pAddBssParams )
2393 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002394 limLog( pMac, LOGE, FL( "Encountered NULL Pointer" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 goto end;
2396 }
2397 //TBD: free the memory before returning, do it for all places where lookup fails.
2398 if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
2399 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002400 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002401 if( NULL != pAddBssParams )
2402 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 return;
2404 }
2405 /* Update PE session Id*/
2406 mlmStartCnf.sessionId = pAddBssParams->sessionId;
2407 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
2408 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002409 PELOG2(limLog(pMac, LOG2, FL("WDA_ADD_BSS_RSP returned with eHAL_STATUS_SUCCESS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 if (limSetLinkState(pMac, eSIR_LINK_AP_STATE,psessionEntry->bssId,
2411 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2412 goto end;
2413 // Set MLME state
2414 psessionEntry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002415 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 if( eSIR_IBSS_MODE == pAddBssParams->bssType )
2417 {
2418 /** IBSS is 'active' when we receive
2419 * Beacon frames from other STAs that are part of same IBSS.
2420 * Mark internal state as inactive until then.
2421 */
2422 psessionEntry->limIbssActive = false;
2423 psessionEntry->statypeForBss = STA_ENTRY_PEER; //to know session created for self/peer
2424 limResetHBPktCount( psessionEntry );
2425 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002426 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 if (limActivateHearBeatTimer(pMac) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002428 limLog(pMac, LOGP, FL("could not activate Heartbeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 }
2430 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2431
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002433
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 if ( eSIR_INFRA_AP_MODE == pAddBssParams->bssType )
2435 psessionEntry->limSystemRole = eLIM_AP_ROLE;
2436 else
2437 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 schEdcaProfileUpdate(pMac, psessionEntry);
2439 limInitPreAuthList(pMac);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002440 limInitPeerIdxpool(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 // Create timers used by LIM
2442 if (!pMac->lim.gLimTimersCreated)
2443 limCreateTimers(pMac);
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07002444
2445 // Start OLBC timer
2446 if (tx_timer_activate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer) != TX_SUCCESS)
2447 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002448 limLog(pMac, LOGE, FL("tx_timer_activate failed"));
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07002449 }
2450
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
2452 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002453 limLog( pMac, LOGP, FL("Failed to get WNI_CFG_TRIG_STA_BK_SCAN!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
2455 // Apply previously set configuration at HW
2456 limApplyConfiguration(pMac,psessionEntry);
2457 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2458 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2459 }
2460 else
2461 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002462 limLog( pMac, LOGE, FL( "WDA_ADD_BSS_REQ failed with status %d" ),pAddBssParams->status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2464 }
2465 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
2466 end:
2467 if( 0 != limMsgQ->bodyptr )
2468 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
2469}
2470
2471
2472/**
2473 * limProcessIbssMlmAddBssRsp()
2474 *
2475 *FUNCTION:
2476 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
2477 * Upon receipt of this message from HAL, MLME -
2478 * > Validates the result of WDA_ADD_BSS_REQ
2479 * > Init other remaining LIM variables
2480 * > Init the AID pool, for that BSSID
2481 * > Init the Pre-AUTH list, for that BSSID
2482 * > Create LIM timers, specific to that BSSID
2483 * > Init DPH related parameters that are specific to that BSSID
2484 * > TODO - When do we do the actual change channel?
2485 *
2486 *LOGIC:
2487 * SME sends eWNI_SME_START_BSS_REQ to LIM
2488 * LIM sends LIM_MLM_START_REQ to MLME
2489 * MLME sends WDA_ADD_BSS_REQ to HAL
2490 * HAL responds with WDA_ADD_BSS_RSP to MLME
2491 * MLME responds with LIM_MLM_START_CNF to LIM
2492 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2493 *
2494 *ASSUMPTIONS:
2495 * tSirMsgQ.body is allocated by MLME during limProcessMlmStartReq
2496 * tSirMsgQ.body will now be freed by this routine
2497 *
2498 *NOTE:
2499 *
2500 * @param pMac Pointer to Global MAC structure
2501 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2502 *
2503 * @return None
2504 */
2505static void
2506limProcessIbssMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry)
2507{
2508 tLimMlmStartCnf mlmStartCnf;
2509 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2510 tANI_U32 val;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302511
2512 if (NULL == pAddBssParams)
2513 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002514 limLog( pMac, LOGE, FL( "Invalid body pointer in message"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302515 goto end;
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
2518 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002519 PELOG1(limLog(pMac, LOG1, FL("WDA_ADD_BSS_RSP returned with eHAL_STATUS_SUCCESS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 if (limSetLinkState(pMac, eSIR_LINK_IBSS_STATE,psessionEntry->bssId,
2521 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2522 goto end;
2523 // Set MLME state
2524 psessionEntry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002525 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 /** IBSS is 'active' when we receive
2527 * Beacon frames from other STAs that are part of same IBSS.
2528 * Mark internal state as inactive until then.
2529 */
2530 psessionEntry->limIbssActive = false;
2531 limResetHBPktCount( psessionEntry );
2532 /* Timer related functions are not modified for BT-AMP : To be Done */
2533 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002534 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 if (limActivateHearBeatTimer(pMac) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002536 limLog(pMac, LOGP, FL("could not activate Heartbeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2538 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2539 psessionEntry->statypeForBss = STA_ENTRY_SELF;
2540 schEdcaProfileUpdate(pMac, psessionEntry);
2541 //TBD-RAJESH limInitPreauthList should re removed for IBSS also ?????
2542 //limInitPreAuthList(pMac);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002543 limInitPeerIdxpool(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 // Create timers used by LIM
2545#ifdef FIXME_GEN6 //following code may not be required, as limCreateTimers is now invoked from limInitialize (peStart)
2546 if (!pMac->lim.gLimTimersCreated)
2547 limCreateTimers(pMac);
2548#endif
2549 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
2550 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002551 limLog( pMac, LOGP, FL("Failed to get WNI_CFG_TRIG_STA_BK_SCAN!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
2553 // Apply previously set configuration at HW
2554 limApplyConfiguration(pMac,psessionEntry);
2555 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2556 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2557 //If ADD BSS was issued as part of IBSS coalescing, don't send the message to SME, as that is internal to LIM
2558 if(true == pMac->lim.gLimIbssCoalescingHappened)
2559 {
2560 limIbssAddBssRspWhenCoalescing(pMac, limMsgQ->bodyptr, psessionEntry);
2561 goto end;
2562 }
2563 }
2564 else
2565 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002566 limLog( pMac, LOGE, FL( "WDA_ADD_BSS_REQ failed with status %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 pAddBssParams->status );
2568 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2569 }
2570 //Send this message to SME, when ADD_BSS is initiated by SME
2571 //If ADD_BSS is done as part of coalescing, this won't happen.
2572 /* Update PE session Id*/
2573 mlmStartCnf.sessionId =psessionEntry->peSessionId;
2574 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
2575 end:
2576 if( 0 != limMsgQ->bodyptr )
2577 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
2578}
2579
2580static void
2581limProcessStaMlmAddBssRspPreAssoc( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ, tpPESession psessionEntry )
2582{
2583 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2584 tAniAuthType cfgAuthType, authMode;
2585 tLimMlmAuthReq *pMlmAuthReq;
2586 tpDphHashNode pStaDs = NULL;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302587
2588 if (NULL == pAddBssParams)
2589 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002590 limLog( pMac, LOGE, FL( "Invalid body pointer in message"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302591 goto joinFailure;
2592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
2594 {
2595 if ((pStaDs = dphAddHashEntry(pMac, pAddBssParams->staContext.staMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) == NULL)
2596 {
2597 // Could not add hash table entry
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002598 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 limPrintMacAddr(pMac, pAddBssParams->staContext.staMac, LOGE);
2600 goto joinFailure;
2601 }
2602 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2603 //Success, handle below
2604 pStaDs->bssId = pAddBssParams->bssIdx;
2605 //STA Index(genr by HAL) for the BSS entry is stored here
2606 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
2607 // Trigger Authentication with AP
2608 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE,
2609 (tANI_U32 *) &cfgAuthType) != eSIR_SUCCESS)
2610 {
2611 /**
2612 * Could not get AuthType from CFG.
2613 * Log error.
2614 */
2615 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002616 FL("could not retrieve AuthType"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 }
2618 if (cfgAuthType == eSIR_AUTO_SWITCH)
2619 authMode = eSIR_OPEN_SYSTEM; // Try Open Authentication first
2620 else
2621 authMode = cfgAuthType;
2622
2623 // Trigger MAC based Authentication
2624 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmAuthReq, sizeof(tLimMlmAuthReq)))
2625 {
2626 // Log error
2627 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002628 FL("call to palAllocateMemory failed for mlmAuthReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 return;
2630 }
2631 #if 0
2632 val = sizeof(tSirMacAddr);
2633 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID,
2634 pMlmAuthReq->peerMacAddr,
2635 &val) != eSIR_SUCCESS)
2636 {
2637 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002638 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 }
2640 #endif //TO SUPPORT BT-AMP
2641 sirCopyMacAddr(pMlmAuthReq->peerMacAddr,psessionEntry->bssId);
2642
2643 pMlmAuthReq->authType = authMode;
2644 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
2645 (tANI_U32 *) &pMlmAuthReq->authFailureTimeout)
2646 != eSIR_SUCCESS)
2647 {
2648 /**
2649 * Could not get AuthFailureTimeout
2650 * value from CFG. Log error.
2651 */
2652 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002653 FL("could not retrieve AuthFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 }
2655 // SUNIT_FIX_ME: Set BOTH? Assume not. Please verify here and below.
2656 //pMac->lim.gLimMlmState = eLIM_MLM_JOINED_STATE;
2657 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002658 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 pMlmAuthReq->sessionId = psessionEntry->peSessionId;
2660 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2661 psessionEntry->limSmeState = eLIM_SME_WT_AUTH_STATE;
2662 // remember staId in case of assoc timeout/failure handling
2663 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2664
Jeff Johnsone7245742012-09-05 17:12:55 -07002665 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 limPostMlmMessage(pMac,
2667 LIM_MLM_AUTH_REQ,
2668 (tANI_U32 *) pMlmAuthReq);
2669 return;
2670 }
2671
2672joinFailure:
2673 {
2674 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002675 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002676
2677 /// Send Join response to Host
2678 limHandleSmeJoinResult(pMac, eSIR_SME_REFUSED, eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
2679
2680 }
2681
2682}
2683
2684#ifdef WLAN_FEATURE_VOWIFI_11R
2685/*------------------------------------------------------------------------------------------
2686 *
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002687 * Function to handle callback after setting link state to post assoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 *
2689 *
2690 *------------------------------------------------------------------------------------------
2691 */
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002692void limSetLinkStateForPostAssocCallback(tpAniSirGlobal pMac, void *msgParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07002693{
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 tLimMlmReassocCnf mlmReassocCnf; // keep sme
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002695 tSetLinkCbackParams * pCbackParams = (tSetLinkCbackParams *)msgParam;
2696 tpPESession psessionEntry = NULL;
2697 tpAddBssParams pAddBssParams = NULL;
2698 tpDphHashNode pStaDs = NULL;
2699 tpAddStaParams pAddStaParams = NULL;
2700 tLimMlmReassocReq * pMlmReassocReq = NULL;
2701 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
2702
2703 /* Sanity Checks */
2704 if (pCbackParams == NULL)
2705 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002706 PELOGE(limLog(pMac, LOGE, FL("Invalid parameters"));)
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002707 goto end;
2708 }
2709
2710 pAddBssParams = (tpAddBssParams)(pCbackParams->cbackDataPtr);
2711
2712 if (pAddBssParams == NULL)
2713 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002714 PELOGE(limLog(pMac, LOGE, FL("Invalid parameters"));)
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002715 goto end;
2716 }
2717
2718 if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
2719 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002720 limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId" ));
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002721 goto end;
2722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002723
2724 pMlmReassocReq = (tLimMlmReassocReq *)(psessionEntry->pLimMlmReassocReq);
2725
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002726 limPrintMacAddr(pMac, pAddBssParams->bssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002727
2728 if ((pStaDs = dphAddHashEntry(pMac, pAddBssParams->bssId, DPH_STA_HASH_INDEX_PEER,
2729 &psessionEntry->dph.dphHashTable)) == NULL)
2730 {
2731 // Could not add hash table entry
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002732 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 limPrintMacAddr(pMac, pAddBssParams->staContext.staMac, LOGE);
2734 goto end;
2735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 // Prepare and send Reassociation request frame
2737 // start reassoc timer.
2738 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2739 /// Start reassociation failure timer
Jeff Johnsone7245742012-09-05 17:12:55 -07002740 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2742 != TX_SUCCESS)
2743 {
2744 /// Could not start reassoc failure timer.
2745 // Log error
2746 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002747 FL("could not start Reassociation failure timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 // Return Reassoc confirm with
2749 // Resources Unavailable
2750 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2751 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2752 goto end;
2753 }
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002754#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
2755 pMac->lim.pSessionEntry = psessionEntry;
2756 if(NULL == pMac->lim.pSessionEntry->pLimMlmReassocRetryReq)
2757 {
2758 /* Take a copy of reassoc request for retrying */
2759 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pMac->lim.pSessionEntry->pLimMlmReassocRetryReq, sizeof(tLimMlmReassocReq))) ) goto end;
2760 palZeroMemory(pMac->hHdd, pMac->lim.pSessionEntry->pLimMlmReassocRetryReq, sizeof(tLimMlmReassocReq));
2761 palCopyMemory( pMac->hHdd,pMac->lim.pSessionEntry->pLimMlmReassocRetryReq, psessionEntry->pLimMlmReassocReq, sizeof(tLimMlmReassocReq));
2762 }
2763 pMac->lim.reAssocRetryAttempt = 0;
2764#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 limSendReassocReqWithFTIEsMgmtFrame(pMac, psessionEntry->pLimMlmReassocReq, psessionEntry);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002766
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2768 psessionEntry->limMlmState = eLIM_MLM_WT_FT_REASSOC_RSP_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002769 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_FT_REASSOC_RSP_STATE));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002770 PELOGE(limLog(pMac, LOG1, FL("Set the mlm state to %d session=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 psessionEntry->limMlmState, psessionEntry->peSessionId);)
2772
2773 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2774
2775 //Success, handle below
2776 pStaDs->bssId = pAddBssParams->bssIdx;
2777 //STA Index(genr by HAL) for the BSS entry is stored here
2778 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
2779 pStaDs->ucUcastSig = pAddBssParams->staContext.ucUcastSig;
2780 pStaDs->ucBcastSig = pAddBssParams->staContext.ucBcastSig;
2781
Jeff Johnson295189b2012-06-20 16:38:30 -07002782#if defined WLAN_FEATURE_VOWIFI
2783 rrmCacheMgmtTxPower( pMac, pAddBssParams->txMgmtPower, psessionEntry );
2784#endif
2785
2786 if( eHAL_STATUS_SUCCESS !=
2787 palAllocateMemory( pMac->hHdd, (void **) &pAddStaParams, sizeof( tAddStaParams )))
2788 {
Jeff Johnson19ba8882013-04-03 17:02:37 -07002789 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during ADD_STA" ));
2790 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 }
2792 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams, sizeof(tAddStaParams));
2793
2794 /// Add STA context at MAC HW (BMU, RHP & TFP)
2795 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->staMac,
2796 (tANI_U8 *) psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
2797
2798 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->bssId,
2799 psessionEntry->bssId, sizeof(tSirMacAddr));
2800
2801 // Update this when we get reassoc rsp , with success.
2802 // pAddStaParams->assocId = psessionEntry->limAID;
2803
2804 pAddStaParams->staType = STA_ENTRY_SELF;
2805 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2806 pAddStaParams->respReqd = 1;
2807
2808 /* Update PE session ID */
2809 pAddStaParams->sessionId = psessionEntry->peSessionId;
2810
2811 // This will indicate HAL to "allocate" a new STA index
2812 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2813 pAddStaParams->updateSta = FALSE;
2814
2815 pAddStaParams->shortPreambleSupported = (tANI_U8)psessionEntry->beaconParams.fShortPreamble;
Jeff Johnsone7245742012-09-05 17:12:55 -07002816#ifdef WLAN_FEATURE_11AC
2817 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry, NULL);
2818#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002821
Jeff Johnsone7245742012-09-05 17:12:55 -07002822 if( psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002824 pAddStaParams->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -07002825#ifdef DISABLE_GF_FOR_INTEROP
2826 /*
2827 * To resolve the interop problem with Broadcom AP,
2828 * where TQ STA could not pass traffic with GF enabled,
2829 * TQ STA will do Greenfield only with TQ AP, for
2830 * everybody else it will be turned off.
Jeff Johnsone7245742012-09-05 17:12:55 -07002831 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2833 {
2834 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2835 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2836 }
2837 else
2838#endif
2839
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
2841 pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
2842 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
2843 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
2844 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
2845 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
2846 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
2847 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
2848 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
2849 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
2850 pAddStaParams->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
2851 pAddStaParams->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 }
2853
2854 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002855 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
2857
2858 limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
2859
2860 // Lets save this for when we receive the Reassoc Rsp
2861 pMac->ft.ftPEContext.pAddStaReq = pAddStaParams;
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002862
2863 if (pCbackParams != NULL)
2864 {
2865 if (pCbackParams->cbackDataPtr != NULL)
2866 {
2867 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams->cbackDataPtr);
2868 }
2869 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams);
2870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 return;
2872
2873end:
2874 // Free up buffer allocated for reassocReq
2875 if (pMlmReassocReq != NULL)
2876 {
2877 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
2878 }
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002879
2880 if (pCbackParams != NULL)
2881 {
2882 if (pCbackParams->cbackDataPtr != NULL)
2883 {
2884 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams->cbackDataPtr);
2885 }
2886 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams);
2887 }
2888
2889 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2890 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkala94273ab2013-03-25 14:47:39 +05302891 /* Update PE session Id*/
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002892 if (psessionEntry != NULL)
2893 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
Jeff Johnson19ba8882013-04-03 17:02:37 -07002894 else
2895 mlmReassocCnf.sessionId = 0;
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002896
2897 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2898}
2899/*------------------------------------------------------------------------------------------
2900 *
2901 * Function to handle WDA_ADD_BSS_RSP, in FT reassoc state.
2902 *
2903 *
2904 *------------------------------------------------------------------------------------------
2905 */
2906static inline void
2907limProcessStaMlmAddBssRspFT(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ, tpPESession psessionEntry)
2908{
2909 tSetLinkCbackParams * pCbackParam = NULL;
2910 tAddBssParams * pAddBssCbackInfo = NULL;
2911 tLimMlmReassocCnf mlmReassocCnf;
2912 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2913
2914 if ( eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE != psessionEntry->limMlmState )
2915 {
2916 goto end;
2917 }
2918
2919 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pCbackParam, sizeof( tSetLinkCbackParams )))
2920 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002921 PELOGE(limLog(pMac, LOGE, FL("Could not allocate memory for LinkState callback params"));)
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002922 goto end;
2923 }
2924
2925 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pAddBssCbackInfo, sizeof( tAddBssParams )))
2926 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002927 PELOGE(limLog(pMac, LOGE, FL("Could not allocate memory for Add BSS info callback param"));)
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002928 goto end;
2929 }
2930
2931 vos_mem_copy(pAddBssCbackInfo, pAddBssParams, sizeof(tAddBssParams));
2932
2933 pCbackParam->cbackDataPtr = (void*)pAddBssCbackInfo;
2934
2935 // Set the filter state to post assoc and send out re-assoc request OTA only after response is received
2936 if (limSetLinkState(pMac, eSIR_LINK_POSTASSOC_STATE,
2937 pAddBssParams->bssId, psessionEntry->selfMacAddr,
2938 (tpSetLinkStateCallback)limSetLinkStateForPostAssocCallback,
2939 (void *)pCbackParam) != eSIR_SUCCESS)
2940 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002941 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState"));)
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002942 goto end;
2943 }
2944
2945 return;
2946
2947end:
2948
2949 if (pCbackParam != NULL)
2950 {
2951 if (pCbackParam->cbackDataPtr != NULL)
2952 {
2953 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParam->cbackDataPtr);
2954 }
2955 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParam);
2956 }
2957
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2959 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2960 /* Update PE sessio Id*/
2961 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2962
2963 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2964}
2965#endif /* WLAN_FEATURE_VOWIFI_11R */
2966
2967
2968/**
2969 * limProcessStaMlmAddBssRsp()
2970 *
2971 *FUNCTION:
2972 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
2973 * Upon receipt of this message from HAL, MLME -
2974 * > Validates the result of WDA_ADD_BSS_REQ
2975 * > Now, send an ADD_STA to HAL and ADD the "local" STA itself
2976 *
2977 *LOGIC:
2978 * MLME had sent WDA_ADD_BSS_REQ to HAL
2979 * HAL responded with WDA_ADD_BSS_RSP to MLME
2980 * MLME now sends WDA_ADD_STA_REQ to HAL
2981 *
2982 *ASSUMPTIONS:
2983 * tSirMsgQ.body is allocated by MLME during limProcessMlmJoinReq
2984 * tSirMsgQ.body will now be freed by this routine
2985 *
2986 *NOTE:
2987 *
2988 * @param pMac Pointer to Global MAC structure
2989 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2990 *
2991 * @return None
2992 */
2993static void
2994limProcessStaMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2995{
2996 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2997 tLimMlmAssocCnf mlmAssocCnf;
2998 tANI_U32 mesgType = LIM_MLM_ASSOC_CNF;
2999 tANI_U32 subType = LIM_ASSOC;
3000 tpDphHashNode pStaDs = NULL;
3001 tANI_U16 staIdx = HAL_STA_INVALID_IDX;
3002 tANI_U8 updateSta = false;
3003 mlmAssocCnf.resultCode = eSIR_SME_SUCCESS;
3004
3005 if(eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE == psessionEntry->limMlmState)
3006 {
3007 //Done: 7-28-2009. JIM_FIX_ME: sessionize the following function
3008 limProcessStaMlmAddBssRspPreAssoc(pMac, limMsgQ, psessionEntry);
3009 goto end;
3010 }
3011 if( eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE == psessionEntry->limMlmState )
3012 {
3013 mesgType = LIM_MLM_REASSOC_CNF;
3014 subType = LIM_REASSOC;
3015 //If Reassoc is happening for the same BSS, then use the existing StaId and indicate to HAL
3016 //to update the existing STA entry.
3017 //If Reassoc is happening for the new BSS, then old BSS and STA entry would have been already deleted
3018 //before PE tries to add BSS for the new BSS, so set the updateSta to false and pass INVALID STA Index.
3019 if (sirCompareMacAddr( psessionEntry->bssId, psessionEntry->limReAssocbssId))
3020 {
3021 staIdx = psessionEntry->staId;
3022 updateSta = true;
3023 }
3024 }
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08003025
Madan Mohan Koyyalamudi830ed802012-11-29 11:38:12 -08003026 if(pAddBssParams == 0)
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08003027 goto end;
3028
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
3030 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003031#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 if( eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE == psessionEntry->limMlmState )
3033 {
3034#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003035 PELOGE(limLog(pMac, LOG1, FL("Mlm=%d %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 psessionEntry->limMlmState,
3037 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE);)
3038#endif
3039 limProcessStaMlmAddBssRspFT( pMac, limMsgQ, psessionEntry);
3040 goto end;
3041 }
3042#endif /* WLAN_FEATURE_VOWIFI_11R */
3043
3044 // Set MLME state
3045 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003046 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 psessionEntry->statypeForBss = STA_ENTRY_PEER; //to know the session started for self or for peer oct6th
3048 // Now, send WDA_ADD_STA_REQ
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003049 limLog( pMac, LOGW, FL( "On STA: ADD_BSS was successful" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3051 if (pStaDs == NULL)
3052 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003053 PELOGE(limLog(pMac, LOGE, FL("could not Add Self Entry for the station"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
3055 }
3056 else
3057 {
3058 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
3059 //Success, handle below
3060 pStaDs->bssId = pAddBssParams->bssIdx;
3061 //STA Index(genr by HAL) for the BSS entry is stored here
3062 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
3063 pStaDs->ucUcastSig = pAddBssParams->staContext.ucUcastSig;
3064 pStaDs->ucBcastSig = pAddBssParams->staContext.ucBcastSig;
3065 // Downgrade the EDCA parameters if needed
3066 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
3067 // Send the active EDCA parameters to HAL
3068 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE) {
3069 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
3070 } else {
3071 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
3072 }
3073#if defined WLAN_FEATURE_VOWIFI
3074 rrmCacheMgmtTxPower( pMac, pAddBssParams->txMgmtPower, psessionEntry );
3075#endif
3076
3077 if (subType == LIM_REASSOC)
3078 limDeactivateAndChangeTimer(pMac, eLIM_KEEPALIVE_TIMER);
3079 if (limAddStaSelf(pMac,staIdx, updateSta, psessionEntry) != eSIR_SUCCESS)
3080 {
3081 // Add STA context at HW
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003082 PELOGE(limLog(pMac, LOGE, FL("could not Add Self Entry for the station"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
3084 }
3085 }
3086 }
3087 else
3088 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003089 limLog( pMac, LOGP, FL( "ADD_BSS failed!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 // Return Assoc confirm to SME with failure
3091 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
3092 }
3093
3094 if(mlmAssocCnf.resultCode != eSIR_SME_SUCCESS)
3095 {
3096 /* Update PE session Id*/
3097 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
3098 limPostSmeMessage( pMac, mesgType, (tANI_U32 *) &mlmAssocCnf );
3099 }
3100 end:
3101 if( 0 != limMsgQ->bodyptr )
3102 palFreeMemory( pMac->hHdd,(void *) pAddBssParams );
3103}
3104
3105
3106
3107/**
3108 * limProcessMlmAddBssRsp()
3109 *
3110 *FUNCTION:
3111 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
3112 * Upon receipt of this message from HAL, MLME -
3113 * > Determines the "state" in which this message was received
3114 * > Forwards it to the appropriate callback
3115 *
3116 *LOGIC:
3117 * WDA_ADD_BSS_RSP can be received by MLME while the LIM is
3118 * in the following two states:
3119 * 1) As AP, LIM state = eLIM_SME_WT_START_BSS_STATE
3120 * 2) As STA, LIM state = eLIM_SME_WT_JOIN_STATE
3121 * Based on these two states, this API will determine where to
3122 * route the message to
3123 *
3124 *ASSUMPTIONS:
3125 *
3126 *NOTE:
3127 *
3128 * @param pMac Pointer to Global MAC structure
3129 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3130 *
3131 * @return None
3132 */
3133void limProcessMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3134{
3135 tLimMlmStartCnf mlmStartCnf;
3136 tpPESession psessionEntry;
3137 tpAddBssParams pAddBssParams = (tpAddBssParams) (limMsgQ->bodyptr);
3138
3139 if(NULL == pAddBssParams )
3140 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003141 limLog( pMac, LOGE, FL( "Encountered NULL Pointer" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 return;
3143 }
3144
3145 //
3146 // TODO & FIXME_GEN4
3147 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
3148 //
3149 //we need to process the deferred message since the initiating req. there might be nested request.
3150 //in the case of nested request the new request initiated from the response will take care of resetting
3151 //the deffered flag.
3152 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3153 // Validate SME/LIM state
3154 // Validate MLME state
3155 if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
3156 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003157 limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003158 if( NULL != pAddBssParams )
3159 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 return;
3161 }
3162 /* update PE session Id*/
3163 mlmStartCnf.sessionId = psessionEntry->peSessionId;
3164 if( eSIR_IBSS_MODE == psessionEntry->bssType )
3165 limProcessIbssMlmAddBssRsp( pMac, limMsgQ, psessionEntry );
3166 else
3167 {
3168 if( eLIM_SME_WT_START_BSS_STATE == psessionEntry->limSmeState )
3169 {
3170 if( eLIM_MLM_WT_ADD_BSS_RSP_STATE != psessionEntry->limMlmState )
3171 {
3172 // Mesg received from HAL in Invalid state!
3173 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003174 FL( "Received unexpected WDA_ADD_BSS_RSP in state %X" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 psessionEntry->limMlmState );
3176 mlmStartCnf.resultCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
3177 if( 0 != limMsgQ->bodyptr )
3178 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
3179 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
3180 }
3181 else if ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE)||(psessionEntry->bssType == eSIR_BTAMP_STA_MODE))
3182 {
3183 limProcessBtampAddBssRsp(pMac,limMsgQ,psessionEntry);
3184 }
3185 else
3186 limProcessApMlmAddBssRsp( pMac,limMsgQ);
3187 }
3188 else
3189 /* Called while processing assoc response */
3190 limProcessStaMlmAddBssRsp( pMac, limMsgQ,psessionEntry);
3191 }
Madan Mohan Koyyalamudi01cba042013-01-10 21:56:05 -08003192
3193 if(limIsInMCC(pMac))
3194 {
3195 WDA_TrafficStatsTimerActivate(TRUE);
3196 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003197
3198#ifdef WLAN_FEATURE_11W
3199 if (psessionEntry->limRmfEnabled)
3200 {
3201 if ( eSIR_SUCCESS != limSendExcludeUnencryptInd(pMac, FALSE, psessionEntry) )
3202 {
3203 limLog( pMac, LOGE,
3204 FL( "Could not send down Exclude Unencrypted Indication!" ),
3205 psessionEntry->limMlmState );
3206 }
3207 }
3208#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003209}
3210/**
3211 * limProcessMlmSetKeyRsp()
3212 *
3213 *FUNCTION:
3214 * This function is called to process the following two
3215 * messages from HAL:
3216 * 1) WDA_SET_BSSKEY_RSP
3217 * 2) WDA_SET_STAKEY_RSP
3218 * 3) WDA_SET_STA_BCASTKEY_RSP
3219 * Upon receipt of this message from HAL,
3220 * MLME -
3221 * > Determines the "state" in which this message was received
3222 * > Forwards it to the appropriate callback
3223 *
3224 *LOGIC:
3225 * WDA_SET_BSSKEY_RSP/WDA_SET_STAKEY_RSP can be
3226 * received by MLME while in the following state:
3227 * MLME state = eLIM_MLM_WT_SET_BSS_KEY_STATE --OR--
3228 * MLME state = eLIM_MLM_WT_SET_STA_KEY_STATE --OR--
3229 * MLME state = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE
3230 * Based on this state, this API will determine where to
3231 * route the message to
3232 *
3233 *ASSUMPTIONS:
3234 * ONLY the MLME state is being taken into account for now.
3235 * This is because, it appears that the handling of the
3236 * SETKEYS REQ is handled symmetrically on both the AP & STA
3237 *
3238 *NOTE:
3239 *
3240 * @param pMac Pointer to Global MAC structure
3241 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3242 *
3243 * @return None
3244 */
3245void limProcessMlmSetStaKeyRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3246{
Jeff Johnsone7245742012-09-05 17:12:55 -07003247 tANI_U8 respReqd = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 tLimMlmSetKeysCnf mlmSetKeysCnf;
3249 tANI_U8 sessionId = 0;
3250 tpPESession psessionEntry;
3251 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3252 palZeroMemory( pMac->hHdd, (void *)&mlmSetKeysCnf, sizeof( tLimMlmSetKeysCnf ));
3253 //BTAMP
Jeff Johnsone7245742012-09-05 17:12:55 -07003254 if( NULL == limMsgQ->bodyptr )
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003256 PELOGE(limLog(pMac, LOGE,FL("limMsgQ bodyptr is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 return;
3258 }
3259 sessionId = ((tpSetStaKeyParams) limMsgQ->bodyptr)->sessionId;
3260 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
3261 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003262 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003263 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 return;
3265 }
3266 if( eLIM_MLM_WT_SET_STA_KEY_STATE != psessionEntry->limMlmState )
3267 {
3268 // Mesg received from HAL in Invalid state!
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003269 limLog( pMac, LOGW, FL( "Received unexpected [Mesg Id - %d] in state %X" ), limMsgQ->type, psessionEntry->limMlmState );
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 // There's not much that MLME can do at this stage...
3271 respReqd = 0;
3272 }
3273 else
3274 mlmSetKeysCnf.resultCode = (tANI_U16) (((tpSetStaKeyParams) limMsgQ->bodyptr)->status);
3275
3276 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
3277 // Restore MLME state
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003279 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 if( respReqd )
3281 {
3282 tpLimMlmSetKeysReq lpLimMlmSetKeysReq = (tpLimMlmSetKeysReq) pMac->lim.gpLimMlmSetKeysReq;
3283 // Prepare and Send LIM_MLM_SETKEYS_CNF
3284 if( NULL != lpLimMlmSetKeysReq )
3285 {
3286 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf.peerMacAddr, (tANI_U8 *) lpLimMlmSetKeysReq->peerMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 // Free the buffer cached for the global pMac->lim.gpLimMlmSetKeysReq
Jeff Johnsone7245742012-09-05 17:12:55 -07003288 palFreeMemory(pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 pMac->lim.gpLimMlmSetKeysReq = NULL;
3290 }
3291 mlmSetKeysCnf.sessionId = sessionId;
Jeff Johnsone7245742012-09-05 17:12:55 -07003292 limPostSmeMessage(pMac, LIM_MLM_SETKEYS_CNF, (tANI_U32 *) &mlmSetKeysCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 }
3294}
3295void limProcessMlmSetBssKeyRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3296{
3297 tANI_U8 respReqd = 1;
3298 tLimMlmSetKeysCnf mlmSetKeysCnf;
Jeff Johnsone7245742012-09-05 17:12:55 -07003299 tANI_U16 resultCode;
3300 tANI_U8 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 tpPESession psessionEntry;
3302 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3303 palZeroMemory( pMac->hHdd, (void *)&mlmSetKeysCnf, sizeof( tLimMlmSetKeysCnf ));
3304 //BTAMP
Jeff Johnsone7245742012-09-05 17:12:55 -07003305 if( NULL == limMsgQ->bodyptr )
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003307 PELOGE(limLog(pMac, LOGE,FL("limMsgQ bodyptr is null"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 return;
3309 }
3310 sessionId = ((tpSetBssKeyParams) limMsgQ->bodyptr)->sessionId;
3311 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
3312 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003313 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003314 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 return;
3316 }
3317 if( eLIM_MLM_WT_SET_BSS_KEY_STATE == psessionEntry->limMlmState )
3318 resultCode = (tANI_U16) (((tpSetBssKeyParams) limMsgQ->bodyptr)->status);
3319 else
3320 resultCode = (tANI_U16) (((tpSetStaKeyParams) limMsgQ->bodyptr)->status); //BCAST key also uses tpSetStaKeyParams. Done this way for readabilty.
3321
Jeff Johnsone7245742012-09-05 17:12:55 -07003322 //
3323 // TODO & FIXME_GEN4
3324 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
3325 //
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 // Validate SME/LIM state - Read the above "ASSUMPTIONS"
3327 //if( eLIM_SME_LINK_EST_STATE == pMac->lim.gLimSmeState )
3328 //{
3329 // Validate MLME state
3330 if( eLIM_MLM_WT_SET_BSS_KEY_STATE != psessionEntry->limMlmState &&
3331 eLIM_MLM_WT_SET_STA_BCASTKEY_STATE != psessionEntry->limMlmState )
3332 {
3333 // Mesg received from HAL in Invalid state!
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003334 limLog( pMac, LOGW, FL( "Received unexpected [Mesg Id - %d] in state %X" ), limMsgQ->type, psessionEntry->limMlmState );
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 // There's not much that MLME can do at this stage...
3336 respReqd = 0;
3337 }
3338 else
3339 mlmSetKeysCnf.resultCode = resultCode;
3340
3341 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
3342 // Restore MLME state
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
3344
Jeff Johnsone7245742012-09-05 17:12:55 -07003345 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 if( respReqd )
3347 {
3348 tpLimMlmSetKeysReq lpLimMlmSetKeysReq = (tpLimMlmSetKeysReq) pMac->lim.gpLimMlmSetKeysReq;
3349 mlmSetKeysCnf.sessionId = sessionId;
3350
3351 // Prepare and Send LIM_MLM_SETKEYS_CNF
3352 if( NULL != lpLimMlmSetKeysReq )
3353 {
3354 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf.peerMacAddr, (tANI_U8 *) lpLimMlmSetKeysReq->peerMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 // Free the buffer cached for the global pMac->lim.gpLimMlmSetKeysReq
Jeff Johnsone7245742012-09-05 17:12:55 -07003356 palFreeMemory(pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 pMac->lim.gpLimMlmSetKeysReq = NULL;
3358 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003359 limPostSmeMessage(pMac, LIM_MLM_SETKEYS_CNF, (tANI_U32 *) &mlmSetKeysCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 }
3361}
3362/**
3363 * limProcessMlmRemoveKeyRsp()
3364 *
3365 *FUNCTION:
3366 *
3367 *LOGIC:
3368 *
3369 *ASSUMPTIONS:
3370 *
3371 *NOTE:
3372 *
3373 * @param pMac Pointer to Global MAC structure
3374 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3375 *
3376 * @return None
3377 */
3378void limProcessMlmRemoveKeyRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3379{
Jeff Johnsone7245742012-09-05 17:12:55 -07003380 tANI_U8 respReqd = 1;
3381 tLimMlmRemoveKeyCnf mlmRemoveCnf;
3382 tANI_U16 resultCode;
3383 tANI_U8 sessionId = 0;
3384 tpPESession psessionEntry;
3385 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3386 palZeroMemory( pMac->hHdd, (void *) &mlmRemoveCnf, sizeof( tLimMlmRemoveKeyCnf ));
3387
3388 if( NULL == limMsgQ->bodyptr )
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003390 PELOGE(limLog(pMac, LOGE,FL("limMsgQ bodyptr is NULL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003391 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 }
3393
Jeff Johnsone7245742012-09-05 17:12:55 -07003394 if (limMsgQ->type == WDA_REMOVE_STAKEY_RSP)
3395 sessionId = ((tpRemoveStaKeyParams) limMsgQ->bodyptr)->sessionId;
3396 else if (limMsgQ->type == WDA_REMOVE_BSSKEY_RSP)
3397 sessionId = ((tpRemoveBssKeyParams) limMsgQ->bodyptr)->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003398
Jeff Johnsone7245742012-09-05 17:12:55 -07003399 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003401 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003402 return;
3403 }
3404
3405 if( eLIM_MLM_WT_REMOVE_BSS_KEY_STATE == psessionEntry->limMlmState )
3406 resultCode = (tANI_U16) (((tpRemoveBssKeyParams) limMsgQ->bodyptr)->status);
3407 else
3408 resultCode = (tANI_U16) (((tpRemoveStaKeyParams) limMsgQ->bodyptr)->status);
3409
3410 // Validate MLME state
3411 if( eLIM_MLM_WT_REMOVE_BSS_KEY_STATE != psessionEntry->limMlmState &&
3412 eLIM_MLM_WT_REMOVE_STA_KEY_STATE != psessionEntry->limMlmState )
3413 {
3414 // Mesg received from HAL in Invalid state!
3415 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003416 FL("Received unexpected [Mesg Id - %d] in state %X"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003417 limMsgQ->type,
3418 psessionEntry->limMlmState );
3419 respReqd = 0;
3420 }
3421 else
3422 mlmRemoveCnf.resultCode = resultCode;
3423
3424 //
3425 // TODO & FIXME_GEN4
3426 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
3427 //
3428
3429 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
3430
3431 // Restore MLME state
3432 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
3433 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
3434
3435 if( respReqd )
3436 {
3437 tpLimMlmRemoveKeyReq lpLimMlmRemoveKeyReq = (tpLimMlmRemoveKeyReq) pMac->lim.gpLimMlmRemoveKeyReq;
3438 mlmRemoveCnf.sessionId = sessionId;
3439
3440 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
3441 if( NULL != lpLimMlmRemoveKeyReq )
3442 {
3443 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmRemoveCnf.peerMacAddr, (tANI_U8 *) lpLimMlmRemoveKeyReq->peerMacAddr,
3444 sizeof( tSirMacAddr ));
3445 // Free the buffer cached for the global pMac->lim.gpLimMlmRemoveKeyReq
3446 palFreeMemory(pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmRemoveKeyReq);
3447 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
3448 }
3449 limPostSmeMessage( pMac, LIM_MLM_REMOVEKEY_CNF, (tANI_U32 *) &mlmRemoveCnf );
3450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003451}
3452
Jeff Johnson295189b2012-06-20 16:38:30 -07003453
3454/** ---------------------------------------------------------------------
3455\fn limProcessInitScanRsp
3456\brief This function is called when LIM receives WDA_INIT_SCAN_RSP
3457\ message from HAL. If status code is failure, then
3458\ update the gLimNumOfConsecutiveBkgndScanFailure count.
3459\param tpAniSirGlobal pMac
3460\param tANI_U32 body
3461\return none
3462\ ----------------------------------------------------------------------- */
3463void limProcessInitScanRsp(tpAniSirGlobal pMac, void *body)
3464{
3465 tpInitScanParams pInitScanParam;
3466 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3468 pInitScanParam = (tpInitScanParams) body;
3469 status = pInitScanParam->status;
3470 palFreeMemory( pMac->hHdd, (char *)body);
3471
3472 //Only abort scan if the we are scanning.
3473 if( pMac->lim.abortScan &&
3474 (eLIM_HAL_INIT_SCAN_WAIT_STATE == pMac->lim.gLimHalScanState) )
3475 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003476 limLog( pMac, LOGW, FL(" finish scan") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 pMac->lim.abortScan = 0;
3478 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
3479 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
3480 //Set the resume channel to Any valid channel (invalid).
3481 //This will instruct HAL to set it to any previous valid channel.
3482 peSetResumeChannel(pMac, 0, 0);
3483 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
3484 }
3485 switch(pMac->lim.gLimHalScanState)
3486 {
3487 case eLIM_HAL_INIT_SCAN_WAIT_STATE:
3488 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
3489 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003490 PELOGW(limLog(pMac, LOGW, FL("InitScanRsp with failed status= %d"), status);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3492 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure += 1;
3493 /*
3494 * On Windows eSIR_SME_HAL_SCAN_INIT_FAILED message to CSR may trigger
3495 * another Scan request in the same context (happens when 11d is enabled
3496 * and first scan request with 11d channels fails for whatever reason, then CSR issues next init
3497 * scan in the same context but with bigger channel list), so the state needs to be
3498 * changed before this response message is sent.
3499 */
3500 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 return;
3502 }
3503 else if (status == eHAL_STATUS_SUCCESS)
3504 {
3505 /* since we have successfully triggered a background scan,
3506 * reset the "consecutive bkgnd scan failure" count to 0
3507 */
3508 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure = 0;
3509 pMac->lim.gLimNumOfBackgroundScanSuccess += 1;
3510 }
3511 limContinueChannelScan(pMac);
3512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003513//WLAN_SUSPEND_LINK Related
3514 case eLIM_HAL_SUSPEND_LINK_WAIT_STATE:
3515 if( pMac->lim.gpLimSuspendCallback )
3516 {
3517 if( status == eHAL_STATUS_SUCCESS )
3518 pMac->lim.gLimHalScanState = eLIM_HAL_SUSPEND_LINK_STATE;
3519 else
3520 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3521
3522 pMac->lim.gpLimSuspendCallback( pMac, status, pMac->lim.gpLimSuspendData );
3523 pMac->lim.gpLimSuspendCallback = NULL;
3524 pMac->lim.gpLimSuspendData = NULL;
3525 }
3526 else
3527 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003528 limLog( pMac, LOGP, "No suspend link callback set but station is in suspend state");
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 return;
3530 }
3531 break;
3532//end WLAN_SUSPEND_LINK Related
3533 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003534 limLog(pMac, LOGW, FL("limProcessInitScanRsp: Rcvd InitScanRsp not in WAIT State, state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 pMac->lim.gLimHalScanState);
3536 break;
3537 }
3538 return;
3539}
3540/**
3541 * limProcessSwitchChannelReAssocReq()
3542 *
3543 *FUNCTION:
3544 * This function is called to send the reassoc req mgmt frame after the
3545 * switchChannelRsp message is received from HAL.
3546 *
3547 *LOGIC:
3548 *
3549 *ASSUMPTIONS:
3550 * NA
3551 *
3552 *NOTE:
3553 * NA
3554 *
3555 * @param pMac - Pointer to Global MAC structure.
3556 * @param psessionEntry - session related information.
3557 * @param status - channel switch success/failure.
3558 *
3559 * @return None
3560 */
3561static void limProcessSwitchChannelReAssocReq(tpAniSirGlobal pMac, tpPESession psessionEntry, eHalStatus status)
3562{
3563 tLimMlmReassocCnf mlmReassocCnf;
3564 tLimMlmReassocReq *pMlmReassocReq;
3565 pMlmReassocReq = (tLimMlmReassocReq *)(psessionEntry->pLimMlmReassocReq);
3566 if(pMlmReassocReq == NULL)
3567 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003568 limLog(pMac, LOGP, FL("pLimMlmReassocReq does not exist for given switchChanSession"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3570 goto end;
3571 }
3572
3573 if(status != eHAL_STATUS_SUCCESS)
3574 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003575 PELOGE(limLog(pMac, LOGE, FL("Change channel failed!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 mlmReassocCnf.resultCode = eSIR_SME_CHANNEL_SWITCH_FAIL;
3577 goto end;
3578 }
3579 /// Start reassociation failure timer
Jeff Johnsone7245742012-09-05 17:12:55 -07003580 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3582 != TX_SUCCESS)
3583 {
3584 /// Could not start reassoc failure timer.
3585 // Log error
3586 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003587 FL("could not start Reassociation failure timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 // Return Reassoc confirm with
3589 // Resources Unavailable
3590 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3591 goto end;
3592 }
3593 /// Prepare and send Reassociation request frame
3594 limSendReassocReqMgmtFrame(pMac, pMlmReassocReq, psessionEntry);
3595 return;
3596end:
3597 // Free up buffer allocated for reassocReq
3598 if(pMlmReassocReq != NULL)
3599 {
3600 /* Update PE session Id*/
3601 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
3602 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
3603 }
3604 else
3605 {
3606 mlmReassocCnf.sessionId = 0;
3607 }
3608
3609 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3610 /* Update PE sessio Id*/
3611 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3612
3613 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3614}
3615/**
3616 * limProcessSwitchChannelJoinReq()
3617 *
3618 *FUNCTION:
3619 * This function is called to send the probe req mgmt frame after the
3620 * switchChannelRsp message is received from HAL.
3621 *
3622 *LOGIC:
3623 *
3624 *ASSUMPTIONS:
3625 * NA
3626 *
3627 *NOTE:
3628 * NA
3629 *
3630 * @param pMac - Pointer to Global MAC structure.
3631 * @param psessionEntry - session related information.
3632 * @param status - channel switch success/failure.
3633 *
3634 * @return None
3635 */
3636static void limProcessSwitchChannelJoinReq(tpAniSirGlobal pMac, tpPESession psessionEntry, eHalStatus status)
3637{
3638 tANI_U32 val;
3639 tSirMacSSid ssId;
3640 tLimMlmJoinCnf mlmJoinCnf;
3641 if(status != eHAL_STATUS_SUCCESS)
3642 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003643 PELOGE(limLog(pMac, LOGE, FL("Change channel failed!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 goto error;
3645 }
3646
3647 if ( (NULL == psessionEntry ) || (NULL == psessionEntry->pLimMlmJoinReq) )
3648 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003649 PELOGE(limLog(pMac, LOGE, FL("invalid pointer!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 goto error;
3651 }
3652
Jeff Johnsone7245742012-09-05 17:12:55 -07003653
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 /* eSIR_BTAMP_AP_MODE stroed as bss type in session Table when join req is received, is to be veified */
3655 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3656 {
3657 if (limSetLinkState(pMac, eSIR_LINK_BTAMP_PREASSOC_STATE, psessionEntry->bssId,
3658 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
3659 goto error;
3660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003661
3662 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
3663 if(wlan_cfgGetInt(pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003664 limLog(pMac, LOGP, FL("failed to get WNI_CFG_TRIG_STA_BK_SCAN cfg value!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
3666 // Apply previously set configuration at HW
3667 limApplyConfiguration(pMac, psessionEntry);
3668 /// Wait for Beacon to announce join success
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 palCopyMemory( pMac->hHdd, ssId.ssId,
3670 psessionEntry->ssId.ssId,
3671 psessionEntry->ssId.length);
3672 ssId.length = psessionEntry->ssId.length;
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003673
3674 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3675
3676 //assign appropriate sessionId to the timer object
3677 pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId = psessionEntry->peSessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 // include additional IE if there is
3679 limSendProbeReqMgmtFrame( pMac, &ssId,
3680 psessionEntry->pLimMlmJoinReq->bssDescription.bssId, psessionEntry->currentOperChannel/*chanNum*/,
3681 psessionEntry->selfMacAddr, psessionEntry->dot11mode,
3682 psessionEntry->pLimJoinReq->addIEScan.length, psessionEntry->pLimJoinReq->addIEScan.addIEdata);
Jeff Johnsone7245742012-09-05 17:12:55 -07003683
3684 // Sending mgmt frame is a blocking call activate Join failure timer now
3685 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_JOIN_FAIL_TIMER));
3686 if (tx_timer_activate(&pMac->lim.limTimers.gLimJoinFailureTimer) != TX_SUCCESS)
3687 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003688 limLog(pMac, LOGP, FL("could not activate Join failure timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003689 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
3690 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, pMac->lim.gLimMlmState));
3691 //memory is freed up below.
3692 psessionEntry->pLimMlmJoinReq = NULL;
3693 goto error;
3694 }
3695
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003696 if( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE )
3697 {
Yathish9f22e662012-12-10 14:21:35 -08003698 // Activate Join Periodic Probe Req timer
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003699 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != TX_SUCCESS)
3700 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003701 limLog(pMac, LOGP, FL("could not activate Periodic Join req failure timer"));
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003702 goto error;
3703 }
3704 }
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 return;
3707error:
3708 if(NULL != psessionEntry)
3709 {
3710 palFreeMemory( pMac->hHdd, (tANI_U8 *) (psessionEntry->pLimMlmJoinReq));
3711 psessionEntry->pLimMlmJoinReq = NULL;
3712 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3713 }
3714 else
3715 {
3716 mlmJoinCnf.sessionId = 0;
3717 }
3718 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3719 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3720 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3721}
3722
3723/**
3724 * limProcessSwitchChannelRsp()
3725 *
3726 *FUNCTION:
3727 * This function is called to process switchChannelRsp message from HAL.
3728 *
3729 *LOGIC:
3730 *
3731 *ASSUMPTIONS:
3732 * NA
3733 *
3734 *NOTE:
3735 * NA
3736 *
3737 * @param pMac - Pointer to Global MAC structure
3738 * @param body - message body.
3739 *
3740 * @return None
3741 */
3742void limProcessSwitchChannelRsp(tpAniSirGlobal pMac, void *body)
3743{
3744 tpSwitchChannelParams pChnlParams = NULL;
3745 eHalStatus status;
3746 tANI_U16 channelChangeReasonCode;
3747 tANI_U8 peSessionId;
3748 tpPESession psessionEntry;
3749 //we need to process the deferred message since the initiating req. there might be nested request.
3750 //in the case of nested request the new request initiated from the response will take care of resetting
3751 //the deffered flag.
3752 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3753 pChnlParams = (tpSwitchChannelParams) body;
3754 status = pChnlParams->status;
3755 peSessionId = pChnlParams->peSessionId;
3756 if((psessionEntry = peFindSessionBySessionId(pMac, peSessionId))== NULL)
3757 {
3758 palFreeMemory( pMac->hHdd, (tANI_U8 *)body);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003759 limLog(pMac, LOGP, FL("session does not exist for given sessionId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 return;
3761 }
3762#if defined WLAN_FEATURE_VOWIFI
3763 //HAL fills in the tx power used for mgmt frames in this field.
3764 //Store this value to use in TPC report IE.
3765 rrmCacheMgmtTxPower( pMac, pChnlParams->txMgmtPower, psessionEntry );
3766#endif
3767 palFreeMemory( pMac->hHdd, (tANI_U8 *)body);
3768 channelChangeReasonCode = psessionEntry->channelChangeReasonCode;
3769 // initialize it back to invalid id
3770 psessionEntry->channelChangeReasonCode = 0xBAD;
3771 switch(channelChangeReasonCode)
3772 {
3773 case LIM_SWITCH_CHANNEL_REASSOC:
3774 limProcessSwitchChannelReAssocReq(pMac, psessionEntry, status);
3775 break;
3776 case LIM_SWITCH_CHANNEL_JOIN:
3777 limProcessSwitchChannelJoinReq(pMac, psessionEntry, status);
3778 break;
3779
3780 case LIM_SWITCH_CHANNEL_OPERATION:
3781 /*
3782 * The above code should also use the callback.
3783 * mechanism below, there is scope for cleanup here.
3784 * THat way all this response handler does is call the call back
3785 * We can get rid of the reason code here.
3786 */
3787 if (pMac->lim.gpchangeChannelCallback)
3788 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003789 PELOG1(limLog( pMac, LOG1, "Channel changed hence invoke registered call back");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 pMac->lim.gpchangeChannelCallback(pMac, status, pMac->lim.gpchangeChannelData, psessionEntry);
3791 }
3792 break;
3793 default:
3794 break;
3795 }
3796}
3797/**
3798 * limProcessStartScanRsp()
3799 *
3800 *FUNCTION:
3801 * This function is called to process startScanRsp message from HAL. If scan/learn was successful
3802 * then it will start scan/learn on the next channel.
3803 *
3804 *LOGIC:
3805 *
3806 *ASSUMPTIONS:
3807 * NA
3808 *
3809 *NOTE:
3810 * NA
3811 *
3812 * @param pMac - Pointer to Global MAC structure
3813 * @param body - message body.
3814 *
3815 * @return None
3816 */
3817
3818void limProcessStartScanRsp(tpAniSirGlobal pMac, void *body)
3819{
3820 tpStartScanParams pStartScanParam;
3821 eHalStatus status;
3822 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3823 pStartScanParam = (tpStartScanParams) body;
3824 status = pStartScanParam->status;
3825#if defined WLAN_FEATURE_VOWIFI
3826 //HAL fills in the tx power used for mgmt frames in this field.
3827 //Store this value to use in TPC report IE.
3828 rrmCacheMgmtTxPower( pMac, pStartScanParam->txMgmtPower, NULL );
3829 //Store start TSF of scan start. This will be stored in BSS params.
3830 rrmUpdateStartTSF( pMac, pStartScanParam->startTSF );
3831#endif
3832 palFreeMemory( pMac->hHdd, (tANI_U8 *)body);
3833 if( pMac->lim.abortScan )
3834 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003835 limLog( pMac, LOGW, FL(" finish scan") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 pMac->lim.abortScan = 0;
3837 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
3838 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
3839 //Set the resume channel to Any valid channel (invalid).
3840 //This will instruct HAL to set it to any previous valid channel.
3841 peSetResumeChannel(pMac, 0, 0);
3842 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
3843 }
3844 switch(pMac->lim.gLimHalScanState)
3845 {
3846 case eLIM_HAL_START_SCAN_WAIT_STATE:
3847 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
3848 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003849 PELOGW(limLog(pMac, LOGW, FL("StartScanRsp with failed status= %d"), status);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 //
3851 // FIXME - With this, LIM will try and recover state, but
3852 // eWNI_SME_SCAN_CNF maybe reporting an incorrect
3853 // status back to the SME
3854 //
3855 //Set the resume channel to Any valid channel (invalid).
3856 //This will instruct HAL to set it to any previous valid channel.
3857 peSetResumeChannel(pMac, 0, 0);
3858 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
3859 //limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
3860 }
3861 else
3862 {
3863 pMac->lim.gLimHalScanState = eLIM_HAL_SCANNING_STATE;
3864 limContinuePostChannelScan(pMac);
3865 }
3866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003868 limLog(pMac, LOGW, FL("Rcvd StartScanRsp not in WAIT State, state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 pMac->lim.gLimHalScanState);
3870 break;
3871 }
3872 return;
3873}
3874void limProcessEndScanRsp(tpAniSirGlobal pMac, void *body)
3875{
3876 tpEndScanParams pEndScanParam;
3877 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3879 pEndScanParam = (tpEndScanParams) body;
3880 status = pEndScanParam->status;
3881 palFreeMemory( pMac->hHdd, (char *)body);
3882 switch(pMac->lim.gLimHalScanState)
3883 {
3884 case eLIM_HAL_END_SCAN_WAIT_STATE:
3885 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
3886 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003887 PELOGW(limLog(pMac, LOGW, FL("EndScanRsp with failed status= %d"), status);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3889 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
3890 }
3891 else
3892 {
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08003893 pMac->lim.gLimCurrentScanChannelId++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 limContinueChannelScan(pMac);
3895 }
3896 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003898 limLog(pMac, LOGW, FL("Rcvd endScanRsp not in WAIT State, state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 pMac->lim.gLimHalScanState);
3900 break;
3901 }
3902 return;
3903}
Jeff Johnsone7245742012-09-05 17:12:55 -07003904/**
3905 * limStopTxAndSwitch()
3906 *
3907 *FUNCTION:
3908 * Start channel switch on all sessions that is in channel switch state.
3909 *
3910 * @param pMac - pointer to global adapter context
3911 *
3912 * @return None
3913 *
3914 */
3915static void
3916limStopTxAndSwitch (tpAniSirGlobal pMac)
3917{
3918 tANI_U8 i;
3919
3920 for(i =0; i < pMac->lim.maxBssId; i++)
3921 {
3922 if(pMac->lim.gpSession[i].valid &&
3923 pMac->lim.gpSession[i].gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING)
3924 {
3925 limStopTxAndSwitchChannel(pMac, i);
3926 }
3927 }
3928 return;
3929}
3930/**
3931 * limStartQuietOnSession()
3932 *
3933 *FUNCTION:
3934 * This function is called to start quiet timer after finish scan if there is
3935 * qeuieting on any session.
3936 *
3937 *LOGIC:
3938 *
3939 *ASSUMPTIONS:
3940 * NA
3941 *
3942 *NOTE:
3943 * NA
3944 *
3945 * @param pMac - Pointer to Global MAC structure
3946 *
3947 * @return None
3948 */
3949static void
3950limStartQuietOnSession (tpAniSirGlobal pMac)
3951{
3952 tANI_U8 i;
3953
3954 for(i =0; i < pMac->lim.maxBssId; i++)
3955 {
3956 if(pMac->lim.gpSession[i].valid &&
3957 pMac->lim.gpSession[i].gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
3958 {
3959 limStartQuietTimer(pMac, i);
3960 }
3961 }
3962 return;
3963}
Jeff Johnson295189b2012-06-20 16:38:30 -07003964void limProcessFinishScanRsp(tpAniSirGlobal pMac, void *body)
3965{
3966 tpFinishScanParams pFinishScanParam;
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 eHalStatus status;
3968 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3969 pFinishScanParam = (tpFinishScanParams) body;
3970 status = pFinishScanParam->status;
3971 palFreeMemory( pMac->hHdd, (char *)body);
3972 switch(pMac->lim.gLimHalScanState)
3973 {
3974 case eLIM_HAL_FINISH_SCAN_WAIT_STATE:
3975 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3976 limCompleteMlmScan(pMac, eSIR_SME_SUCCESS);
Jeff Johnsone7245742012-09-05 17:12:55 -07003977 if (limIsChanSwitchRunning(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 {
3979 /** Right time to stop tx and start the timer for channel switch */
3980 /* Sending Session ID 0, may not be correct, since SCAN is global there should not
3981 * be any associated session id
3982 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003983 limStopTxAndSwitch(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003985 else if (limIsQuietBegin(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 {
3987 /** Start the quieting */
3988 /* Sending Session ID 0, may not be correct, since SCAN is global there should not
3989 * be any associated session id
3990 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003991 limStartQuietOnSession(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
3994 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003995 PELOGW(limLog(pMac, LOGW, FL("EndScanRsp with failed status= %d"), status);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 }
3997 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003998//WLAN_SUSPEND_LINK Related
3999 case eLIM_HAL_RESUME_LINK_WAIT_STATE:
4000 if( pMac->lim.gpLimResumeCallback )
4001 {
4002 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
4003 pMac->lim.gpLimResumeCallback( pMac, status, pMac->lim.gpLimResumeData );
4004 pMac->lim.gpLimResumeCallback = NULL;
4005 pMac->lim.gpLimResumeData = NULL;
4006 pMac->lim.gLimSystemInScanLearnMode = 0;
4007 }
4008 else
4009 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004010 limLog( pMac, LOGP, "No Resume link callback set but station is in suspend state");
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 return;
4012 }
4013 break;
4014//end WLAN_SUSPEND_LINK Related
4015
4016 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004017 limLog(pMac, LOGW, FL("Rcvd FinishScanRsp not in WAIT State, state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 pMac->lim.gLimHalScanState);
4019 break;
4020 }
4021 return;
4022}
4023/**
4024 * @function : limProcessMlmHalAddBARsp
4025 *
4026 * @brief: Process WDA_ADDBA_RSP coming from HAL
4027 *
4028 *
4029 * @param pMac The global tpAniSirGlobal object
4030 *
4031 * @param tSirMsgQ The MsgQ header containing the response buffer
4032 *
4033 * @return none
4034 */
4035void limProcessMlmHalAddBARsp( tpAniSirGlobal pMac,
4036 tpSirMsgQ limMsgQ )
4037{
4038 // Send LIM_MLM_ADDBA_CNF to LIM
4039 tpLimMlmAddBACnf pMlmAddBACnf;
4040 tpPESession psessionEntry;
4041 tpAddBAParams pAddBAParams = (tpAddBAParams) limMsgQ->bodyptr;
4042#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4043 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_RSP_EVENT, psessionEntry, 0, 0);
4044#endif //FEATURE_WLAN_DIAG_SUPPORT
4045 //now LIM can process any defer message.
4046 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
4047 if (pAddBAParams == NULL) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004048 PELOGE(limLog(pMac, LOGE,FL("NULL ADD BA Response from HAL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 return;
4050 }
4051 if((psessionEntry = peFindSessionBySessionId(pMac, pAddBAParams->sessionId))==NULL)
4052 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004053 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionID: %d"),pAddBAParams->sessionId );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
4055 return;
4056 }
4057#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4058 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_RSP_EVENT, psessionEntry, 0, 0);
4059#endif //FEATURE_WLAN_DIAG_SUPPORT
4060
4061 // Allocate for LIM_MLM_ADDBA_CNF
4062 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4063 (void **) &pMlmAddBACnf, sizeof( tLimMlmAddBACnf ))) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004064 limLog( pMac, LOGP, FL(" palAllocateMemory failed with error code %d"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
4066 return;
4067 }
4068 palZeroMemory( pMac->hHdd, (void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ));
4069 // Copy the peer MAC
4070 palCopyMemory( pMac->hHdd, pMlmAddBACnf->peerMacAddr, pAddBAParams->peerMacAddr,
4071 sizeof( tSirMacAddr ));
4072 // Copy other ADDBA Rsp parameters
4073 pMlmAddBACnf->baDialogToken = pAddBAParams->baDialogToken;
4074 pMlmAddBACnf->baTID = pAddBAParams->baTID;
4075 pMlmAddBACnf->baPolicy = pAddBAParams->baPolicy;
4076 pMlmAddBACnf->baBufferSize = pAddBAParams->baBufferSize;
4077 pMlmAddBACnf->baTimeout = pAddBAParams->baTimeout;
4078 pMlmAddBACnf->baDirection = pAddBAParams->baDirection;
4079 pMlmAddBACnf->sessionId = psessionEntry->peSessionId;
4080 if(eHAL_STATUS_SUCCESS == pAddBAParams->status)
4081 pMlmAddBACnf->addBAResultCode = eSIR_MAC_SUCCESS_STATUS;
4082 else
4083 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4084 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
4085 // Send ADDBA CNF to LIM
4086 limPostSmeMessage( pMac, LIM_MLM_ADDBA_CNF, (tANI_U32 *) pMlmAddBACnf );
4087}
4088/**
4089 * \brief Process LIM_MLM_ADDBA_CNF
4090 *
4091 * \sa limProcessMlmAddBACnf
4092 *
4093 * \param pMac The global tpAniSirGlobal object
4094 *
4095 * \param tSirMsgQ The MsgQ header containing the response buffer
4096 *
4097 * \return none
4098 */
4099void limProcessMlmAddBACnf( tpAniSirGlobal pMac,
4100 tANI_U32 *pMsgBuf )
4101{
4102tpLimMlmAddBACnf pMlmAddBACnf;
4103tpDphHashNode pSta;
4104tANI_U16 aid;
4105tLimBAState curBaState;
4106tpPESession psessionEntry = NULL;
4107if(pMsgBuf == NULL)
4108{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004109 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 return;
4111}
4112pMlmAddBACnf = (tpLimMlmAddBACnf) pMsgBuf;
4113 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBACnf->sessionId))== NULL)
4114 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004115 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004116 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 return;
4118 }
4119 // First, extract the DPH entry
4120 pSta = dphLookupHashEntry( pMac, pMlmAddBACnf->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4121 if( NULL == pSta )
4122 {
4123 PELOGE(limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004124 FL( "STA context not found - ignoring ADDBA CNF from HAL" ));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
4126 return;
4127 }
4128 LIM_GET_STA_BA_STATE(pSta, pMlmAddBACnf->baTID, &curBaState);
4129 // Need to validate SME state
4130 if( eLIM_BA_STATE_WT_ADD_RSP != curBaState)
4131 {
4132 PELOGE(limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004133 FL( "Received unexpected ADDBA CNF when STA BA state is %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 curBaState );)
Jeff Johnsone7245742012-09-05 17:12:55 -07004135 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 return;
4137 }
4138 // Restore STA BA state
4139 LIM_SET_STA_BA_STATE(pSta, pMlmAddBACnf->baTID, eLIM_BA_STATE_IDLE);
Jeff Johnson43971f52012-07-17 12:26:56 -07004140 if( eSIR_MAC_SUCCESS_STATUS == pMlmAddBACnf->addBAResultCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 {
4142 // Update LIM internal cache...
4143 if( eBA_RECIPIENT == pMlmAddBACnf->baDirection )
4144 {
4145 pSta->tcCfg[pMlmAddBACnf->baTID].fUseBARx = 1;
4146 pSta->tcCfg[pMlmAddBACnf->baTID].fRxCompBA = 1;
4147 pSta->tcCfg[pMlmAddBACnf->baTID].fRxBApolicy = pMlmAddBACnf->baPolicy;
4148 pSta->tcCfg[pMlmAddBACnf->baTID].rxBufSize = pMlmAddBACnf->baBufferSize;
4149 pSta->tcCfg[pMlmAddBACnf->baTID].tuRxBAWaitTimeout = pMlmAddBACnf->baTimeout;
Shailender Karmuchi2a74d4c2013-03-24 23:25:27 -07004150 // Package LIM_MLM_ADDBA_RSP to MLME, with proper
4151 // status code. MLME will then send an ADDBA RSP
4152 // over the air to the peer MAC entity
4153 if( eSIR_SUCCESS != limPostMlmAddBARsp( pMac,
4154 pMlmAddBACnf->peerMacAddr,
4155 pMlmAddBACnf->addBAResultCode,
4156 pMlmAddBACnf->baDialogToken,
4157 (tANI_U8) pMlmAddBACnf->baTID,
4158 (tANI_U8) pMlmAddBACnf->baPolicy,
4159 pMlmAddBACnf->baBufferSize,
4160 pMlmAddBACnf->baTimeout,psessionEntry))
4161 {
4162 PELOGW(limLog( pMac, LOGW,
4163 FL( "Failed to post LIM_MLM_ADDBA_RSP to " ));
4164 limPrintMacAddr( pMac, pMlmAddBACnf->peerMacAddr, LOGW );)
4165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 }
4167 else
4168 {
4169 pSta->tcCfg[pMlmAddBACnf->baTID].fUseBATx = 1;
4170 pSta->tcCfg[pMlmAddBACnf->baTID].fTxCompBA = 1;
4171 pSta->tcCfg[pMlmAddBACnf->baTID].fTxBApolicy = pMlmAddBACnf->baPolicy;
4172 pSta->tcCfg[pMlmAddBACnf->baTID].txBufSize = pMlmAddBACnf->baBufferSize;
4173 pSta->tcCfg[pMlmAddBACnf->baTID].tuTxBAWaitTimeout = pMlmAddBACnf->baTimeout;
4174 }
4175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 // Free the memory allocated for LIM_MLM_ADDBA_CNF
4177 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
4178}
4179/**
4180 * \brief Process LIM_MLM_DELBA_CNF
4181 *
4182 * \sa limProcessMlmDelBACnf
4183 *
4184 * \param pMac The global tpAniSirGlobal object
4185 *
4186 * \param tSirMsgQ The MsgQ header containing the response buffer
4187 *
4188 * \return none
4189 */
4190void limProcessMlmDelBACnf( tpAniSirGlobal pMac,
4191 tANI_U32 *pMsgBuf )
4192{
4193 tpLimMlmDelBACnf pMlmDelBACnf;
4194 tpDphHashNode pSta;
4195 tANI_U16 aid;
4196// tANI_U8 sessionId;
4197 tLimBAState curBaState;
4198 tpPESession psessionEntry;
4199
4200 if(pMsgBuf == NULL)
4201 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004202 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 return;
4204 }
4205 pMlmDelBACnf = (tpLimMlmDelBACnf) pMsgBuf;
4206 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDelBACnf->sessionId))== NULL)
4207 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004208 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnsone7245742012-09-05 17:12:55 -07004209 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 return;
4211 }
4212 // First, extract the DPH entry
4213 pSta = dphLookupHashEntry( pMac, pMlmDelBACnf->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4214 if( NULL == pSta )
4215 {
4216 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004217 FL( "STA context not found - ignoring DELBA CNF from HAL" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07004218 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 return;
4220 }
4221 if(NULL == pMlmDelBACnf)
4222 {
4223 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004224 FL( "pMlmDelBACnf is NULL - ignoring DELBA CNF from HAL" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 return;
4226 }
4227 // Need to validate baState
4228 LIM_GET_STA_BA_STATE(pSta, pMlmDelBACnf->baTID, &curBaState);
4229 if( eLIM_BA_STATE_WT_DEL_RSP != curBaState )
4230 {
4231 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004232 FL( "Received unexpected DELBA CNF when STA BA state is %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 curBaState );
Jeff Johnsone7245742012-09-05 17:12:55 -07004234 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 return;
4236 }
4237 // Restore STA BA state
4238 LIM_SET_STA_BA_STATE(pSta, pMlmDelBACnf->baTID, eLIM_BA_STATE_IDLE);
4239 // Free the memory allocated for LIM_MLM_DELBA_CNF
4240 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
4241}
4242/**
4243 * \brief Process SIR_LIM_DEL_BA_IND
4244 *
4245 * \sa limProcessMlmHalBADeleteInd
4246 *
4247 * \param pMac The global tpAniSirGlobal object
4248 *
4249 * \param tSirMsgQ The MsgQ header containing the indication buffer
4250 *
4251 * \return none
4252 */
4253void limProcessMlmHalBADeleteInd( tpAniSirGlobal pMac,
4254 tpSirMsgQ limMsgQ )
4255{
4256 tSirRetStatus status = eSIR_SUCCESS;
4257 tpBADeleteParams pBADeleteParams;
4258 tpDphHashNode pSta;
4259 tANI_U16 aid;
4260 tLimBAState curBaState;
4261 tpPESession psessionEntry;
4262 tANI_U8 sessionId;
4263
4264 pBADeleteParams = (tpBADeleteParams) limMsgQ->bodyptr;
4265
4266 if((psessionEntry = peFindSessionByBssid(pMac,pBADeleteParams->bssId,&sessionId))== NULL)
4267 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004268 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004269 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 return;
4271 }
4272 // First, extract the DPH entry
4273 pSta = dphLookupHashEntry( pMac, pBADeleteParams->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4274 if( NULL == pSta )
4275 {
4276 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004277 FL( "STA context not found - ignoring BA Delete IND from HAL" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 goto returnAfterCleanup;
4279 }
4280
4281 // Need to validate BA state
4282 LIM_GET_STA_BA_STATE(pSta, pBADeleteParams->baTID, &curBaState);
4283 if( eLIM_BA_STATE_IDLE != curBaState )
4284 {
4285 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004286 FL( "Received unexpected BA Delete IND when STA BA state is %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 curBaState );
4288 goto returnAfterCleanup;
4289 }
4290
4291 // Validate if a BA is active for the requested TID
4292 // AND in that desired direction
4293 if( eBA_INITIATOR == pBADeleteParams->baDirection )
4294 {
4295 if( 0 == pSta->tcCfg[pBADeleteParams->baTID].fUseBATx )
4296 status = eSIR_FAILURE;
4297 }
4298 else
4299 {
4300 if( 0 == pSta->tcCfg[pBADeleteParams->baTID].fUseBARx )
4301 status = eSIR_FAILURE;
4302 }
4303 if( eSIR_FAILURE == status )
4304 {
4305 limLog( pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004306 FL("Received an INVALID DELBA Delete Ind for TID %d..."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 pBADeleteParams->baTID );
4308 }
4309 else
4310 {
4311 // Post DELBA REQ to MLME...
4312 if( eSIR_SUCCESS !=
4313 (status = limPostMlmDelBAReq( pMac,
4314 pSta,
4315 pBADeleteParams->baDirection,
4316 pBADeleteParams->baTID,
4317 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry )))
4318 {
4319 limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004320 FL( "Attempt to post LIM_MLM_DELBA_REQ failed with status %d" ), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 }
4322 else
4323 {
4324 limLog( pMac, LOGE,
4325 FL( "BA Delete - Reason 0x%08x. Attempting to delete BA session for TID %d with peer STA " ),
4326 pBADeleteParams->reasonCode, pBADeleteParams->baTID );
4327 limPrintMacAddr( pMac, pSta->staAddr, LOGE );
4328 }
4329 }
4330returnAfterCleanup:
4331 // Free the memory allocated for SIR_LIM_DEL_BA_IND
4332 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
4333}
4334/**
4335 * @function : limProcessSetMimoRsp()
4336 *
4337 * @brief : This function is called upon receiving the WDA_SET_MIMOPS_RSP from the HAL
4338 * after Processing the Req from the SME (PMC)
4339 *
4340 * LOGIC:
4341 *
4342 * ASSUMPTIONS:
4343 * NA
4344 *
4345 * NOTE:
4346 * NA
4347 *
4348 * @param pMac - Pointer to Global MAC structure
4349 * @param limMsg - Lim Message structure object with the MimoPSparam in body
4350 * @return None
4351 */
4352
4353void
4354limProcessSetMimoRsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
4355{
4356#if 0
4357 tSirRetStatus retStatus;
4358 tpSetMIMOPS pMIMO_PSParams;
4359
4360
4361 do {
4362
4363 pMIMO_PSParams = (tpSetMIMOPS)limMsg->bodyptr;
4364 if( NULL == pMIMO_PSParams ) {
4365 PELOGE(limLog(pMac, LOGE, "Received the WDA_SET_MIMOPS_RSP with NULL as the PS param");)
4366 return;
4367 }
4368
4369 /** If Updation of the HAL Fail's*/
4370 if (pMIMO_PSParams->status != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004371 limLog(pMac, LOGP, FL("Update HAL / SW Mac for MIMO State has Failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 break;
4373 }
4374
4375 if ((pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) ||
4376 (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) )
4377 break;
4378
4379 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
4380 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
4381
4382 /** In the Case of Exiting out of the Powersave (changing from Dynamic/Static mode to SM Enabled)
4383 * send the action Frame to Peer to update the PS State of the STA , for the case of Entering PowerSave
4384 * the Action Frame is being sent at first before setting the internal structures
4385 */
4386 if (!isEnteringMimoPS(pMac->lim.gHTMIMOPSState, pMIMO_PSParams->htMIMOPSState)) {
4387 tSirMacAddr macAddr;
4388
4389 /** Obtain the AP's Mac Address */
4390 palCopyMemory(pMac -> hHdd, (tANI_U8 *)macAddr, pMac->lim.gLimBssid, sizeof(tSirMacAddr));
4391
4392 /** Send Action Frame with the corresponding mode */
4393 retStatus = limSendSMPowerStateFrame(pMac, macAddr, pMIMO_PSParams->htMIMOPSState);
4394 if (retStatus != eSIR_SUCCESS) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004395 PELOGE(limLog(pMac, LOGE, FL("Sending Action Frame has failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 break;
4397 }
4398 }
4399 PELOG1(limLog(pMac, LOG1, FL("The Setting up of LimGlobals is successful for MIMOPS"));)
4400 }while(0);
4401
4402 palFreeMemory( pMac->hHdd, (void *) pMIMO_PSParams );
4403#endif
4404}
4405/**
4406 * @function : limHandleDelBssInReAssocContext
4407 * @brief : While Processing the ReAssociation Response Frame in STA,
4408 * a. immediately after receiving the Reassoc Response the RxCleanUp is
4409 * being issued and the end of DelBSS the new BSS is being added.
4410 *
4411 * b .If an AP rejects the ReAssociation (Disassoc / Deauth) with some context
4412 * change, We need to update CSR with ReAssocCNF Response with the
4413 * ReAssoc Fail and the reason Code, that is also being handled in the DELBSS
4414 * context only
4415 *
4416 * @param : pMac - tpAniSirGlobal
4417 * pStaDs - Station Descriptor
4418 *
4419 * @return : none
4420 */
4421static void
4422limHandleDelBssInReAssocContext(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry)
4423{
4424 tLimMlmReassocCnf mlmReassocCnf;
4425 /** Skipped the DeleteDPH Hash Entry as we need it for the new BSS*/
4426 /** Set the MlmState to IDLE*/
4427 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 /* Update PE session Id*/
4429 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
4430 switch (psessionEntry->limMlmState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 case eLIM_SME_WT_REASSOC_STATE :
4432 {
4433 tpSirAssocRsp assocRsp;
4434 tpDphHashNode pStaDs;
4435 tSirRetStatus retStatus = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 tSchBeaconStruct beaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 /** Delete the older STA Table entry */
4438 limDeleteDphHashEntry(pMac, psessionEntry->bssId, DPH_STA_HASH_INDEX_PEER, psessionEntry);
4439 /**
4440 * Add an entry for AP to hash table
4441 * maintained by DPH module
4442 */
4443 if ((pStaDs = dphAddHashEntry(pMac, psessionEntry->limReAssocbssId, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) == NULL)
4444 {
4445 // Could not add hash table entry
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004446 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOGE);
4448 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4449 mlmReassocCnf.protStatusCode = eSIR_SME_SUCCESS;
4450 goto Error;
4451 }
4452 /** While Processing the ReAssoc Response Frame the ReAssocRsp Frame
4453 * is being stored to be used here for sending ADDBSS
4454 */
4455 assocRsp = (tpSirAssocRsp)psessionEntry->limAssocResponseData;
4456 limUpdateAssocStaDatas(pMac, pStaDs, assocRsp,psessionEntry);
4457 limUpdateReAssocGlobals(pMac, assocRsp,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 limExtractApCapabilities( pMac,
4459 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
4460 limGetIElenFromBssDescription( &psessionEntry->pLimReAssocReq->bssDescription ),
4461 &beaconStruct );
4462 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
4463 limDecideStaProtectionOnAssoc(pMac, &beaconStruct, psessionEntry);
4464 if(beaconStruct.erpPresent) {
4465 if (beaconStruct.erpIEInfo.barkerPreambleMode)
4466 psessionEntry->beaconParams.fShortPreamble = 0;
4467 else
4468 psessionEntry->beaconParams.fShortPreamble = 1;
4469 }
4470 //updateBss flag is false, as in this case, PE is first deleting the existing BSS and then adding a new one.
4471 if (eSIR_SUCCESS != limStaSendAddBss( pMac, assocRsp, &beaconStruct,
4472 &psessionEntry->pLimReAssocReq->bssDescription, false, psessionEntry)) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004473 limLog( pMac, LOGE, FL( "Posting ADDBSS in the ReAssocContext has Failed "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 retStatus = eSIR_FAILURE;
4475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 if (retStatus != eSIR_SUCCESS)
4477 {
4478 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4479 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4480 palFreeMemory(pMac->hHdd, assocRsp);
4481 pMac->lim.gLimAssocResponseData = NULL;
4482 goto Error;
4483 }
4484 palFreeMemory(pMac->hHdd, assocRsp);
4485 psessionEntry->limAssocResponseData = NULL;
4486 }
4487 break;
4488 case eLIM_SME_WT_REASSOC_LINK_FAIL_STATE:
4489 {
4490 /** Case wherein the DisAssoc / Deauth
4491 * being sent as response to ReAssoc Req*/
4492 /** Send the Reason code as the same received in Disassoc / Deauth Frame*/
4493 mlmReassocCnf.resultCode = pStaDs->mlmStaContext.disassocReason;
4494 mlmReassocCnf.protStatusCode = pStaDs->mlmStaContext.cleanupTrigger;
4495 /** Set the SME State back to WT_Reassoc State*/
4496 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
4498 if((psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4499 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
4500 {
4501 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 }
4503 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
4504 }
4505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004507 PELOGE(limLog(pMac, LOGE, FL("DelBss is being invoked in the wrong system Role /unhandled SME State"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 mlmReassocCnf.resultCode = eSIR_SME_REFUSED;
4509 mlmReassocCnf.protStatusCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
4510 goto Error;
4511 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004512 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07004513Error:
4514 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
4515}
4516
4517/* Added For BT -AMP Support */
4518static void
4519limProcessBtampAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry)
4520{
4521 tLimMlmStartCnf mlmStartCnf;
4522 tANI_U32 val;
4523 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
4524
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304525 if (NULL == pAddBssParams)
4526 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004527 limLog( pMac, LOGE, FL( "Invalid body pointer in message"));
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304528 goto end;
4529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
4531 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004532 limLog(pMac, LOG2, FL("WDA_ADD_BSS_RSP returned with eHAL_STATUS_SUCCESS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
4534 {
4535 if (limSetLinkState(pMac, eSIR_LINK_BTAMP_AP_STATE, psessionEntry->bssId,
4536 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
4537 goto end;
4538 } else if (psessionEntry->bssType == eSIR_BTAMP_STA_MODE) {
4539 if (limSetLinkState(pMac, eSIR_LINK_SCAN_STATE, psessionEntry->bssId,
4540 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
4541 goto end;
4542 }
4543
4544 // Set MLME state
4545 psessionEntry->limMlmState= eLIM_MLM_BSS_STARTED_STATE;
4546 psessionEntry->statypeForBss = STA_ENTRY_SELF; // to know session started for peer or for self
4547 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
4548 schEdcaProfileUpdate(pMac, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004549 limInitPeerIdxpool(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 // Create timers used by LIM
4551 if (!pMac->lim.gLimTimersCreated)
4552 limCreateTimers(pMac);
4553 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
4554 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val ))
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004555 limLog( pMac, LOGP, FL("Failed to get WNI_CFG_TRIG_STA_BK_SCAN!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
4557 // Apply previously set configuration at HW
4558 limApplyConfiguration(pMac,psessionEntry);
4559 psessionEntry->staId = pAddBssParams->staContext.staIdx;
4560 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
4561 }
4562 else
4563 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004564 limLog( pMac, LOGE, FL( "WDA_ADD_BSS_REQ failed with status %d" ),pAddBssParams->status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
4566 }
4567 mlmStartCnf.sessionId = psessionEntry->peSessionId;
4568 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
4569 end:
4570 if( 0 != limMsgQ->bodyptr )
4571 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
4572}
4573
4574/**
4575 * @function : limHandleAddBssInReAssocContext
4576 * @brief : While Processing the ReAssociation Response Frame in STA,
4577 * a. immediately after receiving the Reassoc Response the RxCleanUp is
4578 * being issued and the end of DelBSS the new BSS is being added.
4579 *
4580 * b .If an AP rejects the ReAssociation (Disassoc / Deauth) with some context
4581 * change, We need to update CSR with ReAssocCNF Response with the
4582 * ReAssoc Fail and the reason Code, that is also being handled in the DELBSS
4583 * context only
4584 *
4585 * @param : pMac - tpAniSirGlobal
4586 * pStaDs - Station Descriptor
4587 *
4588 * @return : none
4589 */
4590void
4591limHandleAddBssInReAssocContext(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpPESession psessionEntry)
4592{
4593 tLimMlmReassocCnf mlmReassocCnf;
4594 /** Skipped the DeleteDPH Hash Entry as we need it for the new BSS*/
4595 /** Set the MlmState to IDLE*/
Jeff Johnsone7245742012-09-05 17:12:55 -07004596 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
4597 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 switch (psessionEntry->limSmeState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 case eLIM_SME_WT_REASSOC_STATE : {
4600 tpSirAssocRsp assocRsp;
4601 tpDphHashNode pStaDs;
4602 tSirRetStatus retStatus = eSIR_SUCCESS;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004603 tSchBeaconStruct *pBeaconStruct;
4604 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
4605 (void **)&pBeaconStruct, sizeof(tSchBeaconStruct)))
4606 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004607 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limHandleAddBssInReAssocContext") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004608 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4609 mlmReassocCnf.protStatusCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4610 goto Error;
4611 }
4612
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 // Get the AP entry from DPH hash table
4614 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4615 if (pStaDs == NULL )
4616 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004617 PELOGE(limLog(pMac, LOGE, FL("Fail to get STA PEER entry from hash"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4619 mlmReassocCnf.protStatusCode = eSIR_SME_SUCCESS;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004620 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 goto Error;
4622 }
4623 /** While Processing the ReAssoc Response Frame the ReAssocRsp Frame
4624 * is being stored to be used here for sending ADDBSS
4625 */
4626 assocRsp = (tpSirAssocRsp)psessionEntry->limAssocResponseData;
4627 limUpdateAssocStaDatas(pMac, pStaDs, assocRsp, psessionEntry);
4628 limUpdateReAssocGlobals(pMac, assocRsp, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 limExtractApCapabilities( pMac,
4630 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
4631 limGetIElenFromBssDescription( &psessionEntry->pLimReAssocReq->bssDescription ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004632 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004634 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
4635
4636 if(pBeaconStruct->erpPresent)
4637 {
4638 if (pBeaconStruct->erpIEInfo.barkerPreambleMode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 psessionEntry->beaconParams.fShortPreamble = 0;
4640 else
4641 psessionEntry->beaconParams.fShortPreamble = 1;
4642 }
4643
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004644 if (eSIR_SUCCESS != limStaSendAddBss( pMac, assocRsp, pBeaconStruct,
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 &psessionEntry->pLimReAssocReq->bssDescription, true, psessionEntry)) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004646 limLog( pMac, LOGE, FL( "Posting ADDBSS in the ReAssocContext has Failed "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 retStatus = eSIR_FAILURE;
4648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 if (retStatus != eSIR_SUCCESS)
4650 {
4651 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4652 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4653 palFreeMemory(pMac->hHdd, assocRsp);
4654 pMac->lim.gLimAssocResponseData = NULL;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004655 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 goto Error;
4657 }
4658 palFreeMemory(pMac->hHdd, assocRsp);
4659 psessionEntry->limAssocResponseData = NULL;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004660 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 }
4662 break;
4663 case eLIM_SME_WT_REASSOC_LINK_FAIL_STATE: { /** Case wherein the DisAssoc / Deauth
4664 * being sent as response to ReAssoc Req*/
4665 /** Send the Reason code as the same received in Disassoc / Deauth Frame*/
4666 mlmReassocCnf.resultCode = pStaDs->mlmStaContext.disassocReason;
4667 mlmReassocCnf.protStatusCode = pStaDs->mlmStaContext.cleanupTrigger;
4668 /** Set the SME State back to WT_Reassoc State*/
4669 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
4670 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4671 if(psessionEntry->limSystemRole == eLIM_STA_ROLE)
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08004672 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08004674 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
4675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004676
4677 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
4678 }
4679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004681 PELOGE(limLog(pMac, LOGE, FL("DelBss is being invoked in the wrong system Role /unhandled SME State"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 mlmReassocCnf.resultCode = eSIR_SME_REFUSED;
4683 mlmReassocCnf.protStatusCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
4684 goto Error;
4685 }
4686return;
4687Error:
4688 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
4689}
4690
4691#if 0
4692 static void
4693limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
4694{
4695 tSirSmeAssocCnf assocCnf;
4696 tpDphHashNode pStaDs;
4697 tpPESession psessionEntry;
4698 tANI_U8 sessionId;
4699
4700 if(pMsgBuf == NULL)
4701 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004702 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 goto end;
4704 }
4705 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
4706 !__limIsSmeAssocCnfValid(&assocCnf))
4707 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004708 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 goto end;
4710 }
4711 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
4712 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004713 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 goto end;
4715 }
4716 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
4717 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
4718 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004719 limLog(pMac, LOGE, FL("Received unexpected message %X in state %X, in role %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 msgType, psessionEntry->limSmeState , psessionEntry->limSystemRole);
4721 goto end;
4722 }
4723 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
4724 if (pStaDs == NULL)
4725 {
4726 limLog(pMac, LOG1,
4727 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
4728 msgType, assocCnf.aid);
4729 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4730 /*
4731 ** send a DISASSOC_IND message to WSM to make sure
4732 ** the state in WSM and LIM is the same
4733 **/
4734 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
4735 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
4736 goto end;
4737 }
4738 if ((pStaDs &&
4739 (( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pStaDs->staAddr,
4740 (tANI_U8 *) assocCnf.peerMacAddr,
4741 sizeof(tSirMacAddr)) ) ||
4742 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
4743 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
4744 (msgType != eWNI_SME_ASSOC_CNF)) ||
4745 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
4746 (msgType != eWNI_SME_REASSOC_CNF)))))
4747 {
4748 limLog(pMac, LOG1,
4749 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
4750 msgType, assocCnf.aid);
4751 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4752 goto end;
4753 }
4754 /*
4755 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
4756 ** has been received
4757 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004758 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
4760 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
4761 {
4762 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
4763 * when it had received Assoc Request frame. Now, PE just needs to send
4764 * Association Response frame to the requesting BTAMP-STA.
4765 */
4766 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004767 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
4769 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
4770 goto end;
4771 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
4772 else
4773 {
4774 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
4775 limRejectAssociation(pMac, pStaDs->staAddr,
4776 pStaDs->mlmStaContext.subType,
4777 true, pStaDs->mlmStaContext.authType,
4778 pStaDs->assocId, true,
4779 assocCnf.statusCode, psessionEntry);
4780 return;
4781 }
4782end:
4783 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
4784 {
4785 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
4786 {
4787 palFreeMemory(pMac->hHdd,((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
4788 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
4789 }
4790
4791 palFreeMemory(pMac->hHdd, psessionEntry->parsedAssocReq[pStaDs->assocId]);
4792 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
4793 }
4794} /*** end __limProcessSmeAssocCnfNew() ***/
4795#endif
4796
Jeff Johnson295189b2012-06-20 16:38:30 -07004797void
4798limSendBeaconInd(tpAniSirGlobal pMac, tpPESession psessionEntry){
4799 tBeaconGenParams *pBeaconGenParams = NULL;
4800 tSirMsgQ limMsg;
4801 /** Allocate the Memory for Beacon Pre Message and for Stations in PoweSave*/
4802 if(psessionEntry == NULL ){
4803 PELOGE( limLog( pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004804 FL( "Error:Unable to get the PESessionEntry" ));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 return;
4806 }
4807 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4808 (void **) &pBeaconGenParams, (sizeof(*pBeaconGenParams))))
4809 {
4810 PELOGE( limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004811 FL( "Unable to PAL allocate memory during sending beaconPreMessage" ));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 return;
4813 }
4814 palZeroMemory( pMac->hHdd, pBeaconGenParams, sizeof(*pBeaconGenParams));
4815 palCopyMemory( pMac->hHdd, (void *) pBeaconGenParams->bssId,
4816 (void *)psessionEntry->bssId,
4817 SIR_MAC_ADDR_LENGTH );
4818 limMsg.bodyptr = pBeaconGenParams;
4819 schProcessPreBeaconInd(pMac, &limMsg);
4820 return;
4821}