blob: 4ca42d3df0c3e552ef6f55254252b7b132e2de56 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh00b71972016-01-07 10:51:04 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053043#include "wniCfg.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"
Abhishek Singh00b71972016-01-07 10:51:04 +053052#ifdef WLAN_FEATURE_RMC
53#include "limRMC.h"
54#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56
57/**
58 * ibss_peer_find
59 *
60 *FUNCTION:
61 * This function is called while adding a context at
62 * DPH & Polaris for a peer in IBSS.
63 * If peer is found in the list, capabilities from the
64 * returned BSS description are used at DPH node & Polaris.
65 *
66 *LOGIC:
67 *
68 *ASSUMPTIONS:
69 *
70 *NOTE:
71 *
72 * @param macAddr - MAC address of the peer
73 *
74 * @return Pointer to peer node if found, else NULL
75 */
76
77static tLimIbssPeerNode *
78ibss_peer_find(
79 tpAniSirGlobal pMac,
80 tSirMacAddr macAddr)
81{
82 tLimIbssPeerNode *pTempNode = pMac->lim.gLimIbssPeerList;
83
84 while (pTempNode != NULL)
85 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +053086 if (vos_mem_compare((tANI_U8 *) macAddr,
87 (tANI_U8 *) &pTempNode->peerMacAddr,
88 sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -070089 break;
90 pTempNode = pTempNode->next;
91 }
92 return pTempNode;
93} /*** end ibss_peer_find() ***/
94
95/**
96 * ibss_peer_add
97 *
98 *FUNCTION:
99 * This is called on a STA in IBSS upon receiving Beacon/
100 * Probe Response from a peer.
101 *
102 *LOGIC:
103 * Node is always added to the front of the list
104 *
105 *ASSUMPTIONS:
106 *
107 *NOTE:
108 *
109 * @param pMac - Pointer to Global MAC structure
110 * @param pPeerNode - Pointer to peer node to be added to the list.
111 *
112 * @return None
113 */
114
115static tSirRetStatus
116ibss_peer_add(tpAniSirGlobal pMac, tLimIbssPeerNode *pPeerNode)
117{
118#ifdef ANI_SIR_IBSS_PEER_CACHING
119 tANI_U32 numIbssPeers = (2 * pMac->lim.maxStation);
120
121 if (pMac->lim.gLimNumIbssPeers >= numIbssPeers)
122 {
123 /**
124 * Reached max number of peers to be maintained.
125 * Delete last entry & add new entry at the beginning.
126 */
127 tLimIbssPeerNode *pTemp, *pPrev;
128 pTemp = pPrev = pMac->lim.gLimIbssPeerList;
129 while (pTemp->next != NULL)
130 {
131 pPrev = pTemp;
132 pTemp = pTemp->next;
133 }
134 if(pTemp->beacon)
135 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530136 vos_mem_free(pTemp->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 }
138
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530139 vos_mem_free(pTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 pPrev->next = NULL;
141 }
142 else
143#endif
144 pMac->lim.gLimNumIbssPeers++;
145
146 pPeerNode->next = pMac->lim.gLimIbssPeerList;
147 pMac->lim.gLimIbssPeerList = pPeerNode;
148
149 return eSIR_SUCCESS;
150
151} /*** end limAddIbssPeerToList() ***/
152
153/**
154 * ibss_peer_collect
155 *
156 *FUNCTION:
157 * This is called to collect IBSS peer information
158 * from received Beacon/Probe Response frame from it.
159 *
160 *LOGIC:
161 *
162 *ASSUMPTIONS:
163 *
164 *NOTE:
165 *
166 * @param pMac - Pointer to Global MAC structure
167 * @param pBeacon - Parsed Beacon Frame structure
168 * @param pBD - Pointer to received BD
169 * @param pPeer - Pointer to IBSS peer node
170 *
171 * @return None
172 */
173
174static void
175ibss_peer_collect(
176 tpAniSirGlobal pMac,
177 tpSchBeaconStruct pBeacon,
178 tpSirMacMgmtHdr pHdr,
179 tLimIbssPeerNode *pPeer,
180 tpPESession psessionEntry)
181{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530182 vos_mem_copy(pPeer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700183
184 pPeer->capabilityInfo = pBeacon->capabilityInfo;
185 pPeer->extendedRatesPresent = pBeacon->extendedRatesPresent;
186 pPeer->edcaPresent = pBeacon->edcaPresent;
187 pPeer->wmeEdcaPresent = pBeacon->wmeEdcaPresent;
188 pPeer->wmeInfoPresent = pBeacon->wmeInfoPresent;
189
190 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
191 (pBeacon->HTCaps.present))
192 {
193 pPeer->htCapable = pBeacon->HTCaps.present;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530194 vos_mem_copy((tANI_U8 *)pPeer->supportedMCSSet,
195 (tANI_U8 *)pBeacon->HTCaps.supportedMCSSet,
196 sizeof(pPeer->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 pPeer->htGreenfield = (tANI_U8)pBeacon->HTCaps.greenField;
198 pPeer->htSupportedChannelWidthSet = ( tANI_U8 ) pBeacon->HTCaps.supportedChannelWidthSet;
199 pPeer->htMIMOPSState = (tSirMacHTMIMOPowerSaveState)pBeacon->HTCaps.mimoPowerSave;
200 pPeer->htMaxAmsduLength = ( tANI_U8 ) pBeacon->HTCaps.maximalAMSDUsize;
201 pPeer->htAMpduDensity = pBeacon->HTCaps.mpduDensity;
202 pPeer->htDsssCckRate40MHzSupport = (tANI_U8)pBeacon->HTCaps.dsssCckMode40MHz;
203 pPeer->htShortGI20Mhz = (tANI_U8)pBeacon->HTCaps.shortGI20MHz;
204 pPeer->htShortGI40Mhz = (tANI_U8)pBeacon->HTCaps.shortGI40MHz;
205 pPeer->htMaxRxAMpduFactor = pBeacon->HTCaps.maxRxAMPDUFactor;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700206 pPeer->htSecondaryChannelOffset = pBeacon->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 }
208
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700209 /* Collect peer VHT capabilities based on the received beacon from the peer */
210#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530211 if (IS_BSS_VHT_CAPABLE(pBeacon->VHTCaps))
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700212 {
Bansidhar Gopalachari5fd3d132013-07-30 13:35:35 -0700213 pPeer->vhtSupportedChannelWidthSet = pBeacon->VHTOperation.chanWidth;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700214 pPeer->vhtCapable = pBeacon->VHTCaps.present;
215
216 // Collect VHT capabilities from beacon
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530217 vos_mem_copy((tANI_U8 *) &pPeer->VHTCaps,
218 (tANI_U8 *) &pBeacon->VHTCaps,
219 sizeof(tDot11fIEVHTCaps));
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700220 }
221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 pPeer->erpIePresent = pBeacon->erpPresent;
223
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530224 vos_mem_copy((tANI_U8 *) &pPeer->supportedRates,
225 (tANI_U8 *) &pBeacon->supportedRates,
226 pBeacon->supportedRates.numRates + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700227 if (pPeer->extendedRatesPresent)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530228 vos_mem_copy((tANI_U8 *) &pPeer->extendedRates,
229 (tANI_U8 *) &pBeacon->extendedRates,
230 pBeacon->extendedRates.numRates + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 else
232 pPeer->extendedRates.numRates = 0;
233
234 // TBD copy EDCA parameters
235 // pPeer->edcaParams;
236
237 pPeer->next = NULL;
238} /*** end ibss_peer_collect() ***/
239
240// handle change in peer qos/wme capabilities
241static void
242ibss_sta_caps_update(
243 tpAniSirGlobal pMac,
244 tLimIbssPeerNode *pPeerNode,
245 tpPESession psessionEntry)
246{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800247 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 tpDphHashNode pStaDs;
249
250 pPeerNode->beaconHBCount++; //Update beacon count.
251
252 // if the peer node exists, update its qos capabilities
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800253 if ((pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 return;
255
256
257 //Update HT Capabilities
258 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
259 {
260 pStaDs->mlmStaContext.htCapability = pPeerNode->htCapable;
261 if (pPeerNode->htCapable)
262 {
263 pStaDs->htGreenfield = pPeerNode->htGreenfield;
264 pStaDs->htSupportedChannelWidthSet = pPeerNode->htSupportedChannelWidthSet;
Abhishek Singhe1f1f0b2015-08-06 14:07:59 +0530265 pStaDs->htSecondaryChannelOffset = pPeerNode->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 pStaDs->htMIMOPSState = pPeerNode->htMIMOPSState;
267 pStaDs->htMaxAmsduLength = pPeerNode->htMaxAmsduLength;
268 pStaDs->htAMpduDensity = pPeerNode->htAMpduDensity;
269 pStaDs->htDsssCckRate40MHzSupport = pPeerNode->htDsssCckRate40MHzSupport;
270 pStaDs->htShortGI20Mhz = pPeerNode->htShortGI20Mhz;
271 pStaDs->htShortGI40Mhz = pPeerNode->htShortGI40Mhz;
272 pStaDs->htMaxRxAMpduFactor = pPeerNode->htMaxRxAMpduFactor;
273 // In the future, may need to check for "delayedBA"
274 // For now, it is IMMEDIATE BA only on ALL TID's
275 pStaDs->baPolicyFlag = 0xFF;
276 }
277 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700278#ifdef WLAN_FEATURE_11AC
279 if ( IS_DOT11_MODE_VHT(psessionEntry->dot11mode) )
280 {
281 pStaDs->mlmStaContext.vhtCapability = pPeerNode->vhtCapable;
282 if ( pPeerNode->vhtCapable )
283 {
284 pStaDs->vhtSupportedChannelWidthSet = pPeerNode->vhtSupportedChannelWidthSet;
285 }
286 }
287#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289 if(IS_DOT11_MODE_PROPRIETARY(psessionEntry->dot11mode) &&
290 pPeerNode->aniIndicator)
291 {
292 pStaDs->aniPeer = pPeerNode->aniIndicator;
293 pStaDs->propCapability = pPeerNode->propCapability;
294 }
295
296
297 // peer is 11e capable but is not 11e enabled yet
298 // some STA's when joining Airgo IBSS, assert qos capability even when
299 // they don't suport qos. however, they do not include the edca parameter
300 // set. so let's check for edcaParam in addition to the qos capability
301 if (pPeerNode->capabilityInfo.qos && (psessionEntry->limQosEnabled) && pPeerNode->edcaPresent)
302 {
303 pStaDs->qosMode = 1;
304 pStaDs->wmeEnabled = 0;
305 if (! pStaDs->lleEnabled)
306 {
307 pStaDs->lleEnabled = 1;
308 //dphSetACM(pMac, pStaDs);
309 }
310 return;
311 }
312 // peer is not 11e capable now but was 11e enabled earlier
313 else if (pStaDs->lleEnabled)
314 {
315 pStaDs->qosMode = 0;
316 pStaDs->lleEnabled = 0;
317 }
318
319 // peer is wme capable but is not wme enabled yet
320 if (pPeerNode->wmeInfoPresent && psessionEntry->limWmeEnabled)
321 {
322 pStaDs->qosMode = 1;
323 pStaDs->lleEnabled = 0;
324 if (! pStaDs->wmeEnabled)
325 {
326 pStaDs->wmeEnabled = 1;
327 //dphSetACM(pMac, pStaDs);
328 }
329 return;
330 }
331 /* When the peer device supports EDCA parameters, then we were not
332 considering. Added this code when we saw that one of the Peer Device
333 was advertising WMM param where we were not honouring that. CR# 210756
334 */
335 if (pPeerNode->wmeEdcaPresent && psessionEntry->limWmeEnabled) {
336 pStaDs->qosMode = 1;
337 pStaDs->lleEnabled = 0;
338 if (! pStaDs->wmeEnabled) {
339 pStaDs->wmeEnabled = 1;
340 }
341 return;
342 }
343
344 // peer is not wme capable now but was wme enabled earlier
345 else if (pStaDs->wmeEnabled)
346 {
347 pStaDs->qosMode = 0;
348 pStaDs->wmeEnabled = 0;
349 }
350
351}
352
353static void
354ibss_sta_rates_update(
355 tpAniSirGlobal pMac,
356 tpDphHashNode pStaDs,
357 tLimIbssPeerNode *pPeer,
358 tpPESession psessionEntry)
359{
Jeff Johnsone7245742012-09-05 17:12:55 -0700360#ifdef WLAN_FEATURE_11AC
361 limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates,
362 &pPeer->extendedRates, pPeer->supportedMCSSet,
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700363 &pStaDs->mlmStaContext.propRateSet,psessionEntry, &pPeer->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -0700364#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 // Populate supported rateset
366 limPopulateMatchingRateSet(pMac, pStaDs, &pPeer->supportedRates,
367 &pPeer->extendedRates, pPeer->supportedMCSSet,
368 &pStaDs->mlmStaContext.propRateSet,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700369#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700370
371 pStaDs->mlmStaContext.capabilityInfo = pPeer->capabilityInfo;
372} /*** end ibss_sta_info_update() ***/
373
374/**
375 * ibss_sta_info_update
376 *
377 *FUNCTION:
378 * This is called to program both SW & Polaris context
379 * for peer in IBSS.
380 *
381 *LOGIC:
382 *
383 *ASSUMPTIONS:
384 *
385 *NOTE:
386 *
387 * @param pMac - Pointer to Global MAC structure
388 * @param pStaDs - Pointer to DPH node
389 * @param pPeer - Pointer to IBSS peer node
390 *
391 * @return None
392 */
393
394static void
395ibss_sta_info_update(
396 tpAniSirGlobal pMac,
397 tpDphHashNode pStaDs,
398 tLimIbssPeerNode *pPeer,
399 tpPESession psessionEntry)
400{
401 pStaDs->staType = STA_ENTRY_PEER;
402 ibss_sta_caps_update(pMac, pPeer,psessionEntry);
403 ibss_sta_rates_update(pMac, pStaDs, pPeer,psessionEntry);
404} /*** end ibss_sta_info_update() ***/
405
406static void
407ibss_coalesce_free(
408 tpAniSirGlobal pMac)
409{
410 if (pMac->lim.ibssInfo.pHdr != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530411 vos_mem_free(pMac->lim.ibssInfo.pHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 if (pMac->lim.ibssInfo.pBeacon != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530413 vos_mem_free(pMac->lim.ibssInfo.pBeacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700414
415 pMac->lim.ibssInfo.pHdr = NULL;
416 pMac->lim.ibssInfo.pBeacon = NULL;
417}
418
419/*
420 * save the beacon params for use when adding the bss
421 */
422static void
423ibss_coalesce_save(
424 tpAniSirGlobal pMac,
425 tpSirMacMgmtHdr pHdr,
426 tpSchBeaconStruct pBeacon)
427{
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 // get rid of any saved info
429 ibss_coalesce_free(pMac);
430
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530431 pMac->lim.ibssInfo.pHdr = vos_mem_malloc(sizeof(*pHdr));
432 if (NULL == pMac->lim.ibssInfo.pHdr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700434 PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pHdr"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 return;
436 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530437 pMac->lim.ibssInfo.pBeacon = vos_mem_malloc(sizeof(*pBeacon));
438 if (NULL == pMac->lim.ibssInfo.pBeacon)
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700440 PELOGE(limLog(pMac, LOGE, FL("ibbs-save: Failed malloc pBeacon"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 ibss_coalesce_free(pMac);
442 return;
443 }
444
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530445 vos_mem_copy(pMac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr));
446 vos_mem_copy(pMac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon));
Jeff Johnson295189b2012-06-20 16:38:30 -0700447}
448
449/*
450 * tries to add a new entry to dph hash node
451 * if necessary, an existing entry is eliminated
452 */
453static tSirRetStatus
454ibss_dph_entry_add(
455 tpAniSirGlobal pMac,
456 tSirMacAddr peerAddr,
457 tpDphHashNode *ppSta,
458 tpPESession psessionEntry)
459{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800460 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 tpDphHashNode pStaDs;
462
463 *ppSta = NULL;
464
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800465 pStaDs = dphLookupHashEntry(pMac, peerAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 if (pStaDs != NULL)
467 {
468 /* Trying to add context for already existing STA in IBSS */
469 PELOGE(limLog(pMac, LOGE, FL("STA exists already "));)
470 limPrintMacAddr(pMac, peerAddr, LOGE);
471 return eSIR_FAILURE;
472 }
473
474 /**
475 * Assign an AID, delete context existing with that
476 * AID and then add an entry to hash table maintained
477 * by DPH module.
478 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800479 peerIdx = limAssignPeerIdx(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800481 pStaDs = dphGetHashEntry(pMac, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 if (pStaDs)
483 {
484 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800485 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 }
487
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800488 pStaDs = dphAddHashEntry(pMac, peerAddr, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 if (pStaDs == NULL)
490 {
491 // Could not add hash table entry
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700492 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 -0700493 limPrintMacAddr(pMac, peerAddr, LOGE);
494 return eSIR_FAILURE;
495 }
496
497 *ppSta = pStaDs;
498 return eSIR_SUCCESS;
499}
500
501// send a status change notification
502static void
503ibss_status_chg_notify(
504 tpAniSirGlobal pMac,
505 tSirMacAddr peerAddr,
506 tANI_U16 staIndex,
507 tANI_U8 ucastSig,
508 tANI_U8 bcastSig,
509 tANI_U16 status,
510 tANI_U8 sessionId)
511{
512
513 tLimIbssPeerNode *peerNode;
514 tANI_U8 *beacon = NULL;
515 tANI_U16 bcnLen = 0;
516
517
518 peerNode = ibss_peer_find(pMac,peerAddr);
519 if(peerNode != NULL)
520 {
521 if(peerNode->beacon == NULL) peerNode->beaconLen = 0;
522 beacon = peerNode->beacon;
523 bcnLen = peerNode->beaconLen;
524 peerNode->beacon = NULL;
525 peerNode->beaconLen = 0;
526 }
527
528 limSendSmeIBSSPeerInd(pMac,peerAddr, staIndex, ucastSig, bcastSig,
529 beacon, bcnLen, status, sessionId);
530
531 if(beacon != NULL)
532 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530533 vos_mem_free(beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 }
535}
536
537
538static void
539ibss_bss_add(
540 tpAniSirGlobal pMac,
541 tpPESession psessionEntry)
542{
543 tLimMlmStartReq mlmStartReq;
544 tANI_U32 cfg;
545 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr;
546 tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon;
547 tANI_U8 numExtRates = 0;
548
549 if ((pHdr == NULL) || (pBeacon == NULL))
550 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700551 PELOGE(limLog(pMac, LOGE, FL("Unable to add BSS (no cached BSS info)"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 return;
553 }
554
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530555 vos_mem_copy(psessionEntry->bssId, pHdr->bssId,
556 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
558 #if 0
559 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pHdr->bssId, sizeof(tSirMacAddr))
560 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700561 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 #endif //TO SUPPORT BT-AMP
563
564 sirCopyMacAddr(pHdr->bssId,psessionEntry->bssId);
565 /* We need not use global Mac address since per seesion BSSID is available */
566 //limSetBssid(pMac, pHdr->bssId);
567
568#if 0
569 if (wlan_cfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &cfg) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700570 limLog(pMac, LOGP, FL("Can't read beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700571#endif //TO SUPPORT BT-AMP
572 /* Copy beacon interval from sessionTable */
573 cfg = psessionEntry->beaconParams.beaconInterval;
574 if (cfg != pBeacon->beaconInterval)
575 #if 0
576 if (cfgSetInt(pMac, WNI_CFG_BEACON_INTERVAL, pBeacon->beaconInterval)
577 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700578 limLog(pMac, LOGP, FL("Can't update beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 #endif//TO SUPPORT BT-AMP
580 psessionEntry->beaconParams.beaconInterval = pBeacon->beaconInterval;
581
582 /* This function ibss_bss_add (and hence the below code) is only called during ibss coalescing. We need to
583 * adapt to peer's capability with respect to short slot time. Changes have been made to limApplyConfiguration()
584 * so that the IBSS doesnt blindly start with short slot = 1. If IBSS start is part of coalescing then it will adapt
585 * to peer's short slot using code below.
586 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 /* If cfg is already set to current peer's capability then no need to set it again */
Jeff Johnsone7245742012-09-05 17:12:55 -0700588 if (psessionEntry->shortSlotTimeSupported != pBeacon->capabilityInfo.shortSlotTime)
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700590 psessionEntry->shortSlotTimeSupported = pBeacon->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530592 vos_mem_copy((tANI_U8 *) &psessionEntry->pLimStartBssReq->operationalRateSet,
593 (tANI_U8 *) &pBeacon->supportedRates,
594 pBeacon->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595
596 #if 0
597 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
598 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
599 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
600 != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700601 limLog(pMac, LOGP, FL("could not update OperRateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 #endif //TO SUPPORT BT-AMP
603
604 /**
605 * WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET CFG needs to be reset, when
606 * there is no extended rate IE present in beacon. This is especially important when
607 * supportedRateSet IE contains all the extended rates as well and STA decides to coalesce.
608 * In this IBSS coalescing scenario LIM will tear down the BSS and Add a new one. So LIM needs to
609 * reset this CFG, just in case CSR originally had set this CFG when IBSS was started from the local profile.
610 * If IBSS was started by CSR from the BssDescription, then it would reset this CFG before StartBss is issued.
611 * The idea is that the count of OpRateSet and ExtendedOpRateSet rates should not be more than 12.
612 */
613
614 if(pBeacon->extendedRatesPresent)
615 numExtRates = pBeacon->extendedRates.numRates;
616 if (cfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
617 (tANI_U8 *) &pBeacon->extendedRates.rate, numExtRates) != eSIR_SUCCESS)
618 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700619 limLog(pMac, LOGP, FL("could not update ExtendedOperRateset at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 return;
621 }
622
623
624 /*
625 * Each IBSS node will advertise its own HT Capabilities instead of adapting to the Peer's capabilities
626 * If we don't do this then IBSS may not go back to full capabilities when the STA with lower capabilities
627 * leaves the IBSS. e.g. when non-CB STA joins an IBSS and then leaves, the IBSS will be stuck at non-CB mode
628 * even though all the nodes are capable of doing CB.
629 * so it is decided to leave the self HT capabilties intact. This may change if some issues are found in interop.
630 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530631 vos_mem_set((void *) &mlmStartReq, sizeof(mlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700632
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530633 vos_mem_copy(mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 mlmStartReq.rateSet.numRates = psessionEntry->pLimStartBssReq->operationalRateSet.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530635 vos_mem_copy(&mlmStartReq.rateSet.rate[0],
636 &psessionEntry->pLimStartBssReq->operationalRateSet.rate[0],
637 mlmStartReq.rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 mlmStartReq.bssType = eSIR_IBSS_MODE;
639 mlmStartReq.beaconPeriod = pBeacon->beaconInterval;
640 mlmStartReq.nwType = psessionEntry->pLimStartBssReq->nwType; //psessionEntry->nwType is also OK????
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 mlmStartReq.htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 mlmStartReq.htOperMode = pMac->lim.gHTOperMode;
643 mlmStartReq.dualCTSProtection = pMac->lim.gHTDualCTSProtection;
Jeff Johnsone7245742012-09-05 17:12:55 -0700644 mlmStartReq.txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700645
646 #if 0
647 if (wlan_cfgGetInt(pMac, WNI_CFG_CURRENT_CHANNEL, &cfg) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700648 limLog(pMac, LOGP, FL("CurrentChannel CFG get fialed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 #endif
650
651 //mlmStartReq.channelNumber = (tSirMacChanNum) cfg;
652
653 /* reading the channel num from session Table */
654 mlmStartReq.channelNumber = psessionEntry->currentOperChannel;
655
656 mlmStartReq.cbMode = psessionEntry->pLimStartBssReq->cbMode;
657
658 // Copy the SSID for RxP filtering based on SSID.
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530659 vos_mem_copy((tANI_U8 *) &mlmStartReq.ssId,
660 (tANI_U8 *) &psessionEntry->pLimStartBssReq->ssId,
661 psessionEntry->pLimStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530663 limLog(pMac, LOG1, FL("invoking ADD_BSS as part of coalescing!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 if (limMlmAddBss(pMac, &mlmStartReq,psessionEntry) != eSIR_SME_SUCCESS)
665 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700666 PELOGE(limLog(pMac, LOGE, FL("AddBss failure"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 return;
668 }
669
670 // Update fields in Beacon
671 if (schSetFixedBeaconFields(pMac,psessionEntry) != eSIR_SUCCESS)
672 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700673 PELOGE(limLog(pMac, LOGE, FL("*** Unable to set fixed Beacon fields ***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 return;
675 }
676
677}
678
679
680
681/* delete the current BSS */
682static void
683ibss_bss_delete(
684 tpAniSirGlobal pMac,
685 tpPESession psessionEntry)
686{
687 tSirRetStatus status;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700688 PELOGW(limLog(pMac, LOGW, FL("Initiating IBSS Delete BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 if (psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
690 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700691 limLog(pMac, LOGW, FL("Incorrect LIM MLM state for delBss (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 psessionEntry->limMlmState);
693 return;
694 }
695 status = limDelBss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
696 if (status != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700697 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700698}
699
700/**
701 * limIbssInit
702 *
703 *FUNCTION:
704 * This function is called while starting an IBSS
705 * to initialize list used to maintain IBSS peers.
706 *
707 *LOGIC:
708 *
709 *ASSUMPTIONS:
710 *
711 *NOTE:
712 *
713 * @param pMac - Pointer to Global MAC structure
714 * @return None
715 */
716
717void
718limIbssInit(
719 tpAniSirGlobal pMac)
720{
721 //pMac->lim.gLimIbssActive = 0;
722 pMac->lim.gLimIbssCoalescingHappened = 0;
723 pMac->lim.gLimIbssPeerList = NULL;
724 pMac->lim.gLimNumIbssPeers = 0;
725
726 // ibss info - params for which ibss to join while coalescing
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530727 vos_mem_set(&pMac->lim.ibssInfo, sizeof(tAniSirLimIbss), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700728} /*** end limIbssInit() ***/
729
730/**
731 * limIbssDeleteAllPeers
732 *
733 *FUNCTION:
734 * This function is called to delete all peers.
735 *
736 *LOGIC:
737 *
738 *ASSUMPTIONS:
739 *
740 *NOTE:
741 *
742 * @param pMac - Pointer to Global MAC structure
743 * @return None
744 */
745
746void limIbssDeleteAllPeers( tpAniSirGlobal pMac ,tpPESession psessionEntry)
747{
748 tLimIbssPeerNode *pCurrNode, *pTempNode;
749 tpDphHashNode pStaDs;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800750 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700751
752 pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList;
753
754 while (pCurrNode != NULL)
755 {
756 if (!pMac->lim.gLimNumIbssPeers)
757 {
758 limLog(pMac, LOGP,
759 FL("Number of peers in the list is zero and node present"));
760 return;
761 }
762 /* Delete the dph entry for the station
763 * Since it is called to remove all peers, just delete from dph,
764 * no need to do any beacon related params i.e., dont call limDeleteDphHashEntry
765 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800766 pStaDs = dphLookupHashEntry(pMac, pCurrNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 if( pStaDs )
768 {
769
770 ibss_status_chg_notify( pMac, pCurrNode->peerMacAddr, pStaDs->staIndex,
771 pStaDs->ucUcastSig, pStaDs->ucBcastSig,
772 eWNI_SME_IBSS_PEER_DEPARTED_IND, psessionEntry->smeSessionId );
Ravi Joshi492be3c2013-05-16 19:20:00 -0700773 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800774 dphDeleteHashEntry(pMac, pStaDs->staAddr, peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 }
776
777 pTempNode = pCurrNode->next;
778
779 /* TODO :Sessionize this code */
780 /* Fix CR 227642: PeerList should point to the next node since the current node is being
781 * freed in the next line. In ibss_peerfind in ibss_status_chg_notify above, we use this
782 * peer list to find the next peer. So this list needs to be updated with the no of peers left
783 * after each iteration in this while loop since one by one peers are deleted (freed) in this
784 * loop causing the lim.gLimIbssPeerList to point to some freed memory.
785 */
786 pMac->lim.gLimIbssPeerList = pTempNode;
787
788 if(pCurrNode->beacon)
789 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530790 vos_mem_free(pCurrNode->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530792 vos_mem_free(pCurrNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 if (pMac->lim.gLimNumIbssPeers > 0) // be paranoid
794 pMac->lim.gLimNumIbssPeers--;
795 pCurrNode = pTempNode;
796 }
797
798 if (pMac->lim.gLimNumIbssPeers)
799 limLog(pMac, LOGP, FL("Number of peers[%d] in the list is non-zero"),
800 pMac->lim.gLimNumIbssPeers);
801
802 pMac->lim.gLimNumIbssPeers = 0;
803 pMac->lim.gLimIbssPeerList = NULL;
804
805}
806/**
807 * limIbssDelete
808 *
809 *FUNCTION:
810 * This function is called while tearing down an IBSS.
811 *
812 *LOGIC:
813 *
814 *ASSUMPTIONS:
815 *
816 *NOTE:
817 *
818 * @param pMac - Pointer to Global MAC structure
819 * @return None
820 */
821
822void
823limIbssDelete(
824 tpAniSirGlobal pMac,tpPESession psessionEntry)
825{
Abhishek Singh00b71972016-01-07 10:51:04 +0530826#ifdef WLAN_FEATURE_RMC
827 limRmcIbssDelete(pMac);
828#endif /* WLAN_FEATURE_RMC */
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 limIbssDeleteAllPeers(pMac,psessionEntry);
831
832 ibss_coalesce_free(pMac);
833} /*** end limIbssDelete() ***/
834
835/** Commenting this Code as from no where it is being invoked */
836#if 0
837/**
838 * limIbssPeerDelete
839 *
840 *FUNCTION:
841 * This may be called on a STA in IBSS to delete a peer
842 * from the list.
843 *
844 *LOGIC:
845 *
846 *ASSUMPTIONS:
847 *
848 *NOTE:
849 *
850 * @param pMac - Pointer to Global MAC structure
851 * @param peerMacAddr - MAC address of the peer STA that
852 * need to be deleted from peer list.
853 *
854 * @return None
855 */
856
857void
858limIbssPeerDelete(tpAniSirGlobal pMac, tSirMacAddr macAddr)
859{
860 tLimIbssPeerNode *pPrevNode, *pTempNode;
861
862 pTempNode = pPrevNode = pMac->lim.gLimIbssPeerList;
863
864 if (pTempNode == NULL)
865 return;
866
867 while (pTempNode != NULL)
868 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530869 if (vos_mem_compare((tANI_U8 *) macAddr,
870 (tANI_U8 *) &pTempNode->peerMacAddr,
871 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 {
873 // Found node to be deleted
874 if (pMac->lim.gLimIbssPeerList == pTempNode) /** First Node to be deleted*/
875 pMac->lim.gLimIbssPeerList = pTempNode->next;
876 else
877 pPrevNode->next = pTempNode->next;
878
879 if(pTempNode->beacon)
880 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530881 vos_mem_free(pTempNode->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 pTempNode->beacon = NULL;
883 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530884 vos_mem_free(pTempNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 pMac->lim.gLimNumIbssPeers--;
886 return;
887 }
888
889 pPrevNode = pTempNode;
890 pTempNode = pTempNode->next;
891 }
892
893 // Should not be here
894 PELOGE(limLog(pMac, LOGE, FL("peer not found in the list, addr= "));)
895 limPrintMacAddr(pMac, macAddr, LOGE);
896} /*** end limIbssPeerDelete() ***/
897
898#endif
899
900
901/** -------------------------------------------------------------
902\fn limIbssSetProtection
903\brief Decides all the protection related information.
904\
905\param tpAniSirGlobal pMac
906\param tSirMacAddr peerMacAddr
907\param tpUpdateBeaconParams pBeaconParams
908\return None
909 -------------------------------------------------------------*/
910static void
911limIbssSetProtection(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
912{
913
914 if(!pMac->lim.cfgProtection.fromllb)
915 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530916 limLog(pMac, LOG1, FL("protection from 11b is disabled"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 return;
918 }
919
920 if (enable)
921 {
922 psessionEntry->gLim11bParams.protectionEnabled = true;
923 if(false == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/)
924 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700925 PELOGE(limLog(pMac, LOGE, FL("=> IBSS: Enable Protection "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
927 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
928 }
929 }
930 else if (true == psessionEntry->beaconParams.llbCoexist/*pMac->lim.llbCoexist*/)
931 {
932 psessionEntry->gLim11bParams.protectionEnabled = false;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700933 PELOGE(limLog(pMac, LOGE, FL("===> IBSS: Disable protection "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
935 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
936 }
937 return;
938}
939
940
941/** -------------------------------------------------------------
942\fn limIbssUpdateProtectionParams
943\brief Decides all the protection related information.
944\
945\param tpAniSirGlobal pMac
946\param tSirMacAddr peerMacAddr
947\param tpUpdateBeaconParams pBeaconParams
948\return None
949 -------------------------------------------------------------*/
950static void
951limIbssUpdateProtectionParams(tpAniSirGlobal pMac,
952 tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType,
953 tpPESession psessionEntry)
954{
955 tANI_U32 i;
956
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530957 limLog(pMac,LOG1, FL("A STA is associated:"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 limLog(pMac,LOG1, FL("Addr : "));
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530959 limPrintMacAddr(pMac, peerMacAddr, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
961 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
962 {
963 if (pMac->lim.protStaCache[i].active)
964 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530965 limLog(pMac, LOG1, FL("Addr: "));
966 limPrintMacAddr(pMac, pMac->lim.protStaCache[i].addr, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530968 if (vos_mem_compare(pMac->lim.protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 peerMacAddr, sizeof(tSirMacAddr)))
970 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530971 limLog(pMac, LOG1, FL("matching cache entry at %d already active."), i);
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 return;
973 }
974 }
975 }
976
977 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
978 {
979 if (!pMac->lim.protStaCache[i].active)
980 break;
981 }
982
983 if (i >= LIM_PROT_STA_CACHE_SIZE)
984 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700985 PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 return;
987 }
988
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530989 vos_mem_copy(pMac->lim.protStaCache[i].addr,
990 peerMacAddr,
991 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700992
993 pMac->lim.protStaCache[i].protStaCacheType = protStaCacheType;
994 pMac->lim.protStaCache[i].active = true;
995 if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType)
996 {
997 psessionEntry->gLim11bParams.numSta++;
998 }
999 else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType)
1000 {
1001 psessionEntry->gLim11gParams.numSta++;
1002 }
1003}
1004
1005
1006/** -------------------------------------------------------------
1007\fn limIbssDecideProtection
1008\brief Decides all the protection related information.
1009\
1010\param tpAniSirGlobal pMac
1011\param tSirMacAddr peerMacAddr
1012\param tpUpdateBeaconParams pBeaconParams
1013\return None
1014 -------------------------------------------------------------*/
1015static void
1016limIbssDecideProtection(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1017{
1018 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1019 tANI_U32 phyMode;
1020 tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID;
1021
1022 pBeaconParams->paramChangeBitmap = 0;
1023
1024 if(NULL == pStaDs)
1025 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001026 PELOGE(limLog(pMac, LOGE, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 return;
1028 }
1029
1030 limGetRfBand(pMac, &rfBand, psessionEntry);
1031 if(SIR_BAND_2_4_GHZ== rfBand)
1032 {
1033 limGetPhyMode(pMac, &phyMode, psessionEntry);
1034
1035 //We are 11G or 11n. Check if we need protection from 11b Stations.
Jeff Johnsone7245742012-09-05 17:12:55 -07001036 if ((phyMode == WNI_CFG_PHY_MODE_11G) || (psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 {
1038 /* As we found in the past, it is possible that a 11n STA sends
1039 * Beacon with HT IE but not ERP IE. So the absense of ERP IE
1040 * in the Beacon is not enough to conclude that STA is 11b.
1041 */
1042 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1043 (!pStaDs->mlmStaContext.htCapability))
1044 {
1045 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001046 PELOGE(limLog(pMac, LOGE, FL("Enable protection from 11B"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 limIbssSetProtection(pMac, true, pBeaconParams,psessionEntry);
1048 }
1049 }
1050 }
1051 limIbssUpdateProtectionParams(pMac, pStaDs->staAddr, protStaCacheType, psessionEntry);
1052 return;
1053}
1054
1055
1056/**
1057 * limIbssStaAdd()
1058 *
1059 *FUNCTION:
1060 * This function is called to add an STA context in IBSS role
1061 * whenever a data frame is received from/for a STA that failed
1062 * hash lookup at DPH.
1063 *
1064 *LOGIC:
1065 *
1066 *ASSUMPTIONS:
1067 * NA
1068 *
1069 *NOTE:
1070 * NA
1071 *
1072 * @param pMac Pointer to Global MAC structure
1073 * @param peerAdddr MAC address of the peer being added
1074 * @return retCode Indicates success or failure return code
1075 * @return
1076 */
1077
1078tSirRetStatus
1079limIbssStaAdd(
1080 tpAniSirGlobal pMac,
1081 void *pBody,
1082 tpPESession psessionEntry)
1083{
1084 tSirRetStatus retCode = eSIR_SUCCESS;
1085 tpDphHashNode pStaDs;
1086 tLimIbssPeerNode *pPeerNode;
1087 tLimMlmStates prevState;
1088 tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody;
1089 tUpdateBeaconParams beaconParams;
1090
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301091 vos_mem_set((tANI_U8 *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001092
1093 if (pBody == 0)
1094 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001095 PELOGE(limLog(pMac, LOGE, FL("Invalid IBSS AddSta"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 return eSIR_FAILURE;
1097 }
1098
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001099 PELOGE(limLog(pMac, LOGE, FL("Rx Add-Ibss-Sta for MAC:"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
1101
1102 pPeerNode = ibss_peer_find(pMac, *pPeerAddr);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001103 if (NULL != pPeerNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 {
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001105 retCode = ibss_dph_entry_add(pMac, *pPeerAddr, &pStaDs, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 if (eSIR_SUCCESS == retCode)
1107 {
1108 prevState = pStaDs->mlmStaContext.mlmState;
1109 pStaDs->erpEnabled = pPeerNode->erpIePresent;
1110
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001111 ibss_sta_info_update(pMac, pStaDs, pPeerNode, psessionEntry);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001112 PELOGW(limLog(pMac, LOGW, FL("initiating ADD STA for the IBSS peer."));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001113 retCode = limAddSta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001114 if (retCode != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 {
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001116 PELOGE(limLog(pMac, LOGE, FL("ibss-sta-add failed (reason %x)"),
1117 retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
Jeff Johnson8db48ea2013-04-08 10:15:38 -07001119 pStaDs->mlmStaContext.mlmState = prevState;
1120 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,
1121 &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 }
1123 else
1124 {
1125 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1126 limIbssDecideProtection(pMac, pStaDs, &beaconParams , psessionEntry);
1127
1128 if(beaconParams.paramChangeBitmap)
1129 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001130 PELOGE(limLog(pMac, LOGE, FL("---> Update Beacon Params "));)
Sunil Ravib96f7b52013-05-22 21:40:05 -07001131 schSetFixedBeaconFields(pMac, psessionEntry);
1132 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1134 }
1135 }
1136 }
1137 else
1138 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001139 PELOGE(limLog(pMac, LOGE, FL("hashTblAdd failed (reason %x)"), retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 limPrintMacAddr(pMac, *pPeerAddr, LOGE);
1141 }
1142 }
1143 else
1144 {
1145 retCode = eSIR_FAILURE;
1146 }
1147
1148 return retCode;
1149}
1150
Abhishek Singh026c95c2015-11-25 17:52:51 +05301151static void
1152__limIbssSearchAndDeletePeer(tpAniSirGlobal pMac,
1153 tpPESession psessionEntry,
1154 tSirMacAddr macAddr)
1155{
1156 tLimIbssPeerNode *pTempNode, *pPrevNode;
1157 tLimIbssPeerNode *pTempNextNode = NULL;
1158 tpDphHashNode pStaDs=NULL;
1159 tANI_U16 peerIdx=0;
1160 tANI_U16 staIndex=0;
1161 tANI_U8 ucUcastSig;
1162 tANI_U8 ucBcastSig;
1163
1164 pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList;
1165
1166 limLog(pMac, LOG1,
1167 FL(" PEER ADDR :" MAC_ADDRESS_STR ),MAC_ADDR_ARRAY(macAddr));
1168
1169 /** Compare Peer */
1170 while (NULL != pTempNode)
1171 {
1172 pTempNextNode = pTempNode->next;
1173
1174 /* Delete the STA with MAC address */
1175 if (vos_mem_compare( (tANI_U8 *) macAddr,
1176 (tANI_U8 *) &pTempNode->peerMacAddr,
1177 sizeof(tSirMacAddr)) )
1178 {
1179 pStaDs = dphLookupHashEntry(pMac, macAddr,
1180 &peerIdx, &psessionEntry->dph.dphHashTable);
1181 if (pStaDs)
1182 {
1183 staIndex = pStaDs->staIndex;
1184 ucUcastSig = pStaDs->ucUcastSig;
1185 ucBcastSig = pStaDs->ucBcastSig;
1186
Abhishek Singh00b71972016-01-07 10:51:04 +05301187#ifdef WLAN_FEATURE_RMC
1188 limRmcTransmitterDelete(pMac, pStaDs->staAddr);
1189#endif /* WLAN_FEATURE_RMC */
1190
Abhishek Singh026c95c2015-11-25 17:52:51 +05301191 /* Send DEL STA only if STA id is valid, mean ADD STA was
1192 * success.
1193 */
1194 if(HAL_STA_INVALID_IDX != staIndex)
1195 limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
1196 limDeleteDphHashEntry(pMac,
1197 pStaDs->staAddr, peerIdx, psessionEntry);
1198 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
1199
1200 /* Send indication to upper layers only if ADD STA was success
1201 * i.e staid is Valid.
1202 */
1203 if(HAL_STA_INVALID_IDX != staIndex)
1204 ibss_status_chg_notify(pMac, macAddr, staIndex,
1205 ucUcastSig, ucBcastSig,
1206 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1207 psessionEntry->smeSessionId );
1208 if (pTempNode == pMac->lim.gLimIbssPeerList)
1209 {
1210 pMac->lim.gLimIbssPeerList = pTempNode->next;
1211 pPrevNode = pMac->lim.gLimIbssPeerList;
1212 }
1213 else
1214 pPrevNode->next = pTempNode->next;
1215
1216 vos_mem_free(pTempNode);
1217 pMac->lim.gLimNumIbssPeers--;
1218
1219 pTempNode = pTempNextNode;
1220 break;
1221 }
1222 }
1223 pPrevNode = pTempNode;
1224 pTempNode = pTempNextNode;
1225 }
1226 /*
1227 * if it is the last peer walking out, we better
1228 * we set IBSS state to inactive.
1229 */
1230 if (0 == pMac->lim.gLimNumIbssPeers)
1231 {
1232 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1233 "Last STA from IBSS walked out");
1234 psessionEntry->limIbssActive = false;
1235 }
1236}
1237
Jeff Johnson295189b2012-06-20 16:38:30 -07001238/* handle the response from HAL for an ADD STA request */
1239tSirRetStatus
1240limIbssAddStaRsp(
1241 tpAniSirGlobal pMac,
1242 void *msg,tpPESession psessionEntry)
1243{
1244 tpDphHashNode pStaDs;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001245 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 tpAddStaParams pAddStaParams = (tpAddStaParams) msg;
1247
1248 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1249 if (pAddStaParams == NULL)
1250 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001251 PELOGE(limLog(pMac, LOGE, FL("IBSS: ADD_STA_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 return eSIR_FAILURE;
1253 }
1254
Abhishek Singh026c95c2015-11-25 17:52:51 +05301255 pStaDs = dphLookupHashEntry(pMac,
1256 pAddStaParams->staMac, &peerIdx,
1257 &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 if (pStaDs == NULL)
1259 {
Abhishek Singh026c95c2015-11-25 17:52:51 +05301260 limLog(pMac, LOGE,
1261 FL("IBSS: ADD_STA_RSP for unknown MAC addr: "MAC_ADDRESS_STR),
1262 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301263 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 return eSIR_FAILURE;
1265 }
1266
1267 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
1268 {
Abhishek Singh026c95c2015-11-25 17:52:51 +05301269 limLog(pMac, LOGE,
1270 FL("IBSS: ADD_STA_RSP error (%x) from MAC: " MAC_ADDRESS_STR),
1271 pAddStaParams->status, MAC_ADDR_ARRAY(pAddStaParams->staMac));
1272 __limIbssSearchAndDeletePeer(pMac,
1273 psessionEntry, pAddStaParams->staMac);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301274 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 return eSIR_FAILURE;
1276 }
1277
1278 pStaDs->bssId = pAddStaParams->bssIdx;
1279 pStaDs->staIndex = pAddStaParams->staIdx;
1280 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
1281 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
1282 pStaDs->valid = 1;
1283 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1284
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001285 PELOGW(limLog(pMac, LOGW, FL("IBSS: sending IBSS_NEW_PEER msg to SME!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001286
Abhishek Singh026c95c2015-11-25 17:52:51 +05301287 ibss_status_chg_notify(pMac, pAddStaParams->staMac, pStaDs->staIndex,
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 pStaDs->ucUcastSig, pStaDs->ucBcastSig,
1289 eWNI_SME_IBSS_NEW_PEER_IND,
1290 psessionEntry->smeSessionId);
Abhishek Singh00b71972016-01-07 10:51:04 +05301291
1292#ifdef WLAN_FEATURE_RMC
1293 limRmcTriggerRulerSelection(pMac, psessionEntry->selfMacAddr);
1294#endif
1295
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301296 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001297
1298 return eSIR_SUCCESS;
1299}
1300
1301
1302
1303void limIbssDelBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg,tpPESession psessionEntry)
1304{
1305 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1306
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001307 PELOGW(limLog(pMac, LOGW, FL("IBSS: DEL_BSS_RSP Rcvd during coalescing!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001308
1309 if (pDelBss == NULL)
1310 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001311 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 goto end;
1313 }
1314
1315 if (pDelBss->status != eHAL_STATUS_SUCCESS)
1316 {
1317 limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP(coalesce) error (%x) Bss %d "),
1318 pDelBss->status, pDelBss->bssIdx);
1319 goto end;
1320 }
1321 //Delete peer entries.
1322 limIbssDeleteAllPeers(pMac,psessionEntry);
1323
1324 /* add the new bss */
1325 ibss_bss_add(pMac,psessionEntry);
1326
1327 end:
1328 if(pDelBss != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301329 vos_mem_free(pDelBss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001330}
1331
1332
1333
1334void limIbssAddBssRspWhenCoalescing(tpAniSirGlobal pMac, void *msg, tpPESession pSessionEntry)
1335{
1336 tANI_U8 infoLen;
1337 tSirSmeNewBssInfo newBssInfo;
1338
1339 tpAddBssParams pAddBss = (tpAddBssParams) msg;
1340
1341 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr;
1342 tpSchBeaconStruct pBeacon = (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon;
1343
1344 if ((pHdr == NULL) || (pBeacon == NULL))
1345 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001346 PELOGE(limLog(pMac, LOGE, FL("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 goto end;
1348 }
1349
1350 // Inform Host of IBSS coalescing
1351 infoLen = sizeof(tSirMacAddr) + sizeof(tSirMacChanNum) +
1352 sizeof(tANI_U8) + pBeacon->ssId.length + 1;
1353
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301354 vos_mem_set((void *) &newBssInfo, sizeof(newBssInfo), 0);
1355 vos_mem_copy(newBssInfo.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301357 vos_mem_copy((tANI_U8 *) &newBssInfo.ssId,
1358 (tANI_U8 *) &pBeacon->ssId, pBeacon->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001360 PELOGW(limLog(pMac, LOGW, FL("Sending JOINED_NEW_BSS notification to SME."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
1362 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_JOINED_NEW_BSS,
1363 (tANI_U32 *) &newBssInfo,
1364 infoLen,pSessionEntry->smeSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 {
1366 //Configure beacon and send beacons to HAL
1367 limSendBeaconInd(pMac, pSessionEntry);
1368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001369
Jeff Johnson3c3e1782013-02-27 10:48:42 -08001370 end:
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 ibss_coalesce_free(pMac);
1372}
1373
Jeff Johnson295189b2012-06-20 16:38:30 -07001374void
1375limIbssDelBssRsp(
1376 tpAniSirGlobal pMac,
1377 void *msg,tpPESession psessionEntry)
1378{
1379 tSirResultCodes rc = eSIR_SME_SUCCESS;
1380 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1381 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1382
1383
1384 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1385 if (pDelBss == NULL)
1386 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001387 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP with no body!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 rc = eSIR_SME_REFUSED;
1389 goto end;
1390 }
1391
1392 if((psessionEntry = peFindSessionBySessionId(pMac,pDelBss->sessionId))==NULL)
1393 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001394 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 goto end;
1396 }
1397
1398
1399 /*
1400 * If delBss was issued as part of IBSS Coalescing, gLimIbssCoalescingHappened flag will be true.
1401 * BSS has to be added again in this scenario, so this case needs to be handled separately.
1402 * If delBss was issued as a result of trigger from SME_STOP_BSS Request, then limSme state changes to
1403 * 'IDLE' and gLimIbssCoalescingHappened flag will be false. In this case STOP BSS RSP has to be sent to SME.
1404 */
1405 if(true == pMac->lim.gLimIbssCoalescingHappened)
1406 {
1407
1408 limIbssDelBssRspWhenCoalescing(pMac,msg,psessionEntry);
1409 return;
1410 }
1411
1412
1413
1414 if (pDelBss->status != eHAL_STATUS_SUCCESS)
1415 {
1416 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP error (%x) Bss %d "),
1417 pDelBss->status, pDelBss->bssIdx);)
1418 rc = eSIR_SME_STOP_BSS_FAILURE;
1419 goto end;
1420 }
1421
1422
1423
1424 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
1425 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1426 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001427 PELOGE(limLog(pMac, LOGE, FL("IBSS: DEL_BSS_RSP setLinkState failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 rc = eSIR_SME_REFUSED;
1429 goto end;
1430 }
1431
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001432 limIbssDelete(pMac,psessionEntry);
1433
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
1435 limDeletePreAuthList(pMac);
1436
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
1438
Jeff Johnsone7245742012-09-05 17:12:55 -07001439 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001440
1441 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1442
1443 /* Change the short slot operating mode to Default (which is 1 for now) so that when IBSS starts next time with Libra
1444 * as originator, it picks up the default. This enables us to remove hard coding of short slot = 1 from limApplyConfiguration
1445 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001446 psessionEntry->shortSlotTimeSupported = WNI_CFG_SHORT_SLOT_TIME_STADEF;
Jeff Johnson295189b2012-06-20 16:38:30 -07001447
1448 end:
1449 if(pDelBss != NULL)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301450 vos_mem_free(pDelBss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 /* Delete PE session once BSS is deleted */
1452 if (NULL != psessionEntry) {
1453 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, rc,psessionEntry->smeSessionId,psessionEntry->transactionId);
1454 peDeleteSession(pMac, psessionEntry);
1455 psessionEntry = NULL;
1456 }
1457}
1458
1459/**
1460 * limIbssCoalesce()
1461 *
1462 *FUNCTION:
1463 * This function is called upon receiving Beacon/Probe Response
1464 * while operating in IBSS mode.
1465 *
1466 *LOGIC:
1467 *
1468 *ASSUMPTIONS:
1469 *
1470 *NOTE:
1471 *
1472 * @param pMac - Pointer to Global MAC structure
1473 * @param pBeacon - Parsed Beacon Frame structure
1474 * @param pBD - Pointer to received BD
1475 *
1476 * @return Status whether to process or ignore received Beacon Frame
1477 */
1478
1479tSirRetStatus
1480limIbssCoalesce(
1481 tpAniSirGlobal pMac,
1482 tpSirMacMgmtHdr pHdr,
1483 tpSchBeaconStruct pBeacon,
1484 tANI_U8 *pIEs,
1485 tANI_U32 ieLen,
1486 tANI_U16 fTsfLater,
1487 tpPESession psessionEntry)
1488{
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001489 tANI_U16 peerIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 tSirMacAddr currentBssId;
1491 tLimIbssPeerNode *pPeerNode;
1492 tpDphHashNode pStaDs;
Sushant Kaushike06bd872015-03-12 16:17:48 +05301493 tUpdateBeaconParams beaconParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001494
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301495 vos_mem_set((tANI_U8 *)&beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001496
1497 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
1498
Shailender Karmuchia734f332013-04-19 14:02:48 -07001499 limLog(pMac, LOG1, FL("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :" MAC_ADDRESS_STR ),
1500 MAC_ADDR_ARRAY(currentBssId), MAC_ADDR_ARRAY(pHdr->bssId));
Ravi Joshi92404a32013-08-13 15:40:30 -07001501
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 /* Check for IBSS Coalescing only if Beacon is from different BSS */
krunal sonie9002db2013-11-25 14:24:17 -08001503 if ( !vos_mem_compare(currentBssId, pHdr->bssId, sizeof( tSirMacAddr ))
1504 && psessionEntry->isCoalesingInIBSSAllowed)
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 {
Ravi Joshi92404a32013-08-13 15:40:30 -07001506 /*
1507 * If STA entry is already available in the LIM hash table, then it is
1508 * possible that the peer may have left and rejoined within the heartbeat
1509 * timeout. In the offloaded case with 32 peers, the HB timeout is whopping
1510 * 128 seconds. In that case, the FW will not let any frames come in until
1511 * atleast the last sequence number is received before the peer is left
1512 * Hence, if the coalescing peer is already there in the peer list and if
1513 * the BSSID matches then, invoke delSta() to cleanup the entries. We will
1514 * let the peer coalesce when we receive next beacon from the peer
1515 */
1516 pPeerNode = ibss_peer_find(pMac, pHdr->sa);
1517 if (NULL != pPeerNode)
1518 {
1519 __limIbssSearchAndDeletePeer (pMac, psessionEntry, pHdr->sa);
1520 PELOGW(limLog(pMac, LOGW,
1521 FL("** Peer attempting to reconnect before HB timeout, deleted **"));)
1522 return eSIR_LIM_IGNORE_BEACON;
1523 }
1524
1525 if (! fTsfLater) // No Coalescing happened.
1526 {
1527 PELOGW(limLog(pMac, LOGW, FL("No Coalescing happened"));)
1528 return eSIR_LIM_IGNORE_BEACON;
1529 }
1530 /*
1531 * IBSS Coalescing happened.
1532 * save the received beacon, and delete the current BSS. The rest of the
1533 * processing will be done in the delBss response processing
1534 */
1535 pMac->lim.gLimIbssCoalescingHappened = true;
1536 PELOGW(limLog(pMac, LOGW, FL("IBSS Coalescing happened"));)
1537 ibss_coalesce_save(pMac, pHdr, pBeacon);
1538 limLog(pMac, LOGW, FL("Delete BSSID :" MAC_ADDRESS_STR ),
1539 MAC_ADDR_ARRAY(currentBssId));
1540 ibss_bss_delete(pMac,psessionEntry);
1541 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 }
krunal sonie9002db2013-11-25 14:24:17 -08001543 else
1544 {
1545 if (!vos_mem_compare(currentBssId, pHdr->bssId, sizeof( tSirMacAddr )))
1546 return eSIR_LIM_IGNORE_BEACON;
1547 }
1548
Jeff Johnson295189b2012-06-20 16:38:30 -07001549
1550 // STA in IBSS mode and SSID matches with ours
1551 pPeerNode = ibss_peer_find(pMac, pHdr->sa);
1552 if (pPeerNode == NULL)
1553 {
1554 /* Peer not in the list - Collect BSS description & add to the list */
1555 tANI_U32 frameLen;
1556 tSirRetStatus retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557
krunal soni3c28b102013-10-04 18:38:52 -07001558 /*
1559 * Limit the Max number of IBSS Peers allowed as the max
1560 * number of STA's allowed
1561 * pMac->lim.gLimNumIbssPeers will be increamented after exiting
1562 * this function. so we will add additional 1 to compare against
1563 * pMac->lim.gLimIbssStaLimit
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 */
Abhishek Singh639a5642014-04-22 11:02:54 +05301565 if ((pMac->lim.gLimNumIbssPeers+1) >= pMac->lim.gLimIbssStaLimit)
Sushant Kaushike06bd872015-03-12 16:17:48 +05301566 { /*Print every 100th time */
1567 if (pMac->lim.gLimIbssRetryCnt % 100 == 0)
1568 {
1569 limLog(pMac, LOG1, FL("**** MAX STA LIMIT HAS REACHED ****"));
1570 }
1571 pMac->lim.gLimIbssRetryCnt++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 return eSIR_LIM_MAX_STA_REACHED_ERROR;
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001573 }
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001574 PELOGW(limLog(pMac, LOGW, FL("IBSS Peer node does not exist, adding it***"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 frameLen = sizeof(tLimIbssPeerNode) + ieLen - sizeof(tANI_U32);
1576
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301577 pPeerNode = vos_mem_malloc((tANI_U16)frameLen);
1578 if (NULL == pPeerNode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001580 limLog(pMac, LOGP, FL("alloc fail (%d bytes) storing IBSS peer info"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 frameLen);
1582 return eSIR_MEM_ALLOC_FAILED;
1583 }
1584
1585 pPeerNode->beacon = NULL;
1586 pPeerNode->beaconLen = 0;
1587
1588 ibss_peer_collect(pMac, pBeacon, pHdr, pPeerNode,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301589 pPeerNode->beacon = vos_mem_malloc(ieLen);
1590 if (NULL == pPeerNode->beacon)
1591 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store beacon"));)
1593 }
1594 else
1595 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301596 vos_mem_copy(pPeerNode->beacon, pIEs, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 pPeerNode->beaconLen = (tANI_U16)ieLen;
1598 }
1599 ibss_peer_add(pMac, pPeerNode);
1600
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001601 pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 if (pStaDs != NULL)
1603 {
1604 /// DPH node already exists for the peer
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301605 limLog(pMac, LOG1, FL("DPH Node present for just learned peer"));
1606 limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 ibss_sta_info_update(pMac, pStaDs, pPeerNode,psessionEntry);
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07001608 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 }
1610 retCode = limIbssStaAdd(pMac, pPeerNode->peerMacAddr,psessionEntry);
1611 if (retCode != eSIR_SUCCESS)
1612 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001613 PELOGE(limLog(pMac, LOGE, FL("lim-ibss-sta-add failed (reason %x)"), retCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 limPrintMacAddr(pMac, pPeerNode->peerMacAddr, LOGE);
1615 return retCode;
1616 }
1617
1618 // Decide protection mode
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001619 pStaDs = dphLookupHashEntry(pMac, pPeerNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1621 limIbssDecideProtection(pMac, pStaDs, &beaconParams, psessionEntry);
1622
1623 if(beaconParams.paramChangeBitmap)
1624 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001625 PELOGE(limLog(pMac, LOGE, FL("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params "));)
Sunil Ravib96f7b52013-05-22 21:40:05 -07001626 schSetFixedBeaconFields(pMac, psessionEntry);
1627 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1629 }
1630 }
1631 else
1632 ibss_sta_caps_update(pMac, pPeerNode,psessionEntry);
1633
1634 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE)
1635 return eSIR_SUCCESS;
1636
1637 // Received Beacon from same IBSS we're
1638 // currently part of. Inform Roaming algorithm
1639 // if not already that IBSS is active.
1640 if (psessionEntry->limIbssActive == false)
1641 {
1642 limResetHBPktCount(psessionEntry);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001643 PELOGW(limLog(pMac, LOGW, FL("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 psessionEntry->limIbssActive = true;
1645 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_ACTIVE, NULL, 0, psessionEntry->smeSessionId);
1646 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001648 if (limActivateHearBeatTimer(pMac, psessionEntry) != TX_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001649 limLog(pMac, LOGP, FL("could not activate Heartbeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651
1652 return eSIR_SUCCESS;
1653} /*** end limHandleIBSScoalescing() ***/
1654
1655
1656void limIbssHeartBeatHandle(tpAniSirGlobal pMac,tpPESession psessionEntry)
1657{
1658 tLimIbssPeerNode *pTempNode, *pPrevNode;
1659 tLimIbssPeerNode *pTempNextNode = NULL;
Ravi Joshi0fc681b2013-09-11 16:46:07 -07001660 tANI_U16 peerIdx=0;
1661 tpDphHashNode pStaDs=0;
1662 tANI_U32 threshold=0;
1663 tANI_U16 staIndex=0;
1664 tANI_U8 ucUcastSig=0;
1665 tANI_U8 ucBcastSig=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001666
1667 /** MLM BSS is started and if PE in scanmode then MLM state will be waiting for probe resp.
1668 * If Heart beat timeout triggers during this corner case then we need to reactivate HeartBeat timer
1669 */
1670 if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
1671 /******
1672 * Note: Use this code once you have converted all
1673 * limReactivateHeartBeatTimer() calls to
1674 * limReactivateTimer() calls.
1675 *
1676 ******/
1677 //limReactivateTimer(pMac, eLIM_HEART_BEAT_TIMER, psessionEntry);
1678 limReactivateHeartBeatTimer(pMac, psessionEntry);
1679 return;
1680 }
1681 /** If LinkMonitor is Disabled */
1682 if(!pMac->sys.gSysEnableLinkMonitorMode)
1683 return;
1684
1685 pPrevNode = pTempNode = pMac->lim.gLimIbssPeerList;
1686 threshold = (pMac->lim.gLimNumIbssPeers / 4 ) + 1;
1687
1688 /** Monitor the HeartBeat with the Individual PEERS in the IBSS */
1689 while (pTempNode != NULL)
1690 {
1691 pTempNextNode = pTempNode->next;
1692 if(pTempNode->beaconHBCount) //There was a beacon for this peer during heart beat.
1693 {
1694 pTempNode->beaconHBCount = 0;
1695 pTempNode->heartbeatFailure = 0;
1696 }
1697 else //There wasnt any beacon received during heartbeat timer.
1698 {
1699 pTempNode->heartbeatFailure++;
1700 PELOGE(limLog(pMac, LOGE, FL("Heartbeat fail = %d thres = %d"), pTempNode->heartbeatFailure, pMac->lim.gLimNumIbssPeers);)
1701 if(pTempNode->heartbeatFailure >= threshold )
1702 {
1703 //Remove this entry from the list.
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001704 pStaDs = dphLookupHashEntry(pMac, pTempNode->peerMacAddr, &peerIdx, &psessionEntry->dph.dphHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 if (pStaDs)
1706 {
1707 staIndex = pStaDs->staIndex;
1708 ucUcastSig = pStaDs->ucUcastSig;
1709 ucBcastSig = pStaDs->ucBcastSig;
1710
Abhishek Singh00b71972016-01-07 10:51:04 +05301711#ifdef WLAN_FEATURE_RMC
1712 limRmcTransmitterDelete(pMac, pStaDs->staAddr);
1713#endif /* WLAN_FEATURE_RMC */
1714
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001716 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001717 limReleasePeerIdx(pMac, peerIdx, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 //Send indication.
1719 ibss_status_chg_notify( pMac, pTempNode->peerMacAddr, staIndex,
1720 ucUcastSig, ucBcastSig,
1721 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1722 psessionEntry->smeSessionId );
1723 }
1724 if(pTempNode == pMac->lim.gLimIbssPeerList)
1725 {
1726 pMac->lim.gLimIbssPeerList = pTempNode->next;
1727 pPrevNode = pMac->lim.gLimIbssPeerList;
1728 }
1729 else
1730 pPrevNode->next = pTempNode->next;
1731
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301732 vos_mem_free(pTempNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 pMac->lim.gLimNumIbssPeers--;
1734
1735 pTempNode = pTempNextNode; //Since we deleted current node, prevNode remains same.
1736 continue;
1737 }
1738 }
1739
1740 pPrevNode = pTempNode;
1741 pTempNode = pTempNextNode;
1742 }
1743
1744 /** General IBSS Activity Monitor, check if in IBSS Mode we are received any Beacons */
1745 if(pMac->lim.gLimNumIbssPeers)
1746 {
1747 if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL)
1748 pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++;
1749 else
1750 pMac->lim.gLimHeartBeatBeaconStats[0]++;
1751
1752 limReactivateHeartBeatTimer(pMac, psessionEntry);
1753
1754 // Reset number of beacons received
1755 limResetHBPktCount(psessionEntry);
1756 return;
1757 }
1758 else
1759 {
1760
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001761 PELOGW(limLog(pMac, LOGW, FL("Heartbeat Failure"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 pMac->lim.gLimHBfailureCntInLinkEstState++;
1763
1764 if (psessionEntry->limIbssActive == true)
1765 {
1766 // We don't receive Beacon frames from any
1767 // other STA in IBSS. Announce IBSS inactive
1768 // to Roaming algorithm
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001769 PELOGW(limLog(pMac, LOGW, FL("Alone in IBSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 psessionEntry->limIbssActive = false;
1771
1772 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_IBSS_INACTIVE,
1773 NULL, 0, psessionEntry->smeSessionId);
1774 }
1775 }
1776}
1777
1778
1779/** -------------------------------------------------------------
1780\fn limIbssDecideProtectionOnDelete
1781\brief Decides all the protection related information.
1782\
1783\param tpAniSirGlobal pMac
1784\param tSirMacAddr peerMacAddr
1785\param tpUpdateBeaconParams pBeaconParams
1786\return None
1787 -------------------------------------------------------------*/
1788void
1789limIbssDecideProtectionOnDelete(tpAniSirGlobal pMac,
1790 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1791{
1792 tANI_U32 phyMode;
1793 tHalBitVal erpEnabled = eHAL_CLEAR;
1794 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1795 tANI_U32 i;
1796
1797 if(NULL == pStaDs)
1798 return;
1799
1800 limGetRfBand(pMac, &rfBand, psessionEntry);
1801 if(SIR_BAND_2_4_GHZ == rfBand)
1802 {
1803 limGetPhyMode(pMac, &phyMode, psessionEntry);
1804 erpEnabled = pStaDs->erpEnabled;
1805 //we are HT or 11G and 11B station is getting deleted.
Jeff Johnsone7245742012-09-05 17:12:55 -07001806 if ( ((phyMode == WNI_CFG_PHY_MODE_11G) || psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 && (erpEnabled == eHAL_CLEAR))
1808 {
1809 PELOGE(limLog(pMac, LOGE, FL("(%d) A legacy STA is disassociated. Addr is "),
1810 psessionEntry->gLim11bParams.numSta);
1811 limPrintMacAddr(pMac, pStaDs->staAddr, LOGE);)
1812 if (psessionEntry->gLim11bParams.numSta > 0)
1813 {
1814 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1815 {
1816 if (pMac->lim.protStaCache[i].active)
1817 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301818 if (vos_mem_compare(pMac->lim.protStaCache[i].addr,
1819 pStaDs->staAddr, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 {
1821 psessionEntry->gLim11bParams.numSta--;
1822 pMac->lim.protStaCache[i].active = false;
1823 break;
1824 }
1825 }
1826 }
1827 }
1828
1829 if (psessionEntry->gLim11bParams.numSta == 0)
1830 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001831 PELOGE(limLog(pMac, LOGE, FL("No more 11B STA exists. Disable protection. "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 limIbssSetProtection(pMac, false, pBeaconParams,psessionEntry);
1833 }
1834 }
1835 }
1836}
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001837
1838/** -----------------------------------------------------------------
1839\fn __limIbssPeerInactivityHandler
1840\brief Internal function. Deletes FW indicated peer which is inactive
1841\
1842\param tpAniSirGlobal pMac
1843\param tpPESession psessionEntry
1844\param tpSirIbssPeerInactivityInd peerInactivityInd
1845\return None
1846 -----------------------------------------------------------------*/
1847static void
1848__limIbssPeerInactivityHandler(tpAniSirGlobal pMac,
1849 tpPESession psessionEntry,
1850 tpSirIbssPeerInactivityInd peerInactivityInd)
1851{
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001852 if(psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
1853 {
1854 limReactivateHeartBeatTimer(pMac, psessionEntry);
1855 return;
1856 }
1857
Ravi Joshi92404a32013-08-13 15:40:30 -07001858 /* delete the peer for which heartbeat is observed */
1859 __limIbssSearchAndDeletePeer (pMac, psessionEntry, peerInactivityInd->peerAddr);
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001860
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001861}
1862
Ravi Joshid2ca7c42013-07-23 08:37:49 -07001863/** -------------------------------------------------------------
1864\fn limProcessIbssPeerInactivity
1865\brief Peer inactivity message handler
1866\
1867\param tpAniSirGlobal pMac
1868\param void* buf
1869\return None
1870 -------------------------------------------------------------*/
1871void
1872limProcessIbssPeerInactivity(tpAniSirGlobal pMac, void *buf)
1873{
1874 /*
1875 * --------------- HEARTBEAT OFFLOAD CASE ------------------
1876 * This message handler is executed when the firmware identifies
1877 * inactivity from one or more peer devices. We will come here
1878 * for every inactive peer device
1879 */
1880 tANI_U8 i;
1881
1882 tSirIbssPeerInactivityInd *peerInactivityInd =
1883 (tSirIbssPeerInactivityInd *) buf;
1884
1885 /*
1886 * If IBSS is not started or heartbeat offload is not enabled
1887 * we should not handle this request
1888 */
1889 if (eLIM_STA_IN_IBSS_ROLE != pMac->lim.gLimSystemRole &&
1890 !IS_IBSS_HEARTBEAT_OFFLOAD_FEATURE_ENABLE)
1891 {
1892 return;
1893 }
1894
1895 /** If LinkMonitor is Disabled */
1896 if (!pMac->sys.gSysEnableLinkMonitorMode)
1897 {
1898 return;
1899 }
1900
1901 for (i = 0; i < pMac->lim.maxBssId; i++)
1902 {
1903 if (VOS_TRUE == pMac->lim.gpSession[i].valid &&
1904 eSIR_IBSS_MODE == pMac->lim.gpSession[i].bssType)
1905 {
1906 __limIbssPeerInactivityHandler(pMac,
1907 &pMac->lim.gpSession[i],
1908 peerInactivityInd);
1909 break;
1910 }
1911 }
1912}
1913