Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 61 | void 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 | --------------------------------------------------------------------------*/ |
| 100 | tpPESession 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 Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 147 | #if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 148 | pMac->lim.gpSession[i].isFastTransitionEnabled = FALSE; |
| 149 | #endif |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame^] | 150 | #ifdef FEATURE_WLAN_LFR |
| 151 | pMac->lim.gpSession[i].isFastRoamIniFeatureEnabled = FALSE; |
| 152 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 153 | *sessionId = i; |
| 154 | |
| 155 | pMac->lim.gpSession[i].gLimPhyMode = WNI_CFG_PHY_MODE_11G; //TODO :Check with the team what should be default mode |
| 156 | return(&pMac->lim.gpSession[i]); |
| 157 | } |
| 158 | } |
| 159 | limLog(pMac, LOGE, FL("Session can not be created.. Reached Max permitted sessions \n ")); |
| 160 | return NULL; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /*-------------------------------------------------------------------------- |
| 165 | \brief peFindSessionByBssid() - looks up the PE session given the BSSID. |
| 166 | |
| 167 | This function returns the session context and the session ID if the session |
| 168 | corresponding to the given BSSID is found in the PE session table. |
| 169 | |
| 170 | \param pMac - pointer to global adapter context |
| 171 | \param bssid - BSSID of the session |
| 172 | \param sessionId -session ID is returned here, if session is found. |
| 173 | |
| 174 | \return tpPESession - pointer to the session context or NULL if session is not found. |
| 175 | |
| 176 | \sa |
| 177 | --------------------------------------------------------------------------*/ |
| 178 | tpPESession peFindSessionByBssid(tpAniSirGlobal pMac, tANI_U8* bssid, tANI_U8* sessionId) |
| 179 | { |
| 180 | tANI_U8 i; |
| 181 | |
| 182 | for(i =0; i < pMac->lim.maxBssId; i++) |
| 183 | { |
| 184 | /* If BSSID matches return corresponding tables address*/ |
| 185 | if( (pMac->lim.gpSession[i].valid) && (sirCompareMacAddr(pMac->lim.gpSession[i].bssId, bssid))) |
| 186 | { |
| 187 | *sessionId = i; |
| 188 | return(&pMac->lim.gpSession[i]); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | limLog(pMac, LOG4, FL("Session lookup fails for BSSID: \n ")); |
| 193 | limPrintMacAddr(pMac, bssid, LOG4); |
| 194 | return(NULL); |
| 195 | |
| 196 | } |
| 197 | |
| 198 | |
| 199 | |
| 200 | /*-------------------------------------------------------------------------- |
| 201 | \brief peFindSessionBySessionId() - looks up the PE session given the session ID. |
| 202 | |
| 203 | This function returns the session context if the session |
| 204 | corresponding to the given session ID is found in the PE session table. |
| 205 | |
| 206 | \param pMac - pointer to global adapter context |
| 207 | \param sessionId -session ID for which session context needs to be looked up. |
| 208 | |
| 209 | \return tpPESession - pointer to the session context or NULL if session is not found. |
| 210 | |
| 211 | \sa |
| 212 | --------------------------------------------------------------------------*/ |
| 213 | tpPESession peFindSessionBySessionId(tpAniSirGlobal pMac , tANI_U8 sessionId) |
| 214 | { |
| 215 | if(sessionId >= pMac->lim.maxBssId) |
| 216 | { |
| 217 | limLog(pMac, LOGE, FL("Invalid sessionId: %d \n "), sessionId); |
| 218 | return(NULL); |
| 219 | } |
| 220 | if((pMac->lim.gpSession[sessionId].valid == TRUE)) |
| 221 | { |
| 222 | return(&pMac->lim.gpSession[sessionId]); |
| 223 | } |
| 224 | limLog(pMac, LOG1, FL("Session %d not active\n "), sessionId); |
| 225 | return(NULL); |
| 226 | |
| 227 | } |
| 228 | |
| 229 | |
| 230 | /*-------------------------------------------------------------------------- |
| 231 | \brief peFindSessionByStaId() - looks up the PE session given staid. |
| 232 | |
| 233 | This function returns the session context and the session ID if the session |
| 234 | corresponding to the given StaId is found in the PE session table. |
| 235 | |
| 236 | \param pMac - pointer to global adapter context |
| 237 | \param staid - StaId of the session |
| 238 | \param sessionId -session ID is returned here, if session is found. |
| 239 | |
| 240 | \return tpPESession - pointer to the session context or NULL if session is not found. |
| 241 | |
| 242 | \sa |
| 243 | --------------------------------------------------------------------------*/ |
| 244 | tpPESession peFindSessionByStaId(tpAniSirGlobal pMac, tANI_U8 staid, tANI_U8* sessionId) |
| 245 | { |
| 246 | tANI_U8 i, j; |
| 247 | |
| 248 | for(i =0; i < pMac->lim.maxBssId; i++) |
| 249 | { |
| 250 | if(pMac->lim.gpSession[i].valid) |
| 251 | { |
| 252 | for(j = 0; j < pMac->lim.gpSession[i].dph.dphHashTable.size; j++) |
| 253 | { |
| 254 | if((pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].valid) && |
| 255 | (pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].added) && |
| 256 | (staid == pMac->lim.gpSession[i].dph.dphHashTable.pDphNodeArray[j].staIndex)) |
| 257 | { |
| 258 | *sessionId = i; |
| 259 | return(&pMac->lim.gpSession[i]); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | limLog(pMac, LOG4, FL("Session lookup fails for StaId: \n ")); |
| 266 | return(NULL); |
| 267 | } |
| 268 | |
| 269 | |
| 270 | |
| 271 | /*-------------------------------------------------------------------------- |
| 272 | \brief peDeleteSession() - deletes the PE session given the session ID. |
| 273 | |
| 274 | |
| 275 | \param pMac - pointer to global adapter context |
| 276 | \param sessionId -session ID of the session which needs to be deleted. |
| 277 | |
| 278 | \sa |
| 279 | --------------------------------------------------------------------------*/ |
| 280 | void peDeleteSession(tpAniSirGlobal pMac, tpPESession psessionEntry) |
| 281 | { |
| 282 | tANI_U16 i = 0; |
| 283 | |
| 284 | limLog(pMac, LOGW, FL("Trying to delete a session %d.\n "), psessionEntry->peSessionId); |
| 285 | |
| 286 | if(psessionEntry->pLimStartBssReq != NULL) |
| 287 | { |
| 288 | palFreeMemory( pMac->hHdd, psessionEntry->pLimStartBssReq ); |
| 289 | psessionEntry->pLimStartBssReq = NULL; |
| 290 | } |
| 291 | |
| 292 | if(psessionEntry->pLimJoinReq != NULL) |
| 293 | { |
| 294 | palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq ); |
| 295 | psessionEntry->pLimJoinReq = NULL; |
| 296 | } |
| 297 | |
| 298 | if(psessionEntry->pLimReAssocReq != NULL) |
| 299 | { |
| 300 | palFreeMemory( pMac->hHdd, psessionEntry->pLimReAssocReq ); |
| 301 | psessionEntry->pLimReAssocReq = NULL; |
| 302 | } |
| 303 | |
| 304 | if(psessionEntry->pLimMlmJoinReq != NULL) |
| 305 | { |
| 306 | palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmJoinReq ); |
| 307 | psessionEntry->pLimMlmJoinReq = NULL; |
| 308 | } |
| 309 | |
| 310 | if(psessionEntry->dph.dphHashTable.pHashTable != NULL) |
| 311 | { |
| 312 | palFreeMemory(pMac->hHdd, psessionEntry->dph.dphHashTable.pHashTable); |
| 313 | psessionEntry->dph.dphHashTable.pHashTable = NULL; |
| 314 | } |
| 315 | |
| 316 | if(psessionEntry->dph.dphHashTable.pDphNodeArray != NULL) |
| 317 | { |
| 318 | palFreeMemory(pMac->hHdd, psessionEntry->dph.dphHashTable.pDphNodeArray); |
| 319 | psessionEntry->dph.dphHashTable.pDphNodeArray = NULL; |
| 320 | } |
| 321 | |
| 322 | if(psessionEntry->beacon != NULL) |
| 323 | { |
| 324 | palFreeMemory( pMac->hHdd, psessionEntry->beacon); |
| 325 | psessionEntry->beacon = NULL; |
| 326 | } |
| 327 | |
| 328 | if(psessionEntry->assocReq != NULL) |
| 329 | { |
| 330 | palFreeMemory( pMac->hHdd, psessionEntry->assocReq); |
| 331 | psessionEntry->assocReq = NULL; |
| 332 | } |
| 333 | |
| 334 | if(psessionEntry->assocRsp != NULL) |
| 335 | { |
| 336 | palFreeMemory( pMac->hHdd, psessionEntry->assocRsp); |
| 337 | psessionEntry->assocRsp = NULL; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | if(psessionEntry->parsedAssocReq != NULL) |
| 342 | { |
| 343 | // Cleanup the individual allocation first |
| 344 | for (i=0; i < psessionEntry->dph.dphHashTable.size; i++) |
| 345 | { |
| 346 | if ( psessionEntry->parsedAssocReq[i] != NULL ) |
| 347 | { |
| 348 | if( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame ) |
| 349 | { |
| 350 | palFreeMemory(pMac->hHdd, |
| 351 | ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame); |
| 352 | ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrame = NULL; |
| 353 | ((tpSirAssocReq)(psessionEntry->parsedAssocReq[i]))->assocReqFrameLength = 0; |
| 354 | } |
| 355 | palFreeMemory(pMac->hHdd, (void *)psessionEntry->parsedAssocReq[i]); |
| 356 | psessionEntry->parsedAssocReq[i] = NULL; |
| 357 | } |
| 358 | } |
| 359 | // Cleanup the whole block |
| 360 | palFreeMemory(pMac->hHdd, (void *)psessionEntry->parsedAssocReq); |
| 361 | psessionEntry->parsedAssocReq = NULL; |
| 362 | } |
| 363 | |
| 364 | #ifdef FEATURE_WLAN_CCX |
| 365 | limCleanupCcxCtxt(pMac, psessionEntry); |
| 366 | #endif |
| 367 | |
| 368 | psessionEntry->valid = FALSE; |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | |
| 373 | /*-------------------------------------------------------------------------- |
| 374 | \brief peFindSessionByPeerSta() - looks up the PE session given the Station Address. |
| 375 | |
| 376 | This function returns the session context and the session ID if the session |
| 377 | corresponding to the given station address is found in the PE session table. |
| 378 | |
| 379 | \param pMac - pointer to global adapter context |
| 380 | \param sa - Peer STA Address of the session |
| 381 | \param sessionId -session ID is returned here, if session is found. |
| 382 | |
| 383 | \return tpPESession - pointer to the session context or NULL if session is not found. |
| 384 | |
| 385 | \sa |
| 386 | --------------------------------------------------------------------------*/ |
| 387 | |
| 388 | |
| 389 | tpPESession peFindSessionByPeerSta(tpAniSirGlobal pMac, tANI_U8* sa, tANI_U8* sessionId) |
| 390 | { |
| 391 | tANI_U8 i; |
| 392 | tpDphHashNode pSta; |
| 393 | tANI_U16 aid; |
| 394 | |
| 395 | for(i =0; i < pMac->lim.maxBssId; i++) |
| 396 | { |
| 397 | if( (pMac->lim.gpSession[i].valid)) |
| 398 | { |
| 399 | pSta = dphLookupHashEntry(pMac, sa, &aid, &pMac->lim.gpSession[i].dph.dphHashTable); |
| 400 | if (pSta != NULL) |
| 401 | { |
| 402 | *sessionId = i; |
| 403 | return &pMac->lim.gpSession[i]; |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | return NULL; |
| 409 | } |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |