blob: 6348bf89d035bf455588b3e4c881464374729513 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. 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
22/*
23 * */
24/**=========================================================================
25
26 \file limSession.c
27
28 \brief implementation for lim Session related APIs
29
30 \author Sunit Bhatia
31
32 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
33
34 Qualcomm Confidential and Proprietary.
35
36 ========================================================================*/
37
38
39/*--------------------------------------------------------------------------
40 Include Files
41 ------------------------------------------------------------------------*/
42#include "aniGlobal.h"
43#include "limDebug.h"
44#include "limSession.h"
45#include "limUtils.h"
46#ifdef FEATURE_WLAN_CCX
47#include "ccxApi.h"
48#endif
49
50/*--------------------------------------------------------------------------
51
52 \brief peInitBeaconParams() - Initialize the beaconParams structure
53
54
55 \param tpPESession - pointer to the session context or NULL if session can not be created.
56 \return void
57 \sa
58
59 --------------------------------------------------------------------------*/
60
61void peInitBeaconParams(tpAniSirGlobal pMac, tpPESession psessionEntry)
62{
63 psessionEntry->beaconParams.beaconInterval = 0;
64 psessionEntry->beaconParams.fShortPreamble = 0;
65 psessionEntry->beaconParams.llaCoexist = 0;
66 psessionEntry->beaconParams.llbCoexist = 0;
67 psessionEntry->beaconParams.llgCoexist = 0;
68 psessionEntry->beaconParams.ht20Coexist = 0;
69 psessionEntry->beaconParams.llnNonGFCoexist = 0;
70 psessionEntry->beaconParams.fRIFSMode = 0;
71 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
72 psessionEntry->beaconParams.gHTObssMode = 0;
73
74 // Number of legacy STAs associated
75 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLim11bParams, sizeof(tLimProtStaParams));
76 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLim11aParams, sizeof(tLimProtStaParams));
77 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLim11gParams, sizeof(tLimProtStaParams));
78 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimNonGfParams, sizeof(tLimProtStaParams));
79 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimHt20Params, sizeof(tLimProtStaParams));
80 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimLsigTxopParams, sizeof(tLimProtStaParams));
81 palZeroMemory(pMac->hHdd, (void*)&psessionEntry->gLimOlbcParams, sizeof(tLimProtStaParams));
82}
83
84/*--------------------------------------------------------------------------
85
86 \brief peCreateSession() - creates a new PE session given the BSSID
87
88 This function returns the session context and the session ID if the session
89 corresponding to the passed BSSID is found in the PE session table.
90
91 \param pMac - pointer to global adapter context
92 \param bssid - BSSID of the new session
93 \param sessionId -session ID is returned here, if session is created.
94
95 \return tpPESession - pointer to the session context or NULL if session can not be created.
96
97 \sa
98
99 --------------------------------------------------------------------------*/
100tpPESession peCreateSession(tpAniSirGlobal pMac, tANI_U8 *bssid , tANI_U8* sessionId, tANI_U16 numSta)
101{
102 tANI_U8 i;
103 for(i =0; i < pMac->lim.maxBssId; i++)
104 {
105 /* Find first free room in session table */
106 if(pMac->lim.gpSession[i].valid == FALSE)
107 {
108 palZeroMemory(pMac, (void*)&pMac->lim.gpSession[i], sizeof(tPESession));
109
110 //Allocate space for Station Table for this session.
111 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
112 (void **) &pMac->lim.gpSession[i].dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*numSta))
113 {
114 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
115 return NULL;
116 }
117
118 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
119 (void **) &pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*numSta))
120 {
121 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
122 palFreeMemory(pMac->hHdd,pMac->lim.gpSession[i].dph.dphHashTable.pHashTable);
123 return NULL;
124 }
125 pMac->lim.gpSession[i].dph.dphHashTable.size = numSta;
126
127 dphHashTableClassInit(pMac,
128 &pMac->lim.gpSession[i].dph.dphHashTable);
129
130 /* Copy the BSSID to the session table */
131 sirCopyMacAddr(pMac->lim.gpSession[i].bssId, bssid);
132 pMac->lim.gpSession[i].valid = TRUE;
133
134 /* Intialize the SME and MLM states to IDLE */
135 pMac->lim.gpSession[i].limMlmState = eLIM_MLM_IDLE_STATE;
136 pMac->lim.gpSession[i].limSmeState = eLIM_SME_IDLE_STATE;
137 pMac->lim.gpSession[i].limCurrentAuthType = eSIR_OPEN_SYSTEM;
138 peInitBeaconParams(pMac, &pMac->lim.gpSession[i]);
139#ifdef WLAN_FEATURE_VOWIFI_11R
140 pMac->lim.gpSession[i].is11Rconnection = FALSE;
141#endif
142
143#ifdef FEATURE_WLAN_CCX
144 pMac->lim.gpSession[i].isCCXconnection = FALSE;
145#endif
146
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700147#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 pMac->lim.gpSession[i].isFastTransitionEnabled = FALSE;
149#endif
Jeff Johnson43971f52012-07-17 12:26:56 -0700150#ifdef FEATURE_WLAN_LFR
151 pMac->lim.gpSession[i].isFastRoamIniFeatureEnabled = FALSE;
152#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 *sessionId = i;
154
Jeff Johnsone7245742012-09-05 17:12:55 -0700155 pMac->lim.gpSession[i].gLimPhyMode = WNI_CFG_PHY_MODE_11G; //TODO :Check with the team what should be default mode
156 /* Initialize CB mode variables when session is created */
157 pMac->lim.gpSession[i].htSupportedChannelWidthSet = 0;
158 pMac->lim.gpSession[i].htRecommendedTxWidthSet = 0;
159 pMac->lim.gpSession[i].htSecondaryChannelOffset = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 return(&pMac->lim.gpSession[i]);
161 }
162 }
163 limLog(pMac, LOGE, FL("Session can not be created.. Reached Max permitted sessions \n "));
164 return NULL;
165}
166
167
168/*--------------------------------------------------------------------------
169 \brief peFindSessionByBssid() - looks up the PE session given the BSSID.
170
171 This function returns the session context and the session ID if the session
172 corresponding to the given BSSID is found in the PE session table.
173
174 \param pMac - pointer to global adapter context
175 \param bssid - BSSID of the session
176 \param sessionId -session ID is returned here, if session is found.
177
178 \return tpPESession - pointer to the session context or NULL if session is not found.
179
180 \sa
181 --------------------------------------------------------------------------*/
182tpPESession peFindSessionByBssid(tpAniSirGlobal pMac, tANI_U8* bssid, tANI_U8* sessionId)
183{
184 tANI_U8 i;
185
186 for(i =0; i < pMac->lim.maxBssId; i++)
187 {
188 /* If BSSID matches return corresponding tables address*/
189 if( (pMac->lim.gpSession[i].valid) && (sirCompareMacAddr(pMac->lim.gpSession[i].bssId, bssid)))
190 {
191 *sessionId = i;
192 return(&pMac->lim.gpSession[i]);
193 }
194 }
195
196 limLog(pMac, LOG4, FL("Session lookup fails for BSSID: \n "));
197 limPrintMacAddr(pMac, bssid, LOG4);
198 return(NULL);
199
200}
201
202
203
204/*--------------------------------------------------------------------------
205 \brief peFindSessionBySessionId() - looks up the PE session given the session ID.
206
207 This function returns the session context if the session
208 corresponding to the given session ID is found in the PE session table.
209
210 \param pMac - pointer to global adapter context
211 \param sessionId -session ID for which session context needs to be looked up.
212
213 \return tpPESession - pointer to the session context or NULL if session is not found.
214
215 \sa
216 --------------------------------------------------------------------------*/
217 tpPESession peFindSessionBySessionId(tpAniSirGlobal pMac , tANI_U8 sessionId)
218{
219 if(sessionId >= pMac->lim.maxBssId)
220 {
221 limLog(pMac, LOGE, FL("Invalid sessionId: %d \n "), sessionId);
222 return(NULL);
223 }
224 if((pMac->lim.gpSession[sessionId].valid == TRUE))
225 {
226 return(&pMac->lim.gpSession[sessionId]);
227 }
228 limLog(pMac, LOG1, FL("Session %d not active\n "), sessionId);
229 return(NULL);
230
231}
232
233
234/*--------------------------------------------------------------------------
235 \brief peFindSessionByStaId() - looks up the PE session given staid.
236
237 This function returns the session context and the session ID if the session
238 corresponding to the given StaId is found in the PE session table.
239
240 \param pMac - pointer to global adapter context
241 \param staid - StaId of the session
242 \param sessionId -session ID is returned here, if session is found.
243
244 \return tpPESession - pointer to the session context or NULL if session is not found.
245
246 \sa
247 --------------------------------------------------------------------------*/
248tpPESession peFindSessionByStaId(tpAniSirGlobal pMac, tANI_U8 staid, tANI_U8* sessionId)
249{
250 tANI_U8 i, j;
251
252 for(i =0; i < pMac->lim.maxBssId; i++)
253 {
254 if(pMac->lim.gpSession[i].valid)
255 {
256 for(j = 0; j < pMac->lim.gpSession[i].dph.dphHashTable.size; j++)
257 {
258 if((pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].valid) &&
259 (pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].added) &&
260 (staid == pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].staIndex))
261 {
262 *sessionId = i;
263 return(&pMac->lim.gpSession[i]);
264 }
265 }
266 }
267 }
268
Jeff Johnsone7245742012-09-05 17:12:55 -0700269 limLog(pMac, LOG4, FL("Session lookup fails for StaId: %d\n "), staid);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 return(NULL);
271}
272
273
274
275/*--------------------------------------------------------------------------
276 \brief peDeleteSession() - deletes the PE session given the session ID.
277
278
279 \param pMac - pointer to global adapter context
280 \param sessionId -session ID of the session which needs to be deleted.
281
282 \sa
283 --------------------------------------------------------------------------*/
284void peDeleteSession(tpAniSirGlobal pMac, tpPESession psessionEntry)
285{
286 tANI_U16 i = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700287 tANI_U16 n;
288 TX_TIMER *timer_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -0700289
290 limLog(pMac, LOGW, FL("Trying to delete a session %d.\n "), psessionEntry->peSessionId);
291
Jeff Johnsone7245742012-09-05 17:12:55 -0700292 for (n = 0; n < pMac->lim.maxStation; n++)
293 {
294 timer_ptr = &pMac->lim.limTimers.gpLimCnfWaitTimer[n];
295
296 if(psessionEntry->peSessionId == timer_ptr->sessionId)
297 {
298 if(VOS_TRUE == tx_timer_running(timer_ptr))
299 {
300 tx_timer_deactivate(timer_ptr);
301 }
302 }
303 }
304
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 if(psessionEntry->pLimStartBssReq != NULL)
306 {
307 palFreeMemory( pMac->hHdd, psessionEntry->pLimStartBssReq );
308 psessionEntry->pLimStartBssReq = NULL;
309 }
310
311 if(psessionEntry->pLimJoinReq != NULL)
312 {
313 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq );
314 psessionEntry->pLimJoinReq = NULL;
315 }
316
317 if(psessionEntry->pLimReAssocReq != NULL)
318 {
319 palFreeMemory( pMac->hHdd, psessionEntry->pLimReAssocReq );
320 psessionEntry->pLimReAssocReq = NULL;
321 }
322
323 if(psessionEntry->pLimMlmJoinReq != NULL)
324 {
325 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmJoinReq );
326 psessionEntry->pLimMlmJoinReq = NULL;
327 }
328
329 if(psessionEntry->dph.dphHashTable.pHashTable != NULL)
330 {
331 palFreeMemory(pMac->hHdd, psessionEntry->dph.dphHashTable.pHashTable);
332 psessionEntry->dph.dphHashTable.pHashTable = NULL;
333 }
334
335 if(psessionEntry->dph.dphHashTable.pDphNodeArray != NULL)
336 {
337 palFreeMemory(pMac->hHdd, psessionEntry->dph.dphHashTable.pDphNodeArray);
338 psessionEntry->dph.dphHashTable.pDphNodeArray = NULL;
339 }
340
341 if(psessionEntry->beacon != NULL)
342 {
343 palFreeMemory( pMac->hHdd, psessionEntry->beacon);
344 psessionEntry->beacon = NULL;
345 }
346
347 if(psessionEntry->assocReq != NULL)
348 {
349 palFreeMemory( pMac->hHdd, psessionEntry->assocReq);
350 psessionEntry->assocReq = NULL;
351 }
352
353 if(psessionEntry->assocRsp != NULL)
354 {
355 palFreeMemory( pMac->hHdd, psessionEntry->assocRsp);
356 psessionEntry->assocRsp = NULL;
357 }
358
359
360 if(psessionEntry->parsedAssocReq != NULL)
361 {
362 // Cleanup the individual allocation first
363 for (i=0; i < psessionEntry->dph.dphHashTable.size; i++)
364 {
365 if ( psessionEntry->parsedAssocReq[i] != NULL )
366 {
367 if( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame )
368 {
369 palFreeMemory(pMac->hHdd,
370 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame);
371 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame = NULL;
372 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrameLength = 0;
373 }
374 palFreeMemory(pMac->hHdd, (void *)psessionEntry->parsedAssocReq[i]);
375 psessionEntry->parsedAssocReq[i] = NULL;
376 }
377 }
378 // Cleanup the whole block
379 palFreeMemory(pMac->hHdd, (void *)psessionEntry->parsedAssocReq);
380 psessionEntry->parsedAssocReq = NULL;
381 }
382
383#ifdef FEATURE_WLAN_CCX
384 limCleanupCcxCtxt(pMac, psessionEntry);
385#endif
386
387 psessionEntry->valid = FALSE;
388 return;
389}
390
391
392/*--------------------------------------------------------------------------
393 \brief peFindSessionByPeerSta() - looks up the PE session given the Station Address.
394
395 This function returns the session context and the session ID if the session
396 corresponding to the given station address is found in the PE session table.
397
398 \param pMac - pointer to global adapter context
399 \param sa - Peer STA Address of the session
400 \param sessionId -session ID is returned here, if session is found.
401
402 \return tpPESession - pointer to the session context or NULL if session is not found.
403
404 \sa
405 --------------------------------------------------------------------------*/
406
407
408tpPESession peFindSessionByPeerSta(tpAniSirGlobal pMac, tANI_U8* sa, tANI_U8* sessionId)
409{
410 tANI_U8 i;
411 tpDphHashNode pSta;
412 tANI_U16 aid;
413
414 for(i =0; i < pMac->lim.maxBssId; i++)
415 {
416 if( (pMac->lim.gpSession[i].valid))
417 {
418 pSta = dphLookupHashEntry(pMac, sa, &aid, &pMac->lim.gpSession[i].dph.dphHashTable);
419 if (pSta != NULL)
420 {
421 *sessionId = i;
422 return &pMac->lim.gpSession[i];
423 }
424 }
425 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700426
427 limLog(pMac, LOG1, FL("Session lookup fails for Peer StaId: \n "));
428 limPrintMacAddr(pMac, sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 return NULL;
430}
431
432
433
434
435
436
437
438
439