Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * 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 Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | /* |
| 43 | * Airgo Networks, Inc proprietary. All rights reserved. |
| 44 | * This file limIbssPeerMgmt.cc contains the utility functions |
| 45 | * LIM uses to maintain peers in IBSS. |
| 46 | * Author: Chandra Modumudi |
| 47 | * Date: 03/12/04 |
| 48 | * History:- |
| 49 | * Date Modified by Modification Information |
| 50 | * -------------------------------------------------------------------- |
| 51 | */ |
| 52 | #include "palTypes.h" |
| 53 | #include "aniGlobal.h" |
| 54 | #include "sirCommon.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 55 | #include "wniCfgSta.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 56 | #include "limUtils.h" |
| 57 | #include "limAssocUtils.h" |
| 58 | #include "limStaHashApi.h" |
| 59 | #include "schApi.h" // schSetFixedBeaconFields for IBSS coalesce |
| 60 | #include "limSecurityUtils.h" |
| 61 | #include "limSendMessages.h" |
| 62 | #include "limSession.h" |
| 63 | #include "limIbssPeerMgmt.h" |
| 64 | |
| 65 | |
| 66 | /** |
| 67 | * ibss_peer_find |
| 68 | * |
| 69 | *FUNCTION: |
| 70 | * This function is called while adding a context at |
| 71 | * DPH & Polaris for a peer in IBSS. |
| 72 | * If peer is found in the list, capabilities from the |
| 73 | * returned BSS description are used at DPH node & Polaris. |
| 74 | * |
| 75 | *LOGIC: |
| 76 | * |
| 77 | *ASSUMPTIONS: |
| 78 | * |
| 79 | *NOTE: |
| 80 | * |
| 81 | * @param macAddr - MAC address of the peer |
| 82 | * |
| 83 | * @return Pointer to peer node if found, else NULL |
| 84 | */ |
| 85 | |
| 86 | static tLimIbssPeerNode * |
| 87 | ibss_peer_find( |
| 88 | tpAniSirGlobal pMac, |
| 89 | tSirMacAddr macAddr) |
| 90 | { |
| 91 | tLimIbssPeerNode *pTempNode = pMac->lim.gLimIbssPeerList; |
| 92 | |
| 93 | while (pTempNode != NULL) |
| 94 | { |
| 95 | if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr, |
| 96 | (tANI_U8 *) &pTempNode->peerMacAddr, |
| 97 | sizeof(tSirMacAddr)) ) |
| 98 | break; |
| 99 | pTempNode = pTempNode->next; |
| 100 | } |
| 101 | return pTempNode; |
| 102 | } /*** end ibss_peer_find() ***/ |
| 103 | |
| 104 | /** |
| 105 | * ibss_peer_add |
| 106 | * |
| 107 | *FUNCTION: |
| 108 | * This is called on a STA in IBSS upon receiving Beacon/ |
| 109 | * Probe Response from a peer. |
| 110 | * |
| 111 | *LOGIC: |
| 112 | * Node is always added to the front of the list |
| 113 | * |
| 114 | *ASSUMPTIONS: |
| 115 | * |
| 116 | *NOTE: |
| 117 | * |
| 118 | * @param pMac - Pointer to Global MAC structure |
| 119 | * @param pPeerNode - Pointer to peer node to be added to the list. |
| 120 | * |
| 121 | * @return None |
| 122 | */ |
| 123 | |
| 124 | static tSirRetStatus |
| 125 | ibss_peer_add(tpAniSirGlobal pMac, tLimIbssPeerNode *pPeerNode) |
| 126 | { |
| 127 | #ifdef ANI_SIR_IBSS_PEER_CACHING |
| 128 | tANI_U32 numIbssPeers = (2 * pMac->lim.maxStation); |
| 129 | |
| 130 | if (pMac->lim.gLimNumIbssPeers >= numIbssPeers) |
| 131 | { |
| 132 | /** |
| 133 | * Reached max number of peers to be maintained. |
| 134 | * Delete last entry & add new entry at the beginning. |
| 135 | */ |
| 136 | tLimIbssPeerNode *pTemp, *pPrev; |
| 137 | pTemp = pPrev = pMac->lim.gLimIbssPeerList; |
| 138 | while (pTemp->next != NULL) |
| 139 | { |
| 140 | pPrev = pTemp; |
| 141 | pTemp = pTemp->next; |
| 142 | } |
| 143 | if(pTemp->beacon) |
| 144 | { |
| 145 | palFreeMemory(pMac->hHdd, pTemp->beacon); |
| 146 | } |
| 147 | |
| 148 | palFreeMemory( pMac->hHdd, (tANI_U8 *) pTemp); |
| 149 | pPrev->next = NULL; |
| 150 | } |
| 151 | else |
| 152 | #endif |
| 153 | pMac->lim.gLimNumIbssPeers++; |
| 154 | |
| 155 | pPeerNode->next = pMac->lim.gLimIbssPeerList; |
| 156 | pMac->lim.gLimIbssPeerList = pPeerNode; |
| 157 | |
| 158 | return eSIR_SUCCESS; |
| 159 | |
| 160 | } /*** end limAddIbssPeerToList() ***/ |
| 161 | |
| 162 | /** |
| 163 | * ibss_peer_collect |
| 164 | * |
| 165 | *FUNCTION: |
| 166 | * This is called to collect IBSS peer information |
| 167 | * from received Beacon/Probe Response frame from it. |
| 168 | * |
| 169 | *LOGIC: |
| 170 | * |
| 171 | *ASSUMPTIONS: |
| 172 | * |
| 173 | *NOTE: |
| 174 | * |
| 175 | * @param pMac - Pointer to Global MAC structure |
| 176 | * @param pBeacon - Parsed Beacon Frame structure |
| 177 | * @param pBD - Pointer to received BD |
| 178 | * @param pPeer - Pointer to IBSS peer node |
| 179 | * |
| 180 | * @return None |
| 181 | */ |
| 182 | |
| 183 | static void |
| 184 | ibss_peer_collect( |
| 185 | tpAniSirGlobal pMac, |
| 186 | tpSchBeaconStruct pBeacon, |
| 187 | tpSirMacMgmtHdr pHdr, |
| 188 | tLimIbssPeerNode *pPeer, |
| 189 | tpPESession psessionEntry) |
| 190 | { |
| 191 | palCopyMemory( pMac->hHdd, pPeer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr)); |
| 192 | |
| 193 | pPeer->capabilityInfo = pBeacon->capabilityInfo; |
| 194 | pPeer->extendedRatesPresent = pBeacon->extendedRatesPresent; |
| 195 | pPeer->edcaPresent = pBeacon->edcaPresent; |
| 196 | pPeer->wmeEdcaPresent = pBeacon->wmeEdcaPresent; |
| 197 | pPeer->wmeInfoPresent = pBeacon->wmeInfoPresent; |
| 198 | |
| 199 | if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) && |
| 200 | (pBeacon->HTCaps.present)) |
| 201 | { |
| 202 | pPeer->htCapable = pBeacon->HTCaps.present; |
| 203 | palCopyMemory(pMac->hHdd, (tANI_U8 *)pPeer->supportedMCSSet, |
| 204 | (tANI_U8 *)pBeacon->HTCaps.supportedMCSSet, |
| 205 | sizeof(pPeer->supportedMCSSet)); |
| 206 | pPeer->htGreenfield = (tANI_U8)pBeacon->HTCaps.greenField; |
| 207 | pPeer->htSupportedChannelWidthSet = ( tANI_U8 ) pBeacon->HTCaps.supportedChannelWidthSet; |
| 208 | pPeer->htMIMOPSState = (tSirMacHTMIMOPowerSaveState)pBeacon->HTCaps.mimoPowerSave; |
| 209 | pPeer->htMaxAmsduLength = ( tANI_U8 ) pBeacon->HTCaps.maximalAMSDUsize; |
| 210 | pPeer->htAMpduDensity = pBeacon->HTCaps.mpduDensity; |
| 211 | pPeer->htDsssCckRate40MHzSupport = (tANI_U8)pBeacon->HTCaps.dsssCckMode40MHz; |
| 212 | pPeer->htShortGI20Mhz = (tANI_U8)pBeacon->HTCaps.shortGI20MHz; |
| 213 | pPeer->htShortGI40Mhz = (tANI_U8)pBeacon->HTCaps.shortGI40MHz; |
| 214 | pPeer->htMaxRxAMpduFactor = pBeacon->HTCaps.maxRxAMPDUFactor; |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 215 | pPeer->htSecondaryChannelOffset = pBeacon->HTInfo.secondaryChannelOffset; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 218 | /* Collect peer VHT capabilities based on the received beacon from the peer */ |
| 219 | #ifdef WLAN_FEATURE_11AC |
| 220 | if ( pBeacon->VHTCaps.present ) |
| 221 | { |
| 222 | pPeer->vhtSupportedChannelWidthSet = |
| 223 | (tANI_U8)((pBeacon->VHTOperation.chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) ? |
| 224 | eHT_CHANNEL_WIDTH_80MHZ : WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ); |
| 225 | pPeer->vhtCapable = pBeacon->VHTCaps.present; |
| 226 | |
| 227 | // Collect VHT capabilities from beacon |
| 228 | palCopyMemory(pMac->hHdd, (tANI_U8 *) &pPeer->VHTCaps, (tANI_U8 *) &pBeacon->VHTCaps, sizeof(tDot11fIEVHTCaps) ); |
| 229 | } |
| 230 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 231 | pPeer->erpIePresent = pBeacon->erpPresent; |
| 232 | |
| 233 | palCopyMemory( pMac->hHdd, (tANI_U8 *) &pPeer->supportedRates, |
| 234 | (tANI_U8 *) &pBeacon->supportedRates, |
| 235 | pBeacon->supportedRates.numRates + 1); |
| 236 | if (pPeer->extendedRatesPresent) |
| 237 | palCopyMemory( pMac->hHdd, (tANI_U8 *) &pPeer->extendedRates, |
| 238 | (tANI_U8 *) &pBeacon->extendedRates, |
| 239 | pBeacon->extendedRates.numRates + 1); |
| 240 | else |
| 241 | pPeer->extendedRates.numRates = 0; |
| 242 | |
| 243 | // TBD copy EDCA parameters |
| 244 | // pPeer->edcaParams; |
| 245 | |
| 246 | pPeer->next = NULL; |
| 247 | } /*** end ibss_peer_collect() ***/ |
| 248 | |
| 249 | // handle change in peer qos/wme capabilities |
| 250 | static void |
| 251 | ibss_sta_caps_update( |
| 252 | tpAniSirGlobal pMac, |
| 253 | tLimIbssPeerNode *pPeerNode, |
| 254 | tpPESession psessionEntry) |
| 255 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 256 | tANI_U16 peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 257 | tpDphHashNode pStaDs; |
| 258 | |
| 259 | pPeerNode->beaconHBCount++; //Update beacon count. |
| 260 | |
| 261 | // if the peer node exists, update its qos capabilities |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 262 | if ((pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable)) == NULL) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | return; |
| 264 | |
| 265 | |
| 266 | //Update HT Capabilities |
| 267 | if(IS_DOT11_MODE_HT(psessionEntry->dot11mode)) |
| 268 | { |
| 269 | pStaDs->mlmStaContext.htCapability = pPeerNode->htCapable; |
| 270 | if (pPeerNode->htCapable) |
| 271 | { |
| 272 | pStaDs->htGreenfield = pPeerNode->htGreenfield; |
| 273 | pStaDs->htSupportedChannelWidthSet = pPeerNode->htSupportedChannelWidthSet; |
| 274 | pStaDs->htMIMOPSState = pPeerNode->htMIMOPSState; |
| 275 | pStaDs->htMaxAmsduLength = pPeerNode->htMaxAmsduLength; |
| 276 | pStaDs->htAMpduDensity = pPeerNode->htAMpduDensity; |
| 277 | pStaDs->htDsssCckRate40MHzSupport = pPeerNode->htDsssCckRate40MHzSupport; |
| 278 | pStaDs->htShortGI20Mhz = pPeerNode->htShortGI20Mhz; |
| 279 | pStaDs->htShortGI40Mhz = pPeerNode->htShortGI40Mhz; |
| 280 | pStaDs->htMaxRxAMpduFactor = pPeerNode->htMaxRxAMpduFactor; |
| 281 | // In the future, may need to check for "delayedBA" |
| 282 | // For now, it is IMMEDIATE BA only on ALL TID's |
| 283 | pStaDs->baPolicyFlag = 0xFF; |
| 284 | } |
| 285 | } |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 286 | #ifdef WLAN_FEATURE_11AC |
| 287 | if ( IS_DOT11_MODE_VHT(psessionEntry->dot11mode) ) |
| 288 | { |
| 289 | pStaDs->mlmStaContext.vhtCapability = pPeerNode->vhtCapable; |
| 290 | if ( pPeerNode->vhtCapable ) |
| 291 | { |
| 292 | pStaDs->vhtSupportedChannelWidthSet = pPeerNode->vhtSupportedChannelWidthSet; |
| 293 | } |
| 294 | } |
| 295 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 296 | |
| 297 | if(IS_DOT11_MODE_PROPRIETARY(psessionEntry->dot11mode) && |
| 298 | pPeerNode->aniIndicator) |
| 299 | { |
| 300 | pStaDs->aniPeer = pPeerNode->aniIndicator; |
| 301 | pStaDs->propCapability = pPeerNode->propCapability; |
| 302 | } |
| 303 | |
| 304 | |
| 305 | // peer is 11e capable but is not 11e enabled yet |
| 306 | // some STA's when joining Airgo IBSS, assert qos capability even when |
| 307 | // they don't suport qos. however, they do not include the edca parameter |
| 308 | // set. so let's check for edcaParam in addition to the qos capability |
| 309 | if (pPeerNode->capabilityInfo.qos && (psessionEntry->limQosEnabled) && pPeerNode->edcaPresent) |
| 310 | { |
| 311 | pStaDs->qosMode = 1; |
| 312 | pStaDs->wmeEnabled = 0; |
| 313 | if (! pStaDs->lleEnabled) |
| 314 | { |
| 315 | pStaDs->lleEnabled = 1; |
| 316 | //dphSetACM(pMac, pStaDs); |
| 317 | } |
| 318 | return; |
| 319 | } |
| 320 | // peer is not 11e capable now but was 11e enabled earlier |
| 321 | else if (pStaDs->lleEnabled) |
| 322 | { |
| 323 | pStaDs->qosMode = 0; |
| 324 | pStaDs->lleEnabled = 0; |
| 325 | } |
| 326 | |
| 327 | // peer is wme capable but is not wme enabled yet |
| 328 | if (pPeerNode->wmeInfoPresent && psessionEntry->limWmeEnabled) |
| 329 | { |
| 330 | pStaDs->qosMode = 1; |
| 331 | pStaDs->lleEnabled = 0; |
| 332 | if (! pStaDs->wmeEnabled) |
| 333 | { |
| 334 | pStaDs->wmeEnabled = 1; |
| 335 | //dphSetACM(pMac, pStaDs); |
| 336 | } |
| 337 | return; |
| 338 | } |
| 339 | /* When the peer device supports EDCA parameters, then we were not |
| 340 | considering. Added this code when we saw that one of the Peer Device |
| 341 | was advertising WMM param where we were not honouring that. CR# 210756 |
| 342 | */ |
| 343 | if (pPeerNode->wmeEdcaPresent && psessionEntry->limWmeEnabled) { |
| 344 | pStaDs->qosMode = 1; |
| 345 | pStaDs->lleEnabled = 0; |
| 346 | if (! pStaDs->wmeEnabled) { |
| 347 | pStaDs->wmeEnabled = 1; |
| 348 | } |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | // peer is not wme capable now but was wme enabled earlier |
| 353 | else if (pStaDs->wmeEnabled) |
| 354 | { |
| 355 | pStaDs->qosMode = 0; |
| 356 | pStaDs->wmeEnabled = 0; |
| 357 | } |
| 358 | |
| 359 | } |
| 360 | |
| 361 | static void |
| 362 | ibss_sta_rates_update( |
| 363 | tpAniSirGlobal pMac, |
| 364 | tpDphHashNode pStaDs, |
| 365 | tLimIbssPeerNode *pPeer, |
| 366 | tpPESession psessionEntry) |
| 367 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 368 | #ifdef WLAN_FEATURE_11AC |
| 369 | limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates, |
| 370 | &pPeer->extendedRates, pPeer->supportedMCSSet, |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 371 | &pStaDs->mlmStaContext.propRateSet,psessionEntry, &pPeer->VHTCaps); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 372 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 373 | // Populate supported rateset |
| 374 | limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates, |
| 375 | &pPeer->extendedRates, pPeer->supportedMCSSet, |
| 376 | &pStaDs->mlmStaContext.propRateSet,psessionEntry); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 377 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 378 | |
| 379 | pStaDs->mlmStaContext.capabilityInfo = pPeer->capabilityInfo; |
| 380 | } /*** end ibss_sta_info_update() ***/ |
| 381 | |
| 382 | /** |
| 383 | * ibss_sta_info_update |
| 384 | * |
| 385 | *FUNCTION: |
| 386 | * This is called to program both SW & Polaris context |
| 387 | * for peer in IBSS. |
| 388 | * |
| 389 | *LOGIC: |
| 390 | * |
| 391 | *ASSUMPTIONS: |
| 392 | * |
| 393 | *NOTE: |
| 394 | * |
| 395 | * @param pMac - Pointer to Global MAC structure |
| 396 | * @param pStaDs - Pointer to DPH node |
| 397 | * @param pPeer - Pointer to IBSS peer node |
| 398 | * |
| 399 | * @return None |
| 400 | */ |
| 401 | |
| 402 | static void |
| 403 | ibss_sta_info_update( |
| 404 | tpAniSirGlobal pMac, |
| 405 | tpDphHashNode pStaDs, |
| 406 | tLimIbssPeerNode *pPeer, |
| 407 | tpPESession psessionEntry) |
| 408 | { |
| 409 | pStaDs->staType = STA_ENTRY_PEER; |
| 410 | ibss_sta_caps_update(pMac, pPeer,psessionEntry); |
| 411 | ibss_sta_rates_update(pMac, pStaDs, pPeer,psessionEntry); |
| 412 | } /*** end ibss_sta_info_update() ***/ |
| 413 | |
| 414 | static void |
| 415 | ibss_coalesce_free( |
| 416 | tpAniSirGlobal pMac) |
| 417 | { |
| 418 | if (pMac->lim.ibssInfo.pHdr != NULL) |
| 419 | palFreeMemory(pMac->hHdd, pMac->lim.ibssInfo.pHdr); |
| 420 | if (pMac->lim.ibssInfo.pBeacon != NULL) |
| 421 | palFreeMemory(pMac->hHdd, pMac->lim.ibssInfo.pBeacon); |
| 422 | |
| 423 | pMac->lim.ibssInfo.pHdr = NULL; |
| 424 | pMac->lim.ibssInfo.pBeacon = NULL; |
| 425 | } |
| 426 | |
| 427 | /* |
| 428 | * save the beacon params for use when adding the bss |
| 429 | */ |
| 430 | static void |
| 431 | ibss_coalesce_save( |
| 432 | tpAniSirGlobal pMac, |
| 433 | tpSirMacMgmtHdr pHdr, |
| 434 | tpSchBeaconStruct pBeacon) |
| 435 | { |
| 436 | eHalStatus status; |
| 437 | |
| 438 | // get rid of any saved info |
| 439 | ibss_coalesce_free(pMac); |
| 440 | |
| 441 | status = palAllocateMemory(pMac->hHdd, (void **) &pMac->lim.ibssInfo.pHdr, |
| 442 | sizeof(*pHdr)); |
| 443 | if (status != eHAL_STATUS_SUCCESS) |
| 444 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 445 | PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pHdr"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 446 | return; |
| 447 | } |
| 448 | status = palAllocateMemory(pMac->hHdd, (void **) &pMac->lim.ibssInfo.pBeacon, |
| 449 | sizeof(*pBeacon)); |
| 450 | if (status != eHAL_STATUS_SUCCESS) |
| 451 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 452 | PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pBeacon"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 453 | ibss_coalesce_free(pMac); |
| 454 | return; |
| 455 | } |
| 456 | |
| 457 | palCopyMemory(pMac->hHdd, pMac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr)); |
| 458 | palCopyMemory(pMac->hHdd, pMac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon)); |
| 459 | } |
| 460 | |
| 461 | /* |
| 462 | * tries to add a new entry to dph hash node |
| 463 | * if necessary, an existing entry is eliminated |
| 464 | */ |
| 465 | static tSirRetStatus |
| 466 | ibss_dph_entry_add( |
| 467 | tpAniSirGlobal pMac, |
| 468 | tSirMacAddr peerAddr, |
| 469 | tpDphHashNode *ppSta, |
| 470 | tpPESession psessionEntry) |
| 471 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 472 | tANI_U16 peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 473 | tpDphHashNode pStaDs; |
| 474 | |
| 475 | *ppSta = NULL; |
| 476 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 477 | pStaDs = dphLookupHashEntry(pMac, peerAddr, &peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 478 | if (pStaDs != NULL) |
| 479 | { |
| 480 | /* Trying to add context for already existing STA in IBSS */ |
| 481 | PELOGE(limLog(pMac, LOGE, FL("STA exists already "));) |
| 482 | limPrintMacAddr(pMac, peerAddr, LOGE); |
| 483 | return eSIR_FAILURE; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Assign an AID, delete context existing with that |
| 488 | * AID and then add an entry to hash table maintained |
| 489 | * by DPH module. |
| 490 | */ |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 491 | peerIdx = limAssignPeerIdx(pMac, psessionEntry); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 492 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 493 | pStaDs = dphGetHashEntry(pMac, peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 494 | if (pStaDs) |
| 495 | { |
| 496 | (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry); |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 497 | limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 500 | pStaDs = dphAddHashEntry(pMac, peerAddr, peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 501 | if (pStaDs == NULL) |
| 502 | { |
| 503 | // Could not add hash table entry |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 504 | PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for peerIdx/aid=%d MACaddr:"), peerIdx);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 505 | limPrintMacAddr(pMac, peerAddr, LOGE); |
| 506 | return eSIR_FAILURE; |
| 507 | } |
| 508 | |
| 509 | *ppSta = pStaDs; |
| 510 | return eSIR_SUCCESS; |
| 511 | } |
| 512 | |
| 513 | // send a status change notification |
| 514 | static void |
| 515 | ibss_status_chg_notify( |
| 516 | tpAniSirGlobal pMac, |
| 517 | tSirMacAddr peerAddr, |
| 518 | tANI_U16 staIndex, |
| 519 | tANI_U8 ucastSig, |
| 520 | tANI_U8 bcastSig, |
| 521 | tANI_U16 status, |
| 522 | tANI_U8 sessionId) |
| 523 | { |
| 524 | |
| 525 | tLimIbssPeerNode *peerNode; |
| 526 | tANI_U8 *beacon = NULL; |
| 527 | tANI_U16 bcnLen = 0; |
| 528 | |
| 529 | |
| 530 | peerNode = ibss_peer_find(pMac,peerAddr); |
| 531 | if(peerNode != NULL) |
| 532 | { |
| 533 | if(peerNode->beacon == NULL) peerNode->beaconLen = 0; |
| 534 | beacon = peerNode->beacon; |
| 535 | bcnLen = peerNode->beaconLen; |
| 536 | peerNode->beacon = NULL; |
| 537 | peerNode->beaconLen = 0; |
| 538 | } |
| 539 | |
| 540 | limSendSmeIBSSPeerInd(pMac,peerAddr, staIndex, ucastSig, bcastSig, |
| 541 | beacon, bcnLen, status, sessionId); |
| 542 | |
| 543 | if(beacon != NULL) |
| 544 | { |
| 545 | palFreeMemory(pMac->hHdd, beacon); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | |
| 550 | static void |
| 551 | ibss_bss_add( |
| 552 | tpAniSirGlobal pMac, |
| 553 | tpPESession psessionEntry) |
| 554 | { |
| 555 | tLimMlmStartReq mlmStartReq; |
| 556 | tANI_U32 cfg; |
| 557 | tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr; |
| 558 | tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon; |
| 559 | tANI_U8 numExtRates = 0; |
| 560 | |
| 561 | if ((pHdr == NULL) || (pBeacon == NULL)) |
| 562 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 563 | PELOGE(limLog(pMac, LOGE, FL("Unable to add BSS (no cached BSS info)"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 564 | return; |
| 565 | } |
| 566 | |
| 567 | palCopyMemory( pMac->hHdd, psessionEntry->bssId, pHdr->bssId, |
| 568 | sizeof(tSirMacAddr)); |
| 569 | |
| 570 | #if 0 |
| 571 | if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pHdr->bssId, sizeof(tSirMacAddr)) |
| 572 | != eSIR_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 573 | limLog(pMac, LOGP, FL("could not update BSSID at CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 574 | #endif //TO SUPPORT BT-AMP |
| 575 | |
| 576 | sirCopyMacAddr(pHdr->bssId,psessionEntry->bssId); |
| 577 | /* We need not use global Mac address since per seesion BSSID is available */ |
| 578 | //limSetBssid(pMac, pHdr->bssId); |
| 579 | |
| 580 | #if 0 |
| 581 | if (wlan_cfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &cfg) != eSIR_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 582 | limLog(pMac, LOGP, FL("Can't read beacon interval")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 583 | #endif //TO SUPPORT BT-AMP |
| 584 | /* Copy beacon interval from sessionTable */ |
| 585 | cfg = psessionEntry->beaconParams.beaconInterval; |
| 586 | if (cfg != pBeacon->beaconInterval) |
| 587 | #if 0 |
| 588 | if (cfgSetInt(pMac, WNI_CFG_BEACON_INTERVAL, pBeacon->beaconInterval) |
| 589 | != eSIR_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 590 | limLog(pMac, LOGP, FL("Can't update beacon interval")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 591 | #endif//TO SUPPORT BT-AMP |
| 592 | psessionEntry->beaconParams.beaconInterval = pBeacon->beaconInterval; |
| 593 | |
| 594 | /* This function ibss_bss_add (and hence the below code) is only called during ibss coalescing. We need to |
| 595 | * adapt to peer's capability with respect to short slot time. Changes have been made to limApplyConfiguration() |
| 596 | * so that the IBSS doesnt blindly start with short slot = 1. If IBSS start is part of coalescing then it will adapt |
| 597 | * to peer's short slot using code below. |
| 598 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 599 | /* If cfg is already set to current peer's capability then no need to set it again */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 600 | if (psessionEntry->shortSlotTimeSupported != pBeacon->capabilityInfo.shortSlotTime) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 601 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 602 | psessionEntry->shortSlotTimeSupported = pBeacon->capabilityInfo.shortSlotTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 603 | } |
| 604 | palCopyMemory( pMac->hHdd, |
| 605 | (tANI_U8 *) &psessionEntry->pLimStartBssReq->operationalRateSet, |
| 606 | (tANI_U8 *) &pBeacon->supportedRates, |
| 607 | pBeacon->supportedRates.numRates); |
| 608 | |
| 609 | #if 0 |
| 610 | if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, |
| 611 | (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate, |
| 612 | pMac->lim.gpLimStartBssReq->operationalRateSet.numRates) |
| 613 | != eSIR_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 614 | limLog(pMac, LOGP, FL("could not update OperRateset at CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 615 | #endif //TO SUPPORT BT-AMP |
| 616 | |
| 617 | /** |
| 618 | * WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET CFG needs to be reset, when |
| 619 | * there is no extended rate IE present in beacon. This is especially important when |
| 620 | * supportedRateSet IE contains all the extended rates as well and STA decides to coalesce. |
| 621 | * In this IBSS coalescing scenario LIM will tear down the BSS and Add a new one. So LIM needs to |
| 622 | * reset this CFG, just in case CSR originally had set this CFG when IBSS was started from the local profile. |
| 623 | * If IBSS was started by CSR from the BssDescription, then it would reset this CFG before StartBss is issued. |
| 624 | * The idea is that the count of OpRateSet and ExtendedOpRateSet rates should not be more than 12. |
| 625 | */ |
| 626 | |
| 627 | if(pBeacon->extendedRatesPresent) |
| 628 | numExtRates = pBeacon->extendedRates.numRates; |
| 629 | if (cfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 630 | (tANI_U8 *) &pBeacon->extendedRates.rate, numExtRates) != eSIR_SUCCESS) |
| 631 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 632 | limLog(pMac, LOGP, FL("could not update ExtendedOperRateset at CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 633 | return; |
| 634 | } |
| 635 | |
| 636 | |
| 637 | /* |
| 638 | * Each IBSS node will advertise its own HT Capabilities instead of adapting to the Peer's capabilities |
| 639 | * If we don't do this then IBSS may not go back to full capabilities when the STA with lower capabilities |
| 640 | * leaves the IBSS. e.g. when non-CB STA joins an IBSS and then leaves, the IBSS will be stuck at non-CB mode |
| 641 | * even though all the nodes are capable of doing CB. |
| 642 | * so it is decided to leave the self HT capabilties intact. This may change if some issues are found in interop. |
| 643 | */ |
| 644 | palZeroMemory(pMac->hHdd, (void *) &mlmStartReq, sizeof(mlmStartReq)); |
| 645 | |
| 646 | palCopyMemory(pMac->hHdd, mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr)); |
| 647 | mlmStartReq.rateSet.numRates = psessionEntry->pLimStartBssReq->operationalRateSet.numRates; |
| 648 | palCopyMemory(pMac->hHdd, &mlmStartReq.rateSet.rate[0], |
| 649 | &psessionEntry->pLimStartBssReq->operationalRateSet.rate[0], |
| 650 | mlmStartReq.rateSet.numRates); |
| 651 | mlmStartReq.bssType = eSIR_IBSS_MODE; |
| 652 | mlmStartReq.beaconPeriod = pBeacon->beaconInterval; |
| 653 | mlmStartReq.nwType = psessionEntry->pLimStartBssReq->nwType; //psessionEntry->nwType is also OK???? |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 654 | mlmStartReq.htCapable = psessionEntry->htCapability; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 655 | mlmStartReq.htOperMode = pMac->lim.gHTOperMode; |
| 656 | mlmStartReq.dualCTSProtection = pMac->lim.gHTDualCTSProtection; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 657 | mlmStartReq.txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 658 | |
| 659 | #if 0 |
| 660 | if (wlan_cfgGetInt(pMac, WNI_CFG_CURRENT_CHANNEL, &cfg) != eSIR_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 661 | limLog(pMac, LOGP, FL("CurrentChannel CFG get fialed!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 662 | #endif |
| 663 | |
| 664 | //mlmStartReq.channelNumber = (tSirMacChanNum) cfg; |
| 665 | |
| 666 | /* reading the channel num from session Table */ |
| 667 | mlmStartReq.channelNumber = psessionEntry->currentOperChannel; |
| 668 | |
| 669 | mlmStartReq.cbMode = psessionEntry->pLimStartBssReq->cbMode; |
| 670 | |
| 671 | // Copy the SSID for RxP filtering based on SSID. |
| 672 | palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmStartReq.ssId, |
| 673 | (tANI_U8 *) &psessionEntry->pLimStartBssReq->ssId, |
| 674 | psessionEntry->pLimStartBssReq->ssId.length + 1); |
| 675 | |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 676 | PELOG1(limLog(pMac, LOG1, FL("invoking ADD_BSS as part of coalescing!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 677 | if (limMlmAddBss(pMac, &mlmStartReq,psessionEntry) != eSIR_SME_SUCCESS) |
| 678 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 679 | PELOGE(limLog(pMac, LOGE, FL("AddBss failure"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 680 | return; |
| 681 | } |
| 682 | |
| 683 | // Update fields in Beacon |
| 684 | if (schSetFixedBeaconFields(pMac,psessionEntry) != eSIR_SUCCESS) |
| 685 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 686 | PELOGE(limLog(pMac, LOGE, FL("*** Unable to set fixed Beacon fields ***"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 687 | return; |
| 688 | } |
| 689 | |
| 690 | } |
| 691 | |
| 692 | |
| 693 | |
| 694 | /* delete the current BSS */ |
| 695 | static void |
| 696 | ibss_bss_delete( |
| 697 | tpAniSirGlobal pMac, |
| 698 | tpPESession psessionEntry) |
| 699 | { |
| 700 | tSirRetStatus status; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 701 | PELOGW(limLog(pMac, LOGW, FL("Initiating IBSS Delete BSS"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 702 | if (psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) |
| 703 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 704 | limLog(pMac, LOGW, FL("Incorrect LIM MLM state for delBss (%d)"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 705 | psessionEntry->limMlmState); |
| 706 | return; |
| 707 | } |
| 708 | status = limDelBss(pMac, NULL, psessionEntry->bssIdx, psessionEntry); |
| 709 | if (status != eSIR_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 710 | PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | /** |
| 714 | * limIbssInit |
| 715 | * |
| 716 | *FUNCTION: |
| 717 | * This function is called while starting an IBSS |
| 718 | * to initialize list used to maintain IBSS peers. |
| 719 | * |
| 720 | *LOGIC: |
| 721 | * |
| 722 | *ASSUMPTIONS: |
| 723 | * |
| 724 | *NOTE: |
| 725 | * |
| 726 | * @param pMac - Pointer to Global MAC structure |
| 727 | * @return None |
| 728 | */ |
| 729 | |
| 730 | void |
| 731 | limIbssInit( |
| 732 | tpAniSirGlobal pMac) |
| 733 | { |
| 734 | //pMac->lim.gLimIbssActive = 0; |
| 735 | pMac->lim.gLimIbssCoalescingHappened = 0; |
| 736 | pMac->lim.gLimIbssPeerList = NULL; |
| 737 | pMac->lim.gLimNumIbssPeers = 0; |
| 738 | |
| 739 | // ibss info - params for which ibss to join while coalescing |
| 740 | palZeroMemory(pMac->hHdd, &pMac->lim.ibssInfo, sizeof(tAniSirLimIbss)); |
| 741 | } /*** end limIbssInit() ***/ |
| 742 | |
| 743 | /** |
| 744 | * limIbssDeleteAllPeers |
| 745 | * |
| 746 | *FUNCTION: |
| 747 | * This function is called to delete all peers. |
| 748 | * |
| 749 | *LOGIC: |
| 750 | * |
| 751 | *ASSUMPTIONS: |
| 752 | * |
| 753 | *NOTE: |
| 754 | * |
| 755 | * @param pMac - Pointer to Global MAC structure |
| 756 | * @return None |
| 757 | */ |
| 758 | |
| 759 | void limIbssDeleteAllPeers( tpAniSirGlobal pMac ,tpPESession psessionEntry) |
| 760 | { |
| 761 | tLimIbssPeerNode *pCurrNode, *pTempNode; |
| 762 | tpDphHashNode pStaDs; |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 763 | tANI_U16 peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 764 | |
| 765 | pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList; |
| 766 | |
| 767 | while (pCurrNode != NULL) |
| 768 | { |
| 769 | if (!pMac->lim.gLimNumIbssPeers) |
| 770 | { |
| 771 | limLog(pMac, LOGP, |
| 772 | FL("Number of peers in the list is zero and node present")); |
| 773 | return; |
| 774 | } |
| 775 | /* Delete the dph entry for the station |
| 776 | * Since it is called to remove all peers, just delete from dph, |
| 777 | * no need to do any beacon related params i.e., dont call limDeleteDphHashEntry |
| 778 | */ |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 779 | pStaDs = dphLookupHashEntry(pMac, pCurrNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 780 | if( pStaDs ) |
| 781 | { |
| 782 | |
| 783 | ibss_status_chg_notify( pMac, pCurrNode->peerMacAddr, pStaDs->staIndex, |
| 784 | pStaDs->ucUcastSig, pStaDs->ucBcastSig, |
| 785 | eWNI_SME_IBSS_PEER_DEPARTED_IND, psessionEntry->smeSessionId ); |
Ravi Joshi | 492be3c | 2013-05-16 19:20:00 -0700 | [diff] [blame^] | 786 | limReleasePeerIdx(pMac, peerIdx, psessionEntry); |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 787 | dphDeleteHashEntry(pMac, pStaDs->staAddr, peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | pTempNode = pCurrNode->next; |
| 791 | |
| 792 | /* TODO :Sessionize this code */ |
| 793 | /* Fix CR 227642: PeerList should point to the next node since the current node is being |
| 794 | * freed in the next line. In ibss_peerfind in ibss_status_chg_notify above, we use this |
| 795 | * peer list to find the next peer. So this list needs to be updated with the no of peers left |
| 796 | * after each iteration in this while loop since one by one peers are deleted (freed) in this |
| 797 | * loop causing the lim.gLimIbssPeerList to point to some freed memory. |
| 798 | */ |
| 799 | pMac->lim.gLimIbssPeerList = pTempNode; |
| 800 | |
| 801 | if(pCurrNode->beacon) |
| 802 | { |
| 803 | palFreeMemory(pMac->hHdd, pCurrNode->beacon); |
| 804 | } |
| 805 | palFreeMemory( pMac->hHdd, (tANI_U8 *) pCurrNode); |
| 806 | if (pMac->lim.gLimNumIbssPeers > 0) // be paranoid |
| 807 | pMac->lim.gLimNumIbssPeers--; |
| 808 | pCurrNode = pTempNode; |
| 809 | } |
| 810 | |
| 811 | if (pMac->lim.gLimNumIbssPeers) |
| 812 | limLog(pMac, LOGP, FL("Number of peers[%d] in the list is non-zero"), |
| 813 | pMac->lim.gLimNumIbssPeers); |
| 814 | |
| 815 | pMac->lim.gLimNumIbssPeers = 0; |
| 816 | pMac->lim.gLimIbssPeerList = NULL; |
| 817 | |
| 818 | } |
| 819 | /** |
| 820 | * limIbssDelete |
| 821 | * |
| 822 | *FUNCTION: |
| 823 | * This function is called while tearing down an IBSS. |
| 824 | * |
| 825 | *LOGIC: |
| 826 | * |
| 827 | *ASSUMPTIONS: |
| 828 | * |
| 829 | *NOTE: |
| 830 | * |
| 831 | * @param pMac - Pointer to Global MAC structure |
| 832 | * @return None |
| 833 | */ |
| 834 | |
| 835 | void |
| 836 | limIbssDelete( |
| 837 | tpAniSirGlobal pMac,tpPESession psessionEntry) |
| 838 | { |
| 839 | limIbssDeleteAllPeers(pMac,psessionEntry); |
| 840 | |
| 841 | ibss_coalesce_free(pMac); |
| 842 | } /*** end limIbssDelete() ***/ |
| 843 | |
| 844 | /** Commenting this Code as from no where it is being invoked */ |
| 845 | #if 0 |
| 846 | /** |
| 847 | * limIbssPeerDelete |
| 848 | * |
| 849 | *FUNCTION: |
| 850 | * This may be called on a STA in IBSS to delete a peer |
| 851 | * from the list. |
| 852 | * |
| 853 | *LOGIC: |
| 854 | * |
| 855 | *ASSUMPTIONS: |
| 856 | * |
| 857 | *NOTE: |
| 858 | * |
| 859 | * @param pMac - Pointer to Global MAC structure |
| 860 | * @param peerMacAddr - MAC address of the peer STA that |
| 861 | * need to be deleted from peer list. |
| 862 | * |
| 863 | * @return None |
| 864 | */ |
| 865 | |
| 866 | void |
| 867 | limIbssPeerDelete(tpAniSirGlobal pMac, tSirMacAddr macAddr) |
| 868 | { |
| 869 | tLimIbssPeerNode *pPrevNode, *pTempNode; |
| 870 | |
| 871 | pTempNode = pPrevNode = pMac->lim.gLimIbssPeerList; |
| 872 | |
| 873 | if (pTempNode == NULL) |
| 874 | return; |
| 875 | |
| 876 | while (pTempNode != NULL) |
| 877 | { |
| 878 | if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr, |
| 879 | (tANI_U8 *) &pTempNode->peerMacAddr, |
| 880 | sizeof(tSirMacAddr)) ) |
| 881 | { |
| 882 | // Found node to be deleted |
| 883 | if (pMac->lim.gLimIbssPeerList == pTempNode) /** First Node to be deleted*/ |
| 884 | pMac->lim.gLimIbssPeerList = pTempNode->next; |
| 885 | else |
| 886 | pPrevNode->next = pTempNode->next; |
| 887 | |
| 888 | if(pTempNode->beacon) |
| 889 | { |
| 890 | palFreeMemory(pMac->hHdd, pTempNode->beacon); |
| 891 | pTempNode->beacon = NULL; |
| 892 | } |
| 893 | palFreeMemory( pMac->hHdd, (tANI_U8 *) pTempNode); |
| 894 | pMac->lim.gLimNumIbssPeers--; |
| 895 | return; |
| 896 | } |
| 897 | |
| 898 | pPrevNode = pTempNode; |
| 899 | pTempNode = pTempNode->next; |
| 900 | } |
| 901 | |
| 902 | // Should not be here |
| 903 | PELOGE(limLog(pMac, LOGE, FL("peer not found in the list, addr= "));) |
| 904 | limPrintMacAddr(pMac, macAddr, LOGE); |
| 905 | } /*** end limIbssPeerDelete() ***/ |
| 906 | |
| 907 | #endif |
| 908 | |
| 909 | |
| 910 | /** ------------------------------------------------------------- |
| 911 | \fn limIbssSetProtection |
| 912 | \brief Decides all the protection related information. |
| 913 | \ |
| 914 | \param tpAniSirGlobal pMac |
| 915 | \param tSirMacAddr peerMacAddr |
| 916 | \param tpUpdateBeaconParams pBeaconParams |
| 917 | \return None |
| 918 | -------------------------------------------------------------*/ |
| 919 | static void |
| 920 | limIbssSetProtection(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry) |
| 921 | { |
| 922 | |
| 923 | if(!pMac->lim.cfgProtection.fromllb) |
| 924 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 925 | PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 926 | return; |
| 927 | } |
| 928 | |
| 929 | if (enable) |
| 930 | { |
| 931 | psessionEntry->gLim11bParams.protectionEnabled = true; |
| 932 | if(false == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/) |
| 933 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 934 | PELOGE(limLog(pMac, LOGE, FL("=> IBSS: Enable Protection "));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 935 | pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true; |
| 936 | pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED; |
| 937 | } |
| 938 | } |
| 939 | else if (true == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/) |
| 940 | { |
| 941 | psessionEntry->gLim11bParams.protectionEnabled = false; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 942 | PELOGE(limLog(pMac, LOGE, FL("===> IBSS: Disable protection "));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 943 | pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false; |
| 944 | pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED; |
| 945 | } |
| 946 | return; |
| 947 | } |
| 948 | |
| 949 | |
| 950 | /** ------------------------------------------------------------- |
| 951 | \fn limIbssUpdateProtectionParams |
| 952 | \brief Decides all the protection related information. |
| 953 | \ |
| 954 | \param tpAniSirGlobal pMac |
| 955 | \param tSirMacAddr peerMacAddr |
| 956 | \param tpUpdateBeaconParams pBeaconParams |
| 957 | \return None |
| 958 | -------------------------------------------------------------*/ |
| 959 | static void |
| 960 | limIbssUpdateProtectionParams(tpAniSirGlobal pMac, |
| 961 | tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType, |
| 962 | tpPESession psessionEntry) |
| 963 | { |
| 964 | tANI_U32 i; |
| 965 | |
| 966 | PELOG1(limLog(pMac,LOG1, FL("A STA is associated:")); |
| 967 | limLog(pMac,LOG1, FL("Addr : ")); |
| 968 | limPrintMacAddr(pMac, peerMacAddr, LOG1);) |
| 969 | |
| 970 | for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++) |
| 971 | { |
| 972 | if (pMac->lim.protStaCache[i].active) |
| 973 | { |
| 974 | PELOG1(limLog(pMac, LOG1, FL("Addr: "));) |
| 975 | PELOG1(limPrintMacAddr(pMac, pMac->lim.protStaCache[i].addr, LOG1);) |
| 976 | |
| 977 | if (palEqualMemory( pMac->hHdd, |
| 978 | pMac->lim.protStaCache[i].addr, |
| 979 | peerMacAddr, sizeof(tSirMacAddr))) |
| 980 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 981 | PELOG1(limLog(pMac, LOG1, FL("matching cache entry at %d already active."), i);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 982 | return; |
| 983 | } |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++) |
| 988 | { |
| 989 | if (!pMac->lim.protStaCache[i].active) |
| 990 | break; |
| 991 | } |
| 992 | |
| 993 | if (i >= LIM_PROT_STA_CACHE_SIZE) |
| 994 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 995 | PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 996 | return; |
| 997 | } |
| 998 | |
| 999 | palCopyMemory( pMac->hHdd, pMac->lim.protStaCache[i].addr, |
| 1000 | peerMacAddr, |
| 1001 | sizeof(tSirMacAddr)); |
| 1002 | |
| 1003 | pMac->lim.protStaCache[i].protStaCacheType = protStaCacheType; |
| 1004 | pMac->lim.protStaCache[i].active = true; |
| 1005 | if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType) |
| 1006 | { |
| 1007 | psessionEntry->gLim11bParams.numSta++; |
| 1008 | } |
| 1009 | else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType) |
| 1010 | { |
| 1011 | psessionEntry->gLim11gParams.numSta++; |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | |
| 1016 | /** ------------------------------------------------------------- |
| 1017 | \fn limIbssDecideProtection |
| 1018 | \brief Decides all the protection related information. |
| 1019 | \ |
| 1020 | \param tpAniSirGlobal pMac |
| 1021 | \param tSirMacAddr peerMacAddr |
| 1022 | \param tpUpdateBeaconParams pBeaconParams |
| 1023 | \return None |
| 1024 | -------------------------------------------------------------*/ |
| 1025 | static void |
| 1026 | limIbssDecideProtection(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry) |
| 1027 | { |
| 1028 | tSirRFBand rfBand = SIR_BAND_UNKNOWN; |
| 1029 | tANI_U32 phyMode; |
| 1030 | tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID; |
| 1031 | |
| 1032 | pBeaconParams->paramChangeBitmap = 0; |
| 1033 | |
| 1034 | if(NULL == pStaDs) |
| 1035 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1036 | PELOGE(limLog(pMac, LOGE, FL("pStaDs is NULL"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1037 | return; |
| 1038 | } |
| 1039 | |
| 1040 | limGetRfBand(pMac, &rfBand, psessionEntry); |
| 1041 | if(SIR_BAND_2_4_GHZ== rfBand) |
| 1042 | { |
| 1043 | limGetPhyMode(pMac, &phyMode, psessionEntry); |
| 1044 | |
| 1045 | //We are 11G or 11n. Check if we need protection from 11b Stations. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1046 | if ((phyMode == WNI_CFG_PHY_MODE_11G) || (psessionEntry->htCapability)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1047 | { |
| 1048 | /* As we found in the past, it is possible that a 11n STA sends |
| 1049 | * Beacon with HT IE but not ERP IE. So the absense of ERP IE |
| 1050 | * in the Beacon is not enough to conclude that STA is 11b. |
| 1051 | */ |
| 1052 | if ((pStaDs->erpEnabled == eHAL_CLEAR) && |
| 1053 | (!pStaDs->mlmStaContext.htCapability)) |
| 1054 | { |
| 1055 | protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1056 | PELOGE(limLog(pMac, LOGE, FL("Enable protection from 11B"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1057 | limIbssSetProtection(pMac, true, pBeaconParams,psessionEntry); |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | limIbssUpdateProtectionParams(pMac, pStaDs->staAddr, protStaCacheType, psessionEntry); |
| 1062 | return; |
| 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | /** |
| 1067 | * limIbssStaAdd() |
| 1068 | * |
| 1069 | *FUNCTION: |
| 1070 | * This function is called to add an STA context in IBSS role |
| 1071 | * whenever a data frame is received from/for a STA that failed |
| 1072 | * hash lookup at DPH. |
| 1073 | * |
| 1074 | *LOGIC: |
| 1075 | * |
| 1076 | *ASSUMPTIONS: |
| 1077 | * NA |
| 1078 | * |
| 1079 | *NOTE: |
| 1080 | * NA |
| 1081 | * |
| 1082 | * @param pMac Pointer to Global MAC structure |
| 1083 | * @param peerAdddr MAC address of the peer being added |
| 1084 | * @return retCode Indicates success or failure return code |
| 1085 | * @return |
| 1086 | */ |
| 1087 | |
| 1088 | tSirRetStatus |
| 1089 | limIbssStaAdd( |
| 1090 | tpAniSirGlobal pMac, |
| 1091 | void *pBody, |
| 1092 | tpPESession psessionEntry) |
| 1093 | { |
| 1094 | tSirRetStatus retCode = eSIR_SUCCESS; |
| 1095 | tpDphHashNode pStaDs; |
| 1096 | tLimIbssPeerNode *pPeerNode; |
| 1097 | tLimMlmStates prevState; |
| 1098 | tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody; |
| 1099 | tUpdateBeaconParams beaconParams; |
| 1100 | |
| 1101 | palZeroMemory( pMac->hHdd, (tANI_U8 *) &beaconParams, sizeof(tUpdateBeaconParams)); |
| 1102 | |
| 1103 | if (pBody == 0) |
| 1104 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1105 | PELOGE(limLog(pMac, LOGE, FL("Invalid IBSS AddSta"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1106 | return eSIR_FAILURE; |
| 1107 | } |
| 1108 | |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1109 | PELOGE(limLog(pMac, LOGE, FL("Rx Add-Ibss-Sta for MAC:"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1110 | limPrintMacAddr(pMac, *pPeerAddr, LOGE); |
| 1111 | |
| 1112 | pPeerNode = ibss_peer_find(pMac, *pPeerAddr); |
Jeff Johnson | 8db48ea | 2013-04-08 10:15:38 -0700 | [diff] [blame] | 1113 | if (NULL != pPeerNode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1114 | { |
Jeff Johnson | 8db48ea | 2013-04-08 10:15:38 -0700 | [diff] [blame] | 1115 | retCode = ibss_dph_entry_add(pMac, *pPeerAddr, &pStaDs, psessionEntry); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1116 | if (eSIR_SUCCESS == retCode) |
| 1117 | { |
| 1118 | prevState = pStaDs->mlmStaContext.mlmState; |
| 1119 | pStaDs->erpEnabled = pPeerNode->erpIePresent; |
| 1120 | |
Jeff Johnson | 8db48ea | 2013-04-08 10:15:38 -0700 | [diff] [blame] | 1121 | ibss_sta_info_update(pMac, pStaDs, pPeerNode, psessionEntry); |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1122 | PELOGW(limLog(pMac, LOGW, FL("initiating ADD STA for the IBSS peer."));) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 1123 | retCode = limAddSta(pMac, pStaDs, false, psessionEntry); |
Jeff Johnson | 8db48ea | 2013-04-08 10:15:38 -0700 | [diff] [blame] | 1124 | if (retCode != eSIR_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1125 | { |
Jeff Johnson | 8db48ea | 2013-04-08 10:15:38 -0700 | [diff] [blame] | 1126 | PELOGE(limLog(pMac, LOGE, FL("ibss-sta-add failed (reason %x)"), |
| 1127 | retCode);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1128 | limPrintMacAddr(pMac, *pPeerAddr, LOGE); |
Jeff Johnson | 8db48ea | 2013-04-08 10:15:38 -0700 | [diff] [blame] | 1129 | pStaDs->mlmStaContext.mlmState = prevState; |
| 1130 | dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, |
| 1131 | &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1132 | } |
| 1133 | else |
| 1134 | { |
| 1135 | if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE) |
| 1136 | limIbssDecideProtection(pMac, pStaDs, &beaconParams , psessionEntry); |
| 1137 | |
| 1138 | if(beaconParams.paramChangeBitmap) |
| 1139 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1140 | PELOGE(limLog(pMac, LOGE, FL("---> Update Beacon Params "));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1141 | schSetFixedBeaconFields(pMac, psessionEntry); |
| 1142 | limSendBeaconParams(pMac, &beaconParams, psessionEntry ); |
| 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | else |
| 1147 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1148 | PELOGE(limLog(pMac, LOGE, FL("hashTblAdd failed (reason %x)"), retCode);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1149 | limPrintMacAddr(pMac, *pPeerAddr, LOGE); |
| 1150 | } |
| 1151 | } |
| 1152 | else |
| 1153 | { |
| 1154 | retCode = eSIR_FAILURE; |
| 1155 | } |
| 1156 | |
| 1157 | return retCode; |
| 1158 | } |
| 1159 | |
| 1160 | /* handle the response from HAL for an ADD STA request */ |
| 1161 | tSirRetStatus |
| 1162 | limIbssAddStaRsp( |
| 1163 | tpAniSirGlobal pMac, |
| 1164 | void *msg,tpPESession psessionEntry) |
| 1165 | { |
| 1166 | tpDphHashNode pStaDs; |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1167 | tANI_U16 peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1168 | tpAddStaParams pAddStaParams = (tpAddStaParams) msg; |
| 1169 | |
| 1170 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
| 1171 | if (pAddStaParams == NULL) |
| 1172 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1173 | PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP with no body!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1174 | return eSIR_FAILURE; |
| 1175 | } |
| 1176 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1177 | pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1178 | if (pStaDs == NULL) |
| 1179 | { |
| 1180 | PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP for unknown MAC addr "));) |
| 1181 | limPrintMacAddr(pMac, pAddStaParams->staMac, LOGE); |
| 1182 | palFreeMemory( pMac->hHdd, (void *) pAddStaParams ); |
| 1183 | return eSIR_FAILURE; |
| 1184 | } |
| 1185 | |
| 1186 | if (pAddStaParams->status != eHAL_STATUS_SUCCESS) |
| 1187 | { |
| 1188 | PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP error (%x) "), pAddStaParams->status);) |
| 1189 | limPrintMacAddr(pMac, pAddStaParams->staMac, LOGE); |
| 1190 | palFreeMemory( pMac->hHdd, (void *) pAddStaParams ); |
| 1191 | return eSIR_FAILURE; |
| 1192 | } |
| 1193 | |
| 1194 | pStaDs->bssId = pAddStaParams->bssIdx; |
| 1195 | pStaDs->staIndex = pAddStaParams->staIdx; |
| 1196 | pStaDs->ucUcastSig = pAddStaParams->ucUcastSig; |
| 1197 | pStaDs->ucBcastSig = pAddStaParams->ucBcastSig; |
| 1198 | pStaDs->valid = 1; |
| 1199 | pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE; |
| 1200 | |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1201 | PELOGW(limLog(pMac, LOGW, FL("IBSS: sending IBSS_NEW_PEER msg to SME!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1202 | |
| 1203 | ibss_status_chg_notify(pMac, pAddStaParams->staMac, pStaDs->staIndex, |
| 1204 | pStaDs->ucUcastSig, pStaDs->ucBcastSig, |
| 1205 | eWNI_SME_IBSS_NEW_PEER_IND, |
| 1206 | psessionEntry->smeSessionId); |
| 1207 | palFreeMemory( pMac->hHdd, (void *) pAddStaParams ); |
| 1208 | |
| 1209 | return eSIR_SUCCESS; |
| 1210 | } |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | void limIbssDelBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg,tpPESession psessionEntry) |
| 1215 | { |
| 1216 | tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg; |
| 1217 | |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1218 | PELOGW(limLog(pMac, LOGW, FL("IBSS: DEL_BSS_RSP Rcvd during coalescing!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1219 | |
| 1220 | if (pDelBss == NULL) |
| 1221 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1222 | PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) with no body!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1223 | goto end; |
| 1224 | } |
| 1225 | |
| 1226 | if (pDelBss->status != eHAL_STATUS_SUCCESS) |
| 1227 | { |
| 1228 | limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) error (%x) Bss %d "), |
| 1229 | pDelBss->status, pDelBss->bssIdx); |
| 1230 | goto end; |
| 1231 | } |
| 1232 | //Delete peer entries. |
| 1233 | limIbssDeleteAllPeers(pMac,psessionEntry); |
| 1234 | |
| 1235 | /* add the new bss */ |
| 1236 | ibss_bss_add(pMac,psessionEntry); |
| 1237 | |
| 1238 | end: |
| 1239 | if(pDelBss != NULL) |
| 1240 | palFreeMemory( pMac->hHdd, (void *) pDelBss ); |
| 1241 | } |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | void limIbssAddBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg, tpPESession pSessionEntry) |
| 1246 | { |
| 1247 | tANI_U8 infoLen; |
| 1248 | tSirSmeNewBssInfo newBssInfo; |
| 1249 | |
| 1250 | tpAddBssParams pAddBss = (tpAddBssParams) msg; |
| 1251 | |
| 1252 | tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr; |
| 1253 | tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon; |
| 1254 | |
| 1255 | if ((pHdr == NULL) || (pBeacon == NULL)) |
| 1256 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1257 | PELOGE(limLog(pMac, LOGE, FL("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1258 | goto end; |
| 1259 | } |
| 1260 | |
| 1261 | // Inform Host of IBSS coalescing |
| 1262 | infoLen = sizeof(tSirMacAddr) + sizeof(tSirMacChanNum) + |
| 1263 | sizeof(tANI_U8) + pBeacon->ssId.length + 1; |
| 1264 | |
| 1265 | palZeroMemory(pMac->hHdd, (void *) &newBssInfo, sizeof(newBssInfo)); |
| 1266 | palCopyMemory( pMac->hHdd, newBssInfo.bssId, pHdr->bssId, sizeof(tSirMacAddr)); |
| 1267 | newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel; |
| 1268 | palCopyMemory( pMac->hHdd, (tANI_U8 *) &newBssInfo.ssId, |
| 1269 | (tANI_U8 *) &pBeacon->ssId, pBeacon->ssId.length + 1); |
| 1270 | |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1271 | PELOGW(limLog(pMac, LOGW, FL("Sending JOINED_NEW_BSS notification to SME."));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1272 | |
| 1273 | limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_JOINED_NEW_BSS, |
| 1274 | (tANI_U32 *) &newBssInfo, |
| 1275 | infoLen,pSessionEntry->smeSessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1276 | { |
| 1277 | //Configure beacon and send beacons to HAL |
| 1278 | limSendBeaconInd(pMac, pSessionEntry); |
| 1279 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1280 | |
Jeff Johnson | 3c3e178 | 2013-02-27 10:48:42 -0800 | [diff] [blame] | 1281 | end: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1282 | ibss_coalesce_free(pMac); |
| 1283 | } |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 | void |
| 1288 | limIbssDelBssRsp( |
| 1289 | tpAniSirGlobal pMac, |
| 1290 | void *msg,tpPESession psessionEntry) |
| 1291 | { |
| 1292 | tSirResultCodes rc = eSIR_SME_SUCCESS; |
| 1293 | tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg; |
| 1294 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 1295 | |
| 1296 | |
| 1297 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
| 1298 | if (pDelBss == NULL) |
| 1299 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1300 | PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP with no body!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1301 | rc = eSIR_SME_REFUSED; |
| 1302 | goto end; |
| 1303 | } |
| 1304 | |
| 1305 | if((psessionEntry = peFindSessionBySessionId(pMac,pDelBss->sessionId))==NULL) |
| 1306 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1307 | limLog(pMac, LOGP,FL("Session Does not exist for given sessionID")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1308 | goto end; |
| 1309 | } |
| 1310 | |
| 1311 | |
| 1312 | /* |
| 1313 | * If delBss was issued as part of IBSS Coalescing, gLimIbssCoalescingHappened flag will be true. |
| 1314 | * BSS has to be added again in this scenario, so this case needs to be handled separately. |
| 1315 | * If delBss was issued as a result of trigger from SME_STOP_BSS Request, then limSme state changes to |
| 1316 | * 'IDLE' and gLimIbssCoalescingHappened flag will be false. In this case STOP BSS RSP has to be sent to SME. |
| 1317 | */ |
| 1318 | if(true == pMac->lim.gLimIbssCoalescingHappened) |
| 1319 | { |
| 1320 | |
| 1321 | limIbssDelBssRspWhenCoalescing(pMac,msg,psessionEntry); |
| 1322 | return; |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | |
| 1327 | if (pDelBss->status != eHAL_STATUS_SUCCESS) |
| 1328 | { |
| 1329 | PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP error (%x) Bss %d "), |
| 1330 | pDelBss->status, pDelBss->bssIdx);) |
| 1331 | rc = eSIR_SME_STOP_BSS_FAILURE; |
| 1332 | goto end; |
| 1333 | } |
| 1334 | |
| 1335 | |
| 1336 | |
| 1337 | if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid, |
| 1338 | psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS) |
| 1339 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1340 | PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP setLinkState failed"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1341 | rc = eSIR_SME_REFUSED; |
| 1342 | goto end; |
| 1343 | } |
| 1344 | |
| 1345 | dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable); |
| 1346 | limDeletePreAuthList(pMac); |
| 1347 | |
| 1348 | limIbssDelete(pMac,psessionEntry); |
| 1349 | psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE; |
| 1350 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1351 | MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1352 | |
| 1353 | psessionEntry->limSystemRole = eLIM_STA_ROLE; |
| 1354 | |
| 1355 | /* Change the short slot operating mode to Default (which is 1 for now) so that when IBSS starts next time with Libra |
| 1356 | * as originator, it picks up the default. This enables us to remove hard coding of short slot = 1 from limApplyConfiguration |
| 1357 | */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1358 | psessionEntry->shortSlotTimeSupported = WNI_CFG_SHORT_SLOT_TIME_STADEF; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1359 | |
| 1360 | end: |
| 1361 | if(pDelBss != NULL) |
| 1362 | palFreeMemory( pMac->hHdd, (void *) pDelBss ); |
| 1363 | /* Delete PE session once BSS is deleted */ |
| 1364 | if (NULL != psessionEntry) { |
| 1365 | limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, rc,psessionEntry->smeSessionId,psessionEntry->transactionId); |
| 1366 | peDeleteSession(pMac, psessionEntry); |
| 1367 | psessionEntry = NULL; |
| 1368 | } |
| 1369 | } |
| 1370 | |
| 1371 | /** |
| 1372 | * limIbssCoalesce() |
| 1373 | * |
| 1374 | *FUNCTION: |
| 1375 | * This function is called upon receiving Beacon/Probe Response |
| 1376 | * while operating in IBSS mode. |
| 1377 | * |
| 1378 | *LOGIC: |
| 1379 | * |
| 1380 | *ASSUMPTIONS: |
| 1381 | * |
| 1382 | *NOTE: |
| 1383 | * |
| 1384 | * @param pMac - Pointer to Global MAC structure |
| 1385 | * @param pBeacon - Parsed Beacon Frame structure |
| 1386 | * @param pBD - Pointer to received BD |
| 1387 | * |
| 1388 | * @return Status whether to process or ignore received Beacon Frame |
| 1389 | */ |
| 1390 | |
| 1391 | tSirRetStatus |
| 1392 | limIbssCoalesce( |
| 1393 | tpAniSirGlobal pMac, |
| 1394 | tpSirMacMgmtHdr pHdr, |
| 1395 | tpSchBeaconStruct pBeacon, |
| 1396 | tANI_U8 *pIEs, |
| 1397 | tANI_U32 ieLen, |
| 1398 | tANI_U16 fTsfLater, |
| 1399 | tpPESession psessionEntry) |
| 1400 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1401 | tANI_U16 peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1402 | tSirMacAddr currentBssId; |
| 1403 | tLimIbssPeerNode *pPeerNode; |
| 1404 | tpDphHashNode pStaDs; |
| 1405 | tUpdateBeaconParams beaconParams; |
| 1406 | |
| 1407 | palZeroMemory( pMac->hHdd, (tANI_U8 *) &beaconParams, sizeof(tUpdateBeaconParams)); |
| 1408 | |
| 1409 | sirCopyMacAddr(currentBssId,psessionEntry->bssId); |
| 1410 | |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 1411 | limLog(pMac, LOG1, FL("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :" MAC_ADDRESS_STR ), |
| 1412 | MAC_ADDR_ARRAY(currentBssId), MAC_ADDR_ARRAY(pHdr->bssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1413 | /* Check for IBSS Coalescing only if Beacon is from different BSS */ |
| 1414 | if ( !palEqualMemory( pMac->hHdd, currentBssId, pHdr->bssId, sizeof( tSirMacAddr ) ) ) |
| 1415 | { |
| 1416 | if (! fTsfLater) // No Coalescing happened. |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 1417 | { |
| 1418 | PELOGW(limLog(pMac, LOGW, FL("No Coalescing happened"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1419 | return eSIR_LIM_IGNORE_BEACON; |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 1420 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1421 | /* |
| 1422 | * IBSS Coalescing happened. |
| 1423 | * save the received beacon, and delete the current BSS. The rest of the |
| 1424 | * processing will be done in the delBss response processing |
| 1425 | */ |
| 1426 | pMac->lim.gLimIbssCoalescingHappened = true; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1427 | PELOGW(limLog(pMac, LOGW, FL("IBSS Coalescing happened"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1428 | ibss_coalesce_save(pMac, pHdr, pBeacon); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 1429 | limLog(pMac, LOGW, FL("Delete BSSID :" MAC_ADDRESS_STR ), |
| 1430 | MAC_ADDR_ARRAY(currentBssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1431 | ibss_bss_delete(pMac,psessionEntry); |
| 1432 | return eSIR_SUCCESS; |
| 1433 | } |
| 1434 | |
| 1435 | // STA in IBSS mode and SSID matches with ours |
| 1436 | pPeerNode = ibss_peer_find(pMac, pHdr->sa); |
| 1437 | if (pPeerNode == NULL) |
| 1438 | { |
| 1439 | /* Peer not in the list - Collect BSS description & add to the list */ |
| 1440 | tANI_U32 frameLen; |
| 1441 | tSirRetStatus retCode; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1442 | PELOGW(limLog(pMac, LOGW, FL("IBSS Peer node does not exist, adding it***"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1443 | |
| 1444 | #ifndef ANI_SIR_IBSS_PEER_CACHING |
| 1445 | /** Limit the Max number of IBSS Peers allowed as the max number of STA's allowed |
| 1446 | */ |
| 1447 | if (pMac->lim.gLimNumIbssPeers >= pMac->lim.maxStation) |
| 1448 | return eSIR_LIM_MAX_STA_REACHED_ERROR; |
| 1449 | #endif |
| 1450 | frameLen = sizeof(tLimIbssPeerNode) + ieLen - sizeof(tANI_U32); |
| 1451 | |
| 1452 | if (eHAL_STATUS_SUCCESS != |
| 1453 | palAllocateMemory(pMac->hHdd, (void **) &pPeerNode, (tANI_U16)frameLen)) |
| 1454 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1455 | limLog(pMac, LOGP, FL("alloc fail (%d bytes) storing IBSS peer info"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1456 | frameLen); |
| 1457 | return eSIR_MEM_ALLOC_FAILED; |
| 1458 | } |
| 1459 | |
| 1460 | pPeerNode->beacon = NULL; |
| 1461 | pPeerNode->beaconLen = 0; |
| 1462 | |
| 1463 | ibss_peer_collect(pMac, pBeacon, pHdr, pPeerNode,psessionEntry); |
| 1464 | if(eHAL_STATUS_SUCCESS != |
| 1465 | palAllocateMemory(pMac->hHdd, (void**)&pPeerNode->beacon, ieLen)) |
| 1466 | { |
| 1467 | PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store beacon"));) |
| 1468 | } |
| 1469 | else |
| 1470 | { |
| 1471 | palCopyMemory(pMac->hHdd, pPeerNode->beacon, pIEs, ieLen); |
| 1472 | pPeerNode->beaconLen = (tANI_U16)ieLen; |
| 1473 | } |
| 1474 | ibss_peer_add(pMac, pPeerNode); |
| 1475 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1476 | pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1477 | if (pStaDs != NULL) |
| 1478 | { |
| 1479 | /// DPH node already exists for the peer |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1480 | PELOGW(limLog(pMac, LOGW, FL("DPH Node present for just learned peer"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1481 | PELOG1(limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOG1);) |
| 1482 | ibss_sta_info_update(pMac, pStaDs, pPeerNode,psessionEntry); |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 1483 | return eSIR_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1484 | } |
| 1485 | retCode = limIbssStaAdd(pMac, pPeerNode->peerMacAddr,psessionEntry); |
| 1486 | if (retCode != eSIR_SUCCESS) |
| 1487 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1488 | PELOGE(limLog(pMac, LOGE, FL("lim-ibss-sta-add failed (reason %x)"), retCode);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1489 | limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOGE); |
| 1490 | return retCode; |
| 1491 | } |
| 1492 | |
| 1493 | // Decide protection mode |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1494 | pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1495 | if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE) |
| 1496 | limIbssDecideProtection(pMac, pStaDs, &beaconParams, psessionEntry); |
| 1497 | |
| 1498 | if(beaconParams.paramChangeBitmap) |
| 1499 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1500 | PELOGE(limLog(pMac, LOGE, FL("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params "));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1501 | schSetFixedBeaconFields(pMac, psessionEntry); |
| 1502 | limSendBeaconParams(pMac, &beaconParams, psessionEntry ); |
| 1503 | } |
| 1504 | } |
| 1505 | else |
| 1506 | ibss_sta_caps_update(pMac, pPeerNode,psessionEntry); |
| 1507 | |
| 1508 | if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) |
| 1509 | return eSIR_SUCCESS; |
| 1510 | |
| 1511 | // Received Beacon from same IBSS we're |
| 1512 | // currently part of. Inform Roaming algorithm |
| 1513 | // if not already that IBSS is active. |
| 1514 | if (psessionEntry->limIbssActive == false) |
| 1515 | { |
| 1516 | limResetHBPktCount(psessionEntry); |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1517 | PELOGW(limLog(pMac, LOGW, FL("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1518 | psessionEntry->limIbssActive = true; |
| 1519 | limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_ACTIVE, NULL, 0, psessionEntry->smeSessionId); |
| 1520 | limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1521 | MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1522 | if (limActivateHearBeatTimer(pMac) != TX_SUCCESS) |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1523 | limLog(pMac, LOGP, FL("could not activate Heartbeat timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1524 | } |
| 1525 | |
| 1526 | return eSIR_SUCCESS; |
| 1527 | } /*** end limHandleIBSScoalescing() ***/ |
| 1528 | |
| 1529 | |
| 1530 | void limIbssHeartBeatHandle(tpAniSirGlobal pMac,tpPESession psessionEntry) |
| 1531 | { |
| 1532 | tLimIbssPeerNode *pTempNode, *pPrevNode; |
| 1533 | tLimIbssPeerNode *pTempNextNode = NULL; |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1534 | tANI_U16 peerIdx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1535 | tpDphHashNode pStaDs; |
| 1536 | tANI_U32 threshold; |
| 1537 | tANI_U16 staIndex; |
| 1538 | tANI_U8 ucUcastSig; |
| 1539 | tANI_U8 ucBcastSig; |
| 1540 | |
| 1541 | /** MLM BSS is started and if PE in scanmode then MLM state will be waiting for probe resp. |
| 1542 | * If Heart beat timeout triggers during this corner case then we need to reactivate HeartBeat timer |
| 1543 | */ |
| 1544 | if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) { |
| 1545 | /****** |
| 1546 | * Note: Use this code once you have converted all |
| 1547 | * limReactivateHeartBeatTimer() calls to |
| 1548 | * limReactivateTimer() calls. |
| 1549 | * |
| 1550 | ******/ |
| 1551 | //limReactivateTimer(pMac, eLIM_HEART_BEAT_TIMER, psessionEntry); |
| 1552 | limReactivateHeartBeatTimer(pMac, psessionEntry); |
| 1553 | return; |
| 1554 | } |
| 1555 | /** If LinkMonitor is Disabled */ |
| 1556 | if(!pMac->sys.gSysEnableLinkMonitorMode) |
| 1557 | return; |
| 1558 | |
| 1559 | pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList; |
| 1560 | threshold = (pMac->lim.gLimNumIbssPeers / 4 ) + 1; |
| 1561 | |
| 1562 | /** Monitor the HeartBeat with the Individual PEERS in the IBSS */ |
| 1563 | while (pTempNode != NULL) |
| 1564 | { |
| 1565 | pTempNextNode = pTempNode->next; |
| 1566 | if(pTempNode->beaconHBCount) //There was a beacon for this peer during heart beat. |
| 1567 | { |
| 1568 | pTempNode->beaconHBCount = 0; |
| 1569 | pTempNode->heartbeatFailure = 0; |
| 1570 | } |
| 1571 | else //There wasnt any beacon received during heartbeat timer. |
| 1572 | { |
| 1573 | pTempNode->heartbeatFailure++; |
| 1574 | PELOGE(limLog(pMac, LOGE, FL("Heartbeat fail = %d thres = %d"), pTempNode->heartbeatFailure, pMac->lim.gLimNumIbssPeers);) |
| 1575 | if(pTempNode->heartbeatFailure >= threshold ) |
| 1576 | { |
| 1577 | //Remove this entry from the list. |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1578 | pStaDs = dphLookupHashEntry(pMac, pTempNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1579 | if (pStaDs) |
| 1580 | { |
| 1581 | staIndex = pStaDs->staIndex; |
| 1582 | ucUcastSig = pStaDs->ucUcastSig; |
| 1583 | ucBcastSig = pStaDs->ucBcastSig; |
| 1584 | |
| 1585 | (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry); |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 1586 | limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 1587 | limReleasePeerIdx(pMac, peerIdx, psessionEntry); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1588 | //Send indication. |
| 1589 | ibss_status_chg_notify( pMac, pTempNode->peerMacAddr, staIndex, |
| 1590 | ucUcastSig, ucBcastSig, |
| 1591 | eWNI_SME_IBSS_PEER_DEPARTED_IND, |
| 1592 | psessionEntry->smeSessionId ); |
| 1593 | } |
| 1594 | if(pTempNode == pMac->lim.gLimIbssPeerList) |
| 1595 | { |
| 1596 | pMac->lim.gLimIbssPeerList = pTempNode->next; |
| 1597 | pPrevNode = pMac->lim.gLimIbssPeerList; |
| 1598 | } |
| 1599 | else |
| 1600 | pPrevNode->next = pTempNode->next; |
| 1601 | |
| 1602 | palFreeMemory(pMac->hHdd,pTempNode); |
| 1603 | pMac->lim.gLimNumIbssPeers--; |
| 1604 | |
| 1605 | pTempNode = pTempNextNode; //Since we deleted current node, prevNode remains same. |
| 1606 | continue; |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | pPrevNode = pTempNode; |
| 1611 | pTempNode = pTempNextNode; |
| 1612 | } |
| 1613 | |
| 1614 | /** General IBSS Activity Monitor, check if in IBSS Mode we are received any Beacons */ |
| 1615 | if(pMac->lim.gLimNumIbssPeers) |
| 1616 | { |
| 1617 | if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL) |
| 1618 | pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++; |
| 1619 | else |
| 1620 | pMac->lim.gLimHeartBeatBeaconStats[0]++; |
| 1621 | |
| 1622 | limReactivateHeartBeatTimer(pMac, psessionEntry); |
| 1623 | |
| 1624 | // Reset number of beacons received |
| 1625 | limResetHBPktCount(psessionEntry); |
| 1626 | return; |
| 1627 | } |
| 1628 | else |
| 1629 | { |
| 1630 | |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1631 | PELOGW(limLog(pMac, LOGW, FL("Heartbeat Failure"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1632 | pMac->lim.gLimHBfailureCntInLinkEstState++; |
| 1633 | |
| 1634 | if (psessionEntry->limIbssActive == true) |
| 1635 | { |
| 1636 | // We don't receive Beacon frames from any |
| 1637 | // other STA in IBSS. Announce IBSS inactive |
| 1638 | // to Roaming algorithm |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1639 | PELOGW(limLog(pMac, LOGW, FL("Alone in IBSS"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1640 | psessionEntry->limIbssActive = false; |
| 1641 | |
| 1642 | limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_INACTIVE, |
| 1643 | NULL, 0, psessionEntry->smeSessionId); |
| 1644 | } |
| 1645 | } |
| 1646 | } |
| 1647 | |
| 1648 | |
| 1649 | /** ------------------------------------------------------------- |
| 1650 | \fn limIbssDecideProtectionOnDelete |
| 1651 | \brief Decides all the protection related information. |
| 1652 | \ |
| 1653 | \param tpAniSirGlobal pMac |
| 1654 | \param tSirMacAddr peerMacAddr |
| 1655 | \param tpUpdateBeaconParams pBeaconParams |
| 1656 | \return None |
| 1657 | -------------------------------------------------------------*/ |
| 1658 | void |
| 1659 | limIbssDecideProtectionOnDelete(tpAniSirGlobal pMac, |
| 1660 | tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry) |
| 1661 | { |
| 1662 | tANI_U32 phyMode; |
| 1663 | tHalBitVal erpEnabled = eHAL_CLEAR; |
| 1664 | tSirRFBand rfBand = SIR_BAND_UNKNOWN; |
| 1665 | tANI_U32 i; |
| 1666 | |
| 1667 | if(NULL == pStaDs) |
| 1668 | return; |
| 1669 | |
| 1670 | limGetRfBand(pMac, &rfBand, psessionEntry); |
| 1671 | if(SIR_BAND_2_4_GHZ == rfBand) |
| 1672 | { |
| 1673 | limGetPhyMode(pMac, &phyMode, psessionEntry); |
| 1674 | erpEnabled = pStaDs->erpEnabled; |
| 1675 | //we are HT or 11G and 11B station is getting deleted. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1676 | if ( ((phyMode == WNI_CFG_PHY_MODE_11G) || psessionEntry->htCapability) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1677 | && (erpEnabled == eHAL_CLEAR)) |
| 1678 | { |
| 1679 | PELOGE(limLog(pMac, LOGE, FL("(%d) A legacy STA is disassociated. Addr is "), |
| 1680 | psessionEntry->gLim11bParams.numSta); |
| 1681 | limPrintMacAddr(pMac, pStaDs->staAddr, LOGE);) |
| 1682 | if (psessionEntry->gLim11bParams.numSta > 0) |
| 1683 | { |
| 1684 | for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++) |
| 1685 | { |
| 1686 | if (pMac->lim.protStaCache[i].active) |
| 1687 | { |
| 1688 | if (palEqualMemory( pMac->hHdd,pMac->lim.protStaCache[i].addr, |
| 1689 | pStaDs->staAddr, sizeof(tSirMacAddr))) |
| 1690 | { |
| 1691 | psessionEntry->gLim11bParams.numSta--; |
| 1692 | pMac->lim.protStaCache[i].active = false; |
| 1693 | break; |
| 1694 | } |
| 1695 | } |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | if (psessionEntry->gLim11bParams.numSta == 0) |
| 1700 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1701 | PELOGE(limLog(pMac, LOGE, FL("No more 11B STA exists. Disable protection. "));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1702 | limIbssSetProtection(pMac, false, pBeaconParams,psessionEntry); |
| 1703 | } |
| 1704 | } |
| 1705 | } |
| 1706 | } |