blob: 9ec4525a1a9ff2030be520420d391107ab0ce50d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
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 Johnson295189b2012-06-20 16:38:30 -070055#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#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
86static tLimIbssPeerNode *
87ibss_peer_find(
88 tpAniSirGlobal pMac,
89 tSirMacAddr macAddr)
90{
91 tLimIbssPeerNode *pTempNode = pMac->lim.gLimIbssPeerList;
92
93 while (pTempNode != NULL)
94 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +053095 if (vos_mem_compare((tANI_U8 *) macAddr,
96 (tANI_U8 *) &pTempNode->peerMacAddr,
97 sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -070098 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
124static tSirRetStatus
125ibss_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 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530145 vos_mem_free(pTemp->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 }
147
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530148 vos_mem_free(pTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 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
183static void
184ibss_peer_collect(
185 tpAniSirGlobal pMac,
186 tpSchBeaconStruct pBeacon,
187 tpSirMacMgmtHdr pHdr,
188 tLimIbssPeerNode *pPeer,
189 tpPESession psessionEntry)
190{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530191 vos_mem_copy(pPeer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700192
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;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530203 vos_mem_copy((tANI_U8 *)pPeer->supportedMCSSet,
204 (tANI_U8 *)pBeacon->HTCaps.supportedMCSSet,
205 sizeof(pPeer->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 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 Joshiaeb7d9e2013-05-02 12:28:14 -0700215 pPeer->htSecondaryChannelOffset = pBeacon->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 }
217
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700218 /* Collect peer VHT capabilities based on the received beacon from the peer */
219#ifdef WLAN_FEATURE_11AC
220 if ( pBeacon->VHTCaps.present )
221 {
Bansidhar Gopalachari5fd3d132013-07-30 13:35:35 -0700222 pPeer->vhtSupportedChannelWidthSet = pBeacon->VHTOperation.chanWidth;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700223 pPeer->vhtCapable = pBeacon->VHTCaps.present;
224
225 // Collect VHT capabilities from beacon
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530226 vos_mem_copy((tANI_U8 *) &pPeer->VHTCaps,
227 (tANI_U8 *) &pBeacon->VHTCaps,
228 sizeof(tDot11fIEVHTCaps));
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700229 }
230#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 pPeer->erpIePresent = pBeacon->erpPresent;
232
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530233 vos_mem_copy((tANI_U8 *) &pPeer->supportedRates,
234 (tANI_U8 *) &pBeacon->supportedRates,
235 pBeacon->supportedRates.numRates + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 if (pPeer->extendedRatesPresent)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530237 vos_mem_copy((tANI_U8 *) &pPeer->extendedRates,
238 (tANI_U8 *) &pBeacon->extendedRates,
239 pBeacon->extendedRates.numRates + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 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
250static void
251ibss_sta_caps_update(
252 tpAniSirGlobal pMac,
253 tLimIbssPeerNode *pPeerNode,
254 tpPESession psessionEntry)
255{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800256 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 tpDphHashNode pStaDs;
258
259 pPeerNode->beaconHBCount++; //Update beacon count.
260
261 // if the peer node exists, update its qos capabilities
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800262 if ((pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 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 Joshiaeb7d9e2013-05-02 12:28:14 -0700286#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 Johnson295189b2012-06-20 16:38:30 -0700296
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
361static void
362ibss_sta_rates_update(
363 tpAniSirGlobal pMac,
364 tpDphHashNode pStaDs,
365 tLimIbssPeerNode *pPeer,
366 tpPESession psessionEntry)
367{
Jeff Johnsone7245742012-09-05 17:12:55 -0700368#ifdef WLAN_FEATURE_11AC
369 limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates,
370 &pPeer->extendedRates, pPeer->supportedMCSSet,
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700371 &pStaDs->mlmStaContext.propRateSet,psessionEntry, &pPeer->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -0700372#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 // Populate supported rateset
374 limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates,
375 &pPeer->extendedRates, pPeer->supportedMCSSet,
376 &pStaDs->mlmStaContext.propRateSet,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700377#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
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
402static void
403ibss_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
414static void
415ibss_coalesce_free(
416 tpAniSirGlobal pMac)
417{
418 if (pMac->lim.ibssInfo.pHdr != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530419 vos_mem_free(pMac->lim.ibssInfo.pHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 if (pMac->lim.ibssInfo.pBeacon != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530421 vos_mem_free(pMac->lim.ibssInfo.pBeacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700422
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 */
430static void
431ibss_coalesce_save(
432 tpAniSirGlobal pMac,
433 tpSirMacMgmtHdr pHdr,
434 tpSchBeaconStruct pBeacon)
435{
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 // get rid of any saved info
437 ibss_coalesce_free(pMac);
438
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530439 pMac->lim.ibssInfo.pHdr = vos_mem_malloc(sizeof(*pHdr));
440 if (NULL == pMac->lim.ibssInfo.pHdr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700442 PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pHdr"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700443 return;
444 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530445 pMac->lim.ibssInfo.pBeacon = vos_mem_malloc(sizeof(*pBeacon));
446 if (NULL == pMac->lim.ibssInfo.pBeacon)
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700448 PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pBeacon"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 ibss_coalesce_free(pMac);
450 return;
451 }
452
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530453 vos_mem_copy(pMac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr));
454 vos_mem_copy(pMac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon));
Jeff Johnson295189b2012-06-20 16:38:30 -0700455}
456
457/*
458 * tries to add a new entry to dph hash node
459 * if necessary, an existing entry is eliminated
460 */
461static tSirRetStatus
462ibss_dph_entry_add(
463 tpAniSirGlobal pMac,
464 tSirMacAddr peerAddr,
465 tpDphHashNode *ppSta,
466 tpPESession psessionEntry)
467{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800468 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 tpDphHashNode pStaDs;
470
471 *ppSta = NULL;
472
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800473 pStaDs = dphLookupHashEntry(pMac, peerAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 if (pStaDs != NULL)
475 {
476 /* Trying to add context for already existing STA in IBSS */
477 PELOGE(limLog(pMac, LOGE, FL("STA exists already "));)
478 limPrintMacAddr(pMac, peerAddr, LOGE);
479 return eSIR_FAILURE;
480 }
481
482 /**
483 * Assign an AID, delete context existing with that
484 * AID and then add an entry to hash table maintained
485 * by DPH module.
486 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800487 peerIdx = limAssignPeerIdx(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800489 pStaDs = dphGetHashEntry(pMac, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 if (pStaDs)
491 {
492 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800493 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 }
495
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800496 pStaDs = dphAddHashEntry(pMac, peerAddr, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 if (pStaDs == NULL)
498 {
499 // Could not add hash table entry
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700500 PELOGE(limLog(pMac, LOGE, FL("could not add hash entry at DPH for peerIdx/aid=%d MACaddr:"), peerIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 limPrintMacAddr(pMac, peerAddr, LOGE);
502 return eSIR_FAILURE;
503 }
504
505 *ppSta = pStaDs;
506 return eSIR_SUCCESS;
507}
508
509// send a status change notification
510static void
511ibss_status_chg_notify(
512 tpAniSirGlobal pMac,
513 tSirMacAddr peerAddr,
514 tANI_U16 staIndex,
515 tANI_U8 ucastSig,
516 tANI_U8 bcastSig,
517 tANI_U16 status,
518 tANI_U8 sessionId)
519{
520
521 tLimIbssPeerNode *peerNode;
522 tANI_U8 *beacon = NULL;
523 tANI_U16 bcnLen = 0;
524
525
526 peerNode = ibss_peer_find(pMac,peerAddr);
527 if(peerNode != NULL)
528 {
529 if(peerNode->beacon == NULL) peerNode->beaconLen = 0;
530 beacon = peerNode->beacon;
531 bcnLen = peerNode->beaconLen;
532 peerNode->beacon = NULL;
533 peerNode->beaconLen = 0;
534 }
535
536 limSendSmeIBSSPeerInd(pMac,peerAddr, staIndex, ucastSig, bcastSig,
537 beacon, bcnLen, status, sessionId);
538
539 if(beacon != NULL)
540 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530541 vos_mem_free(beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 }
543}
544
545
546static void
547ibss_bss_add(
548 tpAniSirGlobal pMac,
549 tpPESession psessionEntry)
550{
551 tLimMlmStartReq mlmStartReq;
552 tANI_U32 cfg;
553 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr;
554 tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon;
555 tANI_U8 numExtRates = 0;
556
557 if ((pHdr == NULL) || (pBeacon == NULL))
558 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700559 PELOGE(limLog(pMac, LOGE, FL("Unable to add BSS (no cached BSS info)"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 return;
561 }
562
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530563 vos_mem_copy(psessionEntry->bssId, pHdr->bssId,
564 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700565
566 #if 0
567 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pHdr->bssId, sizeof(tSirMacAddr))
568 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700569 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 #endif //TO SUPPORT BT-AMP
571
572 sirCopyMacAddr(pHdr->bssId,psessionEntry->bssId);
573 /* We need not use global Mac address since per seesion BSSID is available */
574 //limSetBssid(pMac, pHdr->bssId);
575
576#if 0
577 if (wlan_cfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &cfg) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700578 limLog(pMac, LOGP, FL("Can't read beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700579#endif //TO SUPPORT BT-AMP
580 /* Copy beacon interval from sessionTable */
581 cfg = psessionEntry->beaconParams.beaconInterval;
582 if (cfg != pBeacon->beaconInterval)
583 #if 0
584 if (cfgSetInt(pMac, WNI_CFG_BEACON_INTERVAL, pBeacon->beaconInterval)
585 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700586 limLog(pMac, LOGP, FL("Can't update beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 #endif//TO SUPPORT BT-AMP
588 psessionEntry->beaconParams.beaconInterval = pBeacon->beaconInterval;
589
590 /* This function ibss_bss_add (and hence the below code) is only called during ibss coalescing. We need to
591 * adapt to peer's capability with respect to short slot time. Changes have been made to limApplyConfiguration()
592 * so that the IBSS doesnt blindly start with short slot = 1. If IBSS start is part of coalescing then it will adapt
593 * to peer's short slot using code below.
594 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 /* If cfg is already set to current peer's capability then no need to set it again */
Jeff Johnsone7245742012-09-05 17:12:55 -0700596 if (psessionEntry->shortSlotTimeSupported != pBeacon->capabilityInfo.shortSlotTime)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700598 psessionEntry->shortSlotTimeSupported = pBeacon->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530600 vos_mem_copy((tANI_U8 *) &psessionEntry->pLimStartBssReq->operationalRateSet,
601 (tANI_U8 *) &pBeacon->supportedRates,
602 pBeacon->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603
604 #if 0
605 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
606 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
607 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
608 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700609 limLog(pMac, LOGP, FL("could not update OperRateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 #endif //TO SUPPORT BT-AMP
611
612 /**
613 * WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET CFG needs to be reset, when
614 * there is no extended rate IE present in beacon. This is especially important when
615 * supportedRateSet IE contains all the extended rates as well and STA decides to coalesce.
616 * In this IBSS coalescing scenario LIM will tear down the BSS and Add a new one. So LIM needs to
617 * reset this CFG, just in case CSR originally had set this CFG when IBSS was started from the local profile.
618 * If IBSS was started by CSR from the BssDescription, then it would reset this CFG before StartBss is issued.
619 * The idea is that the count of OpRateSet and ExtendedOpRateSet rates should not be more than 12.
620 */
621
622 if(pBeacon->extendedRatesPresent)
623 numExtRates = pBeacon->extendedRates.numRates;
624 if (cfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
625 (tANI_U8 *) &pBeacon->extendedRates.rate, numExtRates) != eSIR_SUCCESS)
626 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700627 limLog(pMac, LOGP, FL("could not update ExtendedOperRateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 return;
629 }
630
631
632 /*
633 * Each IBSS node will advertise its own HT Capabilities instead of adapting to the Peer's capabilities
634 * If we don't do this then IBSS may not go back to full capabilities when the STA with lower capabilities
635 * leaves the IBSS. e.g. when non-CB STA joins an IBSS and then leaves, the IBSS will be stuck at non-CB mode
636 * even though all the nodes are capable of doing CB.
637 * so it is decided to leave the self HT capabilties intact. This may change if some issues are found in interop.
638 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530639 vos_mem_set((void *) &mlmStartReq, sizeof(mlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700640
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530641 vos_mem_copy(mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 mlmStartReq.rateSet.numRates = psessionEntry->pLimStartBssReq->operationalRateSet.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530643 vos_mem_copy(&mlmStartReq.rateSet.rate[0],
644 &psessionEntry->pLimStartBssReq->operationalRateSet.rate[0],
645 mlmStartReq.rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 mlmStartReq.bssType = eSIR_IBSS_MODE;
647 mlmStartReq.beaconPeriod = pBeacon->beaconInterval;
648 mlmStartReq.nwType = psessionEntry->pLimStartBssReq->nwType; //psessionEntry->nwType is also OK????
Jeff Johnsone7245742012-09-05 17:12:55 -0700649 mlmStartReq.htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 mlmStartReq.htOperMode = pMac->lim.gHTOperMode;
651 mlmStartReq.dualCTSProtection = pMac->lim.gHTDualCTSProtection;
Jeff Johnsone7245742012-09-05 17:12:55 -0700652 mlmStartReq.txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700653
654 #if 0
655 if (wlan_cfgGetInt(pMac, WNI_CFG_CURRENT_CHANNEL, &cfg) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700656 limLog(pMac, LOGP, FL("CurrentChannel CFG get fialed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 #endif
658
659 //mlmStartReq.channelNumber = (tSirMacChanNum) cfg;
660
661 /* reading the channel num from session Table */
662 mlmStartReq.channelNumber = psessionEntry->currentOperChannel;
663
664 mlmStartReq.cbMode = psessionEntry->pLimStartBssReq->cbMode;
665
666 // Copy the SSID for RxP filtering based on SSID.
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530667 vos_mem_copy((tANI_U8 *) &mlmStartReq.ssId,
668 (tANI_U8 *) &psessionEntry->pLimStartBssReq->ssId,
669 psessionEntry->pLimStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700671 PELOG1(limLog(pMac, LOG1, FL("invoking ADD_BSS as part of coalescing!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 if (limMlmAddBss(pMac, &mlmStartReq,psessionEntry) != eSIR_SME_SUCCESS)
673 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700674 PELOGE(limLog(pMac, LOGE, FL("AddBss failure"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 return;
676 }
677
678 // Update fields in Beacon
679 if (schSetFixedBeaconFields(pMac,psessionEntry) != eSIR_SUCCESS)
680 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700681 PELOGE(limLog(pMac, LOGE, FL("*** Unable to set fixed Beacon fields ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 return;
683 }
684
685}
686
687
688
689/* delete the current BSS */
690static void
691ibss_bss_delete(
692 tpAniSirGlobal pMac,
693 tpPESession psessionEntry)
694{
695 tSirRetStatus status;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700696 PELOGW(limLog(pMac, LOGW, FL("Initiating IBSS Delete BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 if (psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
698 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700699 limLog(pMac, LOGW, FL("Incorrect LIM MLM state for delBss (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 psessionEntry->limMlmState);
701 return;
702 }
703 status = limDelBss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
704 if (status != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700705 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700706}
707
708/**
709 * limIbssInit
710 *
711 *FUNCTION:
712 * This function is called while starting an IBSS
713 * to initialize list used to maintain IBSS peers.
714 *
715 *LOGIC:
716 *
717 *ASSUMPTIONS:
718 *
719 *NOTE:
720 *
721 * @param pMac - Pointer to Global MAC structure
722 * @return None
723 */
724
725void
726limIbssInit(
727 tpAniSirGlobal pMac)
728{
729 //pMac->lim.gLimIbssActive = 0;
730 pMac->lim.gLimIbssCoalescingHappened = 0;
731 pMac->lim.gLimIbssPeerList = NULL;
732 pMac->lim.gLimNumIbssPeers = 0;
733
734 // ibss info - params for which ibss to join while coalescing
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530735 vos_mem_set(&pMac->lim.ibssInfo, sizeof(tAniSirLimIbss), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700736} /*** end limIbssInit() ***/
737
738/**
739 * limIbssDeleteAllPeers
740 *
741 *FUNCTION:
742 * This function is called to delete all peers.
743 *
744 *LOGIC:
745 *
746 *ASSUMPTIONS:
747 *
748 *NOTE:
749 *
750 * @param pMac - Pointer to Global MAC structure
751 * @return None
752 */
753
754void limIbssDeleteAllPeers( tpAniSirGlobal pMac ,tpPESession psessionEntry)
755{
756 tLimIbssPeerNode *pCurrNode, *pTempNode;
757 tpDphHashNode pStaDs;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800758 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700759
760 pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList;
761
762 while (pCurrNode != NULL)
763 {
764 if (!pMac->lim.gLimNumIbssPeers)
765 {
766 limLog(pMac, LOGP,
767 FL("Number of peers in the list is zero and node present"));
768 return;
769 }
770 /* Delete the dph entry for the station
771 * Since it is called to remove all peers, just delete from dph,
772 * no need to do any beacon related params i.e., dont call limDeleteDphHashEntry
773 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800774 pStaDs = dphLookupHashEntry(pMac, pCurrNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 if( pStaDs )
776 {
777
778 ibss_status_chg_notify( pMac, pCurrNode->peerMacAddr, pStaDs->staIndex,
779 pStaDs->ucUcastSig, pStaDs->ucBcastSig,
780 eWNI_SME_IBSS_PEER_DEPARTED_IND, psessionEntry->smeSessionId );
Ravi Joshi492be3c2013-05-16 19:20:00 -0700781 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800782 dphDeleteHashEntry(pMac, pStaDs->staAddr, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 }
784
785 pTempNode = pCurrNode->next;
786
787 /* TODO :Sessionize this code */
788 /* Fix CR 227642: PeerList should point to the next node since the current node is being
789 * freed in the next line. In ibss_peerfind in ibss_status_chg_notify above, we use this
790 * peer list to find the next peer. So this list needs to be updated with the no of peers left
791 * after each iteration in this while loop since one by one peers are deleted (freed) in this
792 * loop causing the lim.gLimIbssPeerList to point to some freed memory.
793 */
794 pMac->lim.gLimIbssPeerList = pTempNode;
795
796 if(pCurrNode->beacon)
797 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530798 vos_mem_free(pCurrNode->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530800 vos_mem_free(pCurrNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 if (pMac->lim.gLimNumIbssPeers > 0) // be paranoid
802 pMac->lim.gLimNumIbssPeers--;
803 pCurrNode = pTempNode;
804 }
805
806 if (pMac->lim.gLimNumIbssPeers)
807 limLog(pMac, LOGP, FL("Number of peers[%d] in the list is non-zero"),
808 pMac->lim.gLimNumIbssPeers);
809
810 pMac->lim.gLimNumIbssPeers = 0;
811 pMac->lim.gLimIbssPeerList = NULL;
812
813}
814/**
815 * limIbssDelete
816 *
817 *FUNCTION:
818 * This function is called while tearing down an IBSS.
819 *
820 *LOGIC:
821 *
822 *ASSUMPTIONS:
823 *
824 *NOTE:
825 *
826 * @param pMac - Pointer to Global MAC structure
827 * @return None
828 */
829
830void
831limIbssDelete(
832 tpAniSirGlobal pMac,tpPESession psessionEntry)
833{
834 limIbssDeleteAllPeers(pMac,psessionEntry);
835
836 ibss_coalesce_free(pMac);
837} /*** end limIbssDelete() ***/
838
839/** Commenting this Code as from no where it is being invoked */
840#if 0
841/**
842 * limIbssPeerDelete
843 *
844 *FUNCTION:
845 * This may be called on a STA in IBSS to delete a peer
846 * from the list.
847 *
848 *LOGIC:
849 *
850 *ASSUMPTIONS:
851 *
852 *NOTE:
853 *
854 * @param pMac - Pointer to Global MAC structure
855 * @param peerMacAddr - MAC address of the peer STA that
856 * need to be deleted from peer list.
857 *
858 * @return None
859 */
860
861void
862limIbssPeerDelete(tpAniSirGlobal pMac, tSirMacAddr macAddr)
863{
864 tLimIbssPeerNode *pPrevNode, *pTempNode;
865
866 pTempNode = pPrevNode = pMac->lim.gLimIbssPeerList;
867
868 if (pTempNode == NULL)
869 return;
870
871 while (pTempNode != NULL)
872 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530873 if (vos_mem_compare((tANI_U8 *) macAddr,
874 (tANI_U8 *) &pTempNode->peerMacAddr,
875 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 {
877 // Found node to be deleted
878 if (pMac->lim.gLimIbssPeerList == pTempNode) /** First Node to be deleted*/
879 pMac->lim.gLimIbssPeerList = pTempNode->next;
880 else
881 pPrevNode->next = pTempNode->next;
882
883 if(pTempNode->beacon)
884 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530885 vos_mem_free(pTempNode->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 pTempNode->beacon = NULL;
887 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530888 vos_mem_free(pTempNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 pMac->lim.gLimNumIbssPeers--;
890 return;
891 }
892
893 pPrevNode = pTempNode;
894 pTempNode = pTempNode->next;
895 }
896
897 // Should not be here
898 PELOGE(limLog(pMac, LOGE, FL("peer not found in the list, addr= "));)
899 limPrintMacAddr(pMac, macAddr, LOGE);
900} /*** end limIbssPeerDelete() ***/
901
902#endif
903
904
905/** -------------------------------------------------------------
906\fn limIbssSetProtection
907\brief Decides all the protection related information.
908\
909\param tpAniSirGlobal pMac
910\param tSirMacAddr peerMacAddr
911\param tpUpdateBeaconParams pBeaconParams
912\return None
913 -------------------------------------------------------------*/
914static void
915limIbssSetProtection(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
916{
917
918 if(!pMac->lim.cfgProtection.fromllb)
919 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700920 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 return;
922 }
923
924 if (enable)
925 {
926 psessionEntry->gLim11bParams.protectionEnabled = true;
927 if(false == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/)
928 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700929 PELOGE(limLog(pMac, LOGE, FL("=> IBSS: Enable Protection "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
931 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
932 }
933 }
934 else if (true == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/)
935 {
936 psessionEntry->gLim11bParams.protectionEnabled = false;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700937 PELOGE(limLog(pMac, LOGE, FL("===> IBSS: Disable protection "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
939 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
940 }
941 return;
942}
943
944
945/** -------------------------------------------------------------
946\fn limIbssUpdateProtectionParams
947\brief Decides all the protection related information.
948\
949\param tpAniSirGlobal pMac
950\param tSirMacAddr peerMacAddr
951\param tpUpdateBeaconParams pBeaconParams
952\return None
953 -------------------------------------------------------------*/
954static void
955limIbssUpdateProtectionParams(tpAniSirGlobal pMac,
956 tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType,
957 tpPESession psessionEntry)
958{
959 tANI_U32 i;
960
961 PELOG1(limLog(pMac,LOG1, FL("A STA is associated:"));
962 limLog(pMac,LOG1, FL("Addr : "));
963 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
964
965 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
966 {
967 if (pMac->lim.protStaCache[i].active)
968 {
969 PELOG1(limLog(pMac, LOG1, FL("Addr: "));)
970 PELOG1(limPrintMacAddr(pMac, pMac->lim.protStaCache[i].addr, LOG1);)
971
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530972 if (vos_mem_compare(pMac->lim.protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 peerMacAddr, sizeof(tSirMacAddr)))
974 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700975 PELOG1(limLog(pMac, LOG1, FL("matching cache entry at %d already active."), i);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 return;
977 }
978 }
979 }
980
981 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
982 {
983 if (!pMac->lim.protStaCache[i].active)
984 break;
985 }
986
987 if (i >= LIM_PROT_STA_CACHE_SIZE)
988 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700989 PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 return;
991 }
992
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530993 vos_mem_copy(pMac->lim.protStaCache[i].addr,
994 peerMacAddr,
995 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
997 pMac->lim.protStaCache[i].protStaCacheType = protStaCacheType;
998 pMac->lim.protStaCache[i].active = true;
999 if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType)
1000 {
1001 psessionEntry->gLim11bParams.numSta++;
1002 }
1003 else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType)
1004 {
1005 psessionEntry->gLim11gParams.numSta++;
1006 }
1007}
1008
1009
1010/** -------------------------------------------------------------
1011\fn limIbssDecideProtection
1012\brief Decides all the protection related information.
1013\
1014\param tpAniSirGlobal pMac
1015\param tSirMacAddr peerMacAddr
1016\param tpUpdateBeaconParams pBeaconParams
1017\return None
1018 -------------------------------------------------------------*/
1019static void
1020limIbssDecideProtection(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1021{
1022 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1023 tANI_U32 phyMode;
1024 tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID;
1025
1026 pBeaconParams->paramChangeBitmap = 0;
1027
1028 if(NULL == pStaDs)
1029 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001030 PELOGE(limLog(pMac, LOGE, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 return;
1032 }
1033
1034 limGetRfBand(pMac, &rfBand, psessionEntry);
1035 if(SIR_BAND_2_4_GHZ== rfBand)
1036 {
1037 limGetPhyMode(pMac, &phyMode, psessionEntry);
1038
1039 //We are 11G or 11n. Check if we need protection from 11b Stations.
Jeff Johnsone7245742012-09-05 17:12:55 -07001040 if ((phyMode == WNI_CFG_PHY_MODE_11G) || (psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 {
1042 /* As we found in the past, it is possible that a 11n STA sends
1043 * Beacon with HT IE but not ERP IE. So the absense of ERP IE
1044 * in the Beacon is not enough to conclude that STA is 11b.
1045 */
1046 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1047 (!pStaDs->mlmStaContext.htCapability))
1048 {
1049 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001050 PELOGE(limLog(pMac, LOGE, FL("Enable protection from 11B"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 limIbssSetProtection(pMac, true, pBeaconParams,psessionEntry);
1052 }
1053 }
1054 }
1055 limIbssUpdateProtectionParams(pMac, pStaDs->staAddr, protStaCacheType, psessionEntry);
1056 return;
1057}
1058
1059
1060/**
1061 * limIbssStaAdd()
1062 *
1063 *FUNCTION:
1064 * This function is called to add an STA context in IBSS role
1065 * whenever a data frame is received from/for a STA that failed
1066 * hash lookup at DPH.
1067 *
1068 *LOGIC:
1069 *
1070 *ASSUMPTIONS:
1071 * NA
1072 *
1073 *NOTE:
1074 * NA
1075 *
1076 * @param pMac Pointer to Global MAC structure
1077 * @param peerAdddr MAC address of the peer being added
1078 * @return retCode Indicates success or failure return code
1079 * @return
1080 */
1081
1082tSirRetStatus
1083limIbssStaAdd(
1084 tpAniSirGlobal pMac,
1085 void *pBody,
1086 tpPESession psessionEntry)
1087{
1088 tSirRetStatus retCode = eSIR_SUCCESS;
1089 tpDphHashNode pStaDs;
1090 tLimIbssPeerNode *pPeerNode;
1091 tLimMlmStates prevState;
1092 tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody;
1093 tUpdateBeaconParams beaconParams;
1094
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301095 vos_mem_set((tANI_U8 *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097 if (pBody == 0)
1098 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001099 PELOGE(limLog(pMac, LOGE, FL("Invalid IBSS AddSta"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 return eSIR_FAILURE;
1101 }
1102
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001103 PELOGE(limLog(pMac, LOGE, FL("Rx Add-Ibss-Sta for MAC:"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
1105
1106 pPeerNode = ibss_peer_find(pMac, *pPeerAddr);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001107 if (NULL != pPeerNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 {
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001109 retCode = ibss_dph_entry_add(pMac, *pPeerAddr, &pStaDs, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 if (eSIR_SUCCESS == retCode)
1111 {
1112 prevState = pStaDs->mlmStaContext.mlmState;
1113 pStaDs->erpEnabled = pPeerNode->erpIePresent;
1114
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001115 ibss_sta_info_update(pMac, pStaDs, pPeerNode, psessionEntry);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001116 PELOGW(limLog(pMac, LOGW, FL("initiating ADD STA for the IBSS peer."));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001117 retCode = limAddSta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001118 if (retCode != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001120 PELOGE(limLog(pMac, LOGE, FL("ibss-sta-add failed (reason %x)"),
1121 retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001123 pStaDs->mlmStaContext.mlmState = prevState;
1124 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,
1125 &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 }
1127 else
1128 {
1129 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1130 limIbssDecideProtection(pMac, pStaDs, &beaconParams , psessionEntry);
1131
1132 if(beaconParams.paramChangeBitmap)
1133 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001134 PELOGE(limLog(pMac, LOGE, FL("---> Update Beacon Params "));)
Sunil Ravib96f7b52013-05-22 21:40:05 -07001135 schSetFixedBeaconFields(pMac, psessionEntry);
1136 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1138 }
1139 }
1140 }
1141 else
1142 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001143 PELOGE(limLog(pMac, LOGE, FL("hashTblAdd failed (reason %x)"), retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
1145 }
1146 }
1147 else
1148 {
1149 retCode = eSIR_FAILURE;
1150 }
1151
1152 return retCode;
1153}
1154
1155/* handle the response from HAL for an ADD STA request */
1156tSirRetStatus
1157limIbssAddStaRsp(
1158 tpAniSirGlobal pMac,
1159 void *msg,tpPESession psessionEntry)
1160{
1161 tpDphHashNode pStaDs;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001162 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 tpAddStaParams pAddStaParams = (tpAddStaParams) msg;
1164
1165 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1166 if (pAddStaParams == NULL)
1167 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001168 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 return eSIR_FAILURE;
1170 }
1171
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001172 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 if (pStaDs == NULL)
1174 {
1175 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP for unknown MAC addr "));)
1176 limPrintMacAddr(pMac, pAddStaParams->staMac, LOGE);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301177 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 return eSIR_FAILURE;
1179 }
1180
1181 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
1182 {
1183 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP error (%x) "), pAddStaParams->status);)
1184 limPrintMacAddr(pMac, pAddStaParams->staMac, LOGE);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301185 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 return eSIR_FAILURE;
1187 }
1188
1189 pStaDs->bssId = pAddStaParams->bssIdx;
1190 pStaDs->staIndex = pAddStaParams->staIdx;
1191 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
1192 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
1193 pStaDs->valid = 1;
1194 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1195
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001196 PELOGW(limLog(pMac, LOGW, FL("IBSS: sending IBSS_NEW_PEER msg to SME!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001197
1198 ibss_status_chg_notify(pMac, pAddStaParams->staMac, pStaDs->staIndex,
1199 pStaDs->ucUcastSig, pStaDs->ucBcastSig,
1200 eWNI_SME_IBSS_NEW_PEER_IND,
1201 psessionEntry->smeSessionId);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301202 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001203
1204 return eSIR_SUCCESS;
1205}
1206
1207
1208
1209void limIbssDelBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg,tpPESession psessionEntry)
1210{
1211 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1212
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001213 PELOGW(limLog(pMac, LOGW, FL("IBSS: DEL_BSS_RSP Rcvd during coalescing!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001214
1215 if (pDelBss == NULL)
1216 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001217 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 goto end;
1219 }
1220
1221 if (pDelBss->status != eHAL_STATUS_SUCCESS)
1222 {
1223 limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) error (%x) Bss %d "),
1224 pDelBss->status, pDelBss->bssIdx);
1225 goto end;
1226 }
1227 //Delete peer entries.
1228 limIbssDeleteAllPeers(pMac,psessionEntry);
1229
1230 /* add the new bss */
1231 ibss_bss_add(pMac,psessionEntry);
1232
1233 end:
1234 if(pDelBss != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301235 vos_mem_free(pDelBss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001236}
1237
1238
1239
1240void limIbssAddBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg, tpPESession pSessionEntry)
1241{
1242 tANI_U8 infoLen;
1243 tSirSmeNewBssInfo newBssInfo;
1244
1245 tpAddBssParams pAddBss = (tpAddBssParams) msg;
1246
1247 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr;
1248 tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon;
1249
1250 if ((pHdr == NULL) || (pBeacon == NULL))
1251 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001252 PELOGE(limLog(pMac, LOGE, FL("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 goto end;
1254 }
1255
1256 // Inform Host of IBSS coalescing
1257 infoLen = sizeof(tSirMacAddr) + sizeof(tSirMacChanNum) +
1258 sizeof(tANI_U8) + pBeacon->ssId.length + 1;
1259
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301260 vos_mem_set((void *) &newBssInfo, sizeof(newBssInfo), 0);
1261 vos_mem_copy(newBssInfo.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301263 vos_mem_copy((tANI_U8 *) &newBssInfo.ssId,
1264 (tANI_U8 *) &pBeacon->ssId, pBeacon->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001266 PELOGW(limLog(pMac, LOGW, FL("Sending JOINED_NEW_BSS notification to SME."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001267
1268 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_JOINED_NEW_BSS,
1269 (tANI_U32 *) &newBssInfo,
1270 infoLen,pSessionEntry->smeSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 {
1272 //Configure beacon and send beacons to HAL
1273 limSendBeaconInd(pMac, pSessionEntry);
1274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001275
Jeff Johnson3c3e1782013-02-27 10:48:42 -08001276 end:
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 ibss_coalesce_free(pMac);
1278}
1279
1280
1281
1282void
1283limIbssDelBssRsp(
1284 tpAniSirGlobal pMac,
1285 void *msg,tpPESession psessionEntry)
1286{
1287 tSirResultCodes rc = eSIR_SME_SUCCESS;
1288 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1289 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1290
1291
1292 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1293 if (pDelBss == NULL)
1294 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001295 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 rc = eSIR_SME_REFUSED;
1297 goto end;
1298 }
1299
1300 if((psessionEntry = peFindSessionBySessionId(pMac,pDelBss->sessionId))==NULL)
1301 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001302 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 goto end;
1304 }
1305
1306
1307 /*
1308 * If delBss was issued as part of IBSS Coalescing, gLimIbssCoalescingHappened flag will be true.
1309 * BSS has to be added again in this scenario, so this case needs to be handled separately.
1310 * If delBss was issued as a result of trigger from SME_STOP_BSS Request, then limSme state changes to
1311 * 'IDLE' and gLimIbssCoalescingHappened flag will be false. In this case STOP BSS RSP has to be sent to SME.
1312 */
1313 if(true == pMac->lim.gLimIbssCoalescingHappened)
1314 {
1315
1316 limIbssDelBssRspWhenCoalescing(pMac,msg,psessionEntry);
1317 return;
1318 }
1319
1320
1321
1322 if (pDelBss->status != eHAL_STATUS_SUCCESS)
1323 {
1324 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP error (%x) Bss %d "),
1325 pDelBss->status, pDelBss->bssIdx);)
1326 rc = eSIR_SME_STOP_BSS_FAILURE;
1327 goto end;
1328 }
1329
1330
1331
1332 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
1333 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1334 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001335 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP setLinkState failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 rc = eSIR_SME_REFUSED;
1337 goto end;
1338 }
1339
1340 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
1341 limDeletePreAuthList(pMac);
1342
1343 limIbssDelete(pMac,psessionEntry);
1344 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
1345
Jeff Johnsone7245742012-09-05 17:12:55 -07001346 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001347
1348 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1349
1350 /* Change the short slot operating mode to Default (which is 1 for now) so that when IBSS starts next time with Libra
1351 * as originator, it picks up the default. This enables us to remove hard coding of short slot = 1 from limApplyConfiguration
1352 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001353 psessionEntry->shortSlotTimeSupported = WNI_CFG_SHORT_SLOT_TIME_STADEF;
Jeff Johnson295189b2012-06-20 16:38:30 -07001354
1355 end:
1356 if(pDelBss != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301357 vos_mem_free(pDelBss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 /* Delete PE session once BSS is deleted */
1359 if (NULL != psessionEntry) {
1360 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, rc,psessionEntry->smeSessionId,psessionEntry->transactionId);
1361 peDeleteSession(pMac, psessionEntry);
1362 psessionEntry = NULL;
1363 }
1364}
1365
Ravi Joshi92404a32013-08-13 15:40:30 -07001366static void
1367__limIbssSearchAndDeletePeer(tpAniSirGlobal pMac,
1368 tpPESession psessionEntry,
1369 tSirMacAddr macAddr)
1370{
1371 tLimIbssPeerNode *pTempNode, *pPrevNode;
1372 tLimIbssPeerNode *pTempNextNode = NULL;
1373 tpDphHashNode pStaDs;
1374 tANI_U16 peerIdx;
1375 tANI_U16 staIndex;
1376 tANI_U8 ucUcastSig;
1377 tANI_U8 ucBcastSig;
1378
1379 pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList;
1380
1381 limLog(pMac, LOG1, FL(" PEER ADDR :" MAC_ADDRESS_STR ),MAC_ADDR_ARRAY(macAddr));
1382
1383 /** Compare Peer */
1384 while (NULL != pTempNode)
1385 {
1386 pTempNextNode = pTempNode->next;
1387
1388 /* Delete the STA with MAC address */
1389 if (palEqualMemory( pMac->hHdd, (tANI_U8 *) macAddr,
1390 (tANI_U8 *) &pTempNode->peerMacAddr,
1391 sizeof(tSirMacAddr)) )
1392 {
1393 pStaDs = dphLookupHashEntry(pMac, macAddr,
1394 &peerIdx, &psessionEntry->dph.dphHashTable);
1395 if (pStaDs)
1396 {
1397 staIndex = pStaDs->staIndex;
1398 ucUcastSig = pStaDs->ucUcastSig;
1399 ucBcastSig = pStaDs->ucBcastSig;
1400
1401 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
1402 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry);
1403 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
1404
1405 /* Send indication to upper layers */
1406 ibss_status_chg_notify(pMac, macAddr, staIndex,
1407 ucUcastSig, ucBcastSig,
1408 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1409 psessionEntry->smeSessionId );
1410 if (pTempNode == pMac->lim.gLimIbssPeerList)
1411 {
1412 pMac->lim.gLimIbssPeerList = pTempNode->next;
1413 pPrevNode = pMac->lim.gLimIbssPeerList;
1414 }
1415 else
1416 pPrevNode->next = pTempNode->next;
1417
1418 palFreeMemory(pMac->hHdd, pTempNode);
1419 pMac->lim.gLimNumIbssPeers--;
1420
1421 pTempNode = pTempNextNode;
1422 break;
1423 }
1424 }
1425 pPrevNode = pTempNode;
1426 pTempNode = pTempNextNode;
1427 }
1428}
1429
Jeff Johnson295189b2012-06-20 16:38:30 -07001430/**
1431 * limIbssCoalesce()
1432 *
1433 *FUNCTION:
1434 * This function is called upon receiving Beacon/Probe Response
1435 * while operating in IBSS mode.
1436 *
1437 *LOGIC:
1438 *
1439 *ASSUMPTIONS:
1440 *
1441 *NOTE:
1442 *
1443 * @param pMac - Pointer to Global MAC structure
1444 * @param pBeacon - Parsed Beacon Frame structure
1445 * @param pBD - Pointer to received BD
1446 *
1447 * @return Status whether to process or ignore received Beacon Frame
1448 */
1449
1450tSirRetStatus
1451limIbssCoalesce(
1452 tpAniSirGlobal pMac,
1453 tpSirMacMgmtHdr pHdr,
1454 tpSchBeaconStruct pBeacon,
1455 tANI_U8 *pIEs,
1456 tANI_U32 ieLen,
1457 tANI_U16 fTsfLater,
1458 tpPESession psessionEntry)
1459{
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001460 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 tSirMacAddr currentBssId;
1462 tLimIbssPeerNode *pPeerNode;
1463 tpDphHashNode pStaDs;
1464 tUpdateBeaconParams beaconParams;
1465
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301466 vos_mem_set((tANI_U8 *)&beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001467
1468 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
1469
Shailender Karmuchia734f332013-04-19 14:02:48 -07001470 limLog(pMac, LOG1, FL("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :" MAC_ADDRESS_STR ),
1471 MAC_ADDR_ARRAY(currentBssId), MAC_ADDR_ARRAY(pHdr->bssId));
Ravi Joshi92404a32013-08-13 15:40:30 -07001472
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 /* Check for IBSS Coalescing only if Beacon is from different BSS */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301474 if ( !vos_mem_compare(currentBssId, pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 {
Ravi Joshi92404a32013-08-13 15:40:30 -07001476 /*
1477 * If STA entry is already available in the LIM hash table, then it is
1478 * possible that the peer may have left and rejoined within the heartbeat
1479 * timeout. In the offloaded case with 32 peers, the HB timeout is whopping
1480 * 128 seconds. In that case, the FW will not let any frames come in until
1481 * atleast the last sequence number is received before the peer is left
1482 * Hence, if the coalescing peer is already there in the peer list and if
1483 * the BSSID matches then, invoke delSta() to cleanup the entries. We will
1484 * let the peer coalesce when we receive next beacon from the peer
1485 */
1486 pPeerNode = ibss_peer_find(pMac, pHdr->sa);
1487 if (NULL != pPeerNode)
1488 {
1489 __limIbssSearchAndDeletePeer (pMac, psessionEntry, pHdr->sa);
1490 PELOGW(limLog(pMac, LOGW,
1491 FL("** Peer attempting to reconnect before HB timeout, deleted **"));)
1492 return eSIR_LIM_IGNORE_BEACON;
1493 }
1494
1495 if (! fTsfLater) // No Coalescing happened.
1496 {
1497 PELOGW(limLog(pMac, LOGW, FL("No Coalescing happened"));)
1498 return eSIR_LIM_IGNORE_BEACON;
1499 }
1500 /*
1501 * IBSS Coalescing happened.
1502 * save the received beacon, and delete the current BSS. The rest of the
1503 * processing will be done in the delBss response processing
1504 */
1505 pMac->lim.gLimIbssCoalescingHappened = true;
1506 PELOGW(limLog(pMac, LOGW, FL("IBSS Coalescing happened"));)
1507 ibss_coalesce_save(pMac, pHdr, pBeacon);
1508 limLog(pMac, LOGW, FL("Delete BSSID :" MAC_ADDRESS_STR ),
1509 MAC_ADDR_ARRAY(currentBssId));
1510 ibss_bss_delete(pMac,psessionEntry);
1511 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 }
1513
1514 // STA in IBSS mode and SSID matches with ours
1515 pPeerNode = ibss_peer_find(pMac, pHdr->sa);
1516 if (pPeerNode == NULL)
1517 {
1518 /* Peer not in the list - Collect BSS description & add to the list */
1519 tANI_U32 frameLen;
1520 tSirRetStatus retCode;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001521 PELOGW(limLog(pMac, LOGW, FL("IBSS Peer node does not exist, adding it***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001522
1523#ifndef ANI_SIR_IBSS_PEER_CACHING
1524 /** Limit the Max number of IBSS Peers allowed as the max number of STA's allowed
1525 */
1526 if (pMac->lim.gLimNumIbssPeers >= pMac->lim.maxStation)
1527 return eSIR_LIM_MAX_STA_REACHED_ERROR;
1528#endif
1529 frameLen = sizeof(tLimIbssPeerNode) + ieLen - sizeof(tANI_U32);
1530
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301531 pPeerNode = vos_mem_malloc((tANI_U16)frameLen);
1532 if (NULL == pPeerNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001534 limLog(pMac, LOGP, FL("alloc fail (%d bytes) storing IBSS peer info"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 frameLen);
1536 return eSIR_MEM_ALLOC_FAILED;
1537 }
1538
1539 pPeerNode->beacon = NULL;
1540 pPeerNode->beaconLen = 0;
1541
1542 ibss_peer_collect(pMac, pBeacon, pHdr, pPeerNode,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301543 pPeerNode->beacon = vos_mem_malloc(ieLen);
1544 if (NULL == pPeerNode->beacon)
1545 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store beacon"));)
1547 }
1548 else
1549 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301550 vos_mem_copy(pPeerNode->beacon, pIEs, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001551 pPeerNode->beaconLen = (tANI_U16)ieLen;
1552 }
1553 ibss_peer_add(pMac, pPeerNode);
1554
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001555 pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 if (pStaDs != NULL)
1557 {
1558 /// DPH node already exists for the peer
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001559 PELOGW(limLog(pMac, LOGW, FL("DPH Node present for just learned peer"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 PELOG1(limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOG1);)
1561 ibss_sta_info_update(pMac, pStaDs, pPeerNode,psessionEntry);
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07001562 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 }
1564 retCode = limIbssStaAdd(pMac, pPeerNode->peerMacAddr,psessionEntry);
1565 if (retCode != eSIR_SUCCESS)
1566 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001567 PELOGE(limLog(pMac, LOGE, FL("lim-ibss-sta-add failed (reason %x)"), retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOGE);
1569 return retCode;
1570 }
1571
1572 // Decide protection mode
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001573 pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1575 limIbssDecideProtection(pMac, pStaDs, &beaconParams, psessionEntry);
1576
1577 if(beaconParams.paramChangeBitmap)
1578 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001579 PELOGE(limLog(pMac, LOGE, FL("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params "));)
Sunil Ravib96f7b52013-05-22 21:40:05 -07001580 schSetFixedBeaconFields(pMac, psessionEntry);
1581 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1583 }
1584 }
1585 else
1586 ibss_sta_caps_update(pMac, pPeerNode,psessionEntry);
1587
1588 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE)
1589 return eSIR_SUCCESS;
1590
1591 // Received Beacon from same IBSS we're
1592 // currently part of. Inform Roaming algorithm
1593 // if not already that IBSS is active.
1594 if (psessionEntry->limIbssActive == false)
1595 {
1596 limResetHBPktCount(psessionEntry);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001597 PELOGW(limLog(pMac, LOGW, FL("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 psessionEntry->limIbssActive = true;
1599 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_ACTIVE, NULL, 0, psessionEntry->smeSessionId);
1600 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001601 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001602 if (limActivateHearBeatTimer(pMac, psessionEntry) != TX_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001603 limLog(pMac, LOGP, FL("could not activate Heartbeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 }
1605
1606 return eSIR_SUCCESS;
1607} /*** end limHandleIBSScoalescing() ***/
1608
1609
1610void limIbssHeartBeatHandle(tpAniSirGlobal pMac,tpPESession psessionEntry)
1611{
1612 tLimIbssPeerNode *pTempNode, *pPrevNode;
1613 tLimIbssPeerNode *pTempNextNode = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001614 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 tpDphHashNode pStaDs;
1616 tANI_U32 threshold;
1617 tANI_U16 staIndex;
1618 tANI_U8 ucUcastSig;
1619 tANI_U8 ucBcastSig;
1620
1621 /** MLM BSS is started and if PE in scanmode then MLM state will be waiting for probe resp.
1622 * If Heart beat timeout triggers during this corner case then we need to reactivate HeartBeat timer
1623 */
1624 if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
1625 /******
1626 * Note: Use this code once you have converted all
1627 * limReactivateHeartBeatTimer() calls to
1628 * limReactivateTimer() calls.
1629 *
1630 ******/
1631 //limReactivateTimer(pMac, eLIM_HEART_BEAT_TIMER, psessionEntry);
1632 limReactivateHeartBeatTimer(pMac, psessionEntry);
1633 return;
1634 }
1635 /** If LinkMonitor is Disabled */
1636 if(!pMac->sys.gSysEnableLinkMonitorMode)
1637 return;
1638
1639 pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList;
1640 threshold = (pMac->lim.gLimNumIbssPeers / 4 ) + 1;
1641
1642 /** Monitor the HeartBeat with the Individual PEERS in the IBSS */
1643 while (pTempNode != NULL)
1644 {
1645 pTempNextNode = pTempNode->next;
1646 if(pTempNode->beaconHBCount) //There was a beacon for this peer during heart beat.
1647 {
1648 pTempNode->beaconHBCount = 0;
1649 pTempNode->heartbeatFailure = 0;
1650 }
1651 else //There wasnt any beacon received during heartbeat timer.
1652 {
1653 pTempNode->heartbeatFailure++;
1654 PELOGE(limLog(pMac, LOGE, FL("Heartbeat fail = %d thres = %d"), pTempNode->heartbeatFailure, pMac->lim.gLimNumIbssPeers);)
1655 if(pTempNode->heartbeatFailure >= threshold )
1656 {
1657 //Remove this entry from the list.
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001658 pStaDs = dphLookupHashEntry(pMac, pTempNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 if (pStaDs)
1660 {
1661 staIndex = pStaDs->staIndex;
1662 ucUcastSig = pStaDs->ucUcastSig;
1663 ucBcastSig = pStaDs->ucBcastSig;
1664
1665 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001666 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001667 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 //Send indication.
1669 ibss_status_chg_notify( pMac, pTempNode->peerMacAddr, staIndex,
1670 ucUcastSig, ucBcastSig,
1671 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1672 psessionEntry->smeSessionId );
1673 }
1674 if(pTempNode == pMac->lim.gLimIbssPeerList)
1675 {
1676 pMac->lim.gLimIbssPeerList = pTempNode->next;
1677 pPrevNode = pMac->lim.gLimIbssPeerList;
1678 }
1679 else
1680 pPrevNode->next = pTempNode->next;
1681
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301682 vos_mem_free(pTempNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 pMac->lim.gLimNumIbssPeers--;
1684
1685 pTempNode = pTempNextNode; //Since we deleted current node, prevNode remains same.
1686 continue;
1687 }
1688 }
1689
1690 pPrevNode = pTempNode;
1691 pTempNode = pTempNextNode;
1692 }
1693
1694 /** General IBSS Activity Monitor, check if in IBSS Mode we are received any Beacons */
1695 if(pMac->lim.gLimNumIbssPeers)
1696 {
1697 if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL)
1698 pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++;
1699 else
1700 pMac->lim.gLimHeartBeatBeaconStats[0]++;
1701
1702 limReactivateHeartBeatTimer(pMac, psessionEntry);
1703
1704 // Reset number of beacons received
1705 limResetHBPktCount(psessionEntry);
1706 return;
1707 }
1708 else
1709 {
1710
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001711 PELOGW(limLog(pMac, LOGW, FL("Heartbeat Failure"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 pMac->lim.gLimHBfailureCntInLinkEstState++;
1713
1714 if (psessionEntry->limIbssActive == true)
1715 {
1716 // We don't receive Beacon frames from any
1717 // other STA in IBSS. Announce IBSS inactive
1718 // to Roaming algorithm
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001719 PELOGW(limLog(pMac, LOGW, FL("Alone in IBSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 psessionEntry->limIbssActive = false;
1721
1722 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_INACTIVE,
1723 NULL, 0, psessionEntry->smeSessionId);
1724 }
1725 }
1726}
1727
1728
1729/** -------------------------------------------------------------
1730\fn limIbssDecideProtectionOnDelete
1731\brief Decides all the protection related information.
1732\
1733\param tpAniSirGlobal pMac
1734\param tSirMacAddr peerMacAddr
1735\param tpUpdateBeaconParams pBeaconParams
1736\return None
1737 -------------------------------------------------------------*/
1738void
1739limIbssDecideProtectionOnDelete(tpAniSirGlobal pMac,
1740 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1741{
1742 tANI_U32 phyMode;
1743 tHalBitVal erpEnabled = eHAL_CLEAR;
1744 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1745 tANI_U32 i;
1746
1747 if(NULL == pStaDs)
1748 return;
1749
1750 limGetRfBand(pMac, &rfBand, psessionEntry);
1751 if(SIR_BAND_2_4_GHZ == rfBand)
1752 {
1753 limGetPhyMode(pMac, &phyMode, psessionEntry);
1754 erpEnabled = pStaDs->erpEnabled;
1755 //we are HT or 11G and 11B station is getting deleted.
Jeff Johnsone7245742012-09-05 17:12:55 -07001756 if ( ((phyMode == WNI_CFG_PHY_MODE_11G) || psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 && (erpEnabled == eHAL_CLEAR))
1758 {
1759 PELOGE(limLog(pMac, LOGE, FL("(%d) A legacy STA is disassociated. Addr is "),
1760 psessionEntry->gLim11bParams.numSta);
1761 limPrintMacAddr(pMac, pStaDs->staAddr, LOGE);)
1762 if (psessionEntry->gLim11bParams.numSta > 0)
1763 {
1764 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1765 {
1766 if (pMac->lim.protStaCache[i].active)
1767 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301768 if (vos_mem_compare(pMac->lim.protStaCache[i].addr,
1769 pStaDs->staAddr, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 {
1771 psessionEntry->gLim11bParams.numSta--;
1772 pMac->lim.protStaCache[i].active = false;
1773 break;
1774 }
1775 }
1776 }
1777 }
1778
1779 if (psessionEntry->gLim11bParams.numSta == 0)
1780 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001781 PELOGE(limLog(pMac, LOGE, FL("No more 11B STA exists. Disable protection. "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 limIbssSetProtection(pMac, false, pBeaconParams,psessionEntry);
1783 }
1784 }
1785 }
1786}
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001787
1788/** -----------------------------------------------------------------
1789\fn __limIbssPeerInactivityHandler
1790\brief Internal function. Deletes FW indicated peer which is inactive
1791\
1792\param tpAniSirGlobal pMac
1793\param tpPESession psessionEntry
1794\param tpSirIbssPeerInactivityInd peerInactivityInd
1795\return None
1796 -----------------------------------------------------------------*/
1797static void
1798__limIbssPeerInactivityHandler(tpAniSirGlobal pMac,
1799 tpPESession psessionEntry,
1800 tpSirIbssPeerInactivityInd peerInactivityInd)
1801{
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001802 if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
1803 {
1804 limReactivateHeartBeatTimer(pMac, psessionEntry);
1805 return;
1806 }
1807
Ravi Joshi92404a32013-08-13 15:40:30 -07001808 /* delete the peer for which heartbeat is observed */
1809 __limIbssSearchAndDeletePeer (pMac, psessionEntry, peerInactivityInd->peerAddr);
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001810
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001811}
1812
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001813/** -------------------------------------------------------------
1814\fn limProcessIbssPeerInactivity
1815\brief Peer inactivity message handler
1816\
1817\param tpAniSirGlobal pMac
1818\param void* buf
1819\return None
1820 -------------------------------------------------------------*/
1821void
1822limProcessIbssPeerInactivity(tpAniSirGlobal pMac, void *buf)
1823{
1824 /*
1825 * --------------- HEARTBEAT OFFLOAD CASE ------------------
1826 * This message handler is executed when the firmware identifies
1827 * inactivity from one or more peer devices. We will come here
1828 * for every inactive peer device
1829 */
1830 tANI_U8 i;
1831
1832 tSirIbssPeerInactivityInd *peerInactivityInd =
1833 (tSirIbssPeerInactivityInd *) buf;
1834
1835 /*
1836 * If IBSS is not started or heartbeat offload is not enabled
1837 * we should not handle this request
1838 */
1839 if (eLIM_STA_IN_IBSS_ROLE != pMac->lim.gLimSystemRole &&
1840 !IS_IBSS_HEARTBEAT_OFFLOAD_FEATURE_ENABLE)
1841 {
1842 return;
1843 }
1844
1845 /** If LinkMonitor is Disabled */
1846 if (!pMac->sys.gSysEnableLinkMonitorMode)
1847 {
1848 return;
1849 }
1850
1851 for (i = 0; i < pMac->lim.maxBssId; i++)
1852 {
1853 if (VOS_TRUE == pMac->lim.gpSession[i].valid &&
1854 eSIR_IBSS_MODE == pMac->lim.gpSession[i].bssType)
1855 {
1856 __limIbssPeerInactivityHandler(pMac,
1857 &pMac->lim.gpSession[i],
1858 peerInactivityInd);
1859 break;
1860 }
1861 }
1862}
1863