blob: eeefc4ee0aa5c8b6c81528ae6d1e6e2b8bb1b66e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -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
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080031/*
Jeff Johnson295189b2012-06-20 16:38:30 -070032 * This file limIbssPeerMgmt.cc contains the utility functions
33 * LIM uses to maintain peers in IBSS.
34 * Author: Chandra Modumudi
35 * Date: 03/12/04
36 * History:-
37 * Date Modified by Modification Information
38 * --------------------------------------------------------------------
39 */
40#include "palTypes.h"
41#include "aniGlobal.h"
42#include "sirCommon.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070044#include "limUtils.h"
45#include "limAssocUtils.h"
46#include "limStaHashApi.h"
47#include "schApi.h" // schSetFixedBeaconFields for IBSS coalesce
48#include "limSecurityUtils.h"
49#include "limSendMessages.h"
50#include "limSession.h"
51#include "limIbssPeerMgmt.h"
52
53
54/**
55 * ibss_peer_find
56 *
57 *FUNCTION:
58 * This function is called while adding a context at
59 * DPH & Polaris for a peer in IBSS.
60 * If peer is found in the list, capabilities from the
61 * returned BSS description are used at DPH node & Polaris.
62 *
63 *LOGIC:
64 *
65 *ASSUMPTIONS:
66 *
67 *NOTE:
68 *
69 * @param macAddr - MAC address of the peer
70 *
71 * @return Pointer to peer node if found, else NULL
72 */
73
74static tLimIbssPeerNode *
75ibss_peer_find(
76 tpAniSirGlobal pMac,
77 tSirMacAddr macAddr)
78{
79 tLimIbssPeerNode *pTempNode = pMac->lim.gLimIbssPeerList;
80
81 while (pTempNode != NULL)
82 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +053083 if (vos_mem_compare((tANI_U8 *) macAddr,
84 (tANI_U8 *) &pTempNode->peerMacAddr,
85 sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -070086 break;
87 pTempNode = pTempNode->next;
88 }
89 return pTempNode;
90} /*** end ibss_peer_find() ***/
91
92/**
93 * ibss_peer_add
94 *
95 *FUNCTION:
96 * This is called on a STA in IBSS upon receiving Beacon/
97 * Probe Response from a peer.
98 *
99 *LOGIC:
100 * Node is always added to the front of the list
101 *
102 *ASSUMPTIONS:
103 *
104 *NOTE:
105 *
106 * @param pMac - Pointer to Global MAC structure
107 * @param pPeerNode - Pointer to peer node to be added to the list.
108 *
109 * @return None
110 */
111
112static tSirRetStatus
113ibss_peer_add(tpAniSirGlobal pMac, tLimIbssPeerNode *pPeerNode)
114{
115#ifdef ANI_SIR_IBSS_PEER_CACHING
116 tANI_U32 numIbssPeers = (2 * pMac->lim.maxStation);
117
118 if (pMac->lim.gLimNumIbssPeers >= numIbssPeers)
119 {
120 /**
121 * Reached max number of peers to be maintained.
122 * Delete last entry & add new entry at the beginning.
123 */
124 tLimIbssPeerNode *pTemp, *pPrev;
125 pTemp = pPrev = pMac->lim.gLimIbssPeerList;
126 while (pTemp->next != NULL)
127 {
128 pPrev = pTemp;
129 pTemp = pTemp->next;
130 }
131 if(pTemp->beacon)
132 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530133 vos_mem_free(pTemp->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 }
135
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530136 vos_mem_free(pTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 pPrev->next = NULL;
138 }
139 else
140#endif
141 pMac->lim.gLimNumIbssPeers++;
142
143 pPeerNode->next = pMac->lim.gLimIbssPeerList;
144 pMac->lim.gLimIbssPeerList = pPeerNode;
145
146 return eSIR_SUCCESS;
147
148} /*** end limAddIbssPeerToList() ***/
149
150/**
151 * ibss_peer_collect
152 *
153 *FUNCTION:
154 * This is called to collect IBSS peer information
155 * from received Beacon/Probe Response frame from it.
156 *
157 *LOGIC:
158 *
159 *ASSUMPTIONS:
160 *
161 *NOTE:
162 *
163 * @param pMac - Pointer to Global MAC structure
164 * @param pBeacon - Parsed Beacon Frame structure
165 * @param pBD - Pointer to received BD
166 * @param pPeer - Pointer to IBSS peer node
167 *
168 * @return None
169 */
170
171static void
172ibss_peer_collect(
173 tpAniSirGlobal pMac,
174 tpSchBeaconStruct pBeacon,
175 tpSirMacMgmtHdr pHdr,
176 tLimIbssPeerNode *pPeer,
177 tpPESession psessionEntry)
178{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530179 vos_mem_copy(pPeer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
181 pPeer->capabilityInfo = pBeacon->capabilityInfo;
182 pPeer->extendedRatesPresent = pBeacon->extendedRatesPresent;
183 pPeer->edcaPresent = pBeacon->edcaPresent;
184 pPeer->wmeEdcaPresent = pBeacon->wmeEdcaPresent;
185 pPeer->wmeInfoPresent = pBeacon->wmeInfoPresent;
186
187 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
188 (pBeacon->HTCaps.present))
189 {
190 pPeer->htCapable = pBeacon->HTCaps.present;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530191 vos_mem_copy((tANI_U8 *)pPeer->supportedMCSSet,
192 (tANI_U8 *)pBeacon->HTCaps.supportedMCSSet,
193 sizeof(pPeer->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 pPeer->htGreenfield = (tANI_U8)pBeacon->HTCaps.greenField;
195 pPeer->htSupportedChannelWidthSet = ( tANI_U8 ) pBeacon->HTCaps.supportedChannelWidthSet;
196 pPeer->htMIMOPSState = (tSirMacHTMIMOPowerSaveState)pBeacon->HTCaps.mimoPowerSave;
197 pPeer->htMaxAmsduLength = ( tANI_U8 ) pBeacon->HTCaps.maximalAMSDUsize;
198 pPeer->htAMpduDensity = pBeacon->HTCaps.mpduDensity;
199 pPeer->htDsssCckRate40MHzSupport = (tANI_U8)pBeacon->HTCaps.dsssCckMode40MHz;
200 pPeer->htShortGI20Mhz = (tANI_U8)pBeacon->HTCaps.shortGI20MHz;
201 pPeer->htShortGI40Mhz = (tANI_U8)pBeacon->HTCaps.shortGI40MHz;
202 pPeer->htMaxRxAMpduFactor = pBeacon->HTCaps.maxRxAMPDUFactor;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700203 pPeer->htSecondaryChannelOffset = pBeacon->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 }
205
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700206 /* Collect peer VHT capabilities based on the received beacon from the peer */
207#ifdef WLAN_FEATURE_11AC
208 if ( pBeacon->VHTCaps.present )
209 {
Bansidhar Gopalachari5fd3d132013-07-30 13:35:35 -0700210 pPeer->vhtSupportedChannelWidthSet = pBeacon->VHTOperation.chanWidth;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700211 pPeer->vhtCapable = pBeacon->VHTCaps.present;
212
213 // Collect VHT capabilities from beacon
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530214 vos_mem_copy((tANI_U8 *) &pPeer->VHTCaps,
215 (tANI_U8 *) &pBeacon->VHTCaps,
216 sizeof(tDot11fIEVHTCaps));
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700217 }
218#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 pPeer->erpIePresent = pBeacon->erpPresent;
220
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530221 vos_mem_copy((tANI_U8 *) &pPeer->supportedRates,
222 (tANI_U8 *) &pBeacon->supportedRates,
223 pBeacon->supportedRates.numRates + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 if (pPeer->extendedRatesPresent)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530225 vos_mem_copy((tANI_U8 *) &pPeer->extendedRates,
226 (tANI_U8 *) &pBeacon->extendedRates,
227 pBeacon->extendedRates.numRates + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 else
229 pPeer->extendedRates.numRates = 0;
230
231 // TBD copy EDCA parameters
232 // pPeer->edcaParams;
233
234 pPeer->next = NULL;
235} /*** end ibss_peer_collect() ***/
236
237// handle change in peer qos/wme capabilities
238static void
239ibss_sta_caps_update(
240 tpAniSirGlobal pMac,
241 tLimIbssPeerNode *pPeerNode,
242 tpPESession psessionEntry)
243{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800244 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700245 tpDphHashNode pStaDs;
246
247 pPeerNode->beaconHBCount++; //Update beacon count.
248
249 // if the peer node exists, update its qos capabilities
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800250 if ((pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 return;
252
253
254 //Update HT Capabilities
255 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
256 {
257 pStaDs->mlmStaContext.htCapability = pPeerNode->htCapable;
258 if (pPeerNode->htCapable)
259 {
260 pStaDs->htGreenfield = pPeerNode->htGreenfield;
261 pStaDs->htSupportedChannelWidthSet = pPeerNode->htSupportedChannelWidthSet;
262 pStaDs->htMIMOPSState = pPeerNode->htMIMOPSState;
263 pStaDs->htMaxAmsduLength = pPeerNode->htMaxAmsduLength;
264 pStaDs->htAMpduDensity = pPeerNode->htAMpduDensity;
265 pStaDs->htDsssCckRate40MHzSupport = pPeerNode->htDsssCckRate40MHzSupport;
266 pStaDs->htShortGI20Mhz = pPeerNode->htShortGI20Mhz;
267 pStaDs->htShortGI40Mhz = pPeerNode->htShortGI40Mhz;
268 pStaDs->htMaxRxAMpduFactor = pPeerNode->htMaxRxAMpduFactor;
269 // In the future, may need to check for "delayedBA"
270 // For now, it is IMMEDIATE BA only on ALL TID's
271 pStaDs->baPolicyFlag = 0xFF;
272 }
273 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700274#ifdef WLAN_FEATURE_11AC
275 if ( IS_DOT11_MODE_VHT(psessionEntry->dot11mode) )
276 {
277 pStaDs->mlmStaContext.vhtCapability = pPeerNode->vhtCapable;
278 if ( pPeerNode->vhtCapable )
279 {
280 pStaDs->vhtSupportedChannelWidthSet = pPeerNode->vhtSupportedChannelWidthSet;
281 }
282 }
283#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285 if(IS_DOT11_MODE_PROPRIETARY(psessionEntry->dot11mode) &&
286 pPeerNode->aniIndicator)
287 {
288 pStaDs->aniPeer = pPeerNode->aniIndicator;
289 pStaDs->propCapability = pPeerNode->propCapability;
290 }
291
292
293 // peer is 11e capable but is not 11e enabled yet
294 // some STA's when joining Airgo IBSS, assert qos capability even when
295 // they don't suport qos. however, they do not include the edca parameter
296 // set. so let's check for edcaParam in addition to the qos capability
297 if (pPeerNode->capabilityInfo.qos && (psessionEntry->limQosEnabled) && pPeerNode->edcaPresent)
298 {
299 pStaDs->qosMode = 1;
300 pStaDs->wmeEnabled = 0;
301 if (! pStaDs->lleEnabled)
302 {
303 pStaDs->lleEnabled = 1;
304 //dphSetACM(pMac, pStaDs);
305 }
306 return;
307 }
308 // peer is not 11e capable now but was 11e enabled earlier
309 else if (pStaDs->lleEnabled)
310 {
311 pStaDs->qosMode = 0;
312 pStaDs->lleEnabled = 0;
313 }
314
315 // peer is wme capable but is not wme enabled yet
316 if (pPeerNode->wmeInfoPresent && psessionEntry->limWmeEnabled)
317 {
318 pStaDs->qosMode = 1;
319 pStaDs->lleEnabled = 0;
320 if (! pStaDs->wmeEnabled)
321 {
322 pStaDs->wmeEnabled = 1;
323 //dphSetACM(pMac, pStaDs);
324 }
325 return;
326 }
327 /* When the peer device supports EDCA parameters, then we were not
328 considering. Added this code when we saw that one of the Peer Device
329 was advertising WMM param where we were not honouring that. CR# 210756
330 */
331 if (pPeerNode->wmeEdcaPresent && psessionEntry->limWmeEnabled) {
332 pStaDs->qosMode = 1;
333 pStaDs->lleEnabled = 0;
334 if (! pStaDs->wmeEnabled) {
335 pStaDs->wmeEnabled = 1;
336 }
337 return;
338 }
339
340 // peer is not wme capable now but was wme enabled earlier
341 else if (pStaDs->wmeEnabled)
342 {
343 pStaDs->qosMode = 0;
344 pStaDs->wmeEnabled = 0;
345 }
346
347}
348
349static void
350ibss_sta_rates_update(
351 tpAniSirGlobal pMac,
352 tpDphHashNode pStaDs,
353 tLimIbssPeerNode *pPeer,
354 tpPESession psessionEntry)
355{
Jeff Johnsone7245742012-09-05 17:12:55 -0700356#ifdef WLAN_FEATURE_11AC
357 limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates,
358 &pPeer->extendedRates, pPeer->supportedMCSSet,
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700359 &pStaDs->mlmStaContext.propRateSet,psessionEntry, &pPeer->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -0700360#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 // Populate supported rateset
362 limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates,
363 &pPeer->extendedRates, pPeer->supportedMCSSet,
364 &pStaDs->mlmStaContext.propRateSet,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
367 pStaDs->mlmStaContext.capabilityInfo = pPeer->capabilityInfo;
368} /*** end ibss_sta_info_update() ***/
369
370/**
371 * ibss_sta_info_update
372 *
373 *FUNCTION:
374 * This is called to program both SW & Polaris context
375 * for peer in IBSS.
376 *
377 *LOGIC:
378 *
379 *ASSUMPTIONS:
380 *
381 *NOTE:
382 *
383 * @param pMac - Pointer to Global MAC structure
384 * @param pStaDs - Pointer to DPH node
385 * @param pPeer - Pointer to IBSS peer node
386 *
387 * @return None
388 */
389
390static void
391ibss_sta_info_update(
392 tpAniSirGlobal pMac,
393 tpDphHashNode pStaDs,
394 tLimIbssPeerNode *pPeer,
395 tpPESession psessionEntry)
396{
397 pStaDs->staType = STA_ENTRY_PEER;
398 ibss_sta_caps_update(pMac, pPeer,psessionEntry);
399 ibss_sta_rates_update(pMac, pStaDs, pPeer,psessionEntry);
400} /*** end ibss_sta_info_update() ***/
401
402static void
403ibss_coalesce_free(
404 tpAniSirGlobal pMac)
405{
406 if (pMac->lim.ibssInfo.pHdr != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530407 vos_mem_free(pMac->lim.ibssInfo.pHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 if (pMac->lim.ibssInfo.pBeacon != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530409 vos_mem_free(pMac->lim.ibssInfo.pBeacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700410
411 pMac->lim.ibssInfo.pHdr = NULL;
412 pMac->lim.ibssInfo.pBeacon = NULL;
413}
414
415/*
416 * save the beacon params for use when adding the bss
417 */
418static void
419ibss_coalesce_save(
420 tpAniSirGlobal pMac,
421 tpSirMacMgmtHdr pHdr,
422 tpSchBeaconStruct pBeacon)
423{
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 // get rid of any saved info
425 ibss_coalesce_free(pMac);
426
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530427 pMac->lim.ibssInfo.pHdr = vos_mem_malloc(sizeof(*pHdr));
428 if (NULL == pMac->lim.ibssInfo.pHdr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700430 PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pHdr"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 return;
432 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530433 pMac->lim.ibssInfo.pBeacon = vos_mem_malloc(sizeof(*pBeacon));
434 if (NULL == pMac->lim.ibssInfo.pBeacon)
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700436 PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pBeacon"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700437 ibss_coalesce_free(pMac);
438 return;
439 }
440
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530441 vos_mem_copy(pMac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr));
442 vos_mem_copy(pMac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon));
Jeff Johnson295189b2012-06-20 16:38:30 -0700443}
444
445/*
446 * tries to add a new entry to dph hash node
447 * if necessary, an existing entry is eliminated
448 */
449static tSirRetStatus
450ibss_dph_entry_add(
451 tpAniSirGlobal pMac,
452 tSirMacAddr peerAddr,
453 tpDphHashNode *ppSta,
454 tpPESession psessionEntry)
455{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800456 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 tpDphHashNode pStaDs;
458
459 *ppSta = NULL;
460
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800461 pStaDs = dphLookupHashEntry(pMac, peerAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 if (pStaDs != NULL)
463 {
464 /* Trying to add context for already existing STA in IBSS */
465 PELOGE(limLog(pMac, LOGE, FL("STA exists already "));)
466 limPrintMacAddr(pMac, peerAddr, LOGE);
467 return eSIR_FAILURE;
468 }
469
470 /**
471 * Assign an AID, delete context existing with that
472 * AID and then add an entry to hash table maintained
473 * by DPH module.
474 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800475 peerIdx = limAssignPeerIdx(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800477 pStaDs = dphGetHashEntry(pMac, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 if (pStaDs)
479 {
480 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800481 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 }
483
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800484 pStaDs = dphAddHashEntry(pMac, peerAddr, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 if (pStaDs == NULL)
486 {
487 // Could not add hash table entry
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700488 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 -0700489 limPrintMacAddr(pMac, peerAddr, LOGE);
490 return eSIR_FAILURE;
491 }
492
493 *ppSta = pStaDs;
494 return eSIR_SUCCESS;
495}
496
497// send a status change notification
498static void
499ibss_status_chg_notify(
500 tpAniSirGlobal pMac,
501 tSirMacAddr peerAddr,
502 tANI_U16 staIndex,
503 tANI_U8 ucastSig,
504 tANI_U8 bcastSig,
505 tANI_U16 status,
506 tANI_U8 sessionId)
507{
508
509 tLimIbssPeerNode *peerNode;
510 tANI_U8 *beacon = NULL;
511 tANI_U16 bcnLen = 0;
512
513
514 peerNode = ibss_peer_find(pMac,peerAddr);
515 if(peerNode != NULL)
516 {
517 if(peerNode->beacon == NULL) peerNode->beaconLen = 0;
518 beacon = peerNode->beacon;
519 bcnLen = peerNode->beaconLen;
520 peerNode->beacon = NULL;
521 peerNode->beaconLen = 0;
522 }
523
524 limSendSmeIBSSPeerInd(pMac,peerAddr, staIndex, ucastSig, bcastSig,
525 beacon, bcnLen, status, sessionId);
526
527 if(beacon != NULL)
528 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530529 vos_mem_free(beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 }
531}
532
533
534static void
535ibss_bss_add(
536 tpAniSirGlobal pMac,
537 tpPESession psessionEntry)
538{
539 tLimMlmStartReq mlmStartReq;
540 tANI_U32 cfg;
541 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr;
542 tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon;
543 tANI_U8 numExtRates = 0;
544
545 if ((pHdr == NULL) || (pBeacon == NULL))
546 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700547 PELOGE(limLog(pMac, LOGE, FL("Unable to add BSS (no cached BSS info)"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 return;
549 }
550
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530551 vos_mem_copy(psessionEntry->bssId, pHdr->bssId,
552 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
554 #if 0
555 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pHdr->bssId, sizeof(tSirMacAddr))
556 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700557 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 #endif //TO SUPPORT BT-AMP
559
560 sirCopyMacAddr(pHdr->bssId,psessionEntry->bssId);
561 /* We need not use global Mac address since per seesion BSSID is available */
562 //limSetBssid(pMac, pHdr->bssId);
563
564#if 0
565 if (wlan_cfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &cfg) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700566 limLog(pMac, LOGP, FL("Can't read beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700567#endif //TO SUPPORT BT-AMP
568 /* Copy beacon interval from sessionTable */
569 cfg = psessionEntry->beaconParams.beaconInterval;
570 if (cfg != pBeacon->beaconInterval)
571 #if 0
572 if (cfgSetInt(pMac, WNI_CFG_BEACON_INTERVAL, pBeacon->beaconInterval)
573 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700574 limLog(pMac, LOGP, FL("Can't update beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 #endif//TO SUPPORT BT-AMP
576 psessionEntry->beaconParams.beaconInterval = pBeacon->beaconInterval;
577
578 /* This function ibss_bss_add (and hence the below code) is only called during ibss coalescing. We need to
579 * adapt to peer's capability with respect to short slot time. Changes have been made to limApplyConfiguration()
580 * so that the IBSS doesnt blindly start with short slot = 1. If IBSS start is part of coalescing then it will adapt
581 * to peer's short slot using code below.
582 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 /* If cfg is already set to current peer's capability then no need to set it again */
Jeff Johnsone7245742012-09-05 17:12:55 -0700584 if (psessionEntry->shortSlotTimeSupported != pBeacon->capabilityInfo.shortSlotTime)
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700586 psessionEntry->shortSlotTimeSupported = pBeacon->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530588 vos_mem_copy((tANI_U8 *) &psessionEntry->pLimStartBssReq->operationalRateSet,
589 (tANI_U8 *) &pBeacon->supportedRates,
590 pBeacon->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592 #if 0
593 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
594 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
595 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
596 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700597 limLog(pMac, LOGP, FL("could not update OperRateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 #endif //TO SUPPORT BT-AMP
599
600 /**
601 * WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET CFG needs to be reset, when
602 * there is no extended rate IE present in beacon. This is especially important when
603 * supportedRateSet IE contains all the extended rates as well and STA decides to coalesce.
604 * In this IBSS coalescing scenario LIM will tear down the BSS and Add a new one. So LIM needs to
605 * reset this CFG, just in case CSR originally had set this CFG when IBSS was started from the local profile.
606 * If IBSS was started by CSR from the BssDescription, then it would reset this CFG before StartBss is issued.
607 * The idea is that the count of OpRateSet and ExtendedOpRateSet rates should not be more than 12.
608 */
609
610 if(pBeacon->extendedRatesPresent)
611 numExtRates = pBeacon->extendedRates.numRates;
612 if (cfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
613 (tANI_U8 *) &pBeacon->extendedRates.rate, numExtRates) != eSIR_SUCCESS)
614 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700615 limLog(pMac, LOGP, FL("could not update ExtendedOperRateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 return;
617 }
618
619
620 /*
621 * Each IBSS node will advertise its own HT Capabilities instead of adapting to the Peer's capabilities
622 * If we don't do this then IBSS may not go back to full capabilities when the STA with lower capabilities
623 * leaves the IBSS. e.g. when non-CB STA joins an IBSS and then leaves, the IBSS will be stuck at non-CB mode
624 * even though all the nodes are capable of doing CB.
625 * so it is decided to leave the self HT capabilties intact. This may change if some issues are found in interop.
626 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530627 vos_mem_set((void *) &mlmStartReq, sizeof(mlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700628
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530629 vos_mem_copy(mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 mlmStartReq.rateSet.numRates = psessionEntry->pLimStartBssReq->operationalRateSet.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530631 vos_mem_copy(&mlmStartReq.rateSet.rate[0],
632 &psessionEntry->pLimStartBssReq->operationalRateSet.rate[0],
633 mlmStartReq.rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 mlmStartReq.bssType = eSIR_IBSS_MODE;
635 mlmStartReq.beaconPeriod = pBeacon->beaconInterval;
636 mlmStartReq.nwType = psessionEntry->pLimStartBssReq->nwType; //psessionEntry->nwType is also OK????
Jeff Johnsone7245742012-09-05 17:12:55 -0700637 mlmStartReq.htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 mlmStartReq.htOperMode = pMac->lim.gHTOperMode;
639 mlmStartReq.dualCTSProtection = pMac->lim.gHTDualCTSProtection;
Jeff Johnsone7245742012-09-05 17:12:55 -0700640 mlmStartReq.txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700641
642 #if 0
643 if (wlan_cfgGetInt(pMac, WNI_CFG_CURRENT_CHANNEL, &cfg) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700644 limLog(pMac, LOGP, FL("CurrentChannel CFG get fialed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 #endif
646
647 //mlmStartReq.channelNumber = (tSirMacChanNum) cfg;
648
649 /* reading the channel num from session Table */
650 mlmStartReq.channelNumber = psessionEntry->currentOperChannel;
651
652 mlmStartReq.cbMode = psessionEntry->pLimStartBssReq->cbMode;
653
654 // Copy the SSID for RxP filtering based on SSID.
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530655 vos_mem_copy((tANI_U8 *) &mlmStartReq.ssId,
656 (tANI_U8 *) &psessionEntry->pLimStartBssReq->ssId,
657 psessionEntry->pLimStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700658
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530659 limLog(pMac, LOG1, FL("invoking ADD_BSS as part of coalescing!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 if (limMlmAddBss(pMac, &mlmStartReq,psessionEntry) != eSIR_SME_SUCCESS)
661 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700662 PELOGE(limLog(pMac, LOGE, FL("AddBss failure"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 return;
664 }
665
666 // Update fields in Beacon
667 if (schSetFixedBeaconFields(pMac,psessionEntry) != eSIR_SUCCESS)
668 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700669 PELOGE(limLog(pMac, LOGE, FL("*** Unable to set fixed Beacon fields ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 return;
671 }
672
673}
674
675
676
677/* delete the current BSS */
678static void
679ibss_bss_delete(
680 tpAniSirGlobal pMac,
681 tpPESession psessionEntry)
682{
683 tSirRetStatus status;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700684 PELOGW(limLog(pMac, LOGW, FL("Initiating IBSS Delete BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 if (psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
686 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700687 limLog(pMac, LOGW, FL("Incorrect LIM MLM state for delBss (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 psessionEntry->limMlmState);
689 return;
690 }
691 status = limDelBss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
692 if (status != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700693 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700694}
695
696/**
697 * limIbssInit
698 *
699 *FUNCTION:
700 * This function is called while starting an IBSS
701 * to initialize list used to maintain IBSS peers.
702 *
703 *LOGIC:
704 *
705 *ASSUMPTIONS:
706 *
707 *NOTE:
708 *
709 * @param pMac - Pointer to Global MAC structure
710 * @return None
711 */
712
713void
714limIbssInit(
715 tpAniSirGlobal pMac)
716{
717 //pMac->lim.gLimIbssActive = 0;
718 pMac->lim.gLimIbssCoalescingHappened = 0;
719 pMac->lim.gLimIbssPeerList = NULL;
720 pMac->lim.gLimNumIbssPeers = 0;
721
722 // ibss info - params for which ibss to join while coalescing
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530723 vos_mem_set(&pMac->lim.ibssInfo, sizeof(tAniSirLimIbss), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700724} /*** end limIbssInit() ***/
725
726/**
727 * limIbssDeleteAllPeers
728 *
729 *FUNCTION:
730 * This function is called to delete all peers.
731 *
732 *LOGIC:
733 *
734 *ASSUMPTIONS:
735 *
736 *NOTE:
737 *
738 * @param pMac - Pointer to Global MAC structure
739 * @return None
740 */
741
742void limIbssDeleteAllPeers( tpAniSirGlobal pMac ,tpPESession psessionEntry)
743{
744 tLimIbssPeerNode *pCurrNode, *pTempNode;
745 tpDphHashNode pStaDs;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800746 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700747
748 pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList;
749
750 while (pCurrNode != NULL)
751 {
752 if (!pMac->lim.gLimNumIbssPeers)
753 {
754 limLog(pMac, LOGP,
755 FL("Number of peers in the list is zero and node present"));
756 return;
757 }
758 /* Delete the dph entry for the station
759 * Since it is called to remove all peers, just delete from dph,
760 * no need to do any beacon related params i.e., dont call limDeleteDphHashEntry
761 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800762 pStaDs = dphLookupHashEntry(pMac, pCurrNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 if( pStaDs )
764 {
765
766 ibss_status_chg_notify( pMac, pCurrNode->peerMacAddr, pStaDs->staIndex,
767 pStaDs->ucUcastSig, pStaDs->ucBcastSig,
768 eWNI_SME_IBSS_PEER_DEPARTED_IND, psessionEntry->smeSessionId );
Ravi Joshi492be3c2013-05-16 19:20:00 -0700769 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800770 dphDeleteHashEntry(pMac, pStaDs->staAddr, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 }
772
773 pTempNode = pCurrNode->next;
774
775 /* TODO :Sessionize this code */
776 /* Fix CR 227642: PeerList should point to the next node since the current node is being
777 * freed in the next line. In ibss_peerfind in ibss_status_chg_notify above, we use this
778 * peer list to find the next peer. So this list needs to be updated with the no of peers left
779 * after each iteration in this while loop since one by one peers are deleted (freed) in this
780 * loop causing the lim.gLimIbssPeerList to point to some freed memory.
781 */
782 pMac->lim.gLimIbssPeerList = pTempNode;
783
784 if(pCurrNode->beacon)
785 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530786 vos_mem_free(pCurrNode->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530788 vos_mem_free(pCurrNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 if (pMac->lim.gLimNumIbssPeers > 0) // be paranoid
790 pMac->lim.gLimNumIbssPeers--;
791 pCurrNode = pTempNode;
792 }
793
794 if (pMac->lim.gLimNumIbssPeers)
795 limLog(pMac, LOGP, FL("Number of peers[%d] in the list is non-zero"),
796 pMac->lim.gLimNumIbssPeers);
797
798 pMac->lim.gLimNumIbssPeers = 0;
799 pMac->lim.gLimIbssPeerList = NULL;
800
801}
802/**
803 * limIbssDelete
804 *
805 *FUNCTION:
806 * This function is called while tearing down an IBSS.
807 *
808 *LOGIC:
809 *
810 *ASSUMPTIONS:
811 *
812 *NOTE:
813 *
814 * @param pMac - Pointer to Global MAC structure
815 * @return None
816 */
817
818void
819limIbssDelete(
820 tpAniSirGlobal pMac,tpPESession psessionEntry)
821{
822 limIbssDeleteAllPeers(pMac,psessionEntry);
823
824 ibss_coalesce_free(pMac);
825} /*** end limIbssDelete() ***/
826
827/** Commenting this Code as from no where it is being invoked */
828#if 0
829/**
830 * limIbssPeerDelete
831 *
832 *FUNCTION:
833 * This may be called on a STA in IBSS to delete a peer
834 * from the list.
835 *
836 *LOGIC:
837 *
838 *ASSUMPTIONS:
839 *
840 *NOTE:
841 *
842 * @param pMac - Pointer to Global MAC structure
843 * @param peerMacAddr - MAC address of the peer STA that
844 * need to be deleted from peer list.
845 *
846 * @return None
847 */
848
849void
850limIbssPeerDelete(tpAniSirGlobal pMac, tSirMacAddr macAddr)
851{
852 tLimIbssPeerNode *pPrevNode, *pTempNode;
853
854 pTempNode = pPrevNode = pMac->lim.gLimIbssPeerList;
855
856 if (pTempNode == NULL)
857 return;
858
859 while (pTempNode != NULL)
860 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530861 if (vos_mem_compare((tANI_U8 *) macAddr,
862 (tANI_U8 *) &pTempNode->peerMacAddr,
863 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 {
865 // Found node to be deleted
866 if (pMac->lim.gLimIbssPeerList == pTempNode) /** First Node to be deleted*/
867 pMac->lim.gLimIbssPeerList = pTempNode->next;
868 else
869 pPrevNode->next = pTempNode->next;
870
871 if(pTempNode->beacon)
872 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530873 vos_mem_free(pTempNode->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 pTempNode->beacon = NULL;
875 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530876 vos_mem_free(pTempNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 pMac->lim.gLimNumIbssPeers--;
878 return;
879 }
880
881 pPrevNode = pTempNode;
882 pTempNode = pTempNode->next;
883 }
884
885 // Should not be here
886 PELOGE(limLog(pMac, LOGE, FL("peer not found in the list, addr= "));)
887 limPrintMacAddr(pMac, macAddr, LOGE);
888} /*** end limIbssPeerDelete() ***/
889
890#endif
891
892
893/** -------------------------------------------------------------
894\fn limIbssSetProtection
895\brief Decides all the protection related information.
896\
897\param tpAniSirGlobal pMac
898\param tSirMacAddr peerMacAddr
899\param tpUpdateBeaconParams pBeaconParams
900\return None
901 -------------------------------------------------------------*/
902static void
903limIbssSetProtection(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
904{
905
906 if(!pMac->lim.cfgProtection.fromllb)
907 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530908 limLog(pMac, LOG1, FL("protection from 11b is disabled"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 return;
910 }
911
912 if (enable)
913 {
914 psessionEntry->gLim11bParams.protectionEnabled = true;
915 if(false == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/)
916 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700917 PELOGE(limLog(pMac, LOGE, FL("=> IBSS: Enable Protection "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
919 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
920 }
921 }
922 else if (true == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/)
923 {
924 psessionEntry->gLim11bParams.protectionEnabled = false;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700925 PELOGE(limLog(pMac, LOGE, FL("===> IBSS: Disable protection "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
927 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
928 }
929 return;
930}
931
932
933/** -------------------------------------------------------------
934\fn limIbssUpdateProtectionParams
935\brief Decides all the protection related information.
936\
937\param tpAniSirGlobal pMac
938\param tSirMacAddr peerMacAddr
939\param tpUpdateBeaconParams pBeaconParams
940\return None
941 -------------------------------------------------------------*/
942static void
943limIbssUpdateProtectionParams(tpAniSirGlobal pMac,
944 tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType,
945 tpPESession psessionEntry)
946{
947 tANI_U32 i;
948
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530949 limLog(pMac,LOG1, FL("A STA is associated:"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 limLog(pMac,LOG1, FL("Addr : "));
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530951 limPrintMacAddr(pMac, peerMacAddr, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700952
953 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
954 {
955 if (pMac->lim.protStaCache[i].active)
956 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530957 limLog(pMac, LOG1, FL("Addr: "));
958 limPrintMacAddr(pMac, pMac->lim.protStaCache[i].addr, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700959
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530960 if (vos_mem_compare(pMac->lim.protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 peerMacAddr, sizeof(tSirMacAddr)))
962 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530963 limLog(pMac, LOG1, FL("matching cache entry at %d already active."), i);
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 return;
965 }
966 }
967 }
968
969 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
970 {
971 if (!pMac->lim.protStaCache[i].active)
972 break;
973 }
974
975 if (i >= LIM_PROT_STA_CACHE_SIZE)
976 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700977 PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 return;
979 }
980
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530981 vos_mem_copy(pMac->lim.protStaCache[i].addr,
982 peerMacAddr,
983 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 pMac->lim.protStaCache[i].protStaCacheType = protStaCacheType;
986 pMac->lim.protStaCache[i].active = true;
987 if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType)
988 {
989 psessionEntry->gLim11bParams.numSta++;
990 }
991 else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType)
992 {
993 psessionEntry->gLim11gParams.numSta++;
994 }
995}
996
997
998/** -------------------------------------------------------------
999\fn limIbssDecideProtection
1000\brief Decides all the protection related information.
1001\
1002\param tpAniSirGlobal pMac
1003\param tSirMacAddr peerMacAddr
1004\param tpUpdateBeaconParams pBeaconParams
1005\return None
1006 -------------------------------------------------------------*/
1007static void
1008limIbssDecideProtection(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1009{
1010 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1011 tANI_U32 phyMode;
1012 tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID;
1013
1014 pBeaconParams->paramChangeBitmap = 0;
1015
1016 if(NULL == pStaDs)
1017 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001018 PELOGE(limLog(pMac, LOGE, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 return;
1020 }
1021
1022 limGetRfBand(pMac, &rfBand, psessionEntry);
1023 if(SIR_BAND_2_4_GHZ== rfBand)
1024 {
1025 limGetPhyMode(pMac, &phyMode, psessionEntry);
1026
1027 //We are 11G or 11n. Check if we need protection from 11b Stations.
Jeff Johnsone7245742012-09-05 17:12:55 -07001028 if ((phyMode == WNI_CFG_PHY_MODE_11G) || (psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 {
1030 /* As we found in the past, it is possible that a 11n STA sends
1031 * Beacon with HT IE but not ERP IE. So the absense of ERP IE
1032 * in the Beacon is not enough to conclude that STA is 11b.
1033 */
1034 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1035 (!pStaDs->mlmStaContext.htCapability))
1036 {
1037 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001038 PELOGE(limLog(pMac, LOGE, FL("Enable protection from 11B"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 limIbssSetProtection(pMac, true, pBeaconParams,psessionEntry);
1040 }
1041 }
1042 }
1043 limIbssUpdateProtectionParams(pMac, pStaDs->staAddr, protStaCacheType, psessionEntry);
1044 return;
1045}
1046
1047
1048/**
1049 * limIbssStaAdd()
1050 *
1051 *FUNCTION:
1052 * This function is called to add an STA context in IBSS role
1053 * whenever a data frame is received from/for a STA that failed
1054 * hash lookup at DPH.
1055 *
1056 *LOGIC:
1057 *
1058 *ASSUMPTIONS:
1059 * NA
1060 *
1061 *NOTE:
1062 * NA
1063 *
1064 * @param pMac Pointer to Global MAC structure
1065 * @param peerAdddr MAC address of the peer being added
1066 * @return retCode Indicates success or failure return code
1067 * @return
1068 */
1069
1070tSirRetStatus
1071limIbssStaAdd(
1072 tpAniSirGlobal pMac,
1073 void *pBody,
1074 tpPESession psessionEntry)
1075{
1076 tSirRetStatus retCode = eSIR_SUCCESS;
1077 tpDphHashNode pStaDs;
1078 tLimIbssPeerNode *pPeerNode;
1079 tLimMlmStates prevState;
1080 tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody;
1081 tUpdateBeaconParams beaconParams;
1082
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301083 vos_mem_set((tANI_U8 *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001084
1085 if (pBody == 0)
1086 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001087 PELOGE(limLog(pMac, LOGE, FL("Invalid IBSS AddSta"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 return eSIR_FAILURE;
1089 }
1090
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001091 PELOGE(limLog(pMac, LOGE, FL("Rx Add-Ibss-Sta for MAC:"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
1093
1094 pPeerNode = ibss_peer_find(pMac, *pPeerAddr);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001095 if (NULL != pPeerNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 {
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001097 retCode = ibss_dph_entry_add(pMac, *pPeerAddr, &pStaDs, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 if (eSIR_SUCCESS == retCode)
1099 {
1100 prevState = pStaDs->mlmStaContext.mlmState;
1101 pStaDs->erpEnabled = pPeerNode->erpIePresent;
1102
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001103 ibss_sta_info_update(pMac, pStaDs, pPeerNode, psessionEntry);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001104 PELOGW(limLog(pMac, LOGW, FL("initiating ADD STA for the IBSS peer."));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001105 retCode = limAddSta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001106 if (retCode != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 {
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001108 PELOGE(limLog(pMac, LOGE, FL("ibss-sta-add failed (reason %x)"),
1109 retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001111 pStaDs->mlmStaContext.mlmState = prevState;
1112 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,
1113 &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 }
1115 else
1116 {
1117 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1118 limIbssDecideProtection(pMac, pStaDs, &beaconParams , psessionEntry);
1119
1120 if(beaconParams.paramChangeBitmap)
1121 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001122 PELOGE(limLog(pMac, LOGE, FL("---> Update Beacon Params "));)
Sunil Ravib96f7b52013-05-22 21:40:05 -07001123 schSetFixedBeaconFields(pMac, psessionEntry);
1124 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1126 }
1127 }
1128 }
1129 else
1130 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001131 PELOGE(limLog(pMac, LOGE, FL("hashTblAdd failed (reason %x)"), retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
1133 }
1134 }
1135 else
1136 {
1137 retCode = eSIR_FAILURE;
1138 }
1139
1140 return retCode;
1141}
1142
1143/* handle the response from HAL for an ADD STA request */
1144tSirRetStatus
1145limIbssAddStaRsp(
1146 tpAniSirGlobal pMac,
1147 void *msg,tpPESession psessionEntry)
1148{
1149 tpDphHashNode pStaDs;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001150 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 tpAddStaParams pAddStaParams = (tpAddStaParams) msg;
1152
1153 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1154 if (pAddStaParams == NULL)
1155 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001156 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 return eSIR_FAILURE;
1158 }
1159
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001160 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 if (pStaDs == NULL)
1162 {
1163 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP for unknown MAC addr "));)
1164 limPrintMacAddr(pMac, pAddStaParams->staMac, LOGE);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301165 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 return eSIR_FAILURE;
1167 }
1168
1169 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
1170 {
1171 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP error (%x) "), pAddStaParams->status);)
1172 limPrintMacAddr(pMac, pAddStaParams->staMac, LOGE);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301173 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 return eSIR_FAILURE;
1175 }
1176
1177 pStaDs->bssId = pAddStaParams->bssIdx;
1178 pStaDs->staIndex = pAddStaParams->staIdx;
1179 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
1180 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
1181 pStaDs->valid = 1;
1182 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1183
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001184 PELOGW(limLog(pMac, LOGW, FL("IBSS: sending IBSS_NEW_PEER msg to SME!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001185
1186 ibss_status_chg_notify(pMac, pAddStaParams->staMac, pStaDs->staIndex,
1187 pStaDs->ucUcastSig, pStaDs->ucBcastSig,
1188 eWNI_SME_IBSS_NEW_PEER_IND,
1189 psessionEntry->smeSessionId);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301190 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001191
1192 return eSIR_SUCCESS;
1193}
1194
1195
1196
1197void limIbssDelBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg,tpPESession psessionEntry)
1198{
1199 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1200
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001201 PELOGW(limLog(pMac, LOGW, FL("IBSS: DEL_BSS_RSP Rcvd during coalescing!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001202
1203 if (pDelBss == NULL)
1204 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001205 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 goto end;
1207 }
1208
1209 if (pDelBss->status != eHAL_STATUS_SUCCESS)
1210 {
1211 limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) error (%x) Bss %d "),
1212 pDelBss->status, pDelBss->bssIdx);
1213 goto end;
1214 }
1215 //Delete peer entries.
1216 limIbssDeleteAllPeers(pMac,psessionEntry);
1217
1218 /* add the new bss */
1219 ibss_bss_add(pMac,psessionEntry);
1220
1221 end:
1222 if(pDelBss != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301223 vos_mem_free(pDelBss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001224}
1225
1226
1227
1228void limIbssAddBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg, tpPESession pSessionEntry)
1229{
1230 tANI_U8 infoLen;
1231 tSirSmeNewBssInfo newBssInfo;
1232
1233 tpAddBssParams pAddBss = (tpAddBssParams) msg;
1234
1235 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr;
1236 tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon;
1237
1238 if ((pHdr == NULL) || (pBeacon == NULL))
1239 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001240 PELOGE(limLog(pMac, LOGE, FL("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 goto end;
1242 }
1243
1244 // Inform Host of IBSS coalescing
1245 infoLen = sizeof(tSirMacAddr) + sizeof(tSirMacChanNum) +
1246 sizeof(tANI_U8) + pBeacon->ssId.length + 1;
1247
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301248 vos_mem_set((void *) &newBssInfo, sizeof(newBssInfo), 0);
1249 vos_mem_copy(newBssInfo.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301251 vos_mem_copy((tANI_U8 *) &newBssInfo.ssId,
1252 (tANI_U8 *) &pBeacon->ssId, pBeacon->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001253
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001254 PELOGW(limLog(pMac, LOGW, FL("Sending JOINED_NEW_BSS notification to SME."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001255
1256 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_JOINED_NEW_BSS,
1257 (tANI_U32 *) &newBssInfo,
1258 infoLen,pSessionEntry->smeSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 {
1260 //Configure beacon and send beacons to HAL
1261 limSendBeaconInd(pMac, pSessionEntry);
1262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001263
Jeff Johnson3c3e1782013-02-27 10:48:42 -08001264 end:
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 ibss_coalesce_free(pMac);
1266}
1267
1268
1269
1270void
1271limIbssDelBssRsp(
1272 tpAniSirGlobal pMac,
1273 void *msg,tpPESession psessionEntry)
1274{
1275 tSirResultCodes rc = eSIR_SME_SUCCESS;
1276 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1277 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1278
1279
1280 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1281 if (pDelBss == NULL)
1282 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001283 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 rc = eSIR_SME_REFUSED;
1285 goto end;
1286 }
1287
1288 if((psessionEntry = peFindSessionBySessionId(pMac,pDelBss->sessionId))==NULL)
1289 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001290 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 goto end;
1292 }
1293
1294
1295 /*
1296 * If delBss was issued as part of IBSS Coalescing, gLimIbssCoalescingHappened flag will be true.
1297 * BSS has to be added again in this scenario, so this case needs to be handled separately.
1298 * If delBss was issued as a result of trigger from SME_STOP_BSS Request, then limSme state changes to
1299 * 'IDLE' and gLimIbssCoalescingHappened flag will be false. In this case STOP BSS RSP has to be sent to SME.
1300 */
1301 if(true == pMac->lim.gLimIbssCoalescingHappened)
1302 {
1303
1304 limIbssDelBssRspWhenCoalescing(pMac,msg,psessionEntry);
1305 return;
1306 }
1307
1308
1309
1310 if (pDelBss->status != eHAL_STATUS_SUCCESS)
1311 {
1312 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP error (%x) Bss %d "),
1313 pDelBss->status, pDelBss->bssIdx);)
1314 rc = eSIR_SME_STOP_BSS_FAILURE;
1315 goto end;
1316 }
1317
1318
1319
1320 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
1321 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1322 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001323 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP setLinkState failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 rc = eSIR_SME_REFUSED;
1325 goto end;
1326 }
1327
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001328 limIbssDelete(pMac,psessionEntry);
1329
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
1331 limDeletePreAuthList(pMac);
1332
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
1334
Jeff Johnsone7245742012-09-05 17:12:55 -07001335 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001336
1337 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1338
1339 /* Change the short slot operating mode to Default (which is 1 for now) so that when IBSS starts next time with Libra
1340 * as originator, it picks up the default. This enables us to remove hard coding of short slot = 1 from limApplyConfiguration
1341 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001342 psessionEntry->shortSlotTimeSupported = WNI_CFG_SHORT_SLOT_TIME_STADEF;
Jeff Johnson295189b2012-06-20 16:38:30 -07001343
1344 end:
1345 if(pDelBss != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301346 vos_mem_free(pDelBss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 /* Delete PE session once BSS is deleted */
1348 if (NULL != psessionEntry) {
1349 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, rc,psessionEntry->smeSessionId,psessionEntry->transactionId);
1350 peDeleteSession(pMac, psessionEntry);
1351 psessionEntry = NULL;
1352 }
1353}
1354
Ravi Joshi92404a32013-08-13 15:40:30 -07001355static void
1356__limIbssSearchAndDeletePeer(tpAniSirGlobal pMac,
1357 tpPESession psessionEntry,
1358 tSirMacAddr macAddr)
1359{
1360 tLimIbssPeerNode *pTempNode, *pPrevNode;
1361 tLimIbssPeerNode *pTempNextNode = NULL;
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001362 tpDphHashNode pStaDs=NULL;
1363 tANI_U16 peerIdx=0;
1364 tANI_U16 staIndex=0;
Ravi Joshi92404a32013-08-13 15:40:30 -07001365 tANI_U8 ucUcastSig;
1366 tANI_U8 ucBcastSig;
1367
1368 pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList;
1369
1370 limLog(pMac, LOG1, FL(" PEER ADDR :" MAC_ADDRESS_STR ),MAC_ADDR_ARRAY(macAddr));
1371
1372 /** Compare Peer */
1373 while (NULL != pTempNode)
1374 {
1375 pTempNextNode = pTempNode->next;
1376
1377 /* Delete the STA with MAC address */
Kiet Lam842c3e12013-11-16 22:40:57 +05301378 if (vos_mem_compare( (tANI_U8 *) macAddr,
Ravi Joshi92404a32013-08-13 15:40:30 -07001379 (tANI_U8 *) &pTempNode->peerMacAddr,
1380 sizeof(tSirMacAddr)) )
1381 {
1382 pStaDs = dphLookupHashEntry(pMac, macAddr,
1383 &peerIdx, &psessionEntry->dph.dphHashTable);
1384 if (pStaDs)
1385 {
1386 staIndex = pStaDs->staIndex;
1387 ucUcastSig = pStaDs->ucUcastSig;
1388 ucBcastSig = pStaDs->ucBcastSig;
1389
1390 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
1391 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry);
1392 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
1393
1394 /* Send indication to upper layers */
1395 ibss_status_chg_notify(pMac, macAddr, staIndex,
1396 ucUcastSig, ucBcastSig,
1397 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1398 psessionEntry->smeSessionId );
1399 if (pTempNode == pMac->lim.gLimIbssPeerList)
1400 {
1401 pMac->lim.gLimIbssPeerList = pTempNode->next;
1402 pPrevNode = pMac->lim.gLimIbssPeerList;
1403 }
1404 else
1405 pPrevNode->next = pTempNode->next;
1406
Kiet Lam842c3e12013-11-16 22:40:57 +05301407 vos_mem_free(pTempNode);
Ravi Joshi92404a32013-08-13 15:40:30 -07001408 pMac->lim.gLimNumIbssPeers--;
1409
1410 pTempNode = pTempNextNode;
1411 break;
1412 }
1413 }
1414 pPrevNode = pTempNode;
1415 pTempNode = pTempNextNode;
1416 }
krunal sonia6c11e12013-10-17 04:43:42 -07001417 /*
1418 * if it is the last peer walking out, we better
1419 * we set IBSS state to inactive.
1420 */
1421 if (0 == pMac->lim.gLimNumIbssPeers)
1422 {
1423 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1424 "Last STA from IBSS walked out");
1425 psessionEntry->limIbssActive = false;
1426 }
Ravi Joshi92404a32013-08-13 15:40:30 -07001427}
1428
Jeff Johnson295189b2012-06-20 16:38:30 -07001429/**
1430 * limIbssCoalesce()
1431 *
1432 *FUNCTION:
1433 * This function is called upon receiving Beacon/Probe Response
1434 * while operating in IBSS mode.
1435 *
1436 *LOGIC:
1437 *
1438 *ASSUMPTIONS:
1439 *
1440 *NOTE:
1441 *
1442 * @param pMac - Pointer to Global MAC structure
1443 * @param pBeacon - Parsed Beacon Frame structure
1444 * @param pBD - Pointer to received BD
1445 *
1446 * @return Status whether to process or ignore received Beacon Frame
1447 */
1448
1449tSirRetStatus
1450limIbssCoalesce(
1451 tpAniSirGlobal pMac,
1452 tpSirMacMgmtHdr pHdr,
1453 tpSchBeaconStruct pBeacon,
1454 tANI_U8 *pIEs,
1455 tANI_U32 ieLen,
1456 tANI_U16 fTsfLater,
1457 tpPESession psessionEntry)
1458{
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001459 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 tSirMacAddr currentBssId;
1461 tLimIbssPeerNode *pPeerNode;
1462 tpDphHashNode pStaDs;
1463 tUpdateBeaconParams beaconParams;
1464
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301465 vos_mem_set((tANI_U8 *)&beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
1467 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
1468
Shailender Karmuchia734f332013-04-19 14:02:48 -07001469 limLog(pMac, LOG1, FL("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :" MAC_ADDRESS_STR ),
1470 MAC_ADDR_ARRAY(currentBssId), MAC_ADDR_ARRAY(pHdr->bssId));
Ravi Joshi92404a32013-08-13 15:40:30 -07001471
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 /* Check for IBSS Coalescing only if Beacon is from different BSS */
krunal sonie9002db2013-11-25 14:24:17 -08001473 if ( !vos_mem_compare(currentBssId, pHdr->bssId, sizeof( tSirMacAddr ))
1474 && psessionEntry->isCoalesingInIBSSAllowed)
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 }
krunal sonie9002db2013-11-25 14:24:17 -08001513 else
1514 {
1515 if (!vos_mem_compare(currentBssId, pHdr->bssId, sizeof( tSirMacAddr )))
1516 return eSIR_LIM_IGNORE_BEACON;
1517 }
1518
Jeff Johnson295189b2012-06-20 16:38:30 -07001519
1520 // STA in IBSS mode and SSID matches with ours
1521 pPeerNode = ibss_peer_find(pMac, pHdr->sa);
1522 if (pPeerNode == NULL)
1523 {
1524 /* Peer not in the list - Collect BSS description & add to the list */
1525 tANI_U32 frameLen;
1526 tSirRetStatus retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
krunal soni3c28b102013-10-04 18:38:52 -07001528 /*
1529 * Limit the Max number of IBSS Peers allowed as the max
1530 * number of STA's allowed
1531 * pMac->lim.gLimNumIbssPeers will be increamented after exiting
1532 * this function. so we will add additional 1 to compare against
1533 * pMac->lim.gLimIbssStaLimit
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 */
Abhishek Singh639a5642014-04-22 11:02:54 +05301535 if ((pMac->lim.gLimNumIbssPeers+1) >= pMac->lim.gLimIbssStaLimit)
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001536 {
1537 PELOGE(limLog(pMac, LOGE, FL("**** MAX STA LIMIT HAS REACHED ****"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 return eSIR_LIM_MAX_STA_REACHED_ERROR;
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001539 }
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001540 PELOGW(limLog(pMac, LOGW, FL("IBSS Peer node does not exist, adding it***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 frameLen = sizeof(tLimIbssPeerNode) + ieLen - sizeof(tANI_U32);
1542
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301543 pPeerNode = vos_mem_malloc((tANI_U16)frameLen);
1544 if (NULL == pPeerNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001546 limLog(pMac, LOGP, FL("alloc fail (%d bytes) storing IBSS peer info"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 frameLen);
1548 return eSIR_MEM_ALLOC_FAILED;
1549 }
1550
1551 pPeerNode->beacon = NULL;
1552 pPeerNode->beaconLen = 0;
1553
1554 ibss_peer_collect(pMac, pBeacon, pHdr, pPeerNode,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301555 pPeerNode->beacon = vos_mem_malloc(ieLen);
1556 if (NULL == pPeerNode->beacon)
1557 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store beacon"));)
1559 }
1560 else
1561 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301562 vos_mem_copy(pPeerNode->beacon, pIEs, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 pPeerNode->beaconLen = (tANI_U16)ieLen;
1564 }
1565 ibss_peer_add(pMac, pPeerNode);
1566
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001567 pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 if (pStaDs != NULL)
1569 {
1570 /// DPH node already exists for the peer
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301571 limLog(pMac, LOG1, FL("DPH Node present for just learned peer"));
1572 limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 ibss_sta_info_update(pMac, pStaDs, pPeerNode,psessionEntry);
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07001574 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 }
1576 retCode = limIbssStaAdd(pMac, pPeerNode->peerMacAddr,psessionEntry);
1577 if (retCode != eSIR_SUCCESS)
1578 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001579 PELOGE(limLog(pMac, LOGE, FL("lim-ibss-sta-add failed (reason %x)"), retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOGE);
1581 return retCode;
1582 }
1583
1584 // Decide protection mode
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001585 pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1587 limIbssDecideProtection(pMac, pStaDs, &beaconParams, psessionEntry);
1588
1589 if(beaconParams.paramChangeBitmap)
1590 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001591 PELOGE(limLog(pMac, LOGE, FL("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params "));)
Sunil Ravib96f7b52013-05-22 21:40:05 -07001592 schSetFixedBeaconFields(pMac, psessionEntry);
1593 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1595 }
1596 }
1597 else
1598 ibss_sta_caps_update(pMac, pPeerNode,psessionEntry);
1599
1600 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE)
1601 return eSIR_SUCCESS;
1602
1603 // Received Beacon from same IBSS we're
1604 // currently part of. Inform Roaming algorithm
1605 // if not already that IBSS is active.
1606 if (psessionEntry->limIbssActive == false)
1607 {
1608 limResetHBPktCount(psessionEntry);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001609 PELOGW(limLog(pMac, LOGW, FL("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 psessionEntry->limIbssActive = true;
1611 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_ACTIVE, NULL, 0, psessionEntry->smeSessionId);
1612 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001613 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001614 if (limActivateHearBeatTimer(pMac, psessionEntry) != TX_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001615 limLog(pMac, LOGP, FL("could not activate Heartbeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 }
1617
1618 return eSIR_SUCCESS;
1619} /*** end limHandleIBSScoalescing() ***/
1620
1621
1622void limIbssHeartBeatHandle(tpAniSirGlobal pMac,tpPESession psessionEntry)
1623{
1624 tLimIbssPeerNode *pTempNode, *pPrevNode;
1625 tLimIbssPeerNode *pTempNextNode = NULL;
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001626 tANI_U16 peerIdx=0;
1627 tpDphHashNode pStaDs=0;
1628 tANI_U32 threshold=0;
1629 tANI_U16 staIndex=0;
1630 tANI_U8 ucUcastSig=0;
1631 tANI_U8 ucBcastSig=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001632
1633 /** MLM BSS is started and if PE in scanmode then MLM state will be waiting for probe resp.
1634 * If Heart beat timeout triggers during this corner case then we need to reactivate HeartBeat timer
1635 */
1636 if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
1637 /******
1638 * Note: Use this code once you have converted all
1639 * limReactivateHeartBeatTimer() calls to
1640 * limReactivateTimer() calls.
1641 *
1642 ******/
1643 //limReactivateTimer(pMac, eLIM_HEART_BEAT_TIMER, psessionEntry);
1644 limReactivateHeartBeatTimer(pMac, psessionEntry);
1645 return;
1646 }
1647 /** If LinkMonitor is Disabled */
1648 if(!pMac->sys.gSysEnableLinkMonitorMode)
1649 return;
1650
1651 pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList;
1652 threshold = (pMac->lim.gLimNumIbssPeers / 4 ) + 1;
1653
1654 /** Monitor the HeartBeat with the Individual PEERS in the IBSS */
1655 while (pTempNode != NULL)
1656 {
1657 pTempNextNode = pTempNode->next;
1658 if(pTempNode->beaconHBCount) //There was a beacon for this peer during heart beat.
1659 {
1660 pTempNode->beaconHBCount = 0;
1661 pTempNode->heartbeatFailure = 0;
1662 }
1663 else //There wasnt any beacon received during heartbeat timer.
1664 {
1665 pTempNode->heartbeatFailure++;
1666 PELOGE(limLog(pMac, LOGE, FL("Heartbeat fail = %d thres = %d"), pTempNode->heartbeatFailure, pMac->lim.gLimNumIbssPeers);)
1667 if(pTempNode->heartbeatFailure >= threshold )
1668 {
1669 //Remove this entry from the list.
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001670 pStaDs = dphLookupHashEntry(pMac, pTempNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 if (pStaDs)
1672 {
1673 staIndex = pStaDs->staIndex;
1674 ucUcastSig = pStaDs->ucUcastSig;
1675 ucBcastSig = pStaDs->ucBcastSig;
1676
1677 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001678 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001679 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 //Send indication.
1681 ibss_status_chg_notify( pMac, pTempNode->peerMacAddr, staIndex,
1682 ucUcastSig, ucBcastSig,
1683 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1684 psessionEntry->smeSessionId );
1685 }
1686 if(pTempNode == pMac->lim.gLimIbssPeerList)
1687 {
1688 pMac->lim.gLimIbssPeerList = pTempNode->next;
1689 pPrevNode = pMac->lim.gLimIbssPeerList;
1690 }
1691 else
1692 pPrevNode->next = pTempNode->next;
1693
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301694 vos_mem_free(pTempNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 pMac->lim.gLimNumIbssPeers--;
1696
1697 pTempNode = pTempNextNode; //Since we deleted current node, prevNode remains same.
1698 continue;
1699 }
1700 }
1701
1702 pPrevNode = pTempNode;
1703 pTempNode = pTempNextNode;
1704 }
1705
1706 /** General IBSS Activity Monitor, check if in IBSS Mode we are received any Beacons */
1707 if(pMac->lim.gLimNumIbssPeers)
1708 {
1709 if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL)
1710 pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++;
1711 else
1712 pMac->lim.gLimHeartBeatBeaconStats[0]++;
1713
1714 limReactivateHeartBeatTimer(pMac, psessionEntry);
1715
1716 // Reset number of beacons received
1717 limResetHBPktCount(psessionEntry);
1718 return;
1719 }
1720 else
1721 {
1722
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001723 PELOGW(limLog(pMac, LOGW, FL("Heartbeat Failure"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 pMac->lim.gLimHBfailureCntInLinkEstState++;
1725
1726 if (psessionEntry->limIbssActive == true)
1727 {
1728 // We don't receive Beacon frames from any
1729 // other STA in IBSS. Announce IBSS inactive
1730 // to Roaming algorithm
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001731 PELOGW(limLog(pMac, LOGW, FL("Alone in IBSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 psessionEntry->limIbssActive = false;
1733
1734 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_INACTIVE,
1735 NULL, 0, psessionEntry->smeSessionId);
1736 }
1737 }
1738}
1739
1740
1741/** -------------------------------------------------------------
1742\fn limIbssDecideProtectionOnDelete
1743\brief Decides all the protection related information.
1744\
1745\param tpAniSirGlobal pMac
1746\param tSirMacAddr peerMacAddr
1747\param tpUpdateBeaconParams pBeaconParams
1748\return None
1749 -------------------------------------------------------------*/
1750void
1751limIbssDecideProtectionOnDelete(tpAniSirGlobal pMac,
1752 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1753{
1754 tANI_U32 phyMode;
1755 tHalBitVal erpEnabled = eHAL_CLEAR;
1756 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1757 tANI_U32 i;
1758
1759 if(NULL == pStaDs)
1760 return;
1761
1762 limGetRfBand(pMac, &rfBand, psessionEntry);
1763 if(SIR_BAND_2_4_GHZ == rfBand)
1764 {
1765 limGetPhyMode(pMac, &phyMode, psessionEntry);
1766 erpEnabled = pStaDs->erpEnabled;
1767 //we are HT or 11G and 11B station is getting deleted.
Jeff Johnsone7245742012-09-05 17:12:55 -07001768 if ( ((phyMode == WNI_CFG_PHY_MODE_11G) || psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 && (erpEnabled == eHAL_CLEAR))
1770 {
1771 PELOGE(limLog(pMac, LOGE, FL("(%d) A legacy STA is disassociated. Addr is "),
1772 psessionEntry->gLim11bParams.numSta);
1773 limPrintMacAddr(pMac, pStaDs->staAddr, LOGE);)
1774 if (psessionEntry->gLim11bParams.numSta > 0)
1775 {
1776 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1777 {
1778 if (pMac->lim.protStaCache[i].active)
1779 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301780 if (vos_mem_compare(pMac->lim.protStaCache[i].addr,
1781 pStaDs->staAddr, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 {
1783 psessionEntry->gLim11bParams.numSta--;
1784 pMac->lim.protStaCache[i].active = false;
1785 break;
1786 }
1787 }
1788 }
1789 }
1790
1791 if (psessionEntry->gLim11bParams.numSta == 0)
1792 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001793 PELOGE(limLog(pMac, LOGE, FL("No more 11B STA exists. Disable protection. "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 limIbssSetProtection(pMac, false, pBeaconParams,psessionEntry);
1795 }
1796 }
1797 }
1798}
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001799
1800/** -----------------------------------------------------------------
1801\fn __limIbssPeerInactivityHandler
1802\brief Internal function. Deletes FW indicated peer which is inactive
1803\
1804\param tpAniSirGlobal pMac
1805\param tpPESession psessionEntry
1806\param tpSirIbssPeerInactivityInd peerInactivityInd
1807\return None
1808 -----------------------------------------------------------------*/
1809static void
1810__limIbssPeerInactivityHandler(tpAniSirGlobal pMac,
1811 tpPESession psessionEntry,
1812 tpSirIbssPeerInactivityInd peerInactivityInd)
1813{
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001814 if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
1815 {
1816 limReactivateHeartBeatTimer(pMac, psessionEntry);
1817 return;
1818 }
1819
Ravi Joshi92404a32013-08-13 15:40:30 -07001820 /* delete the peer for which heartbeat is observed */
1821 __limIbssSearchAndDeletePeer (pMac, psessionEntry, peerInactivityInd->peerAddr);
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001822
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001823}
1824
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001825/** -------------------------------------------------------------
1826\fn limProcessIbssPeerInactivity
1827\brief Peer inactivity message handler
1828\
1829\param tpAniSirGlobal pMac
1830\param void* buf
1831\return None
1832 -------------------------------------------------------------*/
1833void
1834limProcessIbssPeerInactivity(tpAniSirGlobal pMac, void *buf)
1835{
1836 /*
1837 * --------------- HEARTBEAT OFFLOAD CASE ------------------
1838 * This message handler is executed when the firmware identifies
1839 * inactivity from one or more peer devices. We will come here
1840 * for every inactive peer device
1841 */
1842 tANI_U8 i;
1843
1844 tSirIbssPeerInactivityInd *peerInactivityInd =
1845 (tSirIbssPeerInactivityInd *) buf;
1846
1847 /*
1848 * If IBSS is not started or heartbeat offload is not enabled
1849 * we should not handle this request
1850 */
1851 if (eLIM_STA_IN_IBSS_ROLE != pMac->lim.gLimSystemRole &&
1852 !IS_IBSS_HEARTBEAT_OFFLOAD_FEATURE_ENABLE)
1853 {
1854 return;
1855 }
1856
1857 /** If LinkMonitor is Disabled */
1858 if (!pMac->sys.gSysEnableLinkMonitorMode)
1859 {
1860 return;
1861 }
1862
1863 for (i = 0; i < pMac->lim.maxBssId; i++)
1864 {
1865 if (VOS_TRUE == pMac->lim.gpSession[i].valid &&
1866 eSIR_IBSS_MODE == pMac->lim.gpSession[i].bssType)
1867 {
1868 __limIbssPeerInactivityHandler(pMac,
1869 &pMac->lim.gpSession[i],
1870 peerInactivityInd);
1871 break;
1872 }
1873 }
1874}
1875