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