blob: d196390c481bc9c198b5d128adf7b2cef0558d9f [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"
54#ifdef ANI_PRODUCT_TYPE_AP
55#include "wniCfgAp.h"
56#else
57#include "wniCfgSta.h"
58#endif
59#include "cfgApi.h"
60#include "sirApi.h"
61#include "schApi.h"
62#include "utilsApi.h"
63#include "limUtils.h"
64#include "limAssocUtils.h"
65#include "limSecurityUtils.h"
66#include "limSerDesUtils.h"
67#include "limTimerUtils.h"
68#include "limSendMessages.h"
69#include "limAdmitControl.h"
70#include "limSendMessages.h"
71#include "limIbssPeerMgmt.h"
72#include "limSession.h"
Jeff Johnsone7245742012-09-05 17:12:55 -070073#include "limSessionUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#if defined WLAN_FEATURE_VOWIFI
75#include "rrmApi.h"
76#endif
77#if defined WLAN_FEATURE_VOWIFI_11R
78#include <limFT.h>
79#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070080#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081
82static void limHandleSmeJoinResult(tpAniSirGlobal, tSirResultCodes, tANI_U16,tpPESession);
Jeff Johnsone7245742012-09-05 17:12:55 -070083static void limHandleSmeReaasocResult(tpAniSirGlobal, tSirResultCodes, tANI_U16, tpPESession);
Jeff Johnson295189b2012-06-20 16:38:30 -070084void limProcessMlmScanCnf(tpAniSirGlobal, tANI_U32 *);
Jeff Johnsone7245742012-09-05 17:12:55 -070085#ifdef FEATURE_OEM_DATA_SUPPORT
86void limProcessMlmOemDataReqCnf(tpAniSirGlobal, tANI_U32 *);
87#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070088void limProcessMlmJoinCnf(tpAniSirGlobal, tANI_U32 *);
89void limProcessMlmAuthCnf(tpAniSirGlobal, tANI_U32 *);
90void limProcessMlmStartCnf(tpAniSirGlobal, tANI_U32 *);
91void limProcessMlmAuthInd(tpAniSirGlobal, tANI_U32 *);
92void limProcessMlmAssocInd(tpAniSirGlobal, tANI_U32 *);
93void limProcessMlmAssocCnf(tpAniSirGlobal, tANI_U32 *);
94void limProcessMlmReassocCnf(tpAniSirGlobal, tANI_U32 *);
95void limProcessMlmReassocInd(tpAniSirGlobal, tANI_U32 *);
96void limProcessMlmSetKeysCnf(tpAniSirGlobal, tANI_U32 *);
97void limProcessMlmDisassocInd(tpAniSirGlobal, tANI_U32 *);
98void limProcessMlmDisassocCnf(tpAniSirGlobal, tANI_U32 *);
99void limProcessMlmDeauthInd(tpAniSirGlobal, tANI_U32 *);
100void limProcessMlmDeauthCnf(tpAniSirGlobal, tANI_U32 *);
101void limProcessMlmPurgeStaInd(tpAniSirGlobal, tANI_U32 *);
102void limProcessMlmAddBACnf(tpAniSirGlobal, tANI_U32 *);
103void limProcessMlmDelBACnf(tpAniSirGlobal, tANI_U32 *);
104void limProcessMlmRemoveKeyCnf(tpAniSirGlobal pMac, tANI_U32 * pMsgBuf);
105static void limHandleDelBssInReAssocContext(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry);
106void limGetSessionInfo(tpAniSirGlobal pMac, tANI_U8 *, tANI_U8 *, tANI_U16 *);
107static void
108limProcessBtampAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry);
109/**
110 * limProcessMlmRspMessages()
111 *
112 *FUNCTION:
113 * This function is called to processes various MLM response (CNF/IND
114 * messages from MLM State machine.
115 *
116 *LOGIC:
117 *
118 *ASSUMPTIONS:
119 *
120 *NOTE:
121 *
122 * @param pMac Pointer to Global MAC structure
123 * @param msgType Indicates the MLM message type
124 * @param *pMsgBuf A pointer to the MLM message buffer
125 *
126 * @return None
127 */
128void
129limProcessMlmRspMessages(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
130{
131
132 if(pMsgBuf == NULL)
133 {
134 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
135 return;
136 }
137 switch (msgType)
138 {
139 case LIM_MLM_SCAN_CNF:
140 limProcessMlmScanCnf(pMac, pMsgBuf);
141 break;
142
Jeff Johnsone7245742012-09-05 17:12:55 -0700143#ifdef FEATURE_OEM_DATA_SUPPORT
144 case LIM_MLM_OEM_DATA_CNF:
145 limProcessMlmOemDataReqCnf(pMac, pMsgBuf);
146 break;
147#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
149 case LIM_MLM_AUTH_CNF:
150 limProcessMlmAuthCnf(pMac, pMsgBuf);
151 break;
152 case LIM_MLM_AUTH_IND:
153 limProcessMlmAuthInd(pMac, pMsgBuf);
154 break;
155 case LIM_MLM_ASSOC_CNF:
156 limProcessMlmAssocCnf(pMac, pMsgBuf);
157 break;
158 case LIM_MLM_START_CNF:
159 limProcessMlmStartCnf(pMac, pMsgBuf);
160 break;
161 case LIM_MLM_JOIN_CNF:
162 limProcessMlmJoinCnf(pMac, pMsgBuf);
163 break;
164 case LIM_MLM_ASSOC_IND:
165 limProcessMlmAssocInd(pMac, pMsgBuf);
166 break;
167 case LIM_MLM_REASSOC_CNF:
168 limProcessMlmReassocCnf(pMac, pMsgBuf);
169 break;
170 case LIM_MLM_REASSOC_IND:
171 limProcessMlmReassocInd(pMac, pMsgBuf);
172 break;
173 case LIM_MLM_DISASSOC_CNF:
174 limProcessMlmDisassocCnf(pMac, pMsgBuf);
175 break;
176 case LIM_MLM_DISASSOC_IND:
177 limProcessMlmDisassocInd(pMac, pMsgBuf);
178 break;
179 case LIM_MLM_PURGE_STA_IND:
180 limProcessMlmPurgeStaInd(pMac, pMsgBuf);
181 break;
182 case LIM_MLM_DEAUTH_CNF:
183 limProcessMlmDeauthCnf(pMac, pMsgBuf);
184 break;
185 case LIM_MLM_DEAUTH_IND:
186 limProcessMlmDeauthInd(pMac, pMsgBuf);
187 break;
188 case LIM_MLM_SETKEYS_CNF:
189 limProcessMlmSetKeysCnf(pMac, pMsgBuf);
190 break;
191 case LIM_MLM_REMOVEKEY_CNF:
192 limProcessMlmRemoveKeyCnf(pMac, pMsgBuf);
193 break;
194 case LIM_MLM_TSPEC_CNF:
195 break;
196 case LIM_MLM_ADDBA_CNF:
197 limProcessMlmAddBACnf( pMac, pMsgBuf );
198 break;
199 case LIM_MLM_DELBA_CNF:
200 limProcessMlmDelBACnf( pMac, pMsgBuf );
201 break;
202 default:
203 break;
204 } // switch (msgType)
205 return;
206} /*** end limProcessMlmRspMessages() ***/
207
208/**
209 * limProcessMlmScanCnf()
210 *
211 *FUNCTION:
212 * This function is called to processes MLM_SCAN_CNF
213 * message from MLM State machine.
214 *
215 *LOGIC:
216 *
217 *ASSUMPTIONS:
218 *
219 *NOTE:
220 *
221 * @param pMac Pointer to Global MAC structure
222 * @param pMsgBuf A pointer to the MLM message buffer
223 *
224 * @return None
225 */
226void
227limProcessMlmScanCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
228{
229 switch(pMac->lim.gLimSmeState)
230 {
231 case eLIM_SME_WT_SCAN_STATE:
232 //case eLIM_SME_LINK_EST_WT_SCAN_STATE: //TO SUPPORT BT-AMP
233 //case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE: //TO SUPPORT BT-AMP
234 pMac->lim.gLimSmeState = pMac->lim.gLimPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700235 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 pMac->lim.gLimSystemInScanLearnMode = 0;
237 break;
238 default:
239 /**
240 * Should not have received scan confirm
241 * from MLM in other states.
242 * Log error
243 */
244 PELOGE(limLog(pMac, LOGE,
245 FL("received unexpected MLM_SCAN_CNF in state %X\n"),
246 pMac->lim.gLimSmeState);)
247 return;
248 }
249
250 /// Process received scan confirm
251 /// Increment length of cached scan results
252 pMac->lim.gLimSmeScanResultLength +=
253 ((tLimMlmScanCnf *) pMsgBuf)->scanResultLength;
254 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
255 {
256 tANI_U16 scanRspLen = 0;
257 /// Need to send response to Host
258 pMac->lim.gLimRspReqd = false;
259 if ((((tLimMlmScanCnf *) pMsgBuf)->resultCode ==
260 eSIR_SME_SUCCESS) ||
261 pMac->lim.gLimSmeScanResultLength)
262 {
263 scanRspLen = sizeof(tSirSmeScanRsp) +
264 pMac->lim.gLimSmeScanResultLength -
265 sizeof(tSirBssDescription);
266 }
267 else
268 {
269 scanRspLen = sizeof(tSirSmeScanRsp);
270 }
271 if(pMac->lim.gLimReportBackgroundScanResults)
272 {
273 pMac->lim.gLimBackgroundScanTerminate = TRUE;
274 }
275 if (pMac->lim.gLimSmeScanResultLength == 0)
276 {
277 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
278 }
279 else
280 {
281 limSendSmeScanRsp(pMac, scanRspLen,
282 eSIR_SME_SUCCESS,pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
283 }
284 } // if (pMac->lim.gLimRspReqd)
285 //check to see whether we need to run bgScan timer
286 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
287 {
288 if (tx_timer_activate(
289 &pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
290 {
291 /// Could not activate background scan timer.
292 // Log error
293 limLog(pMac, LOGP,
294 FL("could not activate background scan timer\n"));
295 pMac->lim.gLimBackgroundScanStarted = FALSE;
296 }
297 else
298 {
299 pMac->lim.gLimBackgroundScanStarted = TRUE;
300 }
301 }
302} /*** end limProcessMlmScanCnf() ***/
303
Jeff Johnsone7245742012-09-05 17:12:55 -0700304#ifdef FEATURE_OEM_DATA_SUPPORT
305
306/**
307 * limProcessMlmOemDataReqCnf()
308 *
309 *FUNCTION:
310 * This function is called to processes LIM_MLM_OEM_DATA_REQ_CNF
311 * message from MLM State machine.
312 *
313 *LOGIC:
314 *
315 *ASSUMPTIONS:
316 *
317 *NOTE:
318 *
319 * @param pMac Pointer to Global MAC structure
320 * @param pMsgBuf A pointer to the MLM message buffer
321 *
322 * @return None
323 */
324
325void limProcessMlmOemDataReqCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
326{
327 tLimMlmOemDataRsp* measRsp;
328
329 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
330
331 measRsp = (tLimMlmOemDataRsp*)(pMsgBuf);
332
333 //Now send the meas confirm message to the sme
334 limSendSmeOemDataRsp(pMac, (tANI_U32*)measRsp, resultCode);
335
336 //Dont free the memory here. It will be freed up by the callee
337
338 return;
339}
340#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
342/**
343 * limProcessMlmStartCnf()
344 *
345 *FUNCTION:
346 * This function is called to processes MLM_START_CNF
347 * message from MLM State machine.
348 *
349 *LOGIC:
350 *
351 *ASSUMPTIONS:
352 *
353 *NOTE:
354 *
355 * @param pMac Pointer to Global MAC structure
356 * @param pMsgBuf A pointer to the MLM message buffer
357 *
358 * @return None
359 */
360void
361limProcessMlmStartCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
362{
363 tpPESession psessionEntry = NULL;
364 tLimMlmStartCnf *pLimMlmStartCnf;
365 tANI_U8 smesessionId;
366 tANI_U16 smetransactionId;
367
368 if(pMsgBuf == NULL)
369 {
370 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
371 return;
372 }
373 pLimMlmStartCnf = (tLimMlmStartCnf*)pMsgBuf;
374 if((psessionEntry = peFindSessionBySessionId(pMac,pLimMlmStartCnf->sessionId))==NULL)
375 {
376 PELOGE(limLog(pMac, LOGE,FL("Session does Not exist with given sessionId \n"));)
377 return;
378 }
379 smesessionId = psessionEntry->smeSessionId;
380 smetransactionId = psessionEntry->transactionId;
381
382 if (psessionEntry->limSmeState != eLIM_SME_WT_START_BSS_STATE)
383 {
384 /**
385 * Should not have received Start confirm from MLM
386 * in other states.
387 * Log error
388 */
389 PELOGE(limLog(pMac, LOGE,
390 FL("received unexpected MLM_START_CNF in state %X\n"),
391 psessionEntry->limSmeState);)
392 return;
393 }
394 if (((tLimMlmStartCnf *) pMsgBuf)->resultCode ==
395 eSIR_SME_SUCCESS)
396 {
397
398 /**
399 * Update global SME state so that Beacon Generation
400 * module starts writing Beacon frames into TFP's
401 * Beacon file register.
402 */
403 psessionEntry->limSmeState = eLIM_SME_NORMAL_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700404 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 if(psessionEntry->bssType == eSIR_BTAMP_STA_MODE)
406 {
407 limLog(pMac, LOG1, FL("*** Started BSS in BT_AMP STA SIDE***\n"));
408 }
409 else if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
410 {
411 limLog(pMac, LOG1, FL("*** Started BSS in BT_AMP AP SIDE***\n"));
412 }
413#ifdef WLAN_SOFTAP_FEATURE
414 else if(psessionEntry->bssType == eSIR_INFRA_AP_MODE)
415 {
416 limLog(pMac, LOG1, FL("*** Started BSS in INFRA AP SIDE***\n"));
417 }
418#endif
419 else
420 PELOG1(limLog(pMac, LOG1, FL("*** Started BSS ***\n"));)
421 }
422 else
423 {
424 /// Start BSS is a failure
425 peDeleteSession(pMac,psessionEntry);
426 psessionEntry = NULL;
427 }
428 /// Send response to Host
429 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP,
430 ((tLimMlmStartCnf *) pMsgBuf)->resultCode,psessionEntry,
431 smesessionId,smetransactionId);
432#ifdef WLAN_SOFTAP_FEATURE
433 if (((tLimMlmStartCnf *) pMsgBuf)->resultCode == eSIR_SME_SUCCESS)
434 {
435 //Configure beacon and send beacons to HAL
436 limSendBeaconInd(pMac, psessionEntry);
437 }
438#endif
439}
440
441 /*** end limProcessMlmStartCnf() ***/
442
443/**
444 * limProcessMlmJoinCnf()
445 *
446 *FUNCTION:
447 * This function is called to processes MLM_JOIN_CNF
448 * message from MLM State machine.
449 *
450 *LOGIC:
451 *
452 *ASSUMPTIONS:
453 *
454 *NOTE:
455 *
456 * @param pMac Pointer to Global MAC structure
457 * @param pMsgBuf A pointer to the MLM message buffer
458 *
459 * @return None
460 */
461void
462limProcessMlmJoinCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
463{
464 tSirResultCodes resultCode;
465 tLimMlmJoinCnf *pLimMlmJoinCnf;
466 tpPESession psessionEntry;
467 pLimMlmJoinCnf = (tLimMlmJoinCnf*)pMsgBuf;
468 if( (psessionEntry = peFindSessionBySessionId(pMac,pLimMlmJoinCnf->sessionId))== NULL)
469 {
470 PELOGE(limLog(pMac, LOGE,FL("Session does not exist for given sessionId\n"));)
471 return;
472 }
473
474 if (psessionEntry->limSmeState!= eLIM_SME_WT_JOIN_STATE)
475 {
476 PELOGE(limLog(pMac, LOGE,
477 FL("received unexpected MLM_JOIN_CNF in state %X\n"),
478 psessionEntry->limSmeState);)
479 return;
480 }
481
482 resultCode = ((tLimMlmJoinCnf *) pMsgBuf)->resultCode ;
483 /// Process Join confirm from MLM
484 if (resultCode == eSIR_SME_SUCCESS)
485 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700486 PELOG1(limLog(pMac, LOG1, FL("*** Joined ESS ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 //Setup hardware upfront
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 //Done: 7-27-2009. JIM_FIX_ME sessionize the following function
489 if(limStaSendAddBssPreAssoc( pMac, false, psessionEntry) == eSIR_SUCCESS)
490 return;
491 else
492 resultCode = eSIR_SME_REFUSED;
493 }
494 {
495 /// Join failure
496 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700497 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 /// Send Join response to Host
499 limHandleSmeJoinResult(pMac, resultCode, ((tLimMlmJoinCnf *) pMsgBuf)->protStatusCode, psessionEntry );
500 }
501} /*** end limProcessMlmJoinCnf() ***/
502
503/**
504 * limProcessMlmAuthCnf()
505 *
506 *FUNCTION:
507 * This function is called to processes MLM_AUTH_CNF
508 * message from MLM State machine.
509 *
510 *LOGIC:
511 *
512 *ASSUMPTIONS:
513 *
514 *NOTE:
515 *
516 * @param pMac Pointer to Global MAC structure
517 * @param pMsgBuf A pointer to the MLM message buffer
518 *
519 * @return None
520 */
521void
522limProcessMlmAuthCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
523{
524 tANI_U16 caps;
525 tANI_U32 val;
526 tAniAuthType cfgAuthType, authMode;
527 tLimMlmAuthReq *pMlmAuthReq;
528 tLimMlmAssocReq *pMlmAssocReq;
529 tLimMlmAuthCnf *pMlmAuthCnf;
530 tpPESession psessionEntry;
531 tANI_U32 teleBcnEn = 0;
532// tANI_U8 sessionId;
533
534 if(pMsgBuf == NULL)
535 {
536 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
537 return;
538 }
539 pMlmAuthCnf = (tLimMlmAuthCnf*)pMsgBuf;
540 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAuthCnf->sessionId))== NULL)
541 {
542 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given sessionId\n"));)
543 return;
544 }
545
546 if (((psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
547 (psessionEntry->limSmeState != eLIM_SME_WT_PRE_AUTH_STATE)) ||
548 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
549 {
550 /**
551 * Should not have received AUTH confirm
552 * from MLM in other states or on AP.
553 * Log error
554 */
555 PELOGE(limLog(pMac, LOGE,
556 FL("received unexpected MLM_AUTH_CNF in state %X\n"),
557 psessionEntry->limSmeState);)
558 return;
559 }
560 /// Process AUTH confirm from MLM
561 if (((tLimMlmAuthCnf *) pMsgBuf)->resultCode != eSIR_SME_SUCCESS)
562 {
563 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
564 {
565 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE,
566 (tANI_U32 *) &cfgAuthType) != eSIR_SUCCESS)
567 {
568 /**
569 * Could not get AuthType value from CFG.
570 * Log error.
571 */
572 limLog(pMac, LOGP,
573 FL("could not retrieve AuthType value\n"));
574 }
575 }
576 else
577 cfgAuthType = pMac->lim.gLimPreAuthType;
578
579 if ((cfgAuthType == eSIR_AUTO_SWITCH) &&
580 (((tLimMlmAuthCnf *) pMsgBuf)->authType == eSIR_OPEN_SYSTEM)
581 && (eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS == ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode))
582 {
583 /**
584 * When Open authentication fails with reason code "13" and
585 * authType set to 'auto switch', Try with Shared Authentication
586 */
587 authMode = eSIR_SHARED_KEY;
588 // Trigger MAC based Authentication
589 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmAuthReq, sizeof(tLimMlmAuthReq)))
590 {
591 // Log error
592 limLog(pMac, LOGP,
593 FL("call to palAllocateMemory failed for mlmAuthReq\n"));
594 return;
595 }
596 palZeroMemory( pMac->hHdd, (tANI_U8 *) pMlmAuthReq, sizeof(tLimMlmAuthReq));
597 val = sizeof(tSirMacAddr);
598 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
599 {
600 sirCopyMacAddr(pMlmAuthReq->peerMacAddr,psessionEntry->bssId);
601 }
602 else
603 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmAuthReq->peerMacAddr,
604 (tANI_U8 *) &pMac->lim.gLimPreAuthPeerAddr,
605 sizeof(tSirMacAddr));
606 pMlmAuthReq->authType = authMode;
607 /* Update PE session Id*/
608 pMlmAuthReq->sessionId = pMlmAuthCnf->sessionId;
609 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
610 (tANI_U32 *) &pMlmAuthReq->authFailureTimeout)
611 != eSIR_SUCCESS)
612 {
613 /**
614 * Could not get AuthFailureTimeout value from CFG.
615 * Log error.
616 */
617 limLog(pMac, LOGP,
618 FL("could not retrieve AuthFailureTimeout value\n"));
619 }
620 limPostMlmMessage(pMac,
621 LIM_MLM_AUTH_REQ,
622 (tANI_U32 *) pMlmAuthReq);
623 return;
624 }
625 else
626 {
627 // MAC based authentication failure
628 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
629 {
630 PELOGE(limLog(pMac, LOGE, FL("Auth Failure occurred.\n"));)
631 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700632 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700634 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636#if defined(ANI_AP_CLIENT_SDK)
637 if (psessionEntry->limSystemRole == eLIM_STA_ROLE)
638 {
639 tSirMacAddr nullMacAddr = {0, 0, 0, 0, 0, 0};
640 PELOGE(limLog(pMac, LOGE, FL("Setting current BSSID as NULL in cfg\n"));)
641 palCopyMemory(pMac->hHdd, pMac->lim.gLimBssid, nullMacAddr, sizeof(tSirMacAddr));
642 if (cfgSetStr(pMac, WNI_CFG_BSSID, nullMacAddr, sizeof(tSirMacAddr)) != eSIR_SUCCESS)
643 {
644 limLog(pMac, LOGP, FL("Could not update BSSID on CFG"));
645 }
646 }
647#endif
648 /**
649 * Need to send Join response with
650 * auth failure to Host.
651 */
652 limHandleSmeJoinResult(pMac,
653 ((tLimMlmAuthCnf *) pMsgBuf)->resultCode, ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode,psessionEntry);
654 }
655 else
656 {
657 /**
658 * Pre-authentication failure.
659 * Send Pre-auth failure response to host
660 */
661 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700662 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 limSendSmeAuthRsp(
664 pMac,
665 ((tLimMlmAuthCnf *) pMsgBuf)->resultCode,
666 ((tLimMlmAuthCnf *) pMsgBuf)->peerMacAddr,
667 ((tLimMlmAuthCnf *) pMsgBuf)->authType,
668 ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode,psessionEntry,psessionEntry->smeSessionId,psessionEntry->transactionId);
669 }
670 } // end if (cfgAuthType == eAUTO_SWITCH)
671 } // if (((tLimMlmAuthCnf *) pMsgBuf)->resultCode != ...
672 else
673 {
674 if (psessionEntry->limSmeState == eLIM_SME_WT_AUTH_STATE)
675 {
676 /**
677 * Successful MAC based authentication
678 * Trigger Association with BSS
679 */
680 PELOG1(limLog(pMac, LOG1,
681 FL("*** Authenticated with BSS ***\n"));)
682 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmAssocReq, sizeof(tLimMlmAssocReq)))
683 {
684 // Log error
685 limLog(pMac, LOGP,
686 FL("call to palAllocateMemory failed for mlmAssocReq\n"));
687 return;
688 }
689 val = sizeof(tSirMacAddr);
690 #if 0
691 if (cfgGetStr(pMac, WNI_CFG_BSSID,
692 pMlmAssocReq->peerMacAddr,
693 &val) != eSIR_SUCCESS)
694 {
695 /// Could not get BSSID from CFG. Log error.
696 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
697 }
698 #endif //SUPPORT BT-AMP
699 sirCopyMacAddr(pMlmAssocReq->peerMacAddr,psessionEntry->bssId);
700 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOCIATION_FAILURE_TIMEOUT,
701 (tANI_U32 *) &pMlmAssocReq->assocFailureTimeout)
702 != eSIR_SUCCESS)
703 {
704 /**
705 * Could not get AssocFailureTimeout value
706 * from CFG. Log error.
707 */
708 limLog(pMac, LOGP,
709 FL("could not retrieve AssocFailureTimeout value\n"));
710 }
711 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
712 {
713 /**
714 * Could not get Capabilities value
715 * from CFG. Log error.
716 */
717 limLog(pMac, LOGP,
718 FL("could not retrieve Capabilities value\n"));
719 }
720 /*Clear spectrum management bit if AP doesn't support it*/
721 if(!(psessionEntry->pLimJoinReq->bssDescription.capabilityInfo & LIM_SPECTRUM_MANAGEMENT_BIT_MASK))
722 {
723 /*AP doesn't support spectrum management clear spectrum management bit*/
724 caps &= (~LIM_SPECTRUM_MANAGEMENT_BIT_MASK);
725 }
726
727 pMlmAssocReq->capabilityInfo = caps;
728 PELOG3(limLog(pMac, LOG3,
Jeff Johnsone7245742012-09-05 17:12:55 -0700729 FL("Capabilities to be used in AssocReq=0x%X, privacy bit=%x shortSlotTime %x\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 caps,
Jeff Johnsone7245742012-09-05 17:12:55 -0700731 ((tpSirMacCapabilityInfo) &pMlmAssocReq->capabilityInfo)->privacy,
732 ((tpSirMacCapabilityInfo) &pMlmAssocReq->capabilityInfo)->shortSlotTime);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700733
734 /* If telescopic beaconing is enabled, set listen interval to
735 WNI_CFG_TELE_BCN_MAX_LI */
736 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
737 eSIR_SUCCESS)
738 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN\n"));
739
740 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
741
742 if(teleBcnEn)
743 {
744 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
745 eSIR_SUCCESS)
746 {
747 /**
748 * Could not get ListenInterval value
749 * from CFG. Log error.
750 */
751 limLog(pMac, LOGP, FL("could not retrieve ListenInterval\n"));
752 }
753 }
754 else
755 {
756 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
757 {
758 /**
759 * Could not get ListenInterval value
760 * from CFG. Log error.
761 */
762 limLog(pMac, LOGP, FL("could not retrieve ListenInterval\n"));
763 }
764 }
765
766 pMlmAssocReq->listenInterval = (tANI_U16)val;
767 /* Update PE session ID*/
768 pMlmAssocReq->sessionId = psessionEntry->peSessionId;
769 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
770 psessionEntry->limSmeState = eLIM_SME_WT_ASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 limPostMlmMessage(pMac,
773 LIM_MLM_ASSOC_REQ,
774 (tANI_U32 *) pMlmAssocReq);
775 }
776 else
777 {
778 /**
779 * Successful Pre-authentication.
780 * Send Pre-auth response to host
781 */
782 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700783 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 limSendSmeAuthRsp(
785 pMac,
786 ((tLimMlmAuthCnf *) pMsgBuf)->resultCode,
787 ((tLimMlmAuthCnf *) pMsgBuf)->peerMacAddr,
788 ((tLimMlmAuthCnf *) pMsgBuf)->authType,
789 ((tLimMlmAuthCnf *) pMsgBuf)->protStatusCode,psessionEntry,psessionEntry->smeSessionId,psessionEntry->transactionId);
790 }
791 } // end if (((tLimMlmAuthCnf *) pMsgBuf)->resultCode != ...
792} /*** end limProcessMlmAuthCnf() ***/
793
794/**
795 * limProcessMlmAssocCnf()
796 *
797 *FUNCTION:
798 * This function is called to processes MLM_ASSOC_CNF
799 * message from MLM State machine.
800 *
801 *LOGIC:
802 *
803 *ASSUMPTIONS:
804 *
805 *NOTE:
806 *
807 * @param pMac Pointer to Global MAC structure
808 * @param pMsgBuf A pointer to the MLM message buffer
809 *
810 * @return None
811 */
812void
813limProcessMlmAssocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
814{
815 tpPESession psessionEntry;
816 tLimMlmAssocCnf *pLimMlmAssocCnf;
817
818 if(pMsgBuf == NULL)
819 {
820 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
821 return;
822 }
823 pLimMlmAssocCnf = (tLimMlmAssocCnf*)pMsgBuf;
824 if((psessionEntry = peFindSessionBySessionId(pMac,pLimMlmAssocCnf->sessionId)) == NULL)
825 {
826 PELOGE(limLog(pMac, LOGE,FL("Session does not exist for given sessionId\n"));)
827 return;
828 }
829 if (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE ||
830 psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry ->limSystemRole == eLIM_BT_AMP_AP_ROLE)
831 {
832 /**
833 * Should not have received Assocication confirm
834 * from MLM in other states OR on AP.
835 * Log error
836 */
837 PELOGE(limLog(pMac, LOGE,
838 FL("received unexpected MLM_ASSOC_CNF in state %X\n"),
839 psessionEntry->limSmeState);)
840 return;
841 }
842 if (((tLimMlmAssocCnf *) pMsgBuf)->resultCode != eSIR_SME_SUCCESS)
843 {
844 // Association failure
845 PELOG1(limLog(pMac, LOG1, FL("*** Association failure ***\n"));)
846 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700847 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700848#if defined(ANI_AP_CLIENT_SDK)
849 if (psessionEntry->limSystemRole == eLIM_STA_ROLE)
850 {
851 tSirMacAddr nullMacAddr = {0, 0, 0, 0, 0, 0};
852 palCopyMemory(pMac->hHdd, pMac->lim.gLimBssid, nullMacAddr, sizeof(tSirMacAddr));
853 if (cfgSetStr(pMac, WNI_CFG_BSSID, nullMacAddr, sizeof(tSirMacAddr)) != eSIR_SUCCESS)
854 {
855 limLog(pMac, LOGP, FL("Could not update BSSID on CFG"));
856 }
857 }
858#endif
859 /**
860 * Need to send Join response with
861 * Association failure to Host.
862 */
863 limHandleSmeJoinResult(pMac,
864 ((tLimMlmAssocCnf *) pMsgBuf)->resultCode,
865 ((tLimMlmAssocCnf *) pMsgBuf)->protStatusCode,psessionEntry);
866 } // if (((tLimMlmAssocCnf *) pMsgBuf)->resultCode != ...
867 else
868 {
869 // Successful Association
870 PELOG1(limLog(pMac, LOG1, FL("*** Associated with BSS ***\n"));)
871 psessionEntry->limSmeState = eLIM_SME_LINK_EST_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700872 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 /**
874 * Need to send Join response with
875 * Association success to Host.
876 */
877 limHandleSmeJoinResult(pMac,
878 ((tLimMlmAssocCnf *) pMsgBuf)->resultCode,
879 ((tLimMlmAssocCnf *) pMsgBuf)->protStatusCode,psessionEntry);
880 } // end if (((tLimMlmAssocCnf *) pMsgBuf)->resultCode != ....
881} /*** end limProcessMlmAssocCnf() ***/
882
883/**
884 * limProcessMlmReassocCnf()
885 *
886 *FUNCTION:
887 * This function is called to processes MLM_REASSOC_CNF
888 * message from MLM State machine.
889 *
890 *LOGIC:
891 *
892 *ASSUMPTIONS:
893 *
894 *NOTE:
895 *
896 * @param pMac Pointer to Global MAC structure
897 * @param pMsgBuf A pointer to the MLM message buffer
898 *
899 * @return None
900 */
901void
902limProcessMlmReassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
903{
904 tpPESession psessionEntry;
905 tLimMlmReassocCnf *pLimMlmReassocCnf;
906
907 if(pMsgBuf == NULL)
908 {
909 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
910 return;
911 }
912 pLimMlmReassocCnf = (tLimMlmReassocCnf*) pMsgBuf;
913 if((psessionEntry = peFindSessionBySessionId(pMac,pLimMlmReassocCnf->sessionId))==NULL)
914 {
915 PELOGE(limLog(pMac, LOGE, FL("session Does not exist for given session Id\n"));)
916 return;
917 }
918 if ((psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ||
919 (psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
920 {
921 /**
922 * Should not have received Reassocication confirm
923 * from MLM in other states OR on AP.
924 * Log error
925 */
926 PELOGE(limLog(pMac, LOGE,
927 FL("Rcv unexpected MLM_REASSOC_CNF in role %d, sme state 0x%X\n"),
928 psessionEntry->limSystemRole, psessionEntry->limSmeState);)
929 return;
930 }
931 if (psessionEntry->pLimReAssocReq) {
932 palFreeMemory( pMac->hHdd, psessionEntry->pLimReAssocReq);
933 psessionEntry->pLimReAssocReq = NULL;
934 }
935
936 PELOGE(limLog(pMac, LOGE, FL("Rcv MLM_REASSOC_CNF with result code %d\n"), pLimMlmReassocCnf->resultCode);)
937 if (pLimMlmReassocCnf->resultCode == eSIR_SME_SUCCESS) {
938 // Successful Reassociation
939 PELOG1(limLog(pMac, LOG1, FL("*** Reassociated with new BSS ***\n"));)
940
941 psessionEntry->limSmeState = eLIM_SME_LINK_EST_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700942 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 /**
945 * Need to send Reassoc response with
946 * Reassociation success to Host.
947 */
948 limSendSmeJoinReassocRsp(
949 pMac, eWNI_SME_REASSOC_RSP,
950 pLimMlmReassocCnf->resultCode, pLimMlmReassocCnf->protStatusCode,psessionEntry,
951 psessionEntry->smeSessionId,psessionEntry->transactionId);
952 }else if (pLimMlmReassocCnf->resultCode == eSIR_SME_REASSOC_REFUSED) {
953 /** Reassociation failure With the New AP
954 * but we still have the link with the Older AP
955 */
956 psessionEntry->limSmeState = eLIM_SME_LINK_EST_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700957 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700958
959 /**
960 * Need to send Reassoc response with
961 * Association failure to Host.
962 */
963 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
964 pLimMlmReassocCnf->resultCode, pLimMlmReassocCnf->protStatusCode,psessionEntry,
965 psessionEntry->smeSessionId,psessionEntry->transactionId);
966 }else {
967 // Reassociation failure
968 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700969 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 /**
971 * Need to send Reassoc response with
972 * Association failure to Host.
973 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700974 limHandleSmeReaasocResult(pMac, pLimMlmReassocCnf->resultCode, pLimMlmReassocCnf->protStatusCode, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
976} /*** end limProcessMlmReassocCnf() ***/
977
978/**
979 * limProcessMlmReassocInd()
980 *
981 *FUNCTION:
982 * This function is called to processes MLM_REASSOC_IND
983 * message from MLM State machine.
984 *
985 *LOGIC:
986 *
987 *ASSUMPTIONS:
988 *
989 *NOTE:
990 *
991 * @param pMac Pointer to Global MAC structure
992 * @param pMsgBuf A pointer to the MLM message buffer
993 *
994 * @return None
995 */
996void
997limProcessMlmReassocInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
998{
999 tANI_U32 len;
1000 tSirMsgQ msgQ;
1001 tSirSmeReassocInd *pSirSmeReassocInd;
1002 tpDphHashNode pStaDs=0;
1003 tpPESession psessionEntry;
1004 tANI_U8 sessionId;
1005 if(pMsgBuf == NULL)
1006 {
1007 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1008 return;
1009 }
1010 if((psessionEntry = peFindSessionByBssid(pMac,((tpLimMlmReassocInd)pMsgBuf)->peerMacAddr, &sessionId))== NULL)
1011 {
1012 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));)
1013 return;
1014 }
1015 /// Inform Host of STA reassociation
1016#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
1017 len = sizeof(tSirSmeReassocInd) -
1018 sizeof(tSirNeighborBssInfo) +
1019 (((tpLimMlmReassocInd) pMsgBuf)->numBss *
1020 sizeof(tSirNeighborBssInfo)) -
1021 SIR_MAC_MAX_SSID_LENGTH +
1022 ((tpLimMlmReassocInd) pMsgBuf)->ssId.length;
1023#else
1024 len = sizeof(tSirSmeReassocInd);
1025#endif
1026 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeReassocInd, len))
1027 {
1028 // Log error
1029 limLog(pMac, LOGP,
1030 FL("call to palAllocateMemory failed for eWNI_SME_REASSOC_IND\n"));
1031 return;
1032
1033 }
1034 sirStoreU16N((tANI_U8 *) &pSirSmeReassocInd->messageType,
1035 eWNI_SME_REASSOC_IND);
1036 limReassocIndSerDes(pMac, (tpLimMlmReassocInd) pMsgBuf,
1037 (tANI_U8 *) &(pSirSmeReassocInd->length), psessionEntry);
1038
1039 // Required for indicating the frames to upper layer
1040 pSirSmeReassocInd->assocReqLength = ((tpLimMlmReassocInd) pMsgBuf)->assocReqLength;
1041 pSirSmeReassocInd->assocReqPtr = ((tpLimMlmReassocInd) pMsgBuf)->assocReqPtr;
1042 pSirSmeReassocInd->beaconPtr = psessionEntry->beacon;
1043 pSirSmeReassocInd->beaconLength = psessionEntry->bcnLen;
1044
1045 msgQ.type = eWNI_SME_REASSOC_IND;
1046 msgQ.bodyptr = pSirSmeReassocInd;
1047 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001048 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001049#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1050 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_IND_EVENT, psessionEntry, 0, 0);
1051#endif //FEATURE_WLAN_DIAG_SUPPORT
1052 pStaDs = dphGetHashEntry(pMac, ((tpLimMlmReassocInd) pMsgBuf)->aid, &psessionEntry->dph.dphHashTable);
1053 if (! pStaDs)
1054 {
1055 limLog( pMac, LOGP, FL("MLM ReAssocInd: Station context no longer valid (aid %d)\n"),
1056 ((tpLimMlmReassocInd) pMsgBuf)->aid);
1057 palFreeMemory(pMac->hHdd, pSirSmeReassocInd);
1058 return;
1059 }
1060
1061 limSysProcessMmhMsgApi(pMac, &msgQ, ePROT);
1062 PELOG1(limLog(pMac, LOG1,
1063 FL("Create CNF_WAIT_TIMER after received LIM_MLM_REASSOC_IND\n"));)
1064 /*
1065 ** turn on a timer to detect the loss of REASSOC CNF
1066 **/
1067 limActivateCnfTimer(pMac,
1068 (tANI_U16) ((tpLimMlmReassocInd) pMsgBuf)->aid, psessionEntry);
1069} /*** end limProcessMlmReassocInd() ***/
1070
1071/**
1072 * limProcessMlmAuthInd()
1073 *
1074 *FUNCTION:
1075 * This function is called to processes MLM_AUTH_IND
1076 * message from MLM State machine.
1077 *
1078 *LOGIC:
1079 *
1080 *ASSUMPTIONS:
1081 *
1082 *NOTE:
1083 *
1084 * @param pMac Pointer to Global MAC structure
1085 * @param pMsgBuf A pointer to the MLM message buffer
1086 *
1087 * @return None
1088 */
1089void
1090limProcessMlmAuthInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1091{
1092 tSirMsgQ msgQ;
1093 tSirSmeAuthInd *pSirSmeAuthInd;
1094
1095 if(pMsgBuf == NULL)
1096 {
1097 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1098 return;
1099 }
1100 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeAuthInd, sizeof(tSirSmeAuthInd)))
1101 {
1102 // Log error
1103 limLog(pMac, LOGP,
1104 FL("call to palAllocateMemory failed for eWNI_SME_AUTH_IND\n"));
1105 }
1106 limCopyU16((tANI_U8 *) &pSirSmeAuthInd->messageType, eWNI_SME_AUTH_IND);
1107 limAuthIndSerDes(pMac, (tpLimMlmAuthInd) pMsgBuf,
1108 (tANI_U8 *) &(pSirSmeAuthInd->length));
1109 msgQ.type = eWNI_SME_AUTH_IND;
1110 msgQ.bodyptr = pSirSmeAuthInd;
1111 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001112 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1114 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_IND_EVENT, NULL, 0, 0);
1115#endif //FEATURE_WLAN_DIAG_SUPPORT
1116 limSysProcessMmhMsgApi(pMac, &msgQ, ePROT);
1117} /*** end limProcessMlmAuthInd() ***/
1118
1119
1120
1121
1122void
1123limFillAssocIndParams(tpAniSirGlobal pMac, tpLimMlmAssocInd pAssocInd,
1124 tSirSmeAssocInd *pSirSmeAssocInd,
1125 tpPESession psessionEntry)
1126{
1127 pSirSmeAssocInd->length = sizeof(tSirSmeAssocInd);
1128 pSirSmeAssocInd->sessionId = psessionEntry->smeSessionId;
1129
1130 // Required for indicating the frames to upper layer
1131 pSirSmeAssocInd->assocReqLength = pAssocInd->assocReqLength;
1132 pSirSmeAssocInd->assocReqPtr = pAssocInd->assocReqPtr;
1133
1134 pSirSmeAssocInd->beaconPtr = psessionEntry->beacon;
1135 pSirSmeAssocInd->beaconLength = psessionEntry->bcnLen;
1136
1137 // Fill in peerMacAddr
1138 palCopyMemory( pMac->hHdd, pSirSmeAssocInd->peerMacAddr, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
1139 // Fill in aid
1140 pSirSmeAssocInd->aid = pAssocInd->aid;
1141 // Fill in bssId
1142 palCopyMemory( pMac->hHdd, pSirSmeAssocInd->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
1143 // Fill in staId
1144 //pSirSmeAssocInd->staId = psessionEntry->staId;
1145 // Fill in authType
1146 pSirSmeAssocInd->authType = pAssocInd->authType;
1147 // Fill in ssId
1148 palCopyMemory( pMac->hHdd, (tANI_U8*)&pSirSmeAssocInd->ssId,
1149 (tANI_U8 *) &(pAssocInd->ssId), pAssocInd->ssId.length + 1);
1150 pSirSmeAssocInd->rsnIE.length = pAssocInd->rsnIE.length;
1151 palCopyMemory( pMac->hHdd, (tANI_U8*) &pSirSmeAssocInd->rsnIE.rsnIEdata,
1152 (tANI_U8 *) &(pAssocInd->rsnIE.rsnIEdata),
1153 pAssocInd->rsnIE.length);
1154
1155 pSirSmeAssocInd->addIE.length = pAssocInd->addIE.length;
1156 palCopyMemory( pMac->hHdd, (tANI_U8*) &pSirSmeAssocInd->addIE.addIEdata,
1157 (tANI_U8 *) &(pAssocInd->addIE.addIEdata),
1158 pAssocInd->addIE.length);
1159
1160 // Copy the new TITAN capabilities
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 pSirSmeAssocInd->spectrumMgtIndicator = pAssocInd->spectrumMgtIndicator;
1162 if (pAssocInd->spectrumMgtIndicator == eSIR_TRUE)
1163 {
1164 pSirSmeAssocInd->powerCap.minTxPower = pAssocInd->powerCap.minTxPower;
1165 pSirSmeAssocInd->powerCap.maxTxPower = pAssocInd->powerCap.maxTxPower;
1166 pSirSmeAssocInd->supportedChannels.numChnl = pAssocInd->supportedChannels.numChnl;
1167 palCopyMemory( pMac->hHdd, (tANI_U8*) &pSirSmeAssocInd->supportedChannels.channelList,
1168 (tANI_U8 *) &(pAssocInd->supportedChannels.channelList),
1169 pAssocInd->supportedChannels.numChnl);
1170 }
1171#ifdef WLAN_SOFTAP_FEATURE
1172 // Fill in WmmInfo
1173 pSirSmeAssocInd->wmmEnabledSta = pAssocInd->WmmStaInfoPresent;
1174#endif
1175} /*** end limAssocIndSerDes() ***/
1176
1177
1178
1179/**
1180 * limProcessMlmAssocInd()
1181 *
1182 *FUNCTION:
1183 * This function is called to processes MLM_ASSOC_IND
1184 * message from MLM State machine.
1185 *
1186 *LOGIC:
1187 *
1188 *ASSUMPTIONS:
1189 *
1190 *NOTE:
1191 *
1192 * @param pMac Pointer to Global MAC structure
1193 * @param pMsgBuf A pointer to the MLM message buffer
1194 *
1195 * @return None
1196 */
1197void
1198limProcessMlmAssocInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1199{
1200 tANI_U32 len;
1201 tSirMsgQ msgQ;
1202 tSirSmeAssocInd *pSirSmeAssocInd;
1203 tpDphHashNode pStaDs=0;
1204 tpPESession psessionEntry;
1205 if(pMsgBuf == NULL)
1206 {
1207 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1208 return;
1209 }
1210 if((psessionEntry = peFindSessionBySessionId(pMac,((tpLimMlmAssocInd) pMsgBuf)->sessionId))== NULL)
1211 {
1212 limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId\n" ));
1213 return;
1214 }
1215 /// Inform Host of STA association
1216#if defined (ANI_PRODUCT_TYPE_AP)
1217 len = sizeof(tSirSmeAssocInd) -
1218 sizeof(tSirNeighborBssInfo) +
1219 (((tpLimMlmAssocInd) pMsgBuf)->numBss *
1220 sizeof(tSirNeighborBssInfo)) -
1221 SIR_MAC_MAX_SSID_LENGTH +
1222 ((tpLimMlmAssocInd) pMsgBuf)->ssId.length;
1223#else
1224 len = sizeof(tSirSmeAssocInd);
1225#endif
1226 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeAssocInd, len))
1227 {
1228 // Log error
1229 limLog(pMac, LOGP,
1230 FL("call to palAllocateMemory failed for eWNI_SME_ASSOC_IND\n"));
1231 return;
1232 }
1233
1234#if defined (ANI_PRODUCT_TYPE_AP)
1235 sirStoreU16N((tANI_U8 *) &pSirSmeAssocInd->messageType,
1236 eWNI_SME_ASSOC_IND);
1237 limAssocIndSerDes(pMac, (tpLimMlmAssocInd) pMsgBuf,
1238 (tANI_U8 *) &(pSirSmeAssocInd->length), psessionEntry);
1239#else
1240 pSirSmeAssocInd->messageType = eWNI_SME_ASSOC_IND;
1241 limFillAssocIndParams(pMac, (tpLimMlmAssocInd) pMsgBuf, pSirSmeAssocInd, psessionEntry);
1242#endif
1243 msgQ.type = eWNI_SME_ASSOC_IND;
1244 msgQ.bodyptr = pSirSmeAssocInd;
1245 msgQ.bodyval = 0;
1246 pStaDs = dphGetHashEntry(pMac,
1247 ((tpLimMlmAssocInd) pMsgBuf)->aid, &psessionEntry->dph.dphHashTable);
1248 if (! pStaDs)
1249 { // good time to panic...
1250 limLog(pMac, LOGE, FL("MLM AssocInd: Station context no longer valid (aid %d)\n"),
1251 ((tpLimMlmAssocInd) pMsgBuf)->aid);
1252 palFreeMemory(pMac->hHdd, pSirSmeAssocInd);
1253
1254 return;
1255 }
1256 pSirSmeAssocInd->staId = pStaDs->staIndex;
1257#ifdef WLAN_SOFTAP_FEATURE
1258 pSirSmeAssocInd->reassocReq = pStaDs->mlmStaContext.subType;
1259#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001260 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001261#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1262 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_IND_EVENT, psessionEntry, 0, 0);
1263#endif //FEATURE_WLAN_DIAG_SUPPORT
1264 limSysProcessMmhMsgApi(pMac, &msgQ, ePROT);
1265
1266 PELOG1(limLog(pMac, LOG1,
1267 FL("Create CNF_WAIT_TIMER after received LIM_MLM_ASSOC_IND\n"));)
1268 /*
1269 ** turn on a timer to detect the loss of ASSOC CNF
1270 **/
1271 limActivateCnfTimer(pMac, (tANI_U16) ((tpLimMlmAssocInd) pMsgBuf)->aid, psessionEntry);
1272
1273// Enable this Compile flag to test the BT-AMP -AP assoc sequence
1274#ifdef TEST_BTAMP_AP
1275//tANI_U32 *pMsgBuf;
1276{
1277 tpSirSmeAssocCnf pSmeAssoccnf;
1278 if(!palAllocateMemory(pMac->hHdd,(void **)&pSmeAssoccnf,sizeof(tSirSmeAssocCnf)))
1279 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory failed for pSmeAssoccnf \n"));)
1280 pSmeAssoccnf->messageType = eWNI_SME_ASSOC_CNF;
1281 pSmeAssoccnf->length = sizeof(tSirSmeAssocCnf);
1282 palCopyMemory( pMac->hHdd,pSmeAssoccnf->peerMacAddr,((tpLimMlmAssocInd)pMsgBuf)->peerMacAddr,6);
1283 pSmeAssoccnf->statusCode = eSIR_SME_SUCCESS;
1284 pSmeAssoccnf->aid = ((tpLimMlmAssocInd)pMsgBuf)->aid;
1285 palCopyMemory( pMac->hHdd, pSmeAssoccnf->alternateBssId,pSmeAssoccnf->peerMacAddr,sizeof(tSirMacAddr));
1286 pSmeAssoccnf->alternateChannelId = 6;
1287 palCopyMemory( pMac->hHdd,pSmeAssoccnf->bssId,psessionEntry->selfMacAddr,6);
1288 pMsgBuf = (tANI_U32)pSmeAssoccnf;
1289 __limProcessSmeAssocCnfNew(pMac, eWNI_SME_ASSOC_CNF, pMsgBuf);
1290 palFreeMemory(pMac->hHdd,pSmeAssoccnf);
1291}
1292#endif
1293
1294
1295} /*** end limProcessMlmAssocInd() ***/
1296
1297
1298
1299
1300/**
1301 * limProcessMlmDisassocInd()
1302 *
1303 *FUNCTION:
1304 * This function is called to processes MLM_DISASSOC_IND
1305 * message from MLM State machine.
1306 *
1307 *LOGIC:
1308 *
1309 *ASSUMPTIONS:
1310 *
1311 *NOTE:
1312 *
1313 * @param pMac Pointer to Global MAC structure
1314 * @param pMsgBuf A pointer to the MLM message buffer
1315 *
1316 * @return None
1317 */
1318void
1319limProcessMlmDisassocInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1320{
1321 tLimMlmDisassocInd *pMlmDisassocInd;
1322 tpPESession psessionEntry;
1323 pMlmDisassocInd = (tLimMlmDisassocInd *) pMsgBuf;
1324 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocInd->sessionId) )== NULL)
1325 {
1326 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
1327 return;
1328 }
1329 switch (psessionEntry->limSystemRole)
1330 {
1331 case eLIM_STA_IN_IBSS_ROLE:
1332 break;
1333 case eLIM_STA_ROLE:
1334 case eLIM_BT_AMP_STA_ROLE:
1335 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001336 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 break;
1338 default: // eLIM_AP_ROLE //eLIM_BT_AMP_AP_ROLE
1339 PELOG1(limLog(pMac, LOG1,
1340 FL("*** Peer staId=%d Disassociated ***\n"),
1341 pMlmDisassocInd->aid);)
1342 // Send SME_DISASOC_IND after Polaris cleanup
1343 // (after receiving LIM_MLM_PURGE_STA_IND)
1344 break;
1345 } // end switch (psessionEntry->limSystemRole)
1346} /*** end limProcessMlmDisassocInd() ***/
1347
1348/**
1349 * limProcessMlmDisassocCnf()
1350 *
1351 *FUNCTION:
1352 * This function is called to processes MLM_DISASSOC_CNF
1353 * message from MLM State machine.
1354 *
1355 *LOGIC:
1356 *
1357 *ASSUMPTIONS:
1358 *
1359 *NOTE:
1360 *
1361 * @param pMac Pointer to Global MAC structure
1362 * @param pMsgBuf A pointer to the MLM message buffer
1363 *
1364 * @return None
1365 */
1366void
1367limProcessMlmDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1368{
1369 tSirResultCodes resultCode;
1370 tLimMlmDisassocCnf *pMlmDisassocCnf;
1371 tpPESession psessionEntry;
1372 pMlmDisassocCnf = (tLimMlmDisassocCnf *) pMsgBuf;
1373 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocCnf->sessionId))== NULL)
1374 {
1375 PELOGE(limLog(pMac, LOGE,FL("session Does not exist for given session Id\n"));)
1376 return;
1377 }
1378 resultCode = (tSirResultCodes)
1379 (pMlmDisassocCnf->disassocTrigger ==
1380 eLIM_LINK_MONITORING_DISASSOC) ?
1381 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
1382 pMlmDisassocCnf->resultCode;
1383 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
1384 {
1385#if defined(ANI_AP_CLIENT_SDK)
1386 tSirMacAddr nullMacAddr = {0, 0, 0, 0, 0, 0};
1387#endif
1388 // Disassociate Confirm from MLM
1389 if ( (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
1390 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE) )
1391 {
1392 /**
1393 * Should not have received
1394 * Disassocate confirm
1395 * from MLM in other states.
1396 * Log error
1397 */
1398 PELOGE(limLog(pMac, LOGE,
1399 FL("received unexpected MLM_DISASSOC_CNF in state %X\n"),psessionEntry->limSmeState);)
1400 return;
1401 }
1402#if defined(ANI_AP_CLIENT_SDK)
1403 // Whenever there is a disassoc notification, make sure the bssId is cleared so that
1404 // if the station finds the same AP to which it was associated, it can try to associate
1405 // with it again. If this is not done, the beacons/probe rsp from this AP will not be given
1406 // up to WSM and it never see this is AP unless a cga/reboot is done.
1407 palCopyMemory(pMac->hHdd, pMac->lim.gLimBssid, nullMacAddr, sizeof(tSirMacAddr));
1408 if (cfgSetStr(pMac, WNI_CFG_BSSID, nullMacAddr, sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1409 {
1410 limLog(pMac, LOGP, FL("Could not update BSSID on CFG"));
1411 }
1412#endif
1413 if (pMac->lim.gLimRspReqd)
1414 pMac->lim.gLimRspReqd = false;
1415 if (pMlmDisassocCnf->disassocTrigger ==
1416 eLIM_PROMISCUOUS_MODE_DISASSOC)
1417 {
1418 if (pMlmDisassocCnf->resultCode != eSIR_SME_SUCCESS)
1419 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
1420 else
1421 psessionEntry->limSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001422 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 // Send Promiscuous mode response to host
1424 limSendSmePromiscuousModeRsp(pMac);
1425 }
1426 else
1427 {
1428 if (pMlmDisassocCnf->resultCode != eSIR_SME_SUCCESS)
1429 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
1430 else
1431 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001432 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 limSendSmeDisassocNtf(pMac, pMlmDisassocCnf->peerMacAddr,
1434 resultCode,
1435 pMlmDisassocCnf->disassocTrigger,
1436 pMlmDisassocCnf->aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
1437 }
1438 }
1439 else if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
1440 {
1441 limSendSmeDisassocNtf(pMac, pMlmDisassocCnf->peerMacAddr,
1442 resultCode,
1443 pMlmDisassocCnf->disassocTrigger,
1444 pMlmDisassocCnf->aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
1445 }
1446} /*** end limProcessMlmDisassocCnf() ***/
1447
1448/**
1449 * limProcessMlmDeauthInd()
1450 *
1451 *FUNCTION:
1452 * This function is called to processes MLM_DEAUTH_IND
1453 * message from MLM State machine.
1454 *
1455 *LOGIC:
1456 *
1457 *ASSUMPTIONS:
1458 *
1459 *NOTE:
1460 *
1461 * @param pMac Pointer to Global MAC structure
1462 * @param pMsgBuf A pointer to the MLM message buffer
1463 *
1464 * @return None
1465 */
1466void
1467limProcessMlmDeauthInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1468{
1469 tLimMlmDeauthInd *pMlmDeauthInd;
1470 tpPESession psessionEntry;
1471 tANI_U8 sessionId;
1472 pMlmDeauthInd = (tLimMlmDeauthInd *) pMsgBuf;
1473 if((psessionEntry = peFindSessionByBssid(pMac,pMlmDeauthInd->peerMacAddr,&sessionId))== NULL)
1474 {
1475 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));)
1476 return;
1477 }
1478 switch (psessionEntry->limSystemRole)
1479 {
1480 case eLIM_STA_IN_IBSS_ROLE:
1481 break;
1482 case eLIM_STA_ROLE:
1483 case eLIM_BT_AMP_STA_ROLE:
1484 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001485 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
1487 default: // eLIM_AP_ROLE
1488 {
1489 PELOG1(limLog(pMac, LOG1,
1490 FL("*** Received Deauthentication from staId=%d ***\n"),
1491 pMlmDeauthInd->aid);)
1492 }
1493 // Send SME_DEAUTH_IND after Polaris cleanup
1494 // (after receiving LIM_MLM_PURGE_STA_IND)
1495 break;
1496 } // end switch (psessionEntry->limSystemRole)
1497} /*** end limProcessMlmDeauthInd() ***/
1498
1499/**
1500 * limProcessMlmDeauthCnf()
1501 *
1502 *FUNCTION:
1503 * This function is called to processes MLM_DEAUTH_CNF
1504 * message from MLM State machine.
1505 *
1506 *LOGIC:
1507 *
1508 *ASSUMPTIONS:
1509 *
1510 *NOTE:
1511 *
1512 * @param pMac Pointer to Global MAC structure
1513 * @param pMsgBuf A pointer to the MLM message buffer
1514 *
1515 * @return None
1516 */
1517void
1518limProcessMlmDeauthCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1519{
1520 tANI_U16 aid;
1521 tSirResultCodes resultCode;
1522 tLimMlmDeauthCnf *pMlmDeauthCnf;
1523 tpPESession psessionEntry;
1524
1525 if(pMsgBuf == NULL)
1526 {
1527 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1528 return;
1529 }
1530 pMlmDeauthCnf = (tLimMlmDeauthCnf *) pMsgBuf;
1531 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthCnf->sessionId))==NULL)
1532 {
1533 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given session Id \n"));)
1534 return;
1535 }
1536
1537 resultCode = (tSirResultCodes)
1538 (pMlmDeauthCnf->deauthTrigger ==
1539 eLIM_LINK_MONITORING_DEAUTH) ?
1540 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
1541 pMlmDeauthCnf->resultCode;
1542 aid = (psessionEntry->limSystemRole == eLIM_AP_ROLE) ?
1543 pMlmDeauthCnf->aid : 1;
1544 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
1545 {
1546 #if defined(ANI_AP_CLIENT_SDK)
1547 tSirMacAddr nullMacAddr = {0, 0, 0, 0, 0, 0};
1548 #endif
1549 // Deauth Confirm from MLM
1550 if (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE)
1551 {
1552 /**
1553 * Should not have received Deauth confirm
1554 * from MLM in other states.
1555 * Log error
1556 */
1557 PELOGE(limLog(pMac, LOGE,
1558 FL("received unexpected MLM_DEAUTH_CNF in state %X\n"),
1559 psessionEntry->limSmeState);)
1560 return;
1561 }
1562#if defined(ANI_AP_CLIENT_SDK)
1563 // Whenever there is a disassoc notification, make sure the bssId is cleared so that
1564 // if the station finds the same AP to which it was associated, it can try to associate
1565 // with it again. If this is not done, the beacons/probe rsp from this AP will not be given
1566 // up to WSM and it never see this is AP unless a cga/reboot is done.
1567 palCopyMemory(pMac->hHdd, pMac->lim.gLimBssid, nullMacAddr, sizeof(tSirMacAddr));
1568 if (cfgSetStr(pMac, WNI_CFG_BSSID, nullMacAddr, sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1569 {
1570 limLog(pMac, LOGP, FL("Could not update BSSID on CFG"));
1571 }
1572#endif
1573 if (pMlmDeauthCnf->resultCode == eSIR_SME_SUCCESS)
1574 {
1575 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
1576 PELOG1(limLog(pMac, LOG1,
1577 FL("*** Deauthenticated with BSS ***\n"));)
1578 }
1579 else
1580 psessionEntry->limSmeState = psessionEntry->limPrevSmeState;
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
1583 if (pMac->lim.gLimRspReqd)
1584 pMac->lim.gLimRspReqd = false;
1585 }
1586#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1587 // BP deauthenticated by AP or vice versa
1588 // Send SME_DISASSOC_RSP to host.
1589 limSendSmeDisassocNtf(pMac, pMlmDeauthCnf->peerMacAddr,
1590 resultCode,
1591 pMlmDeauthCnf->deauthTrigger,
1592 aid);
1593#else
1594 // On STA or on BASIC AP, send SME_DEAUTH_RSP to host
1595 limSendSmeDeauthNtf(pMac, pMlmDeauthCnf->peerMacAddr,
1596 resultCode,
1597 pMlmDeauthCnf->deauthTrigger,
1598 aid,psessionEntry->smeSessionId,psessionEntry->transactionId);
1599#endif
1600} /*** end limProcessMlmDeauthCnf() ***/
1601
1602/**
1603 * limProcessMlmPurgeStaInd()
1604 *
1605 *FUNCTION:
1606 * This function is called to processes MLM_PURGE_STA_IND
1607 * message from MLM State machine.
1608 *
1609 *LOGIC:
1610 *
1611 *ASSUMPTIONS:
1612 *
1613 *NOTE:
1614 *
1615 * @param pMac Pointer to Global MAC structure
1616 * @param pMsgBuf A pointer to the MLM message buffer
1617 *
1618 * @return None
1619 */
1620void
1621limProcessMlmPurgeStaInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1622{
1623 tSirResultCodes resultCode;
1624 tpLimMlmPurgeStaInd pMlmPurgeStaInd;
1625 tpPESession psessionEntry;
1626#if defined(ANI_AP_CLIENT_SDK)
1627 tSirMacAddr nullMacAddr = {0, 0, 0, 0, 0, 0};
1628#endif
1629 if(pMsgBuf == NULL)
1630 {
1631 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1632 return;
1633 }
1634 pMlmPurgeStaInd = (tpLimMlmPurgeStaInd) pMsgBuf;
1635 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmPurgeStaInd->sessionId))==NULL)
1636 {
1637 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));)
1638 return;
1639 }
1640 // Purge STA indication from MLM
1641 resultCode = (tSirResultCodes) pMlmPurgeStaInd->reasonCode;
1642 switch (psessionEntry->limSystemRole)
1643 {
1644 case eLIM_STA_IN_IBSS_ROLE:
1645 break;
1646 case eLIM_STA_ROLE:
1647 case eLIM_BT_AMP_STA_ROLE:
1648 default: // eLIM_AP_ROLE
1649 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
1650 (psessionEntry->limSmeState !=
1651 eLIM_SME_WT_DISASSOC_STATE) &&
1652 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
1653 {
1654 /**
1655 * Should not have received
1656 * Purge STA indication
1657 * from MLM in other states.
1658 * Log error
1659 */
1660 PELOGE(limLog(pMac, LOGE,
1661 FL("received unexpected MLM_PURGE_STA_IND in state %X\n"),
1662 psessionEntry->limSmeState);)
1663 break;
1664 }
1665 PELOG1(limLog(pMac, LOG1,
1666 FL("*** Polaris cleanup completed for staId=%d ***\n"),
1667 pMlmPurgeStaInd->aid);)
1668 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
1669 {
1670 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001672
1673#if defined(ANI_AP_CLIENT_SDK)
1674 // Whenever there is a disassoc notification, make sure the bssId is cleared so that
1675 // if the station finds the same AP to which it was associated, it can try to associate
1676 // with it again. If this is not done, the beacons/probe rsp from this AP will not be given
1677 // up to WSM and it never see this is AP unless a cga/reboot is done.
1678 palCopyMemory(pMac->hHdd, pMac->lim.gLimBssid, nullMacAddr, sizeof(tSirMacAddr));
1679 if (cfgSetStr(pMac, WNI_CFG_BSSID, nullMacAddr, sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1680 {
1681 limLog(pMac, LOGP, FL("Could not update BSSID on CFG"));
1682 }
1683#endif
1684 }
1685 if (pMlmPurgeStaInd->purgeTrigger == eLIM_PEER_ENTITY_DEAUTH)
1686 {
1687#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1688 // BP deauthenticated by AP or vice versa
1689 // Send SME_DISASSOC_IND to host.
1690 limSendSmeDisassocNtf(pMac,
1691 pMlmPurgeStaInd->peerMacAddr,
1692 resultCode,
1693 pMlmPurgeStaInd->purgeTrigger,
1694 pMlmPurgeStaInd->aid,psessionEntry);
1695#else
1696 limSendSmeDeauthNtf(pMac,
1697 pMlmPurgeStaInd->peerMacAddr,
1698 resultCode,
1699 pMlmPurgeStaInd->purgeTrigger,
1700 pMlmPurgeStaInd->aid,psessionEntry->smeSessionId,psessionEntry->transactionId);
1701#endif
1702 }
1703 else
1704 limSendSmeDisassocNtf(pMac,
1705 pMlmPurgeStaInd->peerMacAddr,
1706 resultCode,
1707 pMlmPurgeStaInd->purgeTrigger,
1708 pMlmPurgeStaInd->aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
1709 } // end switch (psessionEntry->limSystemRole)
1710} /*** end limProcessMlmPurgeStaInd() ***/
1711
1712/**
1713 * limProcessMlmSetKeysCnf()
1714 *
1715 *FUNCTION:
1716 * This function is called to processes MLM_SETKEYS_CNF
1717 * message from MLM State machine.
1718 *
1719 *LOGIC:
1720 *
1721 *ASSUMPTIONS:
1722 *
1723 *NOTE:
1724 *
1725 * @param pMac Pointer to Global MAC structure
1726 * @param pMsgBuf A pointer to the MLM message buffer
1727 *
1728 * @return None
1729 */
1730void
1731limProcessMlmSetKeysCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1732{
1733 // Prepare and send SME_SETCONTEXT_RSP message
Jeff Johnsone7245742012-09-05 17:12:55 -07001734 tLimMlmSetKeysCnf *pMlmSetKeysCnf;
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 tpPESession psessionEntry;
1736
1737 if(pMsgBuf == NULL)
1738 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001739 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1740 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 }
1742 pMlmSetKeysCnf = (tLimMlmSetKeysCnf *) pMsgBuf;
1743 if ((psessionEntry = peFindSessionBySessionId(pMac, pMlmSetKeysCnf->sessionId))== NULL)
1744 {
1745 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId \n"));)
1746 return;
1747 }
1748 limLog( pMac, LOG1,
1749 FL("Received MLM_SETKEYS_CNF with resultCode = %d\n"),
1750 pMlmSetKeysCnf->resultCode );
1751 limSendSmeSetContextRsp(pMac,
1752 pMlmSetKeysCnf->peerMacAddr,
1753#ifdef ANI_PRODUCT_TYPE_AP
1754 pMlmSetKeysCnf->aid,
1755#else
1756 1,
1757#endif
1758 (tSirResultCodes) pMlmSetKeysCnf->resultCode,psessionEntry,psessionEntry->smeSessionId,
1759 psessionEntry->transactionId);
1760} /*** end limProcessMlmSetKeysCnf() ***/
1761/**
1762 * limProcessMlmRemoveKeyCnf()
1763 *
1764 *FUNCTION:
1765 * This function is called to processes MLM_REMOVEKEY_CNF
1766 * message from MLM State machine.
1767 *
1768 *LOGIC:
1769 *
1770 *ASSUMPTIONS:
1771 *
1772 *NOTE:
1773 *
1774 * @param pMac Pointer to Global MAC structure
1775 * @param pMsgBuf A pointer to the MLM message buffer
1776 *
1777 * @return None
1778 */
1779void
1780limProcessMlmRemoveKeyCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1781{
1782 // Prepare and send SME_REMOVECONTEXT_RSP message
Jeff Johnsone7245742012-09-05 17:12:55 -07001783 tLimMlmRemoveKeyCnf *pMlmRemoveKeyCnf;
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 tpPESession psessionEntry;
1785
1786 if(pMsgBuf == NULL)
1787 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001788 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1789 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 }
1791 pMlmRemoveKeyCnf = (tLimMlmRemoveKeyCnf *) pMsgBuf;
1792 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyCnf->sessionId))== NULL)
1793 {
1794 PELOGE(limLog(pMac, LOGE,FL("session Does not exist for given session Id\n"));)
1795 return;
1796 }
1797 limLog( pMac, LOG1,
1798 FL("Received MLM_REMOVEKEYS_CNF with resultCode = %d\n"),
1799 pMlmRemoveKeyCnf->resultCode );
1800 limSendSmeRemoveKeyRsp(pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001801 pMlmRemoveKeyCnf->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 (tSirResultCodes) pMlmRemoveKeyCnf->resultCode,psessionEntry,
1803 psessionEntry->smeSessionId,psessionEntry->transactionId);
1804} /*** end limProcessMlmRemoveKeyCnf() ***/
1805
1806
1807/**
1808 * limHandleSmeJoinResult()
1809 *
1810 *FUNCTION:
1811 * This function is called to process join/auth/assoc failures
1812 * upon receiving MLM_JOIN/AUTH/ASSOC_CNF with a failure code or
1813 * MLM_ASSOC_CNF with a success code in case of STA role and
1814 * MLM_JOIN_CNF with success in case of STA in IBSS role.
1815 *
1816 *LOGIC:
1817 *
1818 *ASSUMPTIONS:
1819 *
1820 *NOTE:
1821 *
1822 * @param pMac Pointer to Global MAC structure
1823 * @param resultCode Failure code to be sent
1824 *
1825 *
1826 * @return None
1827 */
1828static void
1829limHandleSmeJoinResult(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode, tpPESession psessionEntry)
1830{
1831 tpDphHashNode pStaDs = NULL;
1832 tANI_U8 smesessionId;
1833 tANI_U16 smetransactionId;
1834
1835 /* Newly Added on oct 11 th*/
1836 if(psessionEntry == NULL)
1837 {
1838 PELOGE(limLog(pMac, LOGE,FL("psessionEntry is NULL \n"));)
1839 return;
1840 }
1841 smesessionId = psessionEntry->smeSessionId;
1842 smetransactionId = psessionEntry->transactionId;
1843 /* When associations is failed , delete the session created and pass NULL to limsendsmeJoinReassocRsp() */
1844 if(resultCode != eSIR_SME_SUCCESS)
1845 {
1846 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
1847 if (pStaDs != NULL)
1848 {
1849 pStaDs->mlmStaContext.disassocReason = eSIR_MAC_UNSPEC_FAILURE_REASON;
1850 pStaDs->mlmStaContext.cleanupTrigger = eLIM_JOIN_FAILURE;
1851 pStaDs->mlmStaContext.resultCode = resultCode;
1852 pStaDs->mlmStaContext.protStatusCode = protStatusCode;
1853 //Done: 7-27-2009. JIM_FIX_ME: at the end of limCleanupRxPath, make sure PE is sending eWNI_SME_JOIN_RSP to SME
1854 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001855 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq);
1856 psessionEntry->pLimJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 return;
1858 }
1859 }
1860
1861 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq);
1862 psessionEntry->pLimJoinReq = NULL;
1863 //Delete teh session if JOIN failure occurred.
1864 if(resultCode != eSIR_SME_SUCCESS)
1865 {
1866 if(NULL != psessionEntry)
1867 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001868 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE,psessionEntry->bssId,
1869 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1870 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState.\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 peDeleteSession(pMac,psessionEntry);
1872 psessionEntry = NULL;
1873 }
1874 }
1875 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, resultCode, protStatusCode,psessionEntry,
1876 smesessionId, smetransactionId);
1877} /*** end limHandleSmeJoinResult() ***/
1878
1879/**
Jeff Johnsone7245742012-09-05 17:12:55 -07001880 * limHandleSmeReaasocResult()
1881 *
1882 *FUNCTION:
1883 * This function is called to process reassoc failures
1884 * upon receiving REASSOC_CNF with a failure code or
1885 * MLM_REASSOC_CNF with a success code in case of STA role
1886 *
1887 *LOGIC:
1888 *
1889 *ASSUMPTIONS:
1890 *
1891 *NOTE:
1892 *
1893 * @param pMac Pointer to Global MAC structure
1894 * @param resultCode Failure code to be sent
1895 *
1896 *
1897 * @return None
1898 */
1899static void
1900limHandleSmeReaasocResult(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode, tpPESession psessionEntry)
1901{
1902 tpDphHashNode pStaDs = NULL;
1903 tANI_U8 smesessionId;
1904 tANI_U16 smetransactionId;
1905
1906 if(psessionEntry == NULL)
1907 {
1908 PELOGE(limLog(pMac, LOGE,FL("psessionEntry is NULL \n"));)
1909 return;
1910 }
1911 smesessionId = psessionEntry->smeSessionId;
1912 smetransactionId = psessionEntry->transactionId;
1913 /* When associations is failed , delete the session created and pass NULL to limsendsmeJoinReassocRsp() */
1914 if(resultCode != eSIR_SME_SUCCESS)
1915 {
1916 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
1917 if (pStaDs != NULL)
1918 {
1919 pStaDs->mlmStaContext.disassocReason = eSIR_MAC_UNSPEC_FAILURE_REASON;
1920 pStaDs->mlmStaContext.cleanupTrigger = eLIM_JOIN_FAILURE;
1921 pStaDs->mlmStaContext.resultCode = resultCode;
1922 pStaDs->mlmStaContext.protStatusCode = protStatusCode;
1923 limCleanupRxPath(pMac, pStaDs, psessionEntry);
1924 return;
1925 }
1926 }
1927
1928 //Delete teh session if REASSOC failure occurred.
1929 if(resultCode != eSIR_SME_SUCCESS)
1930 {
1931 if(NULL != psessionEntry)
1932 {
1933 peDeleteSession(pMac,psessionEntry);
1934 psessionEntry = NULL;
1935 }
1936 }
1937 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP, resultCode, protStatusCode,psessionEntry,
1938 smesessionId, smetransactionId);
1939} /*** end limHandleSmeReassocResult() ***/
1940
1941/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 * limProcessMlmAddStaRsp()
1943 *
1944 *FUNCTION:
1945 * This function is called to process a WDA_ADD_STA_RSP from HAL.
1946 * Upon receipt of this message from HAL, MLME -
1947 * > Determines the "state" in which this message was received
1948 * > Forwards it to the appropriate callback
1949 *
1950 *ASSUMPTIONS:
1951 *
1952 *NOTE:
1953 *
1954 * @param pMac Pointer to Global MAC structure
1955 * @param tSirMsgQ The MsgQ header, which contains the response buffer
1956 *
1957 * @return None
1958 */
1959void limProcessMlmAddStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry )
1960{
1961 //we need to process the deferred message since the initiating req. there might be nested request.
1962 //in the case of nested request the new request initiated from the response will take care of resetting
1963 //the deffered flag.
1964 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
1966#ifdef WLAN_SOFTAP_FEATURE
1967 || (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1968#endif
1969 )
1970 {
1971 limProcessBtAmpApMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
1972 return;
1973 }
1974#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
1975 limProcessStaMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
1976#endif
1977}
1978void limProcessStaMlmAddStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry)
1979{
1980 tLimMlmAssocCnf mlmAssocCnf;
1981 tpDphHashNode pStaDs;
1982 tANI_U32 mesgType = LIM_MLM_ASSOC_CNF;
1983 tpAddStaParams pAddStaParams = (tpAddStaParams) limMsgQ->bodyptr;
1984
1985 if(NULL == pAddStaParams )
1986 {
1987 limLog( pMac, LOGE, FL( "Encountered NULL Pointer\n" ));
1988 return;
1989 }
1990 if( eHAL_STATUS_SUCCESS == pAddStaParams->status )
1991 {
1992 if( eLIM_MLM_WT_ADD_STA_RSP_STATE != psessionEntry->limMlmState)
1993 {
1994 //TODO: any response to be sent out here ?
1995 limLog( pMac, LOGE,
1996 FL( "Received unexpected WDA_ADD_STA_RSP in state %X\n" ),
1997 psessionEntry->limMlmState);
1998 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
1999 goto end;
2000 }
2001 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2002 mesgType = LIM_MLM_REASSOC_CNF;
2003 //
2004 // Update the DPH Hash Entry for this STA
2005 // with proper state info
2006 //
2007 pStaDs = dphGetHashEntry( pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
2008 if( NULL != pStaDs)
2009 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
2010 else
2011 limLog( pMac, LOGW,
2012 FL( "Unable to get the DPH Hash Entry for AID - %d\n" ),
2013 DPH_STA_HASH_INDEX_PEER);
2014 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002015 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 /*
2017 * Storing the self StaIndex(Generated by HAL) in session context,
2018 * instead of storing it in DPH Hash entry for Self STA.
2019 * DPH entry for the self STA stores the sta index for the BSS entry
2020 * to which the STA is associated.
2021 */
2022 psessionEntry->staId = pAddStaParams->staIdx;
2023 //if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state
Yathish9f22e662012-12-10 14:21:35 -08002024#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2025 if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
2026#endif
2027 {
2028 limReactivateHeartBeatTimer(pMac, psessionEntry);
2029 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002030 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_KEEPALIVE_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002031
2032 //assign the sessionId to the timer Object
2033 pMac->lim.limTimers.gLimKeepaliveTimer.sessionId = psessionEntry->peSessionId;
2034 if (tx_timer_activate(&pMac->lim.limTimers.gLimKeepaliveTimer) != TX_SUCCESS)
2035 limLog(pMac, LOGP, FL("Cannot activate keepalive timer.\n"));
2036#ifdef WLAN_DEBUG
2037 pMac->lim.gLimNumLinkEsts++;
2038#endif
2039 // Return Assoc confirm to SME with success
2040 // FIXME_GEN4 - Need the correct ASSOC RSP code to
2041 // be passed in here....
2042 //mlmAssocCnf.resultCode = (tSirResultCodes) assoc.statusCode;
2043 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_SUCCESS;
2044 }
2045 else
2046 {
2047 limLog( pMac, LOGW, FL( "ADD_STA failed!\n"));
2048 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
2049 }
2050end:
2051 if( 0 != limMsgQ->bodyptr )
2052 {
2053 palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
2054 }
2055 /* Updating PE session Id*/
2056 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2057 limPostSmeMessage( pMac, mesgType, (tANI_U32 *) &mlmAssocCnf );
2058 return;
2059}
2060void limProcessMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2061{
2062 //we need to process the deferred message since the initiating req. there might be nested request.
2063 //in the case of nested request the new request initiated from the response will take care of resetting
2064 //the deffered flag.
2065 // tpPESession psessionEntry;
2066 // tpDeleteBssParams pDeleteBssParams =( tpDeleteBssParams)limMsgQ->bodyptr;
2067 // if((psessionEntry = peFindSessionBySessionId(pMac,pDeleteBssParams->sessionId)) == NULL)
2068 // {
2069 // limLog( pMac, LOGE, FL( "Session deos not exist with given sessionId\n" ));
2070 // return;
2071 // }
2072 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
2074 if (((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
2075 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
2076#ifdef WLAN_SOFTAP_FEATURE
2077 || (psessionEntry->limSystemRole == eLIM_AP_ROLE)
2078#endif
2079 ) &&
2080 (psessionEntry->statypeForBss == STA_ENTRY_SELF))
2081 {
2082 limProcessBtAmpApMlmDelBssRsp(pMac, limMsgQ,psessionEntry);
2083 return;
2084 }
2085#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2086 limProcessStaMlmDelBssRsp(pMac, limMsgQ,psessionEntry);
2087#endif
2088}
2089
2090void limProcessStaMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2091{
2092 tpDeleteBssParams pDelBssParams = (tpDeleteBssParams) limMsgQ->bodyptr;
2093 tpDphHashNode pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
2094 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302095
2096 if (NULL == pDelBssParams)
2097 {
2098 limLog( pMac, LOGE, FL( "Invalid body pointer in message\n"));
2099 goto end;
2100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 if( eHAL_STATUS_SUCCESS == pDelBssParams->status )
2102 {
2103 PELOGW(limLog( pMac, LOGW,
2104 FL( "STA received the DEL_BSS_RSP for BSSID: %X.\n"),pDelBssParams->bssIdx);)
2105 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
2106 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
2107
2108 {
2109 PELOGE(limLog( pMac, LOGE, FL( "Failure in setting link state to IDLE\n"));)
2110 statusCode = eSIR_SME_REFUSED;
2111 goto end;
2112 }
2113 if(pStaDs == NULL)
2114 {
2115 limLog( pMac, LOGE, FL( "DPH Entry for STA 1 missing.\n"));
2116 statusCode = eSIR_SME_REFUSED;
2117 goto end;
2118 }
2119 if( eLIM_MLM_WT_DEL_BSS_RSP_STATE != pStaDs->mlmStaContext.mlmState)
2120 {
2121 PELOGE(limLog( pMac, LOGE, FL( "Received unexpected WDA_DEL_BSS_RSP in state %X\n" ),
2122 pStaDs->mlmStaContext.mlmState);)
2123 statusCode = eSIR_SME_REFUSED;
2124 goto end;
2125 }
2126 PELOG1(limLog( pMac, LOG1, FL("STA AssocID %d MAC "), pStaDs->assocId );
2127 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
2128 }
2129 else
2130 {
2131 limLog( pMac, LOGP, FL( "DEL BSS failed!\n" ) );
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302132 palFreeMemory( pMac->hHdd, (void *) pDelBssParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 return;
2134 }
2135 end:
2136 if( 0 != limMsgQ->bodyptr )
2137 {
2138 palFreeMemory( pMac->hHdd, (void *) pDelBssParams );
2139 }
2140 if(pStaDs == NULL)
2141 return;
2142 if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2143 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE &&
2144 psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE) &&
2145 pStaDs->mlmStaContext.cleanupTrigger != eLIM_JOIN_FAILURE)
2146 {
2147 /** The Case where the DelBss is invoked from
2148 * context of other than normal DisAssoc / Deauth OR
2149 * as part of Join Failure.
2150 */
2151 limHandleDelBssInReAssocContext(pMac, pStaDs,psessionEntry);
2152 return;
2153 }
2154 limPrepareAndSendDelStaCnf(pMac, pStaDs, statusCode,psessionEntry);
2155 return;
2156}
2157
Jeff Johnson295189b2012-06-20 16:38:30 -07002158void limProcessBtAmpApMlmDelBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2159{
2160 tSirResultCodes rc = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002161 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 tpDeleteBssParams pDelBss = (tpDeleteBssParams) limMsgQ->bodyptr;
2163 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
2164
2165 if(psessionEntry == NULL)
2166 {
2167 limLog(pMac, LOGE,FL("Session entry passed is NULL\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002168 if(pDelBss != NULL)
2169 palFreeMemory( pMac->hHdd, (void *) pDelBss );
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 return;
2171 }
2172
2173 if (pDelBss == NULL)
2174 {
2175 PELOGE(limLog(pMac, LOGE, FL("BSS: DEL_BSS_RSP with no body!\n"));)
2176 rc = eSIR_SME_REFUSED;
2177 goto end;
2178 }
2179 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
2180 if( eLIM_MLM_WT_DEL_BSS_RSP_STATE != psessionEntry->limMlmState)
2181 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002182 limLog( pMac, LOGE,
Jeff Johnson43971f52012-07-17 12:26:56 -07002183 FL( "Received unexpected WDA_DEL_BSS_RSP in state %X" ),
2184 psessionEntry->limMlmState);
Jeff Johnsone7245742012-09-05 17:12:55 -07002185 rc = eSIR_SME_REFUSED;
2186 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 }
2188 if (pDelBss->status != eHAL_STATUS_SUCCESS)
2189 {
2190 limLog(pMac, LOGE, FL("BSS: DEL_BSS_RSP error (%x) Bss %d "),
2191 pDelBss->status, pDelBss->bssIdx);
2192 rc = eSIR_SME_STOP_BSS_FAILURE;
2193 goto end;
2194 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002195 status = limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 psessionEntry->selfMacAddr, NULL, NULL);
Jeff Johnson43971f52012-07-17 12:26:56 -07002197 if (status != eSIR_SUCCESS)
2198 {
2199 rc = eSIR_SME_REFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 goto end;
Jeff Johnson43971f52012-07-17 12:26:56 -07002201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 /** Softmac may send all the buffered packets right after resuming the transmission hence
2203 * to occupy the medium during non channel occupancy period. So resume the transmission after
2204 * HAL gives back the response.
2205 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002206#if 0 //TODO: How to handle this per session
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 if (LIM_IS_RADAR_DETECTED(pMac))
2208 {
2209 limFrameTransmissionControl(pMac, eLIM_TX_BSS_BUT_BEACON, eLIM_RESUME_TX);
2210 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
2211 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002212#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);//TBD-RAJESH is it needed ?
2214 limDeletePreAuthList(pMac);
2215#ifdef WLAN_SOFTAP_FEATURE
2216 //Initialize number of associated stations during cleanup
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002217 psessionEntry->gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002218#endif
2219 end:
2220 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, rc, psessionEntry->smeSessionId, psessionEntry->transactionId);
2221 peDeleteSession(pMac, psessionEntry);
2222
2223 if(pDelBss != NULL)
2224 palFreeMemory( pMac->hHdd, (void *) pDelBss );
2225}
2226
2227void limProcessMlmDelStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
2228{
2229 //we need to process the deferred message since the initiating req. there might be nested request.
2230 //in the case of nested request the new request initiated from the response will take care of resetting
2231 //the deffered flag.
2232
2233 tpPESession psessionEntry;
2234 tpDeleteStaParams pDeleteStaParams;
2235 pDeleteStaParams = (tpDeleteStaParams)limMsgQ->bodyptr;
2236 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302237
2238 if(NULL == pDeleteStaParams ||
2239 NULL == (psessionEntry = peFindSessionBySessionId(pMac, pDeleteStaParams->sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302241 limLog(pMac, LOGP,FL("Session Does not exist or invalid body pointer in message\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002242 if(pDeleteStaParams != NULL)
2243 palFreeMemory( pMac->hHdd, (void *) pDeleteStaParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 return;
2245 }
2246
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
2248#ifdef WLAN_SOFTAP_FEATURE
2249 || (psessionEntry->limSystemRole == eLIM_AP_ROLE)
2250#endif
2251 )
2252 {
2253 limProcessBtAmpApMlmDelStaRsp(pMac,limMsgQ,psessionEntry);
2254 return;
2255 }
2256#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2257 limProcessStaMlmDelStaRsp(pMac, limMsgQ,psessionEntry);
2258#endif
2259}
2260
Jeff Johnson295189b2012-06-20 16:38:30 -07002261void limProcessBtAmpApMlmDelStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2262{
2263 tpDeleteStaParams pDelStaParams = (tpDeleteStaParams) limMsgQ->bodyptr;
2264 tpDphHashNode pStaDs;
2265 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
2266 if(limMsgQ->bodyptr == NULL)
2267 {
2268 return;
2269 }
2270
2271 pStaDs = dphGetHashEntry(pMac, pDelStaParams->assocId, &psessionEntry->dph.dphHashTable);
2272 if(pStaDs == NULL)
2273 {
2274 limLog( pMac, LOGE,
2275 FL( "DPH Entry for STA %X missing.\n"), pDelStaParams->assocId);
2276 statusCode = eSIR_SME_REFUSED;
2277 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2278
2279 return;
2280 }
2281 if( eHAL_STATUS_SUCCESS == pDelStaParams->status )
2282 {
2283 limLog( pMac, LOGW,
2284 FL( "AP received the DEL_STA_RSP for assocID: %X.\n"), pDelStaParams->assocId);
2285
2286 if(( eLIM_MLM_WT_DEL_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState) &&
2287 ( eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState))
2288 {
2289 limLog( pMac, LOGE,
2290 FL( "Received unexpected WDA_DEL_STA_RSP in state %s for staId %d assocId %d \n" ),
2291 limMlmStateStr(pStaDs->mlmStaContext.mlmState), pStaDs->staIndex, pStaDs->assocId);
2292 statusCode = eSIR_SME_REFUSED;
2293 goto end;
2294 }
2295
2296 limLog( pMac, LOG1,
2297 FL("Deleted STA AssocID %d staId %d MAC "),
2298 pStaDs->assocId, pStaDs->staIndex);
2299 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);
2300 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE == pStaDs->mlmStaContext.mlmState)
2301 {
2302 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2303 if (limAddSta(pMac, pStaDs,psessionEntry) != eSIR_SUCCESS)
2304 {
2305 PELOGE(limLog(pMac, LOGE,
2306 FL("could not Add STA with assocId=%d\n"),
2307 pStaDs->assocId);)
2308 // delete the TS if it has already been added.
2309 // send the response with error status.
2310 if(pStaDs->qos.addtsPresent)
2311 {
2312 tpLimTspecInfo pTspecInfo;
2313 if(eSIR_SUCCESS == limTspecFindByAssocId(pMac, pStaDs->assocId,
2314 &pStaDs->qos.addts.tspec, &pMac->lim.tspecInfo[0], &pTspecInfo))
2315 {
2316 limAdmitControlDeleteTS(pMac, pStaDs->assocId, &pStaDs->qos.addts.tspec.tsinfo,
2317 NULL, &pTspecInfo->idx);
2318 }
2319 }
2320 limRejectAssociation(pMac,
2321 pStaDs->staAddr,
2322 pStaDs->mlmStaContext.subType,
2323 true, pStaDs->mlmStaContext.authType,
2324 pStaDs->assocId, true,
2325 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
2326 psessionEntry);
2327 }
2328 return;
2329 }
2330 }
2331 else
2332 {
2333 limLog( pMac, LOGW,
2334 FL( "DEL STA failed!\n" ));
2335 statusCode = eSIR_SME_REFUSED;
2336 }
2337 end:
2338 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2339 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState)
2340 {
2341 limPrepareAndSendDelStaCnf(pMac, pStaDs, statusCode,psessionEntry);
2342 }
2343 return;
2344}
2345
2346void limProcessStaMlmDelStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2347{
2348 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
2349 tpDeleteStaParams pDelStaParams = (tpDeleteStaParams) limMsgQ->bodyptr;
2350 tpDphHashNode pStaDs = NULL;
2351 if(NULL == pDelStaParams )
2352 {
2353 limLog( pMac, LOGE, FL( "Encountered NULL Pointer\n" ));
2354 goto end;
2355 }
2356 if( eHAL_STATUS_SUCCESS == pDelStaParams->status )
2357 {
2358 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
2359 if (pStaDs == NULL)
2360 {
2361 //TODO: any response to be sent out here ?
2362 limLog( pMac, LOGE, FL( "DPH Entry for STA %X missing.\n"),
2363 pDelStaParams->assocId);
2364 statusCode = eSIR_SME_REFUSED;
2365 goto end;
2366 }
2367 if( eLIM_MLM_WT_DEL_STA_RSP_STATE != psessionEntry->limMlmState)
2368 {
2369 //TODO: any response to be sent out here ?
2370 limLog( pMac, LOGE, FL( "Received unexpected WDA_DELETE_STA_RSP in state %s\n" ),
2371 limMlmStateStr(psessionEntry->limMlmState));
2372 statusCode = eSIR_SME_REFUSED;
2373 goto end;
2374 }
2375 PELOG1(limLog( pMac, LOG1, FL("STA AssocID %d MAC "), pStaDs->assocId );
2376 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
2377 limLog( pMac, LOGW, FL( "DEL_STA_RSP received for assocID: %X\n"), pDelStaParams->assocId);
2378 //we must complete all cleanup related to delSta before calling limDelBSS.
2379 if( 0 != limMsgQ->bodyptr )
2380 {
2381 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2382 }
2383 statusCode = (tSirResultCodes) limDelBss(pMac, pStaDs, 0,psessionEntry);
2384 return;
2385 }
2386 else
2387 {
2388 limLog( pMac, LOGW, FL( "DEL_STA failed!\n" ));
2389 statusCode = eSIR_SME_REFUSED;
2390 }
2391end:
2392 if( 0 != limMsgQ->bodyptr )
2393 {
2394 palFreeMemory( pMac->hHdd, (void *) pDelStaParams );
2395 }
2396 return;
2397}
2398
Jeff Johnson295189b2012-06-20 16:38:30 -07002399void limProcessBtAmpApMlmAddStaRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
2400{
2401 tpAddStaParams pAddStaParams = (tpAddStaParams) limMsgQ->bodyptr;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302402 tpDphHashNode pStaDs = NULL;
2403
2404 if (NULL == pAddStaParams)
2405 {
2406 limLog( pMac, LOGE, FL( "Invalid body pointer in message\n"));
2407 goto end;
2408 }
2409
2410 pStaDs = dphGetHashEntry(pMac, pAddStaParams->assocId, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 if(pStaDs == NULL)
2412 {
2413 //TODO: any response to be sent out here ?
2414 limLog( pMac, LOGE, FL( "DPH Entry for STA %X missing.\n"), pAddStaParams->assocId);
2415 goto end;
2416 }
2417 //
2418 // TODO & FIXME_GEN4
2419 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
2420 //
2421 //TODO: any check for pMac->lim.gLimMlmState ?
2422 if( eLIM_MLM_WT_ADD_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState)
2423 {
2424 //TODO: any response to be sent out here ?
2425 limLog( pMac, LOGE,
2426 FL( "Received unexpected WDA_ADD_STA_RSP in state %X\n" ),
2427 pStaDs->mlmStaContext.mlmState);
2428 goto end;
2429 }
2430 if(eHAL_STATUS_SUCCESS != pAddStaParams->status)
2431 {
2432 PELOGE(limLog(pMac, LOGE, FL("Error! rcvd delSta rsp from HAL with status %d\n"),pAddStaParams->status);)
2433 limRejectAssociation(pMac, pStaDs->staAddr,
2434 pStaDs->mlmStaContext.subType,
2435 true, pStaDs->mlmStaContext.authType,
2436 pStaDs->assocId, true,
2437 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
2438 psessionEntry);
2439 goto end;
2440 }
2441 pStaDs->bssId = pAddStaParams->bssIdx;
2442 pStaDs->staIndex = pAddStaParams->staIdx;
2443 //if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state
2444 pStaDs->valid = 1;
2445 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ASSOC_CNF_STATE;
2446 limLog( pMac, LOG1,
2447 FL("STA AssocID %d staId %d MAC "),
2448 pStaDs->assocId,
2449 pStaDs->staIndex);
2450 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);
2451
2452 /* For BTAMP-AP, the flow sequence shall be:
2453 * 1) PE sends eWNI_SME_ASSOC_IND to SME
2454 * 2) PE receives eWNI_SME_ASSOC_CNF from SME
2455 * 3) BTAMP-AP sends Re/Association Response to BTAMP-STA
2456 */
2457 limSendMlmAssocInd(pMac, pStaDs, psessionEntry);
2458 // fall though to reclaim the original Add STA Response message
2459end:
2460 if( 0 != limMsgQ->bodyptr )
2461 {
2462 palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
2463 }
2464 return;
2465}
2466
2467/**
2468 * limProcessApMlmAddBssRsp()
2469 *
2470 *FUNCTION:
2471 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
2472 * Upon receipt of this message from HAL, MLME -
2473 * > Validates the result of WDA_ADD_BSS_REQ
2474 * > Init other remaining LIM variables
2475 * > Init the AID pool, for that BSSID
2476 * > Init the Pre-AUTH list, for that BSSID
2477 * > Create LIM timers, specific to that BSSID
2478 * > Init DPH related parameters that are specific to that BSSID
2479 * > TODO - When do we do the actual change channel?
2480 *
2481 *LOGIC:
2482 * SME sends eWNI_SME_START_BSS_REQ to LIM
2483 * LIM sends LIM_MLM_START_REQ to MLME
2484 * MLME sends WDA_ADD_BSS_REQ to HAL
2485 * HAL responds with WDA_ADD_BSS_RSP to MLME
2486 * MLME responds with LIM_MLM_START_CNF to LIM
2487 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2488 *
2489 *ASSUMPTIONS:
2490 * tSirMsgQ.body is allocated by MLME during limProcessMlmStartReq
2491 * tSirMsgQ.body will now be freed by this routine
2492 *
2493 *NOTE:
2494 *
2495 * @param pMac Pointer to Global MAC structure
2496 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2497 *
2498 * @return None
2499 */
2500static void
2501limProcessApMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ)
2502{
2503 tLimMlmStartCnf mlmStartCnf;
2504 tANI_U32 val;
2505 tpPESession psessionEntry;
2506// tANI_U8 sessionId;
2507 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2508 if(NULL == pAddBssParams )
2509 {
2510 limLog( pMac, LOGE, FL( "Encountered NULL Pointer\n" ));
2511 goto end;
2512 }
2513 //TBD: free the memory before returning, do it for all places where lookup fails.
2514 if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
2515 {
2516 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002517 if( NULL != pAddBssParams )
2518 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 return;
2520 }
2521 /* Update PE session Id*/
2522 mlmStartCnf.sessionId = pAddBssParams->sessionId;
2523 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
2524 {
2525 PELOG2(limLog(pMac, LOG2, FL("WDA_ADD_BSS_RSP returned with eHAL_STATUS_SUCCESS\n"));)
2526 if (limSetLinkState(pMac, eSIR_LINK_AP_STATE,psessionEntry->bssId,
2527 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2528 goto end;
2529 // Set MLME state
2530 psessionEntry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002531 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 if( eSIR_IBSS_MODE == pAddBssParams->bssType )
2533 {
2534 /** IBSS is 'active' when we receive
2535 * Beacon frames from other STAs that are part of same IBSS.
2536 * Mark internal state as inactive until then.
2537 */
2538 psessionEntry->limIbssActive = false;
2539 psessionEntry->statypeForBss = STA_ENTRY_PEER; //to know session created for self/peer
2540 limResetHBPktCount( psessionEntry );
2541 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002542 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 if (limActivateHearBeatTimer(pMac) != TX_SUCCESS)
2544 limLog(pMac, LOGP, FL("could not activate Heartbeat timer\n"));
2545 }
2546 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2547
2548#ifdef ANI_PRODUCT_TYPE_AP
2549 psessionEntry->limSystemRole = eLIM_AP_ROLE;
2550#else
2551 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2552#endif
2553
2554#ifdef WLAN_SOFTAP_FEATURE
2555 if ( eSIR_INFRA_AP_MODE == pAddBssParams->bssType )
2556 psessionEntry->limSystemRole = eLIM_AP_ROLE;
2557 else
2558 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2559#endif
2560 schEdcaProfileUpdate(pMac, psessionEntry);
2561 limInitPreAuthList(pMac);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002562 limInitPeerIdxpool(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 // Create timers used by LIM
2564 if (!pMac->lim.gLimTimersCreated)
2565 limCreateTimers(pMac);
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07002566
2567 // Start OLBC timer
2568 if (tx_timer_activate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer) != TX_SUCCESS)
2569 {
2570 limLog(pMac, LOGE, FL("tx_timer_activate failed\n"));
2571 }
2572
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
2574 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val ))
2575 limLog( pMac, LOGP, FL("Failed to get WNI_CFG_TRIG_STA_BK_SCAN!\n"));
2576 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
2577 // Apply previously set configuration at HW
2578 limApplyConfiguration(pMac,psessionEntry);
2579 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2580 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2581 }
2582 else
2583 {
2584 limLog( pMac, LOGE, FL( "WDA_ADD_BSS_REQ failed with status %d\n" ),pAddBssParams->status );
2585 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2586 }
2587 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
2588 end:
2589 if( 0 != limMsgQ->bodyptr )
2590 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
2591}
2592
2593
2594/**
2595 * limProcessIbssMlmAddBssRsp()
2596 *
2597 *FUNCTION:
2598 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
2599 * Upon receipt of this message from HAL, MLME -
2600 * > Validates the result of WDA_ADD_BSS_REQ
2601 * > Init other remaining LIM variables
2602 * > Init the AID pool, for that BSSID
2603 * > Init the Pre-AUTH list, for that BSSID
2604 * > Create LIM timers, specific to that BSSID
2605 * > Init DPH related parameters that are specific to that BSSID
2606 * > TODO - When do we do the actual change channel?
2607 *
2608 *LOGIC:
2609 * SME sends eWNI_SME_START_BSS_REQ to LIM
2610 * LIM sends LIM_MLM_START_REQ to MLME
2611 * MLME sends WDA_ADD_BSS_REQ to HAL
2612 * HAL responds with WDA_ADD_BSS_RSP to MLME
2613 * MLME responds with LIM_MLM_START_CNF to LIM
2614 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2615 *
2616 *ASSUMPTIONS:
2617 * tSirMsgQ.body is allocated by MLME during limProcessMlmStartReq
2618 * tSirMsgQ.body will now be freed by this routine
2619 *
2620 *NOTE:
2621 *
2622 * @param pMac Pointer to Global MAC structure
2623 * @param tSirMsgQ The MsgQ header, which contains the response buffer
2624 *
2625 * @return None
2626 */
2627static void
2628limProcessIbssMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry)
2629{
2630 tLimMlmStartCnf mlmStartCnf;
2631 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2632 tANI_U32 val;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302633
2634 if (NULL == pAddBssParams)
2635 {
2636 limLog( pMac, LOGE, FL( "Invalid body pointer in message\n"));
2637 goto end;
2638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
2640 {
2641 PELOG1(limLog(pMac, LOG1, FL("WDA_ADD_BSS_RSP returned with eHAL_STATUS_SUCCESS\n"));)
2642 if (limSetLinkState(pMac, eSIR_LINK_IBSS_STATE,psessionEntry->bssId,
2643 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2644 goto end;
2645 // Set MLME state
2646 psessionEntry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002647 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 /** IBSS is 'active' when we receive
2649 * Beacon frames from other STAs that are part of same IBSS.
2650 * Mark internal state as inactive until then.
2651 */
2652 psessionEntry->limIbssActive = false;
2653 limResetHBPktCount( psessionEntry );
2654 /* Timer related functions are not modified for BT-AMP : To be Done */
2655 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002656 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 if (limActivateHearBeatTimer(pMac) != TX_SUCCESS)
2658 limLog(pMac, LOGP, FL("could not activate Heartbeat timer\n"));
2659 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2660 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2661 psessionEntry->statypeForBss = STA_ENTRY_SELF;
2662 schEdcaProfileUpdate(pMac, psessionEntry);
2663 //TBD-RAJESH limInitPreauthList should re removed for IBSS also ?????
2664 //limInitPreAuthList(pMac);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002665 limInitPeerIdxpool(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 // Create timers used by LIM
2667#ifdef FIXME_GEN6 //following code may not be required, as limCreateTimers is now invoked from limInitialize (peStart)
2668 if (!pMac->lim.gLimTimersCreated)
2669 limCreateTimers(pMac);
2670#endif
2671 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
2672 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val ))
2673 limLog( pMac, LOGP, FL("Failed to get WNI_CFG_TRIG_STA_BK_SCAN!\n"));
2674 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
2675 // Apply previously set configuration at HW
2676 limApplyConfiguration(pMac,psessionEntry);
2677 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2678 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2679 //If ADD BSS was issued as part of IBSS coalescing, don't send the message to SME, as that is internal to LIM
2680 if(true == pMac->lim.gLimIbssCoalescingHappened)
2681 {
2682 limIbssAddBssRspWhenCoalescing(pMac, limMsgQ->bodyptr, psessionEntry);
2683 goto end;
2684 }
2685 }
2686 else
2687 {
2688 limLog( pMac, LOGE, FL( "WDA_ADD_BSS_REQ failed with status %d\n" ),
2689 pAddBssParams->status );
2690 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2691 }
2692 //Send this message to SME, when ADD_BSS is initiated by SME
2693 //If ADD_BSS is done as part of coalescing, this won't happen.
2694 /* Update PE session Id*/
2695 mlmStartCnf.sessionId =psessionEntry->peSessionId;
2696 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
2697 end:
2698 if( 0 != limMsgQ->bodyptr )
2699 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
2700}
2701
2702static void
2703limProcessStaMlmAddBssRspPreAssoc( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ, tpPESession psessionEntry )
2704{
2705 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2706 tAniAuthType cfgAuthType, authMode;
2707 tLimMlmAuthReq *pMlmAuthReq;
2708 tpDphHashNode pStaDs = NULL;
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05302709
2710 if (NULL == pAddBssParams)
2711 {
2712 limLog( pMac, LOGE, FL( "Invalid body pointer in message\n"));
2713 goto joinFailure;
2714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
2716 {
2717 if ((pStaDs = dphAddHashEntry(pMac, pAddBssParams->staContext.staMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) == NULL)
2718 {
2719 // Could not add hash table entry
2720 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for \n"));)
2721 limPrintMacAddr(pMac, pAddBssParams->staContext.staMac, LOGE);
2722 goto joinFailure;
2723 }
2724 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2725 //Success, handle below
2726 pStaDs->bssId = pAddBssParams->bssIdx;
2727 //STA Index(genr by HAL) for the BSS entry is stored here
2728 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
2729 // Trigger Authentication with AP
2730 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE,
2731 (tANI_U32 *) &cfgAuthType) != eSIR_SUCCESS)
2732 {
2733 /**
2734 * Could not get AuthType from CFG.
2735 * Log error.
2736 */
2737 limLog(pMac, LOGP,
2738 FL("could not retrieve AuthType\n"));
2739 }
2740 if (cfgAuthType == eSIR_AUTO_SWITCH)
2741 authMode = eSIR_OPEN_SYSTEM; // Try Open Authentication first
2742 else
2743 authMode = cfgAuthType;
2744
2745 // Trigger MAC based Authentication
2746 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmAuthReq, sizeof(tLimMlmAuthReq)))
2747 {
2748 // Log error
2749 limLog(pMac, LOGP,
2750 FL("call to palAllocateMemory failed for mlmAuthReq\n"));
2751 return;
2752 }
2753 #if 0
2754 val = sizeof(tSirMacAddr);
2755 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID,
2756 pMlmAuthReq->peerMacAddr,
2757 &val) != eSIR_SUCCESS)
2758 {
2759 /// Could not get BSSID from CFG. Log error.
2760 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
2761 }
2762 #endif //TO SUPPORT BT-AMP
2763 sirCopyMacAddr(pMlmAuthReq->peerMacAddr,psessionEntry->bssId);
2764
2765 pMlmAuthReq->authType = authMode;
2766 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
2767 (tANI_U32 *) &pMlmAuthReq->authFailureTimeout)
2768 != eSIR_SUCCESS)
2769 {
2770 /**
2771 * Could not get AuthFailureTimeout
2772 * value from CFG. Log error.
2773 */
2774 limLog(pMac, LOGP,
2775 FL("could not retrieve AuthFailureTimeout value\n"));
2776 }
2777 // SUNIT_FIX_ME: Set BOTH? Assume not. Please verify here and below.
2778 //pMac->lim.gLimMlmState = eLIM_MLM_JOINED_STATE;
2779 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002780 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 pMlmAuthReq->sessionId = psessionEntry->peSessionId;
2782 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2783 psessionEntry->limSmeState = eLIM_SME_WT_AUTH_STATE;
2784 // remember staId in case of assoc timeout/failure handling
2785 psessionEntry->staId = pAddBssParams->staContext.staIdx;
2786
Jeff Johnsone7245742012-09-05 17:12:55 -07002787 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 limPostMlmMessage(pMac,
2789 LIM_MLM_AUTH_REQ,
2790 (tANI_U32 *) pMlmAuthReq);
2791 return;
2792 }
2793
2794joinFailure:
2795 {
2796 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002797 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002798
2799 /// Send Join response to Host
2800 limHandleSmeJoinResult(pMac, eSIR_SME_REFUSED, eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
2801
2802 }
2803
2804}
2805
2806#ifdef WLAN_FEATURE_VOWIFI_11R
2807/*------------------------------------------------------------------------------------------
2808 *
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002809 * Function to handle callback after setting link state to post assoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 *
2811 *
2812 *------------------------------------------------------------------------------------------
2813 */
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002814void limSetLinkStateForPostAssocCallback(tpAniSirGlobal pMac, void *msgParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07002815{
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 tLimMlmReassocCnf mlmReassocCnf; // keep sme
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002817 tSetLinkCbackParams * pCbackParams = (tSetLinkCbackParams *)msgParam;
2818 tpPESession psessionEntry = NULL;
2819 tpAddBssParams pAddBssParams = NULL;
2820 tpDphHashNode pStaDs = NULL;
2821 tpAddStaParams pAddStaParams = NULL;
2822 tLimMlmReassocReq * pMlmReassocReq = NULL;
2823 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
2824
2825 /* Sanity Checks */
2826 if (pCbackParams == NULL)
2827 {
2828 PELOGE(limLog(pMac, LOGE, FL("Invalid parameters\n"));)
2829 goto end;
2830 }
2831
2832 pAddBssParams = (tpAddBssParams)(pCbackParams->cbackDataPtr);
2833
2834 if (pAddBssParams == NULL)
2835 {
2836 PELOGE(limLog(pMac, LOGE, FL("Invalid parameters\n"));)
2837 goto end;
2838 }
2839
2840 if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
2841 {
2842 limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId\n" ));
2843 if( NULL != pAddBssParams )
2844 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
2845 goto end;
2846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002847
2848 pMlmReassocReq = (tLimMlmReassocReq *)(psessionEntry->pLimMlmReassocReq);
2849
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08002850 limPrintMacAddr(pMac, pAddBssParams->bssId, LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002851
2852 if ((pStaDs = dphAddHashEntry(pMac, pAddBssParams->bssId, DPH_STA_HASH_INDEX_PEER,
2853 &psessionEntry->dph.dphHashTable)) == NULL)
2854 {
2855 // Could not add hash table entry
2856 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for \n"));)
2857 limPrintMacAddr(pMac, pAddBssParams->staContext.staMac, LOGE);
2858 goto end;
2859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 // Prepare and send Reassociation request frame
2861 // start reassoc timer.
2862 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2863 /// Start reassociation failure timer
Jeff Johnsone7245742012-09-05 17:12:55 -07002864 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2866 != TX_SUCCESS)
2867 {
2868 /// Could not start reassoc failure timer.
2869 // Log error
2870 limLog(pMac, LOGP,
2871 FL("could not start Reassociation failure timer\n"));
2872 // Return Reassoc confirm with
2873 // Resources Unavailable
2874 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2875 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2876 goto end;
2877 }
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002878#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
2879 pMac->lim.pSessionEntry = psessionEntry;
2880 if(NULL == pMac->lim.pSessionEntry->pLimMlmReassocRetryReq)
2881 {
2882 /* Take a copy of reassoc request for retrying */
2883 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pMac->lim.pSessionEntry->pLimMlmReassocRetryReq, sizeof(tLimMlmReassocReq))) ) goto end;
2884 palZeroMemory(pMac->hHdd, pMac->lim.pSessionEntry->pLimMlmReassocRetryReq, sizeof(tLimMlmReassocReq));
2885 palCopyMemory( pMac->hHdd,pMac->lim.pSessionEntry->pLimMlmReassocRetryReq, psessionEntry->pLimMlmReassocReq, sizeof(tLimMlmReassocReq));
2886 }
2887 pMac->lim.reAssocRetryAttempt = 0;
2888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 limSendReassocReqWithFTIEsMgmtFrame(pMac, psessionEntry->pLimMlmReassocReq, psessionEntry);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002890
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2892 psessionEntry->limMlmState = eLIM_MLM_WT_FT_REASSOC_RSP_STATE;
2893 PELOGE(limLog(pMac, LOGE, FL("Set the mlm state to %d session=%d\n"),
2894 psessionEntry->limMlmState, psessionEntry->peSessionId);)
2895
2896 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
2897
2898 //Success, handle below
2899 pStaDs->bssId = pAddBssParams->bssIdx;
2900 //STA Index(genr by HAL) for the BSS entry is stored here
2901 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
2902 pStaDs->ucUcastSig = pAddBssParams->staContext.ucUcastSig;
2903 pStaDs->ucBcastSig = pAddBssParams->staContext.ucBcastSig;
2904
Jeff Johnson295189b2012-06-20 16:38:30 -07002905#if defined WLAN_FEATURE_VOWIFI
2906 rrmCacheMgmtTxPower( pMac, pAddBssParams->txMgmtPower, psessionEntry );
2907#endif
2908
2909 if( eHAL_STATUS_SUCCESS !=
2910 palAllocateMemory( pMac->hHdd, (void **) &pAddStaParams, sizeof( tAddStaParams )))
2911 {
2912 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during ADD_STA\n" ));
2913 return;
2914 }
2915 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams, sizeof(tAddStaParams));
2916
2917 /// Add STA context at MAC HW (BMU, RHP & TFP)
2918 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->staMac,
2919 (tANI_U8 *) psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
2920
2921 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->bssId,
2922 psessionEntry->bssId, sizeof(tSirMacAddr));
2923
2924 // Update this when we get reassoc rsp , with success.
2925 // pAddStaParams->assocId = psessionEntry->limAID;
2926
2927 pAddStaParams->staType = STA_ENTRY_SELF;
2928 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2929 pAddStaParams->respReqd = 1;
2930
2931 /* Update PE session ID */
2932 pAddStaParams->sessionId = psessionEntry->peSessionId;
2933
2934 // This will indicate HAL to "allocate" a new STA index
2935 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2936 pAddStaParams->updateSta = FALSE;
2937
2938 pAddStaParams->shortPreambleSupported = (tANI_U8)psessionEntry->beaconParams.fShortPreamble;
Jeff Johnsone7245742012-09-05 17:12:55 -07002939#ifdef WLAN_FEATURE_11AC
2940 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry, NULL);
2941#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002943#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002944
Jeff Johnsone7245742012-09-05 17:12:55 -07002945 if( psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002947 pAddStaParams->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -07002948#ifdef DISABLE_GF_FOR_INTEROP
2949 /*
2950 * To resolve the interop problem with Broadcom AP,
2951 * where TQ STA could not pass traffic with GF enabled,
2952 * TQ STA will do Greenfield only with TQ AP, for
2953 * everybody else it will be turned off.
Jeff Johnsone7245742012-09-05 17:12:55 -07002954 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2956 {
2957 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2958 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2959 }
2960 else
2961#endif
2962
2963#ifdef WLAN_SOFTAP_FEATURE
2964 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
2965 pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
2966 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
2967 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
2968 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
2969 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
2970 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
2971 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
2972 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
2973 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
2974 pAddStaParams->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
2975 pAddStaParams->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
2976#else
2977 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD );
2978 pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET );
2979 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE );
2980 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE );
2981 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION );
2982 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA );
2983 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY );
2984 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR);
2985 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH );
2986 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ);
2987 pAddStaParams->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ);
2988 pAddStaParams->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ);
2989#endif
2990 }
2991
2992 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
2993 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL\n"));
2994 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
2995
2996 limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
2997
2998 // Lets save this for when we receive the Reassoc Rsp
2999 pMac->ft.ftPEContext.pAddStaReq = pAddStaParams;
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08003000
3001 if (pCbackParams != NULL)
3002 {
3003 if (pCbackParams->cbackDataPtr != NULL)
3004 {
3005 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams->cbackDataPtr);
3006 }
3007 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams);
3008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 return;
3010
3011end:
3012 // Free up buffer allocated for reassocReq
3013 if (pMlmReassocReq != NULL)
3014 {
3015 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
3016 }
Dhanashri Atre4a6e3ea2012-12-12 14:10:33 -08003017
3018 if (pCbackParams != NULL)
3019 {
3020 if (pCbackParams->cbackDataPtr != NULL)
3021 {
3022 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams->cbackDataPtr);
3023 }
3024 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams);
3025 }
3026
3027 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3028 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3029 /* Update PE sessio Id*/
3030 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3031
3032 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3033}
3034/*------------------------------------------------------------------------------------------
3035 *
3036 * Function to handle WDA_ADD_BSS_RSP, in FT reassoc state.
3037 *
3038 *
3039 *------------------------------------------------------------------------------------------
3040 */
3041static inline void
3042limProcessStaMlmAddBssRspFT(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ, tpPESession psessionEntry)
3043{
3044 tSetLinkCbackParams * pCbackParam = NULL;
3045 tAddBssParams * pAddBssCbackInfo = NULL;
3046 tLimMlmReassocCnf mlmReassocCnf;
3047 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
3048
3049 if ( eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE != psessionEntry->limMlmState )
3050 {
3051 goto end;
3052 }
3053
3054 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pCbackParam, sizeof( tSetLinkCbackParams )))
3055 {
3056 PELOGE(limLog(pMac, LOGE, FL("Could not allocate memory for LinkState callback params\n"));)
3057 goto end;
3058 }
3059
3060 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pAddBssCbackInfo, sizeof( tAddBssParams )))
3061 {
3062 PELOGE(limLog(pMac, LOGE, FL("Could not allocate memory for Add BSS info callback param\n"));)
3063 goto end;
3064 }
3065
3066 vos_mem_copy(pAddBssCbackInfo, pAddBssParams, sizeof(tAddBssParams));
3067
3068 pCbackParam->cbackDataPtr = (void*)pAddBssCbackInfo;
3069
3070 // Set the filter state to post assoc and send out re-assoc request OTA only after response is received
3071 if (limSetLinkState(pMac, eSIR_LINK_POSTASSOC_STATE,
3072 pAddBssParams->bssId, psessionEntry->selfMacAddr,
3073 (tpSetLinkStateCallback)limSetLinkStateForPostAssocCallback,
3074 (void *)pCbackParam) != eSIR_SUCCESS)
3075 {
3076 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState\n"));)
3077 goto end;
3078 }
3079
3080 return;
3081
3082end:
3083
3084 if (pCbackParam != NULL)
3085 {
3086 if (pCbackParam->cbackDataPtr != NULL)
3087 {
3088 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParam->cbackDataPtr);
3089 }
3090 palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParam);
3091 }
3092
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3094 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3095 /* Update PE sessio Id*/
3096 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3097
3098 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3099}
3100#endif /* WLAN_FEATURE_VOWIFI_11R */
3101
3102
3103/**
3104 * limProcessStaMlmAddBssRsp()
3105 *
3106 *FUNCTION:
3107 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
3108 * Upon receipt of this message from HAL, MLME -
3109 * > Validates the result of WDA_ADD_BSS_REQ
3110 * > Now, send an ADD_STA to HAL and ADD the "local" STA itself
3111 *
3112 *LOGIC:
3113 * MLME had sent WDA_ADD_BSS_REQ to HAL
3114 * HAL responded with WDA_ADD_BSS_RSP to MLME
3115 * MLME now sends WDA_ADD_STA_REQ to HAL
3116 *
3117 *ASSUMPTIONS:
3118 * tSirMsgQ.body is allocated by MLME during limProcessMlmJoinReq
3119 * tSirMsgQ.body will now be freed by this routine
3120 *
3121 *NOTE:
3122 *
3123 * @param pMac Pointer to Global MAC structure
3124 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3125 *
3126 * @return None
3127 */
3128static void
3129limProcessStaMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ,tpPESession psessionEntry)
3130{
3131 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
3132 tLimMlmAssocCnf mlmAssocCnf;
3133 tANI_U32 mesgType = LIM_MLM_ASSOC_CNF;
3134 tANI_U32 subType = LIM_ASSOC;
3135 tpDphHashNode pStaDs = NULL;
3136 tANI_U16 staIdx = HAL_STA_INVALID_IDX;
3137 tANI_U8 updateSta = false;
3138 mlmAssocCnf.resultCode = eSIR_SME_SUCCESS;
3139
3140 if(eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE == psessionEntry->limMlmState)
3141 {
3142 //Done: 7-28-2009. JIM_FIX_ME: sessionize the following function
3143 limProcessStaMlmAddBssRspPreAssoc(pMac, limMsgQ, psessionEntry);
3144 goto end;
3145 }
3146 if( eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE == psessionEntry->limMlmState )
3147 {
3148 mesgType = LIM_MLM_REASSOC_CNF;
3149 subType = LIM_REASSOC;
3150 //If Reassoc is happening for the same BSS, then use the existing StaId and indicate to HAL
3151 //to update the existing STA entry.
3152 //If Reassoc is happening for the new BSS, then old BSS and STA entry would have been already deleted
3153 //before PE tries to add BSS for the new BSS, so set the updateSta to false and pass INVALID STA Index.
3154 if (sirCompareMacAddr( psessionEntry->bssId, psessionEntry->limReAssocbssId))
3155 {
3156 staIdx = psessionEntry->staId;
3157 updateSta = true;
3158 }
3159 }
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08003160
Madan Mohan Koyyalamudi830ed802012-11-29 11:38:12 -08003161 if(pAddBssParams == 0)
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08003162 goto end;
3163
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
3165 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003166#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 if( eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE == psessionEntry->limMlmState )
3168 {
3169#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3170 PELOGE(limLog(pMac, LOGE, FL("Mlm=%d %d\n"),
3171 psessionEntry->limMlmState,
3172 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE);)
3173#endif
3174 limProcessStaMlmAddBssRspFT( pMac, limMsgQ, psessionEntry);
3175 goto end;
3176 }
3177#endif /* WLAN_FEATURE_VOWIFI_11R */
3178
3179 // Set MLME state
3180 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003181 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 psessionEntry->statypeForBss = STA_ENTRY_PEER; //to know the session started for self or for peer oct6th
3183 // Now, send WDA_ADD_STA_REQ
3184 limLog( pMac, LOGW, FL( "On STA: ADD_BSS was successful\n" ));
3185 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3186 if (pStaDs == NULL)
3187 {
3188 PELOGE(limLog(pMac, LOGE, FL("could not Add Self Entry for the station\n"));)
3189 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
3190 }
3191 else
3192 {
3193 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
3194 //Success, handle below
3195 pStaDs->bssId = pAddBssParams->bssIdx;
3196 //STA Index(genr by HAL) for the BSS entry is stored here
3197 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
3198 pStaDs->ucUcastSig = pAddBssParams->staContext.ucUcastSig;
3199 pStaDs->ucBcastSig = pAddBssParams->staContext.ucBcastSig;
3200 // Downgrade the EDCA parameters if needed
3201 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
3202 // Send the active EDCA parameters to HAL
3203 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE) {
3204 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
3205 } else {
3206 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
3207 }
3208#if defined WLAN_FEATURE_VOWIFI
3209 rrmCacheMgmtTxPower( pMac, pAddBssParams->txMgmtPower, psessionEntry );
3210#endif
3211
3212 if (subType == LIM_REASSOC)
3213 limDeactivateAndChangeTimer(pMac, eLIM_KEEPALIVE_TIMER);
3214 if (limAddStaSelf(pMac,staIdx, updateSta, psessionEntry) != eSIR_SUCCESS)
3215 {
3216 // Add STA context at HW
3217 PELOGE(limLog(pMac, LOGE, FL("could not Add Self Entry for the station\n"));)
3218 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
3219 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003220#ifdef FEATURE_WLAN_TDLS
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003221 else {
3222 /* initialize TDLS peer related data */
3223 limInitTdlsData(pMac,psessionEntry);
3224 }
3225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 }
3227 }
3228 else
3229 {
3230 limLog( pMac, LOGP, FL( "ADD_BSS failed!\n" ));
3231 // Return Assoc confirm to SME with failure
3232 mlmAssocCnf.resultCode = (tSirResultCodes) eSIR_SME_REFUSED;
3233 }
3234
3235 if(mlmAssocCnf.resultCode != eSIR_SME_SUCCESS)
3236 {
3237 /* Update PE session Id*/
3238 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
3239 limPostSmeMessage( pMac, mesgType, (tANI_U32 *) &mlmAssocCnf );
3240 }
3241 end:
3242 if( 0 != limMsgQ->bodyptr )
3243 palFreeMemory( pMac->hHdd,(void *) pAddBssParams );
3244}
3245
3246
3247
3248/**
3249 * limProcessMlmAddBssRsp()
3250 *
3251 *FUNCTION:
3252 * This function is called to process a WDA_ADD_BSS_RSP from HAL.
3253 * Upon receipt of this message from HAL, MLME -
3254 * > Determines the "state" in which this message was received
3255 * > Forwards it to the appropriate callback
3256 *
3257 *LOGIC:
3258 * WDA_ADD_BSS_RSP can be received by MLME while the LIM is
3259 * in the following two states:
3260 * 1) As AP, LIM state = eLIM_SME_WT_START_BSS_STATE
3261 * 2) As STA, LIM state = eLIM_SME_WT_JOIN_STATE
3262 * Based on these two states, this API will determine where to
3263 * route the message to
3264 *
3265 *ASSUMPTIONS:
3266 *
3267 *NOTE:
3268 *
3269 * @param pMac Pointer to Global MAC structure
3270 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3271 *
3272 * @return None
3273 */
3274void limProcessMlmAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3275{
3276 tLimMlmStartCnf mlmStartCnf;
3277 tpPESession psessionEntry;
3278 tpAddBssParams pAddBssParams = (tpAddBssParams) (limMsgQ->bodyptr);
3279
3280 if(NULL == pAddBssParams )
3281 {
3282 limLog( pMac, LOGE, FL( "Encountered NULL Pointer\n" ));
3283 return;
3284 }
3285
3286 //
3287 // TODO & FIXME_GEN4
3288 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
3289 //
3290 //we need to process the deferred message since the initiating req. there might be nested request.
3291 //in the case of nested request the new request initiated from the response will take care of resetting
3292 //the deffered flag.
3293 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3294 // Validate SME/LIM state
3295 // Validate MLME state
3296 if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
3297 {
3298 limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003299 if( NULL != pAddBssParams )
3300 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 return;
3302 }
3303 /* update PE session Id*/
3304 mlmStartCnf.sessionId = psessionEntry->peSessionId;
3305 if( eSIR_IBSS_MODE == psessionEntry->bssType )
3306 limProcessIbssMlmAddBssRsp( pMac, limMsgQ, psessionEntry );
3307 else
3308 {
3309 if( eLIM_SME_WT_START_BSS_STATE == psessionEntry->limSmeState )
3310 {
3311 if( eLIM_MLM_WT_ADD_BSS_RSP_STATE != psessionEntry->limMlmState )
3312 {
3313 // Mesg received from HAL in Invalid state!
3314 limLog( pMac, LOGE,
3315 FL( "Received unexpected WDA_ADD_BSS_RSP in state %X\n" ),
3316 psessionEntry->limMlmState );
3317 mlmStartCnf.resultCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
3318 if( 0 != limMsgQ->bodyptr )
3319 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
3320 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
3321 }
3322 else if ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE)||(psessionEntry->bssType == eSIR_BTAMP_STA_MODE))
3323 {
3324 limProcessBtampAddBssRsp(pMac,limMsgQ,psessionEntry);
3325 }
3326 else
3327 limProcessApMlmAddBssRsp( pMac,limMsgQ);
3328 }
3329 else
3330 /* Called while processing assoc response */
3331 limProcessStaMlmAddBssRsp( pMac, limMsgQ,psessionEntry);
3332 }
3333}
3334/**
3335 * limProcessMlmSetKeyRsp()
3336 *
3337 *FUNCTION:
3338 * This function is called to process the following two
3339 * messages from HAL:
3340 * 1) WDA_SET_BSSKEY_RSP
3341 * 2) WDA_SET_STAKEY_RSP
3342 * 3) WDA_SET_STA_BCASTKEY_RSP
3343 * Upon receipt of this message from HAL,
3344 * MLME -
3345 * > Determines the "state" in which this message was received
3346 * > Forwards it to the appropriate callback
3347 *
3348 *LOGIC:
3349 * WDA_SET_BSSKEY_RSP/WDA_SET_STAKEY_RSP can be
3350 * received by MLME while in the following state:
3351 * MLME state = eLIM_MLM_WT_SET_BSS_KEY_STATE --OR--
3352 * MLME state = eLIM_MLM_WT_SET_STA_KEY_STATE --OR--
3353 * MLME state = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE
3354 * Based on this state, this API will determine where to
3355 * route the message to
3356 *
3357 *ASSUMPTIONS:
3358 * ONLY the MLME state is being taken into account for now.
3359 * This is because, it appears that the handling of the
3360 * SETKEYS REQ is handled symmetrically on both the AP & STA
3361 *
3362 *NOTE:
3363 *
3364 * @param pMac Pointer to Global MAC structure
3365 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3366 *
3367 * @return None
3368 */
3369void limProcessMlmSetStaKeyRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3370{
Jeff Johnsone7245742012-09-05 17:12:55 -07003371 tANI_U8 respReqd = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 tLimMlmSetKeysCnf mlmSetKeysCnf;
3373 tANI_U8 sessionId = 0;
3374 tpPESession psessionEntry;
3375 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3376 palZeroMemory( pMac->hHdd, (void *)&mlmSetKeysCnf, sizeof( tLimMlmSetKeysCnf ));
3377 //BTAMP
Jeff Johnsone7245742012-09-05 17:12:55 -07003378 if( NULL == limMsgQ->bodyptr )
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 {
3380 PELOGE(limLog(pMac, LOGE,FL("limMsgQ bodyptr is NULL\n"));)
3381 return;
3382 }
3383 sessionId = ((tpSetStaKeyParams) limMsgQ->bodyptr)->sessionId;
3384 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
3385 {
3386 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003387 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 return;
3389 }
3390 if( eLIM_MLM_WT_SET_STA_KEY_STATE != psessionEntry->limMlmState )
3391 {
3392 // Mesg received from HAL in Invalid state!
Jeff Johnsone7245742012-09-05 17:12:55 -07003393 limLog( pMac, LOGW, FL( "Received unexpected [Mesg Id - %d] in state %X\n" ), limMsgQ->type, psessionEntry->limMlmState );
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 // There's not much that MLME can do at this stage...
3395 respReqd = 0;
3396 }
3397 else
3398 mlmSetKeysCnf.resultCode = (tANI_U16) (((tpSetStaKeyParams) limMsgQ->bodyptr)->status);
3399
3400 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
3401 // Restore MLME state
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003403 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 if( respReqd )
3405 {
3406 tpLimMlmSetKeysReq lpLimMlmSetKeysReq = (tpLimMlmSetKeysReq) pMac->lim.gpLimMlmSetKeysReq;
3407 // Prepare and Send LIM_MLM_SETKEYS_CNF
3408 if( NULL != lpLimMlmSetKeysReq )
3409 {
3410 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf.peerMacAddr, (tANI_U8 *) lpLimMlmSetKeysReq->peerMacAddr, sizeof(tSirMacAddr) );
3411#ifdef ANI_PRODUCT_TYPE_AP
Jeff Johnsone7245742012-09-05 17:12:55 -07003412 mlmSetKeysCnf.aid = lpLimMlmSetKeysReq->aid;
Jeff Johnson295189b2012-06-20 16:38:30 -07003413#endif
3414 // Free the buffer cached for the global pMac->lim.gpLimMlmSetKeysReq
Jeff Johnsone7245742012-09-05 17:12:55 -07003415 palFreeMemory(pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 pMac->lim.gpLimMlmSetKeysReq = NULL;
3417 }
3418 mlmSetKeysCnf.sessionId = sessionId;
Jeff Johnsone7245742012-09-05 17:12:55 -07003419 limPostSmeMessage(pMac, LIM_MLM_SETKEYS_CNF, (tANI_U32 *) &mlmSetKeysCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 }
3421}
3422void limProcessMlmSetBssKeyRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3423{
3424 tANI_U8 respReqd = 1;
3425 tLimMlmSetKeysCnf mlmSetKeysCnf;
Jeff Johnsone7245742012-09-05 17:12:55 -07003426 tANI_U16 resultCode;
3427 tANI_U8 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 tpPESession psessionEntry;
3429 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3430 palZeroMemory( pMac->hHdd, (void *)&mlmSetKeysCnf, sizeof( tLimMlmSetKeysCnf ));
3431 //BTAMP
Jeff Johnsone7245742012-09-05 17:12:55 -07003432 if( NULL == limMsgQ->bodyptr )
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 {
3434 PELOGE(limLog(pMac, LOGE,FL("limMsgQ bodyptr is null\n"));)
3435 return;
3436 }
3437 sessionId = ((tpSetBssKeyParams) limMsgQ->bodyptr)->sessionId;
3438 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
3439 {
3440 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003441 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 return;
3443 }
3444 if( eLIM_MLM_WT_SET_BSS_KEY_STATE == psessionEntry->limMlmState )
3445 resultCode = (tANI_U16) (((tpSetBssKeyParams) limMsgQ->bodyptr)->status);
3446 else
3447 resultCode = (tANI_U16) (((tpSetStaKeyParams) limMsgQ->bodyptr)->status); //BCAST key also uses tpSetStaKeyParams. Done this way for readabilty.
3448
Jeff Johnsone7245742012-09-05 17:12:55 -07003449 //
3450 // TODO & FIXME_GEN4
3451 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
3452 //
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 // Validate SME/LIM state - Read the above "ASSUMPTIONS"
3454 //if( eLIM_SME_LINK_EST_STATE == pMac->lim.gLimSmeState )
3455 //{
3456 // Validate MLME state
3457 if( eLIM_MLM_WT_SET_BSS_KEY_STATE != psessionEntry->limMlmState &&
3458 eLIM_MLM_WT_SET_STA_BCASTKEY_STATE != psessionEntry->limMlmState )
3459 {
3460 // Mesg received from HAL in Invalid state!
Jeff Johnsone7245742012-09-05 17:12:55 -07003461 limLog( pMac, LOGW, FL( "Received unexpected [Mesg Id - %d] in state %X\n" ), limMsgQ->type, psessionEntry->limMlmState );
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 // There's not much that MLME can do at this stage...
3463 respReqd = 0;
3464 }
3465 else
3466 mlmSetKeysCnf.resultCode = resultCode;
3467
3468 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
3469 // Restore MLME state
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
3471
Jeff Johnsone7245742012-09-05 17:12:55 -07003472 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 if( respReqd )
3474 {
3475 tpLimMlmSetKeysReq lpLimMlmSetKeysReq = (tpLimMlmSetKeysReq) pMac->lim.gpLimMlmSetKeysReq;
3476 mlmSetKeysCnf.sessionId = sessionId;
3477
3478 // Prepare and Send LIM_MLM_SETKEYS_CNF
3479 if( NULL != lpLimMlmSetKeysReq )
3480 {
3481 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf.peerMacAddr, (tANI_U8 *) lpLimMlmSetKeysReq->peerMacAddr, sizeof(tSirMacAddr) );
3482#ifdef ANI_PRODUCT_TYPE_AP
Jeff Johnsone7245742012-09-05 17:12:55 -07003483 mlmSetKeysCnf.aid = lpLimMlmSetKeysReq->aid;
Jeff Johnson295189b2012-06-20 16:38:30 -07003484#endif
3485 // Free the buffer cached for the global pMac->lim.gpLimMlmSetKeysReq
Jeff Johnsone7245742012-09-05 17:12:55 -07003486 palFreeMemory(pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 pMac->lim.gpLimMlmSetKeysReq = NULL;
3488 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003489 limPostSmeMessage(pMac, LIM_MLM_SETKEYS_CNF, (tANI_U32 *) &mlmSetKeysCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 }
3491}
3492/**
3493 * limProcessMlmRemoveKeyRsp()
3494 *
3495 *FUNCTION:
3496 *
3497 *LOGIC:
3498 *
3499 *ASSUMPTIONS:
3500 *
3501 *NOTE:
3502 *
3503 * @param pMac Pointer to Global MAC structure
3504 * @param tSirMsgQ The MsgQ header, which contains the response buffer
3505 *
3506 * @return None
3507 */
3508void limProcessMlmRemoveKeyRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ )
3509{
Jeff Johnsone7245742012-09-05 17:12:55 -07003510 tANI_U8 respReqd = 1;
3511 tLimMlmRemoveKeyCnf mlmRemoveCnf;
3512 tANI_U16 resultCode;
3513 tANI_U8 sessionId = 0;
3514 tpPESession psessionEntry;
3515 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3516 palZeroMemory( pMac->hHdd, (void *) &mlmRemoveCnf, sizeof( tLimMlmRemoveKeyCnf ));
3517
3518 if( NULL == limMsgQ->bodyptr )
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003520 PELOGE(limLog(pMac, LOGE,FL("limMsgQ bodyptr is NULL\n"));)
3521 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 }
3523
Jeff Johnsone7245742012-09-05 17:12:55 -07003524 if (limMsgQ->type == WDA_REMOVE_STAKEY_RSP)
3525 sessionId = ((tpRemoveStaKeyParams) limMsgQ->bodyptr)->sessionId;
3526 else if (limMsgQ->type == WDA_REMOVE_BSSKEY_RSP)
3527 sessionId = ((tpRemoveBssKeyParams) limMsgQ->bodyptr)->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003528
Jeff Johnsone7245742012-09-05 17:12:55 -07003529 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003531 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId\n"));)
3532 return;
3533 }
3534
3535 if( eLIM_MLM_WT_REMOVE_BSS_KEY_STATE == psessionEntry->limMlmState )
3536 resultCode = (tANI_U16) (((tpRemoveBssKeyParams) limMsgQ->bodyptr)->status);
3537 else
3538 resultCode = (tANI_U16) (((tpRemoveStaKeyParams) limMsgQ->bodyptr)->status);
3539
3540 // Validate MLME state
3541 if( eLIM_MLM_WT_REMOVE_BSS_KEY_STATE != psessionEntry->limMlmState &&
3542 eLIM_MLM_WT_REMOVE_STA_KEY_STATE != psessionEntry->limMlmState )
3543 {
3544 // Mesg received from HAL in Invalid state!
3545 limLog(pMac, LOGW,
3546 FL("Received unexpected [Mesg Id - %d] in state %X\n"),
3547 limMsgQ->type,
3548 psessionEntry->limMlmState );
3549 respReqd = 0;
3550 }
3551 else
3552 mlmRemoveCnf.resultCode = resultCode;
3553
3554 //
3555 // TODO & FIXME_GEN4
3556 // Need to inspect tSirMsgQ.reserved for a valid Dialog token!
3557 //
3558
3559 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
3560
3561 // Restore MLME state
3562 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
3563 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
3564
3565 if( respReqd )
3566 {
3567 tpLimMlmRemoveKeyReq lpLimMlmRemoveKeyReq = (tpLimMlmRemoveKeyReq) pMac->lim.gpLimMlmRemoveKeyReq;
3568 mlmRemoveCnf.sessionId = sessionId;
3569
3570 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
3571 if( NULL != lpLimMlmRemoveKeyReq )
3572 {
3573 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmRemoveCnf.peerMacAddr, (tANI_U8 *) lpLimMlmRemoveKeyReq->peerMacAddr,
3574 sizeof( tSirMacAddr ));
3575 // Free the buffer cached for the global pMac->lim.gpLimMlmRemoveKeyReq
3576 palFreeMemory(pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmRemoveKeyReq);
3577 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
3578 }
3579 limPostSmeMessage( pMac, LIM_MLM_REMOVEKEY_CNF, (tANI_U32 *) &mlmRemoveCnf );
3580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003581}
3582
3583#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
3584/**----------------------------------------------------
3585\fn __limProcessFinishLearnRsp
3586\brief Handle finish learn rsp state, only for AP.
3587\param pMac
3588\return NONE
3589-----------------------------------------------------*/
3590static void __limProcessFinishLearnRsp(tpAniSirGlobal pMac)
3591{
3592 PELOG2(limLog(pMac, LOG2, FL("System Role: %d\n"), pMac->lim.gLimSystemRole);)
3593 if (pMac->lim.gpLimMeasReq == NULL)
3594 {
3595 limRestorePreLearnState(pMac);
3596 return;
3597 }
3598 /**
3599 * Initial measurement -> periodic measurement should keep enabled, so that
3600 * if system Role is UNKNOWN LIM can send indication to WSM. Overloading
3601 * periodic measurement to distinguish initial measurement and radar
3602 * detect park basically to avoid sending measurement indication after
3603 * radar detect park.
3604 * Radar detect park -> periodic measurement should be disabled, so that
3605 * LIM wont send indication even when role is UNKNOWN.
3606 * Final measurement -> periodic measurement should be enabled, so that
3607 * LIM could start measurement indication timer.
3608 */
3609 if (pMac->lim.gpLimMeasReq->measControl.periodicMeasEnabled &&
3610 !pMac->lim.gLimMeasParams.isMeasIndTimerActive)
3611 {
3612#if 0 /* Will we be ever in UNKNOWN ROLE: Veerendra */
3613 if (pMac->lim.gLimSystemRole == eLIM_UNKNOWN_ROLE)
3614 {
3615 limSendSmeMeasurementInd(pMac);
3616 limCleanupMeasResources(pMac);
3617 limRestorePreLearnState(pMac);
3618 return;
3619 }
3620 else
3621#endif
3622 {
3623#ifdef GEN6_TODO
3624 /* revisit this piece of code to assign the appropriate sessionId below
3625 * priority - MEDIUM
3626 */
3627 pMac->lim.gLimMeasParams.measurementIndTimer.sessionId = sessionId;
3628#endif
3629 // Activate periodic measurement indication timer
3630 if (tx_timer_activate(
3631 &pMac->lim.gLimMeasParams.measurementIndTimer)
3632 != TX_SUCCESS)
3633 {
3634 limLog(pMac, LOGP, FL("could not start Meas IND timer\n"));
3635 return;
3636 }
3637 pMac->lim.gLimMeasParams.isMeasIndTimerActive = 1;
3638 }
3639 }
3640 if (pMac->lim.gLimMeasParams.nextLearnChannelId >=
3641 pMac->lim.gpLimMeasReq->channelList.numChannels - 1)
3642 {
3643 // All channels in the channel set are learned.
3644 pMac->lim.gLimMeasParams.nextLearnChannelId = 0;
3645 }
3646 // Go back to previous state.
3647 limRestorePreLearnState(pMac);
3648 // Restart the learn interval timer.
3649 if (pMac->lim.gpLimMeasReq->measControl.periodicMeasEnabled)
3650 limReEnableLearnMode(pMac);
3651 return;
3652}
3653#endif
3654
3655/** ---------------------------------------------------------------------
3656\fn limProcessInitScanRsp
3657\brief This function is called when LIM receives WDA_INIT_SCAN_RSP
3658\ message from HAL. If status code is failure, then
3659\ update the gLimNumOfConsecutiveBkgndScanFailure count.
3660\param tpAniSirGlobal pMac
3661\param tANI_U32 body
3662\return none
3663\ ----------------------------------------------------------------------- */
3664void limProcessInitScanRsp(tpAniSirGlobal pMac, void *body)
3665{
3666 tpInitScanParams pInitScanParam;
3667 eHalStatus status;
3668#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
3669 tANI_U8 channelNum;
3670#endif
3671 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3672 pInitScanParam = (tpInitScanParams) body;
3673 status = pInitScanParam->status;
3674 palFreeMemory( pMac->hHdd, (char *)body);
3675
3676 //Only abort scan if the we are scanning.
3677 if( pMac->lim.abortScan &&
3678 (eLIM_HAL_INIT_SCAN_WAIT_STATE == pMac->lim.gLimHalScanState) )
3679 {
3680 limLog( pMac, LOGW, FL(" finish scan\n") );
3681 pMac->lim.abortScan = 0;
3682 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
3683 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
3684 //Set the resume channel to Any valid channel (invalid).
3685 //This will instruct HAL to set it to any previous valid channel.
3686 peSetResumeChannel(pMac, 0, 0);
3687 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
3688 }
3689 switch(pMac->lim.gLimHalScanState)
3690 {
3691 case eLIM_HAL_INIT_SCAN_WAIT_STATE:
3692 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
3693 {
3694 PELOGW(limLog(pMac, LOGW, FL("InitScanRsp with failed status= %d\n"), status);)
3695 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3696 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure += 1;
3697 /*
3698 * On Windows eSIR_SME_HAL_SCAN_INIT_FAILED message to CSR may trigger
3699 * another Scan request in the same context (happens when 11d is enabled
3700 * and first scan request with 11d channels fails for whatever reason, then CSR issues next init
3701 * scan in the same context but with bigger channel list), so the state needs to be
3702 * changed before this response message is sent.
3703 */
3704 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
3705#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
3706 /* For handling the measurement request from WSM as scan request in LIM*/
3707#if 0
3708 if (pMac->lim.gLimSystemRole == eLIM_STA_ROLE && pMac->lim.gpLimMeasReq != NULL)
3709 {
3710 limRestorePreLearnState(pMac);
3711 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3712 limReEnableLearnMode(pMac);
3713 }
3714#endif
3715#endif
3716 return;
3717 }
3718 else if (status == eHAL_STATUS_SUCCESS)
3719 {
3720 /* since we have successfully triggered a background scan,
3721 * reset the "consecutive bkgnd scan failure" count to 0
3722 */
3723 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure = 0;
3724 pMac->lim.gLimNumOfBackgroundScanSuccess += 1;
3725 }
3726 limContinueChannelScan(pMac);
3727 break;
3728#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
3729 case eLIM_HAL_INIT_LEARN_WAIT_STATE:
3730// if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
3731 {
3732 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
3733 {
3734 limRestorePreLearnState(pMac);
3735 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3736 limReEnableLearnMode(pMac);
3737 return;
3738 }
3739 channelNum = limGetCurrentLearnChannel(pMac);
3740 limSendHalStartScanReq(pMac, channelNum, eLIM_HAL_START_LEARN_WAIT_STATE);
3741 }
3742 break;
3743#endif
3744//WLAN_SUSPEND_LINK Related
3745 case eLIM_HAL_SUSPEND_LINK_WAIT_STATE:
3746 if( pMac->lim.gpLimSuspendCallback )
3747 {
3748 if( status == eHAL_STATUS_SUCCESS )
3749 pMac->lim.gLimHalScanState = eLIM_HAL_SUSPEND_LINK_STATE;
3750 else
3751 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
3752
3753 pMac->lim.gpLimSuspendCallback( pMac, status, pMac->lim.gpLimSuspendData );
3754 pMac->lim.gpLimSuspendCallback = NULL;
3755 pMac->lim.gpLimSuspendData = NULL;
3756 }
3757 else
3758 {
3759 limLog( pMac, LOGP, "No suspend link callback set but station is in suspend state\n");
3760 return;
3761 }
3762 break;
3763//end WLAN_SUSPEND_LINK Related
3764 default:
3765 limLog(pMac, LOGW, FL("limProcessInitScanRsp: Rcvd InitScanRsp not in WAIT State, state %d\n"),
3766 pMac->lim.gLimHalScanState);
3767 break;
3768 }
3769 return;
3770}
3771/**
3772 * limProcessSwitchChannelReAssocReq()
3773 *
3774 *FUNCTION:
3775 * This function is called to send the reassoc req mgmt frame after the
3776 * switchChannelRsp message is received from HAL.
3777 *
3778 *LOGIC:
3779 *
3780 *ASSUMPTIONS:
3781 * NA
3782 *
3783 *NOTE:
3784 * NA
3785 *
3786 * @param pMac - Pointer to Global MAC structure.
3787 * @param psessionEntry - session related information.
3788 * @param status - channel switch success/failure.
3789 *
3790 * @return None
3791 */
3792static void limProcessSwitchChannelReAssocReq(tpAniSirGlobal pMac, tpPESession psessionEntry, eHalStatus status)
3793{
3794 tLimMlmReassocCnf mlmReassocCnf;
3795 tLimMlmReassocReq *pMlmReassocReq;
3796 pMlmReassocReq = (tLimMlmReassocReq *)(psessionEntry->pLimMlmReassocReq);
3797 if(pMlmReassocReq == NULL)
3798 {
3799 limLog(pMac, LOGP, FL("pLimMlmReassocReq does not exist for given switchChanSession\n"));
3800 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3801 goto end;
3802 }
3803
3804 if(status != eHAL_STATUS_SUCCESS)
3805 {
3806 PELOGE(limLog(pMac, LOGE, FL("Change channel failed!!\n"));)
3807 mlmReassocCnf.resultCode = eSIR_SME_CHANNEL_SWITCH_FAIL;
3808 goto end;
3809 }
3810 /// Start reassociation failure timer
Jeff Johnsone7245742012-09-05 17:12:55 -07003811 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3813 != TX_SUCCESS)
3814 {
3815 /// Could not start reassoc failure timer.
3816 // Log error
3817 limLog(pMac, LOGP,
3818 FL("could not start Reassociation failure timer\n"));
3819 // Return Reassoc confirm with
3820 // Resources Unavailable
3821 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3822 goto end;
3823 }
3824 /// Prepare and send Reassociation request frame
3825 limSendReassocReqMgmtFrame(pMac, pMlmReassocReq, psessionEntry);
3826 return;
3827end:
3828 // Free up buffer allocated for reassocReq
3829 if(pMlmReassocReq != NULL)
3830 {
3831 /* Update PE session Id*/
3832 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
3833 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
3834 }
3835 else
3836 {
3837 mlmReassocCnf.sessionId = 0;
3838 }
3839
3840 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3841 /* Update PE sessio Id*/
3842 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3843
3844 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3845}
3846/**
3847 * limProcessSwitchChannelJoinReq()
3848 *
3849 *FUNCTION:
3850 * This function is called to send the probe req mgmt frame after the
3851 * switchChannelRsp message is received from HAL.
3852 *
3853 *LOGIC:
3854 *
3855 *ASSUMPTIONS:
3856 * NA
3857 *
3858 *NOTE:
3859 * NA
3860 *
3861 * @param pMac - Pointer to Global MAC structure.
3862 * @param psessionEntry - session related information.
3863 * @param status - channel switch success/failure.
3864 *
3865 * @return None
3866 */
3867static void limProcessSwitchChannelJoinReq(tpAniSirGlobal pMac, tpPESession psessionEntry, eHalStatus status)
3868{
3869 tANI_U32 val;
3870 tSirMacSSid ssId;
3871 tLimMlmJoinCnf mlmJoinCnf;
3872 if(status != eHAL_STATUS_SUCCESS)
3873 {
3874 PELOGE(limLog(pMac, LOGE, FL("Change channel failed!!\n"));)
3875 goto error;
3876 }
3877
3878 if ( (NULL == psessionEntry ) || (NULL == psessionEntry->pLimMlmJoinReq) )
3879 {
3880 PELOGE(limLog(pMac, LOGE, FL("invalid pointer!!\n"));)
3881 goto error;
3882 }
3883
Jeff Johnsone7245742012-09-05 17:12:55 -07003884
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 /* eSIR_BTAMP_AP_MODE stroed as bss type in session Table when join req is received, is to be veified */
3886 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3887 {
3888 if (limSetLinkState(pMac, eSIR_LINK_BTAMP_PREASSOC_STATE, psessionEntry->bssId,
3889 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
3890 goto error;
3891 }
3892 else
3893 {
3894 if(limSetLinkState(pMac, eSIR_LINK_PREASSOC_STATE, psessionEntry->bssId,
3895 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
3896 goto error;
3897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898
3899 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
3900 if(wlan_cfgGetInt(pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val) != eSIR_SUCCESS)
3901 limLog(pMac, LOGP, FL("failed to get WNI_CFG_TRIG_STA_BK_SCAN cfg value!\n"));
3902 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
3903 // Apply previously set configuration at HW
3904 limApplyConfiguration(pMac, psessionEntry);
3905 /// Wait for Beacon to announce join success
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 palCopyMemory( pMac->hHdd, ssId.ssId,
3907 psessionEntry->ssId.ssId,
3908 psessionEntry->ssId.length);
3909 ssId.length = psessionEntry->ssId.length;
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003910
3911 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3912
3913 //assign appropriate sessionId to the timer object
3914 pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId = psessionEntry->peSessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 // include additional IE if there is
3916 limSendProbeReqMgmtFrame( pMac, &ssId,
3917 psessionEntry->pLimMlmJoinReq->bssDescription.bssId, psessionEntry->currentOperChannel/*chanNum*/,
3918 psessionEntry->selfMacAddr, psessionEntry->dot11mode,
3919 psessionEntry->pLimJoinReq->addIEScan.length, psessionEntry->pLimJoinReq->addIEScan.addIEdata);
Jeff Johnsone7245742012-09-05 17:12:55 -07003920
3921 // Sending mgmt frame is a blocking call activate Join failure timer now
3922 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_JOIN_FAIL_TIMER));
3923 if (tx_timer_activate(&pMac->lim.limTimers.gLimJoinFailureTimer) != TX_SUCCESS)
3924 {
3925 limLog(pMac, LOGP, FL("could not activate Join failure timer\n"));
3926 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
3927 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, pMac->lim.gLimMlmState));
3928 //memory is freed up below.
3929 psessionEntry->pLimMlmJoinReq = NULL;
3930 goto error;
3931 }
3932
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003933#ifdef WLAN_FEATURE_P2P
3934 if( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE )
3935 {
Yathish9f22e662012-12-10 14:21:35 -08003936 // Activate Join Periodic Probe Req timer
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003937 if (tx_timer_activate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != TX_SUCCESS)
3938 {
3939 limLog(pMac, LOGP, FL("could not activate Periodic Join req failure timer\n"));
3940 goto error;
3941 }
3942 }
3943#endif
3944
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 return;
3946error:
3947 if(NULL != psessionEntry)
3948 {
3949 palFreeMemory( pMac->hHdd, (tANI_U8 *) (psessionEntry->pLimMlmJoinReq));
3950 psessionEntry->pLimMlmJoinReq = NULL;
3951 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3952 }
3953 else
3954 {
3955 mlmJoinCnf.sessionId = 0;
3956 }
3957 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3958 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3959 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3960}
3961
3962/**
3963 * limProcessSwitchChannelRsp()
3964 *
3965 *FUNCTION:
3966 * This function is called to process switchChannelRsp message from HAL.
3967 *
3968 *LOGIC:
3969 *
3970 *ASSUMPTIONS:
3971 * NA
3972 *
3973 *NOTE:
3974 * NA
3975 *
3976 * @param pMac - Pointer to Global MAC structure
3977 * @param body - message body.
3978 *
3979 * @return None
3980 */
3981void limProcessSwitchChannelRsp(tpAniSirGlobal pMac, void *body)
3982{
3983 tpSwitchChannelParams pChnlParams = NULL;
3984 eHalStatus status;
3985 tANI_U16 channelChangeReasonCode;
3986 tANI_U8 peSessionId;
3987 tpPESession psessionEntry;
3988 //we need to process the deferred message since the initiating req. there might be nested request.
3989 //in the case of nested request the new request initiated from the response will take care of resetting
3990 //the deffered flag.
3991 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3992 pChnlParams = (tpSwitchChannelParams) body;
3993 status = pChnlParams->status;
3994 peSessionId = pChnlParams->peSessionId;
3995 if((psessionEntry = peFindSessionBySessionId(pMac, peSessionId))== NULL)
3996 {
3997 palFreeMemory( pMac->hHdd, (tANI_U8 *)body);
3998 limLog(pMac, LOGP, FL("session does not exist for given sessionId\n"));
3999 return;
4000 }
4001#if defined WLAN_FEATURE_VOWIFI
4002 //HAL fills in the tx power used for mgmt frames in this field.
4003 //Store this value to use in TPC report IE.
4004 rrmCacheMgmtTxPower( pMac, pChnlParams->txMgmtPower, psessionEntry );
4005#endif
4006 palFreeMemory( pMac->hHdd, (tANI_U8 *)body);
4007 channelChangeReasonCode = psessionEntry->channelChangeReasonCode;
4008 // initialize it back to invalid id
4009 psessionEntry->channelChangeReasonCode = 0xBAD;
4010 switch(channelChangeReasonCode)
4011 {
4012 case LIM_SWITCH_CHANNEL_REASSOC:
4013 limProcessSwitchChannelReAssocReq(pMac, psessionEntry, status);
4014 break;
4015 case LIM_SWITCH_CHANNEL_JOIN:
4016 limProcessSwitchChannelJoinReq(pMac, psessionEntry, status);
4017 break;
4018
4019 case LIM_SWITCH_CHANNEL_OPERATION:
4020 /*
4021 * The above code should also use the callback.
4022 * mechanism below, there is scope for cleanup here.
4023 * THat way all this response handler does is call the call back
4024 * We can get rid of the reason code here.
4025 */
4026 if (pMac->lim.gpchangeChannelCallback)
4027 {
4028 PELOG1(limLog( pMac, LOG1, "Channel changed hence invoke registered call back\n");)
4029 pMac->lim.gpchangeChannelCallback(pMac, status, pMac->lim.gpchangeChannelData, psessionEntry);
4030 }
4031 break;
4032 default:
4033 break;
4034 }
4035}
4036/**
4037 * limProcessStartScanRsp()
4038 *
4039 *FUNCTION:
4040 * This function is called to process startScanRsp message from HAL. If scan/learn was successful
4041 * then it will start scan/learn on the next channel.
4042 *
4043 *LOGIC:
4044 *
4045 *ASSUMPTIONS:
4046 * NA
4047 *
4048 *NOTE:
4049 * NA
4050 *
4051 * @param pMac - Pointer to Global MAC structure
4052 * @param body - message body.
4053 *
4054 * @return None
4055 */
4056
4057void limProcessStartScanRsp(tpAniSirGlobal pMac, void *body)
4058{
4059 tpStartScanParams pStartScanParam;
4060 eHalStatus status;
4061 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
4062 pStartScanParam = (tpStartScanParams) body;
4063 status = pStartScanParam->status;
4064#if defined WLAN_FEATURE_VOWIFI
4065 //HAL fills in the tx power used for mgmt frames in this field.
4066 //Store this value to use in TPC report IE.
4067 rrmCacheMgmtTxPower( pMac, pStartScanParam->txMgmtPower, NULL );
4068 //Store start TSF of scan start. This will be stored in BSS params.
4069 rrmUpdateStartTSF( pMac, pStartScanParam->startTSF );
4070#endif
4071 palFreeMemory( pMac->hHdd, (tANI_U8 *)body);
4072 if( pMac->lim.abortScan )
4073 {
4074 limLog( pMac, LOGW, FL(" finish scan\n") );
4075 pMac->lim.abortScan = 0;
4076 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
4077 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
4078 //Set the resume channel to Any valid channel (invalid).
4079 //This will instruct HAL to set it to any previous valid channel.
4080 peSetResumeChannel(pMac, 0, 0);
4081 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
4082 }
4083 switch(pMac->lim.gLimHalScanState)
4084 {
4085 case eLIM_HAL_START_SCAN_WAIT_STATE:
4086 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
4087 {
4088 PELOGW(limLog(pMac, LOGW, FL("StartScanRsp with failed status= %d\n"), status);)
4089 //
4090 // FIXME - With this, LIM will try and recover state, but
4091 // eWNI_SME_SCAN_CNF maybe reporting an incorrect
4092 // status back to the SME
4093 //
4094 //Set the resume channel to Any valid channel (invalid).
4095 //This will instruct HAL to set it to any previous valid channel.
4096 peSetResumeChannel(pMac, 0, 0);
4097 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
4098 //limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
4099 }
4100 else
4101 {
4102 pMac->lim.gLimHalScanState = eLIM_HAL_SCANNING_STATE;
4103 limContinuePostChannelScan(pMac);
4104 }
4105 break;
4106#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
4107 case eLIM_HAL_START_LEARN_WAIT_STATE:
4108 // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
4109 {
4110 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
4111 {
4112 //Set the resume channel to Any valid channel (invalid).
4113 //This will instruct HAL to set it to any previous valid channel.
4114 peSetResumeChannel(pMac, 0, 0);
4115 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
4116 }
4117 else
4118 {
4119 limContinueChannelLearn(pMac);
4120 }
4121 }
4122 break;
4123#endif
4124 default:
4125 limLog(pMac, LOGW, FL("Rcvd StartScanRsp not in WAIT State, state %d\n"),
4126 pMac->lim.gLimHalScanState);
4127 break;
4128 }
4129 return;
4130}
4131void limProcessEndScanRsp(tpAniSirGlobal pMac, void *body)
4132{
4133 tpEndScanParams pEndScanParam;
4134 eHalStatus status;
4135#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
4136 tANI_U8 channelNum;
4137#endif
4138 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
4139 pEndScanParam = (tpEndScanParams) body;
4140 status = pEndScanParam->status;
4141 palFreeMemory( pMac->hHdd, (char *)body);
4142 switch(pMac->lim.gLimHalScanState)
4143 {
4144 case eLIM_HAL_END_SCAN_WAIT_STATE:
4145 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
4146 {
4147 PELOGW(limLog(pMac, LOGW, FL("EndScanRsp with failed status= %d\n"), status);)
4148 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
4149 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
4150 }
4151 else
4152 {
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08004153 pMac->lim.gLimCurrentScanChannelId++;
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 limContinueChannelScan(pMac);
4155 }
4156 break;
4157#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
4158 case eLIM_HAL_END_LEARN_WAIT_STATE:
4159 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
4160 {
4161 //Set the resume channel to Any valid channel (invalid).
4162 //This will instruct HAL to set it to any previous valid channel.
4163 peSetResumeChannel(pMac, 0, 0);
4164 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
4165 }
4166#if 0 /* Will we be in UNKNOWN ROLE ever in this context: Veerendra */
4167 else if (pMac->lim.gLimSystemRole == eLIM_UNKNOWN_ROLE)
4168 {
4169 /** Before starting BSS, we do complete set of measurement before putting
4170 * softmac back into normal mode.
4171 */
4172 channelNum = limGetCurrentLearnChannel(pMac);
4173 limSendHalStartScanReq(pMac, channelNum, eLIM_HAL_START_LEARN_WAIT_STATE);
4174 }
4175 else
4176#endif
4177 {
4178 limLog(pMac, LOGW, FL("ERROR! This state is set only when AP in UNKNOWN_ROLE\n"),
4179 pMac->lim.gLimHalScanState);
4180 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
4181 }
4182 break;
4183#endif
4184 default:
4185 limLog(pMac, LOGW, FL("Rcvd endScanRsp not in WAIT State, state %d\n"),
4186 pMac->lim.gLimHalScanState);
4187 break;
4188 }
4189 return;
4190}
Jeff Johnsone7245742012-09-05 17:12:55 -07004191/**
4192 * limStopTxAndSwitch()
4193 *
4194 *FUNCTION:
4195 * Start channel switch on all sessions that is in channel switch state.
4196 *
4197 * @param pMac - pointer to global adapter context
4198 *
4199 * @return None
4200 *
4201 */
4202static void
4203limStopTxAndSwitch (tpAniSirGlobal pMac)
4204{
4205 tANI_U8 i;
4206
4207 for(i =0; i < pMac->lim.maxBssId; i++)
4208 {
4209 if(pMac->lim.gpSession[i].valid &&
4210 pMac->lim.gpSession[i].gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING)
4211 {
4212 limStopTxAndSwitchChannel(pMac, i);
4213 }
4214 }
4215 return;
4216}
4217/**
4218 * limStartQuietOnSession()
4219 *
4220 *FUNCTION:
4221 * This function is called to start quiet timer after finish scan if there is
4222 * qeuieting on any session.
4223 *
4224 *LOGIC:
4225 *
4226 *ASSUMPTIONS:
4227 * NA
4228 *
4229 *NOTE:
4230 * NA
4231 *
4232 * @param pMac - Pointer to Global MAC structure
4233 *
4234 * @return None
4235 */
4236static void
4237limStartQuietOnSession (tpAniSirGlobal pMac)
4238{
4239 tANI_U8 i;
4240
4241 for(i =0; i < pMac->lim.maxBssId; i++)
4242 {
4243 if(pMac->lim.gpSession[i].valid &&
4244 pMac->lim.gpSession[i].gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
4245 {
4246 limStartQuietTimer(pMac, i);
4247 }
4248 }
4249 return;
4250}
Jeff Johnson295189b2012-06-20 16:38:30 -07004251void limProcessFinishScanRsp(tpAniSirGlobal pMac, void *body)
4252{
4253 tpFinishScanParams pFinishScanParam;
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 eHalStatus status;
4255 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
4256 pFinishScanParam = (tpFinishScanParams) body;
4257 status = pFinishScanParam->status;
4258 palFreeMemory( pMac->hHdd, (char *)body);
4259 switch(pMac->lim.gLimHalScanState)
4260 {
4261 case eLIM_HAL_FINISH_SCAN_WAIT_STATE:
4262 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
4263 limCompleteMlmScan(pMac, eSIR_SME_SUCCESS);
Jeff Johnsone7245742012-09-05 17:12:55 -07004264 if (limIsChanSwitchRunning(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 {
4266 /** Right time to stop tx and start the timer for channel switch */
4267 /* Sending Session ID 0, may not be correct, since SCAN is global there should not
4268 * be any associated session id
4269 */
Jeff Johnsone7245742012-09-05 17:12:55 -07004270 limStopTxAndSwitch(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004272 else if (limIsQuietBegin(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 {
4274 /** Start the quieting */
4275 /* Sending Session ID 0, may not be correct, since SCAN is global there should not
4276 * be any associated session id
4277 */
Jeff Johnsone7245742012-09-05 17:12:55 -07004278 limStartQuietOnSession(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 }
4280#ifdef ANI_PRODUCT_TYPE_AP
4281 /* For handling the measurement request from WSM as scan request in LIM*/
4282#if 0
4283 if (pMac->lim.gLimSystemRole == eLIM_STA_ROLE && pMac->lim.gpLimMeasReq != NULL)
4284 {
4285 limSendSmeMeasurementInd(pMac);
4286 limCleanupMeasResources(pMac);
4287 limRestorePreLearnState(pMac);
4288 }
4289#endif
4290#endif
4291 if (status != (tANI_U32) eHAL_STATUS_SUCCESS)
4292 {
4293 PELOGW(limLog(pMac, LOGW, FL("EndScanRsp with failed status= %d\n"), status);)
4294 }
4295 break;
4296#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4297 case eLIM_HAL_FINISH_LEARN_WAIT_STATE:
4298 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
4299 __limProcessFinishLearnRsp(pMac);
4300 break;
4301#endif //#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4302//WLAN_SUSPEND_LINK Related
4303 case eLIM_HAL_RESUME_LINK_WAIT_STATE:
4304 if( pMac->lim.gpLimResumeCallback )
4305 {
4306 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
4307 pMac->lim.gpLimResumeCallback( pMac, status, pMac->lim.gpLimResumeData );
4308 pMac->lim.gpLimResumeCallback = NULL;
4309 pMac->lim.gpLimResumeData = NULL;
4310 pMac->lim.gLimSystemInScanLearnMode = 0;
4311 }
4312 else
4313 {
4314 limLog( pMac, LOGP, "No Resume link callback set but station is in suspend state\n");
4315 return;
4316 }
4317 break;
4318//end WLAN_SUSPEND_LINK Related
4319
4320 default:
4321 limLog(pMac, LOGW, FL("Rcvd FinishScanRsp not in WAIT State, state %d\n"),
4322 pMac->lim.gLimHalScanState);
4323 break;
4324 }
4325 return;
4326}
4327/**
4328 * @function : limProcessMlmHalAddBARsp
4329 *
4330 * @brief: Process WDA_ADDBA_RSP coming from HAL
4331 *
4332 *
4333 * @param pMac The global tpAniSirGlobal object
4334 *
4335 * @param tSirMsgQ The MsgQ header containing the response buffer
4336 *
4337 * @return none
4338 */
4339void limProcessMlmHalAddBARsp( tpAniSirGlobal pMac,
4340 tpSirMsgQ limMsgQ )
4341{
4342 // Send LIM_MLM_ADDBA_CNF to LIM
4343 tpLimMlmAddBACnf pMlmAddBACnf;
4344 tpPESession psessionEntry;
4345 tpAddBAParams pAddBAParams = (tpAddBAParams) limMsgQ->bodyptr;
4346#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4347 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_RSP_EVENT, psessionEntry, 0, 0);
4348#endif //FEATURE_WLAN_DIAG_SUPPORT
4349 //now LIM can process any defer message.
4350 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
4351 if (pAddBAParams == NULL) {
4352 PELOGE(limLog(pMac, LOGE,FL("NULL ADD BA Response from HAL\n"));)
4353 return;
4354 }
4355 if((psessionEntry = peFindSessionBySessionId(pMac, pAddBAParams->sessionId))==NULL)
4356 {
4357 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionID: %d\n"),pAddBAParams->sessionId );)
4358 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
4359 return;
4360 }
4361#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4362 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_RSP_EVENT, psessionEntry, 0, 0);
4363#endif //FEATURE_WLAN_DIAG_SUPPORT
4364
4365 // Allocate for LIM_MLM_ADDBA_CNF
4366 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4367 (void **) &pMlmAddBACnf, sizeof( tLimMlmAddBACnf ))) {
4368 limLog( pMac, LOGP, FL(" palAllocateMemory failed with error code %d\n"));
4369 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
4370 return;
4371 }
4372 palZeroMemory( pMac->hHdd, (void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ));
4373 // Copy the peer MAC
4374 palCopyMemory( pMac->hHdd, pMlmAddBACnf->peerMacAddr, pAddBAParams->peerMacAddr,
4375 sizeof( tSirMacAddr ));
4376 // Copy other ADDBA Rsp parameters
4377 pMlmAddBACnf->baDialogToken = pAddBAParams->baDialogToken;
4378 pMlmAddBACnf->baTID = pAddBAParams->baTID;
4379 pMlmAddBACnf->baPolicy = pAddBAParams->baPolicy;
4380 pMlmAddBACnf->baBufferSize = pAddBAParams->baBufferSize;
4381 pMlmAddBACnf->baTimeout = pAddBAParams->baTimeout;
4382 pMlmAddBACnf->baDirection = pAddBAParams->baDirection;
4383 pMlmAddBACnf->sessionId = psessionEntry->peSessionId;
4384 if(eHAL_STATUS_SUCCESS == pAddBAParams->status)
4385 pMlmAddBACnf->addBAResultCode = eSIR_MAC_SUCCESS_STATUS;
4386 else
4387 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4388 palFreeMemory(pMac->hHdd, (void*)limMsgQ->bodyptr);
4389 // Send ADDBA CNF to LIM
4390 limPostSmeMessage( pMac, LIM_MLM_ADDBA_CNF, (tANI_U32 *) pMlmAddBACnf );
4391}
4392/**
4393 * \brief Process LIM_MLM_ADDBA_CNF
4394 *
4395 * \sa limProcessMlmAddBACnf
4396 *
4397 * \param pMac The global tpAniSirGlobal object
4398 *
4399 * \param tSirMsgQ The MsgQ header containing the response buffer
4400 *
4401 * \return none
4402 */
4403void limProcessMlmAddBACnf( tpAniSirGlobal pMac,
4404 tANI_U32 *pMsgBuf )
4405{
4406tpLimMlmAddBACnf pMlmAddBACnf;
4407tpDphHashNode pSta;
4408tANI_U16 aid;
4409tLimBAState curBaState;
4410tpPESession psessionEntry = NULL;
4411if(pMsgBuf == NULL)
4412{
4413 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
4414 return;
4415}
4416pMlmAddBACnf = (tpLimMlmAddBACnf) pMsgBuf;
4417 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBACnf->sessionId))== NULL)
4418 {
4419 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004420 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 return;
4422 }
4423 // First, extract the DPH entry
4424 pSta = dphLookupHashEntry( pMac, pMlmAddBACnf->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4425 if( NULL == pSta )
4426 {
4427 PELOGE(limLog( pMac, LOGE,
4428 FL( "STA context not found - ignoring ADDBA CNF from HAL\n" ));)
4429 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
4430 return;
4431 }
4432 LIM_GET_STA_BA_STATE(pSta, pMlmAddBACnf->baTID, &curBaState);
4433 // Need to validate SME state
4434 if( eLIM_BA_STATE_WT_ADD_RSP != curBaState)
4435 {
4436 PELOGE(limLog( pMac, LOGE,
4437 FL( "Received unexpected ADDBA CNF when STA BA state is %d\n" ),
4438 curBaState );)
Jeff Johnsone7245742012-09-05 17:12:55 -07004439 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 return;
4441 }
4442 // Restore STA BA state
4443 LIM_SET_STA_BA_STATE(pSta, pMlmAddBACnf->baTID, eLIM_BA_STATE_IDLE);
Jeff Johnson43971f52012-07-17 12:26:56 -07004444 if( eSIR_MAC_SUCCESS_STATUS == pMlmAddBACnf->addBAResultCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 {
4446 // Update LIM internal cache...
4447 if( eBA_RECIPIENT == pMlmAddBACnf->baDirection )
4448 {
4449 pSta->tcCfg[pMlmAddBACnf->baTID].fUseBARx = 1;
4450 pSta->tcCfg[pMlmAddBACnf->baTID].fRxCompBA = 1;
4451 pSta->tcCfg[pMlmAddBACnf->baTID].fRxBApolicy = pMlmAddBACnf->baPolicy;
4452 pSta->tcCfg[pMlmAddBACnf->baTID].rxBufSize = pMlmAddBACnf->baBufferSize;
4453 pSta->tcCfg[pMlmAddBACnf->baTID].tuRxBAWaitTimeout = pMlmAddBACnf->baTimeout;
4454 }
4455 else
4456 {
4457 pSta->tcCfg[pMlmAddBACnf->baTID].fUseBATx = 1;
4458 pSta->tcCfg[pMlmAddBACnf->baTID].fTxCompBA = 1;
4459 pSta->tcCfg[pMlmAddBACnf->baTID].fTxBApolicy = pMlmAddBACnf->baPolicy;
4460 pSta->tcCfg[pMlmAddBACnf->baTID].txBufSize = pMlmAddBACnf->baBufferSize;
4461 pSta->tcCfg[pMlmAddBACnf->baTID].tuTxBAWaitTimeout = pMlmAddBACnf->baTimeout;
4462 }
4463 }
4464 if( eBA_RECIPIENT == pMlmAddBACnf->baDirection )
4465 {
4466 //
4467 // Package LIM_MLM_ADDBA_RSP to MLME, with proper
4468 // status code. MLME will then send an ADDBA RSP
4469 // over the air to the peer MAC entity
4470 //
4471 if( eSIR_SUCCESS != limPostMlmAddBARsp( pMac,
4472 pMlmAddBACnf->peerMacAddr,
4473 pMlmAddBACnf->addBAResultCode,
4474 pMlmAddBACnf->baDialogToken,
4475 (tANI_U8) pMlmAddBACnf->baTID,
4476 (tANI_U8) pMlmAddBACnf->baPolicy,
4477 pMlmAddBACnf->baBufferSize,
4478 pMlmAddBACnf->baTimeout,psessionEntry))
4479 {
4480 PELOGW(limLog( pMac, LOGW,
4481 FL( "Failed to post LIM_MLM_ADDBA_RSP to " ));
4482 limPrintMacAddr( pMac, pMlmAddBACnf->peerMacAddr, LOGW );)
4483 }
4484 }
4485 // Free the memory allocated for LIM_MLM_ADDBA_CNF
4486 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
4487}
4488/**
4489 * \brief Process LIM_MLM_DELBA_CNF
4490 *
4491 * \sa limProcessMlmDelBACnf
4492 *
4493 * \param pMac The global tpAniSirGlobal object
4494 *
4495 * \param tSirMsgQ The MsgQ header containing the response buffer
4496 *
4497 * \return none
4498 */
4499void limProcessMlmDelBACnf( tpAniSirGlobal pMac,
4500 tANI_U32 *pMsgBuf )
4501{
4502 tpLimMlmDelBACnf pMlmDelBACnf;
4503 tpDphHashNode pSta;
4504 tANI_U16 aid;
4505// tANI_U8 sessionId;
4506 tLimBAState curBaState;
4507 tpPESession psessionEntry;
4508
4509 if(pMsgBuf == NULL)
4510 {
4511 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
4512 return;
4513 }
4514 pMlmDelBACnf = (tpLimMlmDelBACnf) pMsgBuf;
4515 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDelBACnf->sessionId))== NULL)
4516 {
4517 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07004518 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 return;
4520 }
4521 // First, extract the DPH entry
4522 pSta = dphLookupHashEntry( pMac, pMlmDelBACnf->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4523 if( NULL == pSta )
4524 {
4525 limLog( pMac, LOGE,
4526 FL( "STA context not found - ignoring DELBA CNF from HAL\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07004527 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 return;
4529 }
4530 if(NULL == pMlmDelBACnf)
4531 {
4532 limLog( pMac, LOGE,
4533 FL( "pMlmDelBACnf is NULL - ignoring DELBA CNF from HAL\n" ));
4534 return;
4535 }
4536 // Need to validate baState
4537 LIM_GET_STA_BA_STATE(pSta, pMlmDelBACnf->baTID, &curBaState);
4538 if( eLIM_BA_STATE_WT_DEL_RSP != curBaState )
4539 {
4540 limLog( pMac, LOGE,
4541 FL( "Received unexpected DELBA CNF when STA BA state is %d\n" ),
4542 curBaState );
Jeff Johnsone7245742012-09-05 17:12:55 -07004543 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 return;
4545 }
4546 // Restore STA BA state
4547 LIM_SET_STA_BA_STATE(pSta, pMlmDelBACnf->baTID, eLIM_BA_STATE_IDLE);
4548 // Free the memory allocated for LIM_MLM_DELBA_CNF
4549 palFreeMemory( pMac->hHdd, (void *) pMsgBuf );
4550}
4551/**
4552 * \brief Process SIR_LIM_DEL_BA_IND
4553 *
4554 * \sa limProcessMlmHalBADeleteInd
4555 *
4556 * \param pMac The global tpAniSirGlobal object
4557 *
4558 * \param tSirMsgQ The MsgQ header containing the indication buffer
4559 *
4560 * \return none
4561 */
4562void limProcessMlmHalBADeleteInd( tpAniSirGlobal pMac,
4563 tpSirMsgQ limMsgQ )
4564{
4565 tSirRetStatus status = eSIR_SUCCESS;
4566 tpBADeleteParams pBADeleteParams;
4567 tpDphHashNode pSta;
4568 tANI_U16 aid;
4569 tLimBAState curBaState;
4570 tpPESession psessionEntry;
4571 tANI_U8 sessionId;
4572
4573 pBADeleteParams = (tpBADeleteParams) limMsgQ->bodyptr;
4574
4575 if((psessionEntry = peFindSessionByBssid(pMac,pBADeleteParams->bssId,&sessionId))== NULL)
4576 {
4577 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004578 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 return;
4580 }
4581 // First, extract the DPH entry
4582 pSta = dphLookupHashEntry( pMac, pBADeleteParams->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
4583 if( NULL == pSta )
4584 {
4585 limLog( pMac, LOGE,
4586 FL( "STA context not found - ignoring BA Delete IND from HAL\n" ));
4587 goto returnAfterCleanup;
4588 }
4589
4590 // Need to validate BA state
4591 LIM_GET_STA_BA_STATE(pSta, pBADeleteParams->baTID, &curBaState);
4592 if( eLIM_BA_STATE_IDLE != curBaState )
4593 {
4594 limLog( pMac, LOGE,
4595 FL( "Received unexpected BA Delete IND when STA BA state is %d\n" ),
4596 curBaState );
4597 goto returnAfterCleanup;
4598 }
4599
4600 // Validate if a BA is active for the requested TID
4601 // AND in that desired direction
4602 if( eBA_INITIATOR == pBADeleteParams->baDirection )
4603 {
4604 if( 0 == pSta->tcCfg[pBADeleteParams->baTID].fUseBATx )
4605 status = eSIR_FAILURE;
4606 }
4607 else
4608 {
4609 if( 0 == pSta->tcCfg[pBADeleteParams->baTID].fUseBARx )
4610 status = eSIR_FAILURE;
4611 }
4612 if( eSIR_FAILURE == status )
4613 {
4614 limLog( pMac, LOGW,
4615 FL("Received an INVALID DELBA Delete Ind for TID %d...\n"),
4616 pBADeleteParams->baTID );
4617 }
4618 else
4619 {
4620 // Post DELBA REQ to MLME...
4621 if( eSIR_SUCCESS !=
4622 (status = limPostMlmDelBAReq( pMac,
4623 pSta,
4624 pBADeleteParams->baDirection,
4625 pBADeleteParams->baTID,
4626 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry )))
4627 {
4628 limLog( pMac, LOGE,
4629 FL( "Attempt to post LIM_MLM_DELBA_REQ failed with status %d\n" ), status);
4630 }
4631 else
4632 {
4633 limLog( pMac, LOGE,
4634 FL( "BA Delete - Reason 0x%08x. Attempting to delete BA session for TID %d with peer STA " ),
4635 pBADeleteParams->reasonCode, pBADeleteParams->baTID );
4636 limPrintMacAddr( pMac, pSta->staAddr, LOGE );
4637 }
4638 }
4639returnAfterCleanup:
4640 // Free the memory allocated for SIR_LIM_DEL_BA_IND
4641 palFreeMemory( pMac->hHdd, (void *) limMsgQ->bodyptr );
4642}
4643/**
4644 * @function : limProcessSetMimoRsp()
4645 *
4646 * @brief : This function is called upon receiving the WDA_SET_MIMOPS_RSP from the HAL
4647 * after Processing the Req from the SME (PMC)
4648 *
4649 * LOGIC:
4650 *
4651 * ASSUMPTIONS:
4652 * NA
4653 *
4654 * NOTE:
4655 * NA
4656 *
4657 * @param pMac - Pointer to Global MAC structure
4658 * @param limMsg - Lim Message structure object with the MimoPSparam in body
4659 * @return None
4660 */
4661
4662void
4663limProcessSetMimoRsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
4664{
4665#if 0
4666 tSirRetStatus retStatus;
4667 tpSetMIMOPS pMIMO_PSParams;
4668
4669
4670 do {
4671
4672 pMIMO_PSParams = (tpSetMIMOPS)limMsg->bodyptr;
4673 if( NULL == pMIMO_PSParams ) {
4674 PELOGE(limLog(pMac, LOGE, "Received the WDA_SET_MIMOPS_RSP with NULL as the PS param");)
4675 return;
4676 }
4677
4678 /** If Updation of the HAL Fail's*/
4679 if (pMIMO_PSParams->status != eSIR_SUCCESS) {
4680 limLog(pMac, LOGP, FL("Update HAL / SW Mac for MIMO State has Failed\n"));
4681 break;
4682 }
4683
4684 if ((pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) ||
4685 (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) )
4686 break;
4687
4688 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
4689 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
4690
4691 /** In the Case of Exiting out of the Powersave (changing from Dynamic/Static mode to SM Enabled)
4692 * send the action Frame to Peer to update the PS State of the STA , for the case of Entering PowerSave
4693 * the Action Frame is being sent at first before setting the internal structures
4694 */
4695 if (!isEnteringMimoPS(pMac->lim.gHTMIMOPSState, pMIMO_PSParams->htMIMOPSState)) {
4696 tSirMacAddr macAddr;
4697
4698 /** Obtain the AP's Mac Address */
4699 palCopyMemory(pMac -> hHdd, (tANI_U8 *)macAddr, pMac->lim.gLimBssid, sizeof(tSirMacAddr));
4700
4701 /** Send Action Frame with the corresponding mode */
4702 retStatus = limSendSMPowerStateFrame(pMac, macAddr, pMIMO_PSParams->htMIMOPSState);
4703 if (retStatus != eSIR_SUCCESS) {
4704 PELOGE(limLog(pMac, LOGE, FL("Sending Action Frame has failed\n"));)
4705 break;
4706 }
4707 }
4708 PELOG1(limLog(pMac, LOG1, FL("The Setting up of LimGlobals is successful for MIMOPS"));)
4709 }while(0);
4710
4711 palFreeMemory( pMac->hHdd, (void *) pMIMO_PSParams );
4712#endif
4713}
4714/**
4715 * @function : limHandleDelBssInReAssocContext
4716 * @brief : While Processing the ReAssociation Response Frame in STA,
4717 * a. immediately after receiving the Reassoc Response the RxCleanUp is
4718 * being issued and the end of DelBSS the new BSS is being added.
4719 *
4720 * b .If an AP rejects the ReAssociation (Disassoc / Deauth) with some context
4721 * change, We need to update CSR with ReAssocCNF Response with the
4722 * ReAssoc Fail and the reason Code, that is also being handled in the DELBSS
4723 * context only
4724 *
4725 * @param : pMac - tpAniSirGlobal
4726 * pStaDs - Station Descriptor
4727 *
4728 * @return : none
4729 */
4730static void
4731limHandleDelBssInReAssocContext(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry)
4732{
4733 tLimMlmReassocCnf mlmReassocCnf;
4734 /** Skipped the DeleteDPH Hash Entry as we need it for the new BSS*/
4735 /** Set the MlmState to IDLE*/
4736 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004737 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 /* Update PE session Id*/
4739 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
4740 switch (psessionEntry->limMlmState) {
4741#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
4742 case eLIM_SME_WT_REASSOC_STATE :
4743 {
4744 tpSirAssocRsp assocRsp;
4745 tpDphHashNode pStaDs;
4746 tSirRetStatus retStatus = eSIR_SUCCESS;
4747#ifdef ANI_PRODUCT_TYPE_CLIENT
4748 tSchBeaconStruct beaconStruct;
4749#endif
4750 /** Delete the older STA Table entry */
4751 limDeleteDphHashEntry(pMac, psessionEntry->bssId, DPH_STA_HASH_INDEX_PEER, psessionEntry);
4752 /**
4753 * Add an entry for AP to hash table
4754 * maintained by DPH module
4755 */
4756 if ((pStaDs = dphAddHashEntry(pMac, psessionEntry->limReAssocbssId, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) == NULL)
4757 {
4758 // Could not add hash table entry
4759 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for \n"));)
4760 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOGE);
4761 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4762 mlmReassocCnf.protStatusCode = eSIR_SME_SUCCESS;
4763 goto Error;
4764 }
4765 /** While Processing the ReAssoc Response Frame the ReAssocRsp Frame
4766 * is being stored to be used here for sending ADDBSS
4767 */
4768 assocRsp = (tpSirAssocRsp)psessionEntry->limAssocResponseData;
4769 limUpdateAssocStaDatas(pMac, pStaDs, assocRsp,psessionEntry);
4770 limUpdateReAssocGlobals(pMac, assocRsp,psessionEntry);
4771#ifdef ANI_PRODUCT_TYPE_CLIENT
4772 limExtractApCapabilities( pMac,
4773 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
4774 limGetIElenFromBssDescription( &psessionEntry->pLimReAssocReq->bssDescription ),
4775 &beaconStruct );
4776 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
4777 limDecideStaProtectionOnAssoc(pMac, &beaconStruct, psessionEntry);
4778 if(beaconStruct.erpPresent) {
4779 if (beaconStruct.erpIEInfo.barkerPreambleMode)
4780 psessionEntry->beaconParams.fShortPreamble = 0;
4781 else
4782 psessionEntry->beaconParams.fShortPreamble = 1;
4783 }
4784 //updateBss flag is false, as in this case, PE is first deleting the existing BSS and then adding a new one.
4785 if (eSIR_SUCCESS != limStaSendAddBss( pMac, assocRsp, &beaconStruct,
4786 &psessionEntry->pLimReAssocReq->bssDescription, false, psessionEntry)) {
4787 limLog( pMac, LOGE, FL( "Posting ADDBSS in the ReAssocContext has Failed \n"));
4788 retStatus = eSIR_FAILURE;
4789 }
4790#elif defined(ANI_AP_CLIENT_SDK)
4791 if (eSIR_SUCCESS != limStaSendAddBss( pMac, (*assocRsp), &psessionEntry->pLimReAssocReq->neighborBssList.bssList[0],
4792 false, psessionEntry)) {
4793 limLog( pMac, LOGE, FL( "Posting ADDBSS in the ReAssocContext has Failed \n"));
4794 retStatus = eSIR_FAILURE;
4795 }
4796#endif
4797 if (retStatus != eSIR_SUCCESS)
4798 {
4799 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4800 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4801 palFreeMemory(pMac->hHdd, assocRsp);
4802 pMac->lim.gLimAssocResponseData = NULL;
4803 goto Error;
4804 }
4805 palFreeMemory(pMac->hHdd, assocRsp);
4806 psessionEntry->limAssocResponseData = NULL;
4807 }
4808 break;
4809 case eLIM_SME_WT_REASSOC_LINK_FAIL_STATE:
4810 {
4811 /** Case wherein the DisAssoc / Deauth
4812 * being sent as response to ReAssoc Req*/
4813 /** Send the Reason code as the same received in Disassoc / Deauth Frame*/
4814 mlmReassocCnf.resultCode = pStaDs->mlmStaContext.disassocReason;
4815 mlmReassocCnf.protStatusCode = pStaDs->mlmStaContext.cleanupTrigger;
4816 /** Set the SME State back to WT_Reassoc State*/
4817 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004818 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
4820 if((psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4821 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
4822 {
4823 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004824 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 }
4826 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
4827 }
4828 break;
4829#endif
4830 default:
4831 PELOGE(limLog(pMac, LOGE, FL("DelBss is being invoked in the wrong system Role /unhandled SME State\n"));)
4832 mlmReassocCnf.resultCode = eSIR_SME_REFUSED;
4833 mlmReassocCnf.protStatusCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
4834 goto Error;
4835 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004836 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07004837Error:
4838 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
4839}
4840
4841/* Added For BT -AMP Support */
4842static void
4843limProcessBtampAddBssRsp( tpAniSirGlobal pMac, tpSirMsgQ limMsgQ ,tpPESession psessionEntry)
4844{
4845 tLimMlmStartCnf mlmStartCnf;
4846 tANI_U32 val;
4847 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
4848
Pratik Bhalgataa1ae392012-11-22 17:44:33 +05304849 if (NULL == pAddBssParams)
4850 {
4851 limLog( pMac, LOGE, FL( "Invalid body pointer in message\n"));
4852 goto end;
4853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 if( eHAL_STATUS_SUCCESS == pAddBssParams->status )
4855 {
4856 limLog(pMac, LOG2, FL("WDA_ADD_BSS_RSP returned with eHAL_STATUS_SUCCESS\n"));
4857 if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
4858 {
4859 if (limSetLinkState(pMac, eSIR_LINK_BTAMP_AP_STATE, psessionEntry->bssId,
4860 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
4861 goto end;
4862 } else if (psessionEntry->bssType == eSIR_BTAMP_STA_MODE) {
4863 if (limSetLinkState(pMac, eSIR_LINK_SCAN_STATE, psessionEntry->bssId,
4864 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
4865 goto end;
4866 }
4867
4868 // Set MLME state
4869 psessionEntry->limMlmState= eLIM_MLM_BSS_STARTED_STATE;
4870 psessionEntry->statypeForBss = STA_ENTRY_SELF; // to know session started for peer or for self
4871 psessionEntry->bssIdx = (tANI_U8) pAddBssParams->bssIdx;
4872 schEdcaProfileUpdate(pMac, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004873 limInitPeerIdxpool(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 // Create timers used by LIM
4875 if (!pMac->lim.gLimTimersCreated)
4876 limCreateTimers(pMac);
4877 /* Update the lim global gLimTriggerBackgroundScanDuringQuietBss */
4878 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TRIG_STA_BK_SCAN, &val ))
4879 limLog( pMac, LOGP, FL("Failed to get WNI_CFG_TRIG_STA_BK_SCAN!\n"));
4880 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = (val) ? 1 : 0;
4881 // Apply previously set configuration at HW
4882 limApplyConfiguration(pMac,psessionEntry);
4883 psessionEntry->staId = pAddBssParams->staContext.staIdx;
4884 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
4885 }
4886 else
4887 {
4888 limLog( pMac, LOGE, FL( "WDA_ADD_BSS_REQ failed with status %d\n" ),pAddBssParams->status );
4889 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
4890 }
4891 mlmStartCnf.sessionId = psessionEntry->peSessionId;
4892 limPostSmeMessage( pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf );
4893 end:
4894 if( 0 != limMsgQ->bodyptr )
4895 palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
4896}
4897
4898/**
4899 * @function : limHandleAddBssInReAssocContext
4900 * @brief : While Processing the ReAssociation Response Frame in STA,
4901 * a. immediately after receiving the Reassoc Response the RxCleanUp is
4902 * being issued and the end of DelBSS the new BSS is being added.
4903 *
4904 * b .If an AP rejects the ReAssociation (Disassoc / Deauth) with some context
4905 * change, We need to update CSR with ReAssocCNF Response with the
4906 * ReAssoc Fail and the reason Code, that is also being handled in the DELBSS
4907 * context only
4908 *
4909 * @param : pMac - tpAniSirGlobal
4910 * pStaDs - Station Descriptor
4911 *
4912 * @return : none
4913 */
4914void
4915limHandleAddBssInReAssocContext(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpPESession psessionEntry)
4916{
4917 tLimMlmReassocCnf mlmReassocCnf;
4918 /** Skipped the DeleteDPH Hash Entry as we need it for the new BSS*/
4919 /** Set the MlmState to IDLE*/
Jeff Johnsone7245742012-09-05 17:12:55 -07004920 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
4921 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 switch (psessionEntry->limSmeState) {
4923#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
4924 case eLIM_SME_WT_REASSOC_STATE : {
4925 tpSirAssocRsp assocRsp;
4926 tpDphHashNode pStaDs;
4927 tSirRetStatus retStatus = eSIR_SUCCESS;
4928#ifdef ANI_PRODUCT_TYPE_CLIENT
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004929 tSchBeaconStruct *pBeaconStruct;
4930 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
4931 (void **)&pBeaconStruct, sizeof(tSchBeaconStruct)))
4932 {
4933 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limHandleAddBssInReAssocContext\n") );
4934 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4935 mlmReassocCnf.protStatusCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4936 goto Error;
4937 }
4938
Jeff Johnson295189b2012-06-20 16:38:30 -07004939#endif
4940 // Get the AP entry from DPH hash table
4941 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4942 if (pStaDs == NULL )
4943 {
4944 PELOGE(limLog(pMac, LOGE, FL("Fail to get STA PEER entry from hash\n"));)
4945 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4946 mlmReassocCnf.protStatusCode = eSIR_SME_SUCCESS;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004947 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 goto Error;
4949 }
4950 /** While Processing the ReAssoc Response Frame the ReAssocRsp Frame
4951 * is being stored to be used here for sending ADDBSS
4952 */
4953 assocRsp = (tpSirAssocRsp)psessionEntry->limAssocResponseData;
4954 limUpdateAssocStaDatas(pMac, pStaDs, assocRsp, psessionEntry);
4955 limUpdateReAssocGlobals(pMac, assocRsp, psessionEntry);
4956#ifdef ANI_PRODUCT_TYPE_CLIENT
4957 limExtractApCapabilities( pMac,
4958 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
4959 limGetIElenFromBssDescription( &psessionEntry->pLimReAssocReq->bssDescription ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004960 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004962 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
4963
4964 if(pBeaconStruct->erpPresent)
4965 {
4966 if (pBeaconStruct->erpIEInfo.barkerPreambleMode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 psessionEntry->beaconParams.fShortPreamble = 0;
4968 else
4969 psessionEntry->beaconParams.fShortPreamble = 1;
4970 }
4971
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004972 if (eSIR_SUCCESS != limStaSendAddBss( pMac, assocRsp, pBeaconStruct,
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 &psessionEntry->pLimReAssocReq->bssDescription, true, psessionEntry)) {
4974 limLog( pMac, LOGE, FL( "Posting ADDBSS in the ReAssocContext has Failed \n"));
4975 retStatus = eSIR_FAILURE;
4976 }
4977#elif defined(ANI_AP_CLIENT_SDK)
4978 if (eSIR_SUCCESS != limStaSendAddBss( pMac, (*assocRsp), &pMac->lim.gpLimReassocReq->neighborBssList.bssList[0], true)) {
4979 limLog( pMac, LOGE, FL( "Posting ADDBSS in the ReAssocContext has Failed \n"));
4980 retStatus = eSIR_FAILURE;
4981 }
4982#endif
4983 if (retStatus != eSIR_SUCCESS)
4984 {
4985 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
4986 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4987 palFreeMemory(pMac->hHdd, assocRsp);
4988 pMac->lim.gLimAssocResponseData = NULL;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004989 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 goto Error;
4991 }
4992 palFreeMemory(pMac->hHdd, assocRsp);
4993 psessionEntry->limAssocResponseData = NULL;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07004994 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 }
4996 break;
4997 case eLIM_SME_WT_REASSOC_LINK_FAIL_STATE: { /** Case wherein the DisAssoc / Deauth
4998 * being sent as response to ReAssoc Req*/
4999 /** Send the Reason code as the same received in Disassoc / Deauth Frame*/
5000 mlmReassocCnf.resultCode = pStaDs->mlmStaContext.disassocReason;
5001 mlmReassocCnf.protStatusCode = pStaDs->mlmStaContext.cleanupTrigger;
5002 /** Set the SME State back to WT_Reassoc State*/
5003 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
5004 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
5005 if(psessionEntry->limSystemRole == eLIM_STA_ROLE)
5006 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
5007
5008 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
5009 }
5010 break;
5011#endif
5012 default:
5013 PELOGE(limLog(pMac, LOGE, FL("DelBss is being invoked in the wrong system Role /unhandled SME State\n"));)
5014 mlmReassocCnf.resultCode = eSIR_SME_REFUSED;
5015 mlmReassocCnf.protStatusCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
5016 goto Error;
5017 }
5018return;
5019Error:
5020 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
5021}
5022
5023#if 0
5024 static void
5025limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
5026{
5027 tSirSmeAssocCnf assocCnf;
5028 tpDphHashNode pStaDs;
5029 tpPESession psessionEntry;
5030 tANI_U8 sessionId;
5031
5032 if(pMsgBuf == NULL)
5033 {
5034 limLog(pMac, LOGE, FL("pMsgBuf is NULL \n"));
5035 goto end;
5036 }
5037 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
5038 !__limIsSmeAssocCnfValid(&assocCnf))
5039 {
5040 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message \n"));
5041 goto end;
5042 }
5043 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
5044 {
5045 limLog(pMac, LOGE, FL("session does not exist for given bssId\n"));
5046 goto end;
5047 }
5048 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
5049 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
5050 {
5051 limLog(pMac, LOGE, FL("Received unexpected message %X in state %X, in role %X\n"),
5052 msgType, psessionEntry->limSmeState , psessionEntry->limSystemRole);
5053 goto end;
5054 }
5055 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
5056 if (pStaDs == NULL)
5057 {
5058 limLog(pMac, LOG1,
5059 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
5060 msgType, assocCnf.aid);
5061 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
5062 /*
5063 ** send a DISASSOC_IND message to WSM to make sure
5064 ** the state in WSM and LIM is the same
5065 **/
5066 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
5067 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
5068 goto end;
5069 }
5070 if ((pStaDs &&
5071 (( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pStaDs->staAddr,
5072 (tANI_U8 *) assocCnf.peerMacAddr,
5073 sizeof(tSirMacAddr)) ) ||
5074 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
5075 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
5076 (msgType != eWNI_SME_ASSOC_CNF)) ||
5077 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
5078 (msgType != eWNI_SME_REASSOC_CNF)))))
5079 {
5080 limLog(pMac, LOG1,
5081 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
5082 msgType, assocCnf.aid);
5083 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
5084 goto end;
5085 }
5086 /*
5087 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
5088 ** has been received
5089 **/
5090 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer\n"));
5091 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
5092 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
5093 {
5094 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
5095 * when it had received Assoc Request frame. Now, PE just needs to send
5096 * Association Response frame to the requesting BTAMP-STA.
5097 */
5098 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
5099 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) \n"), pStaDs->assocId);
5100 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
5101 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
5102 goto end;
5103 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
5104 else
5105 {
5106 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
5107 limRejectAssociation(pMac, pStaDs->staAddr,
5108 pStaDs->mlmStaContext.subType,
5109 true, pStaDs->mlmStaContext.authType,
5110 pStaDs->assocId, true,
5111 assocCnf.statusCode, psessionEntry);
5112 return;
5113 }
5114end:
5115 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
5116 {
5117 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
5118 {
5119 palFreeMemory(pMac->hHdd,((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
5120 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
5121 }
5122
5123 palFreeMemory(pMac->hHdd, psessionEntry->parsedAssocReq[pStaDs->assocId]);
5124 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
5125 }
5126} /*** end __limProcessSmeAssocCnfNew() ***/
5127#endif
5128
5129#ifdef WLAN_SOFTAP_FEATURE
5130void
5131limSendBeaconInd(tpAniSirGlobal pMac, tpPESession psessionEntry){
5132 tBeaconGenParams *pBeaconGenParams = NULL;
5133 tSirMsgQ limMsg;
5134 /** Allocate the Memory for Beacon Pre Message and for Stations in PoweSave*/
5135 if(psessionEntry == NULL ){
5136 PELOGE( limLog( pMac, LOGE,
5137 FL( "Error:Unable to get the PESessionEntry\n" ));)
5138 return;
5139 }
5140 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5141 (void **) &pBeaconGenParams, (sizeof(*pBeaconGenParams))))
5142 {
5143 PELOGE( limLog( pMac, LOGP,
5144 FL( "Unable to PAL allocate memory during sending beaconPreMessage\n" ));)
5145 return;
5146 }
5147 palZeroMemory( pMac->hHdd, pBeaconGenParams, sizeof(*pBeaconGenParams));
5148 palCopyMemory( pMac->hHdd, (void *) pBeaconGenParams->bssId,
5149 (void *)psessionEntry->bssId,
5150 SIR_MAC_ADDR_LENGTH );
5151 limMsg.bodyptr = pBeaconGenParams;
5152 schProcessPreBeaconInd(pMac, &limMsg);
5153 return;
5154}
5155#endif