blob: 3bf314c17e7933e67e483f69ead1dc268782e333 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042/**=========================================================================
43
44 \file limSession.c
45
46 \brief implementation for lim Session related APIs
47
48 \author Sunit Bhatia
49
50 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
51
52 Qualcomm Confidential and Proprietary.
53
54 ========================================================================*/
55
56
57/*--------------------------------------------------------------------------
58 Include Files
59 ------------------------------------------------------------------------*/
60#include "aniGlobal.h"
61#include "limDebug.h"
62#include "limSession.h"
63#include "limUtils.h"
64#ifdef FEATURE_WLAN_CCX
65#include "ccxApi.h"
66#endif
67
68/*--------------------------------------------------------------------------
69
70 \brief peInitBeaconParams() - Initialize the beaconParams structure
71
72
73 \param tpPESession - pointer to the session context or NULL if session can not be created.
74 \return void
75 \sa
76
77 --------------------------------------------------------------------------*/
78
79void peInitBeaconParams(tpAniSirGlobal pMac, tpPESession psessionEntry)
80{
81 psessionEntry->beaconParams.beaconInterval = 0;
82 psessionEntry->beaconParams.fShortPreamble = 0;
83 psessionEntry->beaconParams.llaCoexist = 0;
84 psessionEntry->beaconParams.llbCoexist = 0;
85 psessionEntry->beaconParams.llgCoexist = 0;
86 psessionEntry->beaconParams.ht20Coexist = 0;
87 psessionEntry->beaconParams.llnNonGFCoexist = 0;
88 psessionEntry->beaconParams.fRIFSMode = 0;
89 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
90 psessionEntry->beaconParams.gHTObssMode = 0;
91
92 // Number of legacy STAs associated
93 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLim11bParams, sizeof(tLimProtStaParams));
94 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLim11aParams, sizeof(tLimProtStaParams));
95 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLim11gParams, sizeof(tLimProtStaParams));
96 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimNonGfParams, sizeof(tLimProtStaParams));
97 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimHt20Params, sizeof(tLimProtStaParams));
98 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimLsigTxopParams, sizeof(tLimProtStaParams));
99 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimOlbcParams, sizeof(tLimProtStaParams));
100}
101
102/*--------------------------------------------------------------------------
103
104 \brief peCreateSession() - creates a new PE session given the BSSID
105
106 This function returns the session context and the session ID if the session
107 corresponding to the passed BSSID is found in the PE session table.
108
109 \param pMac - pointer to global adapter context
110 \param bssid - BSSID of the new session
111 \param sessionId -session ID is returned here, if session is created.
112
113 \return tpPESession - pointer to the session context or NULL if session can not be created.
114
115 \sa
116
117 --------------------------------------------------------------------------*/
118tpPESession peCreateSession(tpAniSirGlobal pMac, tANI_U8 *bssid , tANI_U8* sessionId, tANI_U16 numSta)
119{
120 tANI_U8 i;
121 for(i =0; i < pMac->lim.maxBssId; i++)
122 {
123 /* Find first free room in session table */
124 if(pMac->lim.gpSession[i].valid == FALSE)
125 {
126 palZeroMemory(pMac, (void*)&pMac->lim.gpSession[i], sizeof(tPESession));
127
128 //Allocate space for Station Table for this session.
129 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
130 (void **) &pMac->lim.gpSession[i].dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*numSta))
131 {
132 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
133 return NULL;
134 }
135
136 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
137 (void **) &pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*numSta))
138 {
139 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
140 palFreeMemory(pMac->hHdd,pMac->lim.gpSession[i].dph.dphHashTable.pHashTable);
141 return NULL;
142 }
143 pMac->lim.gpSession[i].dph.dphHashTable.size = numSta;
144
145 dphHashTableClassInit(pMac,
146 &pMac->lim.gpSession[i].dph.dphHashTable);
147
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800148 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
149 (void **) &pMac->lim.gpSession[i].gpLimPeerIdxpool,
150 sizeof(*pMac->lim.gpSession[i].gpLimPeerIdxpool) * (numSta+1)))
151 {
152 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
153 palFreeMemory(pMac->hHdd,pMac->lim.gpSession[i].dph.dphHashTable.pHashTable);
154 palFreeMemory(pMac->hHdd,pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray);
155 return NULL;
156 }
157 palZeroMemory(pMac->hHdd, pMac->lim.gpSession[i].gpLimPeerIdxpool,
158 sizeof(*pMac->lim.gpSession[i].gpLimPeerIdxpool) * (numSta+1));
159 pMac->lim.gpSession[i].freePeerIdxHead = 0;
160 pMac->lim.gpSession[i].freePeerIdxTail = 0;
161 pMac->lim.gpSession[i].gLimNumOfCurrentSTAs = 0;
162
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 /* Copy the BSSID to the session table */
164 sirCopyMacAddr(pMac->lim.gpSession[i].bssId, bssid);
165 pMac->lim.gpSession[i].valid = TRUE;
166
167 /* Intialize the SME and MLM states to IDLE */
168 pMac->lim.gpSession[i].limMlmState = eLIM_MLM_IDLE_STATE;
169 pMac->lim.gpSession[i].limSmeState = eLIM_SME_IDLE_STATE;
170 pMac->lim.gpSession[i].limCurrentAuthType = eSIR_OPEN_SYSTEM;
171 peInitBeaconParams(pMac, &pMac->lim.gpSession[i]);
172#ifdef WLAN_FEATURE_VOWIFI_11R
173 pMac->lim.gpSession[i].is11Rconnection = FALSE;
174#endif
175
176#ifdef FEATURE_WLAN_CCX
177 pMac->lim.gpSession[i].isCCXconnection = FALSE;
178#endif
179
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700180#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 pMac->lim.gpSession[i].isFastTransitionEnabled = FALSE;
182#endif
Jeff Johnson43971f52012-07-17 12:26:56 -0700183#ifdef FEATURE_WLAN_LFR
184 pMac->lim.gpSession[i].isFastRoamIniFeatureEnabled = FALSE;
185#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 *sessionId = i;
187
Jeff Johnsone7245742012-09-05 17:12:55 -0700188 pMac->lim.gpSession[i].gLimPhyMode = WNI_CFG_PHY_MODE_11G; //TODO :Check with the team what should be default mode
189 /* Initialize CB mode variables when session is created */
190 pMac->lim.gpSession[i].htSupportedChannelWidthSet = 0;
191 pMac->lim.gpSession[i].htRecommendedTxWidthSet = 0;
192 pMac->lim.gpSession[i].htSecondaryChannelOffset = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800193#ifdef FEATURE_WLAN_TDLS
194 palZeroMemory(pMac->hHdd, pMac->lim.gpSession[i].peerAIDBitmap,
195 sizeof(pMac->lim.gpSession[i].peerAIDBitmap));
196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 return(&pMac->lim.gpSession[i]);
198 }
199 }
200 limLog(pMac, LOGE, FL("Session can not be created.. Reached Max permitted sessions \n "));
201 return NULL;
202}
203
204
205/*--------------------------------------------------------------------------
206 \brief peFindSessionByBssid() - looks up the PE session given the BSSID.
207
208 This function returns the session context and the session ID if the session
209 corresponding to the given BSSID is found in the PE session table.
210
211 \param pMac - pointer to global adapter context
212 \param bssid - BSSID of the session
213 \param sessionId -session ID is returned here, if session is found.
214
215 \return tpPESession - pointer to the session context or NULL if session is not found.
216
217 \sa
218 --------------------------------------------------------------------------*/
219tpPESession peFindSessionByBssid(tpAniSirGlobal pMac, tANI_U8* bssid, tANI_U8* sessionId)
220{
221 tANI_U8 i;
222
223 for(i =0; i < pMac->lim.maxBssId; i++)
224 {
225 /* If BSSID matches return corresponding tables address*/
226 if( (pMac->lim.gpSession[i].valid) && (sirCompareMacAddr(pMac->lim.gpSession[i].bssId, bssid)))
227 {
228 *sessionId = i;
229 return(&pMac->lim.gpSession[i]);
230 }
231 }
232
233 limLog(pMac, LOG4, FL("Session lookup fails for BSSID: \n "));
234 limPrintMacAddr(pMac, bssid, LOG4);
235 return(NULL);
236
237}
238
239
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -0800240/*--------------------------------------------------------------------------
241 \brief peFindSessionByBssIdx() - looks up the PE session given the bssIdx.
242
243 This function returns the session context if the session
244 corresponding to the given bssIdx is found in the PE session table.
245 \param pMac - pointer to global adapter context
246 \param bssIdx - bss index of the session
247 \return tpPESession - pointer to the session context or NULL if session is not found.
248 \sa
249 --------------------------------------------------------------------------*/
250tpPESession peFindSessionByBssIdx(tpAniSirGlobal pMac, tANI_U8 bssIdx)
251{
252 tANI_U8 i;
253 for (i = 0; i < pMac->lim.maxBssId; i++)
254 {
255 /* If BSSID matches return corresponding tables address*/
256 if ( (pMac->lim.gpSession[i].valid) && (pMac->lim.gpSession[i].bssIdx == bssIdx))
257 {
258 return &pMac->lim.gpSession[i];
259 }
260 }
261 limLog(pMac, LOG4, FL("Session lookup fails for bssIdx: %d"), bssIdx);
262 return NULL;
263}
Jeff Johnson295189b2012-06-20 16:38:30 -0700264
265/*--------------------------------------------------------------------------
266 \brief peFindSessionBySessionId() - looks up the PE session given the session ID.
267
268 This function returns the session context if the session
269 corresponding to the given session ID is found in the PE session table.
270
271 \param pMac - pointer to global adapter context
272 \param sessionId -session ID for which session context needs to be looked up.
273
274 \return tpPESession - pointer to the session context or NULL if session is not found.
275
276 \sa
277 --------------------------------------------------------------------------*/
278 tpPESession peFindSessionBySessionId(tpAniSirGlobal pMac , tANI_U8 sessionId)
279{
280 if(sessionId >= pMac->lim.maxBssId)
281 {
282 limLog(pMac, LOGE, FL("Invalid sessionId: %d \n "), sessionId);
283 return(NULL);
284 }
285 if((pMac->lim.gpSession[sessionId].valid == TRUE))
286 {
287 return(&pMac->lim.gpSession[sessionId]);
288 }
289 limLog(pMac, LOG1, FL("Session %d not active\n "), sessionId);
290 return(NULL);
291
292}
293
294
295/*--------------------------------------------------------------------------
296 \brief peFindSessionByStaId() - looks up the PE session given staid.
297
298 This function returns the session context and the session ID if the session
299 corresponding to the given StaId is found in the PE session table.
300
301 \param pMac - pointer to global adapter context
302 \param staid - StaId of the session
303 \param sessionId -session ID is returned here, if session is found.
304
305 \return tpPESession - pointer to the session context or NULL if session is not found.
306
307 \sa
308 --------------------------------------------------------------------------*/
309tpPESession peFindSessionByStaId(tpAniSirGlobal pMac, tANI_U8 staid, tANI_U8* sessionId)
310{
311 tANI_U8 i, j;
312
313 for(i =0; i < pMac->lim.maxBssId; i++)
314 {
315 if(pMac->lim.gpSession[i].valid)
316 {
317 for(j = 0; j < pMac->lim.gpSession[i].dph.dphHashTable.size; j++)
318 {
319 if((pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].valid) &&
320 (pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].added) &&
321 (staid == pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].staIndex))
322 {
323 *sessionId = i;
324 return(&pMac->lim.gpSession[i]);
325 }
326 }
327 }
328 }
329
Jeff Johnsone7245742012-09-05 17:12:55 -0700330 limLog(pMac, LOG4, FL("Session lookup fails for StaId: %d\n "), staid);
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 return(NULL);
332}
333
334
335
336/*--------------------------------------------------------------------------
337 \brief peDeleteSession() - deletes the PE session given the session ID.
338
339
340 \param pMac - pointer to global adapter context
341 \param sessionId -session ID of the session which needs to be deleted.
342
343 \sa
344 --------------------------------------------------------------------------*/
345void peDeleteSession(tpAniSirGlobal pMac, tpPESession psessionEntry)
346{
347 tANI_U16 i = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700348 tANI_U16 n;
349 TX_TIMER *timer_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -0700350
351 limLog(pMac, LOGW, FL("Trying to delete a session %d.\n "), psessionEntry->peSessionId);
352
Jeff Johnsone7245742012-09-05 17:12:55 -0700353 for (n = 0; n < pMac->lim.maxStation; n++)
354 {
355 timer_ptr = &pMac->lim.limTimers.gpLimCnfWaitTimer[n];
356
357 if(psessionEntry->peSessionId == timer_ptr->sessionId)
358 {
359 if(VOS_TRUE == tx_timer_running(timer_ptr))
360 {
361 tx_timer_deactivate(timer_ptr);
362 }
363 }
364 }
365
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 if(psessionEntry->pLimStartBssReq != NULL)
367 {
368 palFreeMemory( pMac->hHdd, psessionEntry->pLimStartBssReq );
369 psessionEntry->pLimStartBssReq = NULL;
370 }
371
372 if(psessionEntry->pLimJoinReq != NULL)
373 {
374 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq );
375 psessionEntry->pLimJoinReq = NULL;
376 }
377
378 if(psessionEntry->pLimReAssocReq != NULL)
379 {
380 palFreeMemory( pMac->hHdd, psessionEntry->pLimReAssocReq );
381 psessionEntry->pLimReAssocReq = NULL;
382 }
383
384 if(psessionEntry->pLimMlmJoinReq != NULL)
385 {
386 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmJoinReq );
387 psessionEntry->pLimMlmJoinReq = NULL;
388 }
389
390 if(psessionEntry->dph.dphHashTable.pHashTable != NULL)
391 {
392 palFreeMemory(pMac->hHdd, psessionEntry->dph.dphHashTable.pHashTable);
393 psessionEntry->dph.dphHashTable.pHashTable = NULL;
394 }
395
396 if(psessionEntry->dph.dphHashTable.pDphNodeArray != NULL)
397 {
398 palFreeMemory(pMac->hHdd, psessionEntry->dph.dphHashTable.pDphNodeArray);
399 psessionEntry->dph.dphHashTable.pDphNodeArray = NULL;
400 }
401
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800402 if(psessionEntry->gpLimPeerIdxpool != NULL)
403 {
404 palFreeMemory(pMac->hHdd, psessionEntry->gpLimPeerIdxpool);
405 psessionEntry->gpLimPeerIdxpool = NULL;
406 }
407
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 if(psessionEntry->beacon != NULL)
409 {
410 palFreeMemory( pMac->hHdd, psessionEntry->beacon);
411 psessionEntry->beacon = NULL;
412 }
413
414 if(psessionEntry->assocReq != NULL)
415 {
416 palFreeMemory( pMac->hHdd, psessionEntry->assocReq);
417 psessionEntry->assocReq = NULL;
418 }
419
420 if(psessionEntry->assocRsp != NULL)
421 {
422 palFreeMemory( pMac->hHdd, psessionEntry->assocRsp);
423 psessionEntry->assocRsp = NULL;
424 }
425
426
427 if(psessionEntry->parsedAssocReq != NULL)
428 {
429 // Cleanup the individual allocation first
430 for (i=0; i < psessionEntry->dph.dphHashTable.size; i++)
431 {
432 if ( psessionEntry->parsedAssocReq[i] != NULL )
433 {
434 if( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame )
435 {
436 palFreeMemory(pMac->hHdd,
437 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame);
438 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame = NULL;
439 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrameLength = 0;
440 }
441 palFreeMemory(pMac->hHdd, (void *)psessionEntry->parsedAssocReq[i]);
442 psessionEntry->parsedAssocReq[i] = NULL;
443 }
444 }
445 // Cleanup the whole block
446 palFreeMemory(pMac->hHdd, (void *)psessionEntry->parsedAssocReq);
447 psessionEntry->parsedAssocReq = NULL;
448 }
Dhanashri Atree3a2a592013-03-08 13:18:42 -0800449 if (NULL != psessionEntry->limAssocResponseData)
450 {
451 palFreeMemory( pMac->hHdd, psessionEntry->limAssocResponseData);
452 psessionEntry->limAssocResponseData = NULL;
453 }
454
455#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
456 if (NULL != psessionEntry->pLimMlmReassocRetryReq)
457 {
458 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmReassocRetryReq);
459 psessionEntry->pLimMlmReassocRetryReq = NULL;
460 }
461#endif
462
463 if (NULL != psessionEntry->pLimMlmReassocReq)
464 {
465 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmReassocReq);
466 psessionEntry->pLimMlmReassocReq = NULL;
467 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700468
469#ifdef FEATURE_WLAN_CCX
470 limCleanupCcxCtxt(pMac, psessionEntry);
471#endif
472
473 psessionEntry->valid = FALSE;
474 return;
475}
476
477
478/*--------------------------------------------------------------------------
479 \brief peFindSessionByPeerSta() - looks up the PE session given the Station Address.
480
481 This function returns the session context and the session ID if the session
482 corresponding to the given station address is found in the PE session table.
483
484 \param pMac - pointer to global adapter context
485 \param sa - Peer STA Address of the session
486 \param sessionId -session ID is returned here, if session is found.
487
488 \return tpPESession - pointer to the session context or NULL if session is not found.
489
490 \sa
491 --------------------------------------------------------------------------*/
492
493
494tpPESession peFindSessionByPeerSta(tpAniSirGlobal pMac, tANI_U8* sa, tANI_U8* sessionId)
495{
496 tANI_U8 i;
497 tpDphHashNode pSta;
498 tANI_U16 aid;
499
500 for(i =0; i < pMac->lim.maxBssId; i++)
501 {
502 if( (pMac->lim.gpSession[i].valid))
503 {
504 pSta = dphLookupHashEntry(pMac, sa, &aid, &pMac->lim.gpSession[i].dph.dphHashTable);
505 if (pSta != NULL)
506 {
507 *sessionId = i;
508 return &pMac->lim.gpSession[i];
509 }
510 }
511 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700512
513 limLog(pMac, LOG1, FL("Session lookup fails for Peer StaId: \n "));
514 limPrintMacAddr(pMac, sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 return NULL;
516}
517
518
519
520
521
522
523
524
525