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