blob: 94a2064045f8fdfd45b3ac76c4fb538202bf1f79 [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 limApi.cc contains the functions that are
45 * exported by LIM to other modules.
46 *
47 * Author: Chandra Modumudi
48 * Date: 02/11/02
49 * History:-
50 * Date Modified by Modification Information
51 * --------------------------------------------------------------------
52 *
53 */
54#include "palTypes.h"
55#ifdef ANI_PRODUCT_TYPE_AP
56#include "wniCfgAp.h"
57#else
58#include "wniCfgSta.h"
59#include "wniApi.h"
60#endif
61#include "sirCommon.h"
62#include "sirDebug.h"
63#include "aniParam.h"
64#include "cfgApi.h"
65
66#include "schApi.h"
67#include "utilsApi.h"
68#include "limApi.h"
69#include "limGlobal.h"
70#include "limTypes.h"
71#include "limUtils.h"
72#include "limAssocUtils.h"
73#include "limPropExtsUtils.h"
74#include "limSerDesUtils.h"
75#include "limIbssPeerMgmt.h"
76#include "limAdmitControl.h"
77#include "pmmApi.h"
78#include "logDump.h"
79#include "limSendSmeRspMessages.h"
80#include "wmmApsd.h"
81#include "limTrace.h"
82#include "limSession.h"
83#include "wlan_qct_wda.h"
84
85#if defined WLAN_FEATURE_VOWIFI
86#include "rrmApi.h"
87#endif
88
89#include <limFT.h>
90
91#ifdef VOSS_ENABLED
92#include "vos_types.h"
93#include "vos_packet.h"
94#include "wlan_qct_tl.h"
95#include "sysStartup.h"
96#endif
97
98
99static void __limInitScanVars(tpAniSirGlobal pMac)
100{
101 pMac->lim.gLimUseScanModeForLearnMode = 1;
102
103 pMac->lim.gLimSystemInScanLearnMode = 0;
104
105 // Scan related globals on STA
106 pMac->lim.gLimReturnAfterFirstMatch = 0;
107 pMac->lim.gLim24Band11dScanDone = 0;
108 pMac->lim.gLim50Band11dScanDone = 0;
109 pMac->lim.gLimReturnUniqueResults = 0;
110
111 // Background Scan related globals on STA
112 pMac->lim.gLimNumOfBackgroundScanSuccess = 0;
113 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure = 0;
114 pMac->lim.gLimNumOfForcedBkgndScan = 0;
115 pMac->lim.gLimBackgroundScanDisable = false; //based on BG timer
116 pMac->lim.gLimForceBackgroundScanDisable = false; //debug control flag
117 pMac->lim.gLimBackgroundScanTerminate = TRUE; //controlled by SME
118 pMac->lim.gLimReportBackgroundScanResults = FALSE; //controlled by SME
119
120 pMac->lim.gLimCurrentScanChannelId = 0;
121 pMac->lim.gpLimMlmScanReq = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800122#ifdef WLAN_FEATURE_P2P
123 pMac->lim.gpLimSmeScanReq = NULL;
124#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700125 pMac->lim.gLimMlmScanResultLength = 0;
126 pMac->lim.gLimSmeScanResultLength = 0;
127
128 palZeroMemory(pMac->hHdd, pMac->lim.gLimCachedScanHashTable,
129 sizeof(pMac->lim.gLimCachedScanHashTable));
130
131#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
132 pMac->lim.gLimBackgroundScanChannelId = 0;
133 pMac->lim.gLimBackgroundScanStarted = 0;
134 pMac->lim.gLimRestoreCBNumScanInterval = LIM_RESTORE_CB_NUM_SCAN_INTERVAL_DEFAULT;
135 pMac->lim.gLimRestoreCBCount = 0;
136 palZeroMemory(pMac->hHdd, pMac->lim.gLimLegacyBssidList, sizeof(pMac->lim.gLimLegacyBssidList));
137#endif
138
139 /* Fill in default values */
140 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = 0;
141
142#ifdef ANI_AP_SDK
143 palZeroMemory(pMac->hHdd, &pMac->lim.gLimScanDurationConvert, sizeof(tLimScanDurationConvert)); /* Used to store converted scan duration values in TU and TICKS */
144#endif /* ANI_AP_SDK */
145
146 // abort scan is used to abort an on-going scan
147 pMac->lim.abortScan = 0;
148 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
149
150//WLAN_SUSPEND_LINK Related
151 pMac->lim.gpLimSuspendCallback = NULL;
152 pMac->lim.gpLimResumeCallback = NULL;
153//end WLAN_SUSPEND_LINK Related
154}
155
156
157static void __limInitBssVars(tpAniSirGlobal pMac)
158{
159
160 palZeroMemory(pMac->hHdd, (void*)pMac->lim.gpSession, sizeof(*pMac->lim.gpSession)*pMac->lim.maxBssId);
161
162
163 //pMac->lim.gpLimStartBssReq = NULL;
164
165#if defined(ANI_PRODUCT_TYPE_AP)
166 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNeighborBssList, sizeof(tSirMultipleNeighborBssInfo));
167#endif
168
169
170
171/* These global variables are moved to session table and intialization is done during session creation Oct 9th Review */
172#if 0
173
174 // Place holder for BSS description that we're
175 // currently joined with
176 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentBssId, sizeof(tSirMacAddr));
177 pMac->lim.gLimCurrentChannelId = HAL_INVALID_CHANNEL_ID;
178 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentSSID, sizeof(tSirMacSSid));
179 pMac->lim.gLimCurrentBssCaps = 0;
180 QosCaps is a bit map of various qos capabilities - see defn above
181 pMac->lim.gLimCurrentBssQosCaps = 0;
182 pMac->lim.gLimCurrentBssPropCap = 0;
183 pMac->lim.gLimSentCapsChangeNtf = 0;
184
185 // Place holder for BSS description that
186 // we're currently Reassociating
187 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocBssId, sizeof(tSirMacAddr));
188 pMac->lim.gLimReassocChannelId = 0;
189 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocSSID, sizeof(tSirMacSSid));
190 pMac->lim.gLimReassocBssCaps = 0;
191 pMac->lim.gLimReassocBssQosCaps = 0;
192 pMac->lim.gLimReassocBssPropCap = 0;
193 #endif
194
195 /* This is for testing purposes only, be default should always be off */
196 pMac->lim.gLimForceNoPropIE = 0;
197
198 // pMac->lim.gLimBssIdx = 0;
199
200 pMac->lim.gpLimMlmSetKeysReq = NULL;
201 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
202 // pMac->lim.gLimStaid = 0; //TO SUPPORT BT-AMP
203
204}
205
206
207static void __limInitStatsVars(tpAniSirGlobal pMac)
208{
209 pMac->lim.gLimNumBeaconsRcvd = 0;
210 pMac->lim.gLimNumBeaconsIgnored = 0;
211
212 pMac->lim.gLimNumDeferredMsgs = 0;
213
214 /// Variable to keep track of number of currently associated STAs
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800215 //pMac->lim.gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 pMac->lim.gLimNumOfAniSTAs = 0; // count of ANI peers
217
218 /// This indicates number of RXed Beacons during HB period
219 //pMac->lim.gLimRxedBeaconCntDuringHB = 0;
220
221 // Heart-Beat interval value
222 pMac->lim.gLimHeartBeatCount = 0;
223
224 // Statistics to keep track of no. beacons rcvd in heart beat interval
225 palZeroMemory(pMac->hHdd, pMac->lim.gLimHeartBeatBeaconStats, sizeof(pMac->lim.gLimHeartBeatBeaconStats));
226
227#ifdef WLAN_DEBUG
228 // Debug counters
229 pMac->lim.numTot = 0;
230 pMac->lim.numBbt = 0;
231 pMac->lim.numProtErr = 0;
232 pMac->lim.numLearn = 0;
233 pMac->lim.numLearnIgnore = 0;
234 pMac->lim.numSme = 0;
235 palZeroMemory(pMac->hHdd, pMac->lim.numMAC, sizeof(pMac->lim.numMAC));
236 pMac->lim.gLimNumAssocReqDropInvldState = 0;
237 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
238 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
239 pMac->lim.gLimNumReassocReqDropInvldState = 0;
240 pMac->lim.gLimNumHashMissIgnored = 0;
241 pMac->lim.gLimUnexpBcnCnt = 0;
242 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
243 pMac->lim.gLimNumLinkEsts = 0;
244 pMac->lim.gLimNumRxCleanup = 0;
245 pMac->lim.gLim11bStaAssocRejectCount = 0;
246#endif
247}
248
249
250
251static void __limInitStates(tpAniSirGlobal pMac)
252{
253 // Counts Heartbeat failures
254 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
255 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
256 pMac->lim.gLimHBfailureCntInOtherStates = 0;
257 pMac->lim.gLimRspReqd = 0;
258 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
259
260 /// MLM State visible across all Sirius modules
Jeff Johnsone7245742012-09-05 17:12:55 -0700261 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
263
264 /// Previous MLM State
265 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
266
267#ifdef GEN4_SCAN
268 // LIM to HAL SCAN Management Message Interface states
269 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
270#endif // GEN4_SCAN
271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 /**
Jeff Johnsone7245742012-09-05 17:12:55 -0700273 * Initialize state to eLIM_SME_OFFLINE_STATE
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700275 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
277 /**
278 * By default assume 'unknown' role. This will be updated
279 * when SME_START_BSS_REQ is received.
280 */
281
282 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11gParams, sizeof(tLimProtStaParams));
283 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11aParams, sizeof(tLimProtStaParams));
284 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapHt20Params, sizeof(tLimProtStaParams));
285 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapNonGfParams, sizeof(tLimProtStaParams));
286 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams));
287 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortSlotParams, sizeof(tLimNoShortSlotParams));
288
289 pMac->lim.gLimPhyMode = 0;
290 pMac->lim.scanStartTime = 0; // used to measure scan time
291
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 palZeroMemory(pMac->hHdd, pMac->lim.gLimMyMacAddr, sizeof(pMac->lim.gLimMyMacAddr));
293 pMac->lim.ackPolicy = 0;
294
295#if 0 /* Moving all these to session specific elements */
296 pMac->lim.gLimQosEnabled = 0; //11E
297 pMac->lim.gLimWmeEnabled = 0; //WME
298 pMac->lim.gLimWsmEnabled = 0; //WSM
299 pMac->lim.gLimHcfEnabled = 0;
300 pMac->lim.gLim11dEnabled = 0;
301#endif
302
303 pMac->lim.gLimProbeRespDisableFlag = 0; // control over probe response
304}
305
306static void __limInitVars(tpAniSirGlobal pMac)
307{
308
309#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
310 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAlternateRadioList, sizeof(tSirMultipleAlternateRadioInfo));
311#endif
312
313 // Place holder for Measurement Req/Rsp/Ind related info
314#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
315 pMac->lim.gpLimMeasReq = NULL;
316 palZeroMemory(pMac->hHdd, &pMac->lim.gLimMeasParams, sizeof(tLimMeasParams));
317 pMac->lim.gpLimMeasData = NULL;
318#endif
319
320 // WDS info
321 pMac->lim.gLimNumWdsInfoInd = 0;
322 pMac->lim.gLimNumWdsInfoSet = 0;
323 palZeroMemory(pMac->hHdd, &pMac->lim.gLimWdsInfo, sizeof(tSirWdsInfo));
324 /* initialize some parameters */
325 limInitWdsInfoParams(pMac);
326
327 // Deferred Queue Paramters
328 palZeroMemory(pMac->hHdd, &pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq));
329
330 // addts request if any - only one can be outstanding at any time
331 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq));
332 pMac->lim.gLimAddtsSent = 0;
333 pMac->lim.gLimAddtsRspTimerCount = 0;
334
335 //protection related config cache
336 palZeroMemory(pMac->hHdd, &pMac->lim.cfgProtection, sizeof(tCfgProtection));
337 pMac->lim.gLimProtectionControl = 0;
338 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAlternateRadio, sizeof(tSirAlternateRadioInfo));
339 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
340
Jeff Johnsone7245742012-09-05 17:12:55 -0700341#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 // 11h Spectrum Management Related Flag
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
344 pMac->sys.gSysEnableLearnMode = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 // WMM Related Flag
347 pMac->lim.gUapsdEnable = 0;
348 pMac->lim.gUapsdPerAcBitmask = 0;
349 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
350 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
351
352 // QoS-AC Downgrade: Initially, no AC is admitted
353 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
354 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
355
356 //dialogue token List head/tail for Action frames request sent.
357 pMac->lim.pDialogueTokenHead = NULL;
358 pMac->lim.pDialogueTokenTail = NULL;
359
360 palZeroMemory(pMac->hHdd, &pMac->lim.tspecInfo, sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX);
361
362 // admission control policy information
363 palZeroMemory(pMac->hHdd, &pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo));
364
365 pMac->lim.gLastBeaconDtimCount = 0;
366 pMac->lim.gLastBeaconDtimPeriod = 0;
367
368 //Scan in Power Save Flag
369 pMac->lim.gScanInPowersave = 0;
370}
371
372static void __limInitAssocVars(tpAniSirGlobal pMac)
373{
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800374 tANI_U32 val;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800375#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700376 palZeroMemory(pMac->hHdd, pMac->lim.gpLimAIDpool,
377 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1));
378 pMac->lim.freeAidHead = 0;
379 pMac->lim.freeAidTail = 0;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800380#endif
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800381 if(wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS)
382 {
383 limLog( pMac, LOGP, FL( "cfg get assoc sta limit failed" ));
384 }
385 pMac->lim.gLimAssocStaLimit = val;
Jeff Johnson295189b2012-06-20 16:38:30 -0700386
387 // Place holder for current authentication request
388 // being handled
389 pMac->lim.gpLimMlmAuthReq = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -0700390 //pMac->lim.gpLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391
392 /// MAC level Pre-authentication related globals
393 pMac->lim.gLimPreAuthChannelNumber = 0;
394 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
395 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr));
396 pMac->lim.gLimNumPreAuthContexts = 0;
397 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable));
398
399 // Placed holder to deauth reason
400 pMac->lim.gLimDeauthReasonCode = 0;
401
402 // Place holder for Pre-authentication node list
403 pMac->lim.pLimPreAuthList = NULL;
404
405 // Send Disassociate frame threshold parameters
406 pMac->lim.gLimDisassocFrameThreshold = LIM_SEND_DISASSOC_FRAME_THRESHOLD;
407 pMac->lim.gLimDisassocFrameCredit = 0;
408
409 //One cache for each overlap and associated case.
410 palZeroMemory(pMac->hHdd, pMac->lim.protStaOverlapCache, sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE);
411 palZeroMemory(pMac->hHdd, pMac->lim.protStaCache, sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE);
412
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -0700413#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
414 pMac->lim.pSessionEntry = NULL;
415 pMac->lim.reAssocRetryAttempt = 0;
416#endif
417
Jeff Johnson295189b2012-06-20 16:38:30 -0700418}
419
420
421static void __limInitTitanVars(tpAniSirGlobal pMac)
422{
Jeff Johnsone7245742012-09-05 17:12:55 -0700423#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 palZeroMemory(pMac->hHdd, &pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700426 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
427#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 // Debug workaround for BEACON's
429 // State change triggered by "dump 222"
430 pMac->lim.gLimScanOverride = 1;
431 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700432 pMac->lim.gLimTitanStaCount = 0;
433 pMac->lim.gLimBlockNonTitanSta = 0;
434}
435
436static void __limInitHTVars(tpAniSirGlobal pMac)
437{
438 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 pMac->lim.gHTShortGI40Mhz = 0;
441 pMac->lim.gHTShortGI20Mhz = 0;
442 pMac->lim.gHTMaxAmsduLength = 0;
443 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
444 pMac->lim.gHTPSMPSupport = 0;
445 pMac->lim.gHTLsigTXOPProtection = 0;
446 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
447 pMac->lim.gHTAMpduDensity = 0;
448
449 pMac->lim.gMaxAmsduSizeEnabled = false;
450 pMac->lim.gHTMaxRxAMpduFactor = 0;
451 pMac->lim.gHTServiceIntervalGranularity = 0;
452 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
454 pMac->lim.gHTPCOActive = 0;
455
456 pMac->lim.gHTPCOPhase = 0;
457 pMac->lim.gHTSecondaryBeacon = 0;
458 pMac->lim.gHTDualCTSProtection = 0;
459 pMac->lim.gHTSTBCBasicMCS = 0;
460 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
461}
462
Jeff Johnson295189b2012-06-20 16:38:30 -0700463static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
464{
Jeff Johnsone7245742012-09-05 17:12:55 -0700465 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 tANI_U16 val16;
467 tANI_U8 val8;
468 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
469 tSirMacHTInfoField1 *pHTInfoField1;
470 tpSirPowerSaveCfg pPowerSaveConfig;
471 tSirMacHTParametersInfo *pAmpduParamInfo;
472
473 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700474 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
475 * and they will be used throughout when there is no session
476 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
479 {
480 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG\n"));)
481 return eSIR_FAILURE;
482 }
483
484 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
485 {
486 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG\n"));)
487 return eSIR_FAILURE;
488 }
489 val16 = ( tANI_U16 ) val1;
490 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
491
492 //channel bonding mode could be set to anything from 0 to 4(Titan had these
493 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
494 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
495 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
496 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
497 != eSIR_SUCCESS)
498 {
499 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG\n"));)
500 return eSIR_FAILURE;
501 }
502
503 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
504 {
505 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG\n"));)
506 return eSIR_FAILURE;
507 }
508
509 val8 = ( tANI_U8 ) val1;
510 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
511 pHTInfoField1->recommendedTxWidthSet =
512 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
514 != eSIR_SUCCESS)
515 {
516 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field\n"));)
517 return eSIR_FAILURE;
518 }
519
520 /* WNI_CFG_HEART_BEAT_THRESHOLD */
521
522 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
523 eSIR_SUCCESS )
524 {
525 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG\n"));)
526 return eSIR_FAILURE;
527 }
528 if(!val1)
529 {
530 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
531 pMac->sys.gSysEnableLinkMonitorMode = 0;
532 }
533 else
534 {
535 //No need to activate the timer during init time.
536 pMac->sys.gSysEnableLinkMonitorMode = 1;
537 }
538
539 /* WNI_CFG_SHORT_GI_20MHZ */
540
541 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
542 {
543 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG\n"));)
544 return eSIR_FAILURE;
545 }
546 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
547 {
548 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG\n"));)
549 return eSIR_FAILURE;
550 }
551 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
552 {
553 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG\n"));)
554 return eSIR_FAILURE;
555 }
556
557 val16 = ( tANI_U16 ) val1;
558 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
559 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
560 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
561
562 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
563 eSIR_SUCCESS)
564 {
565 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG\n"));)
566 return eSIR_FAILURE;
567 }
568
569 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
570
571 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
572 {
573 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG\n"));)
574 return eSIR_FAILURE;
575 }
576 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
577 {
578 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG\n"));)
579 return eSIR_FAILURE;
580 }
581 val16 = ( tANI_U16 ) val1;
582 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
583 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
584 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
585 eSIR_SUCCESS)
586 {
587 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG\n"));)
588 return eSIR_FAILURE;
589 }
590
591 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
592 limHandleCFGparamUpdate do we want to update this? */
593 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
594 {
595 limLog(pMac, LOGP, FL("cfg get short preamble failed\n"));
596 return eSIR_FAILURE;
597 }
598
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 /* WNI_CFG_MAX_PS_POLL */
600
601 /* Allocate and fill in power save configuration. */
602 if (palAllocateMemory(pMac->hHdd, (void **)&pPowerSaveConfig,
603 sizeof(tSirPowerSaveCfg)) != eHAL_STATUS_SUCCESS)
604 {
605 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
606 "configuration\n"));)
607 return eSIR_FAILURE;
608 }
609
610 /* This context should be valid if power-save configuration message has been
611 * already dispatched during initialization process. Re-using the present
612 * configuration mask
613 */
614 palCopyMemory(pMac->hHdd, pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg,
615 sizeof(tSirPowerSaveCfg));
616
617 /* Note: it is okay to do this since DAL/HAL is alrady started */
618 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
619 {
620 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed \n"));)
621 return eSIR_FAILURE;
622 }
623
624 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
625
626#if (WNI_POLARIS_FW_PRODUCT == WLAN_STA) || defined(ANI_AP_CLIENT_SDK)
627 PELOG1(limLog(pMac, LOG1,
628 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel\n"));)
629 pMac->lim.gLimBackgroundScanChannelId = 0;
630#endif
631
632 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
633
634 /* This was initially done after resume notification from HAL. Now, DAL is
635 started before PE so this can be done here */
Jeff Johnsone7245742012-09-05 17:12:55 -0700636 handleHTCapabilityandHTInfo(pMac, NULL);
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800637 if(wlan_cfgGetInt(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,(tANI_U32 *) &pMac->lim.disableLDPCWithTxbfAP) != eSIR_SUCCESS)
638 {
639 limLog(pMac, LOGP, FL("cfg get disableLDPCWithTxbfAP failed\n"));
640 return eSIR_FAILURE;
641 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700642
643 return eSIR_SUCCESS;
644}
Jeff Johnson295189b2012-06-20 16:38:30 -0700645
646/*
647 limStart
648 This function is to replace the __limProcessSmeStartReq since there is no
649 eWNI_SME_START_REQ post to PE.
650*/
651tSirRetStatus limStart(tpAniSirGlobal pMac)
652{
653 tSirResultCodes retCode = eSIR_SUCCESS;
654
655 PELOG1(limLog(pMac, LOG1, FL(" enter\n"));)
656
657 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
658 {
659 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
660
Jeff Johnsone7245742012-09-05 17:12:55 -0700661 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700662
663 // By default do not return after first scan match
664 pMac->lim.gLimReturnAfterFirstMatch = 0;
665
666 // Initialize MLM state machine
667 limInitMlm(pMac);
668
669 // By default return unique scan results
670 pMac->lim.gLimReturnUniqueResults = true;
671 pMac->lim.gLimSmeScanResultLength = 0;
672 }
673 else
674 {
675 /**
676 * Should not have received eWNI_SME_START_REQ in states
677 * other than OFFLINE. Return response to host and
678 * log error
679 */
680 limLog(pMac, LOGE, FL("Invalid SME state %X\n"),pMac->lim.gLimSmeState );
681 retCode = eSIR_FAILURE;
682 }
683
684 return retCode;
685}
686
687/**
688 * limInitialize()
689 *
690 *FUNCTION:
691 * This function is called from LIM thread entry function.
692 * LIM related global data structures are initialized in this function.
693 *
694 *LOGIC:
695 * NA
696 *
697 *ASSUMPTIONS:
698 * NA
699 *
700 *NOTE:
701 * NA
702 *
703 * @param pMac - Pointer to global MAC structure
704 * @return None
705 */
706
707tSirRetStatus
708limInitialize(tpAniSirGlobal pMac)
709{
710 tSirRetStatus status = eSIR_SUCCESS;
711
712 __limInitAssocVars(pMac);
713 __limInitVars(pMac);
714 __limInitStates(pMac);
715 __limInitStatsVars(pMac);
716 __limInitBssVars(pMac);
717 __limInitScanVars(pMac);
718 __limInitHTVars(pMac);
719 __limInitTitanVars(pMac);
720
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 status = limStart(pMac);
722 if(eSIR_SUCCESS != status)
723 {
724 return status;
725 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
727 /*
728 * MLM will be intitalized when 'START' request comes from SME.
729 * limInitMlm calls limCreateTimers, which actually relies on
730 * CFG to be downloaded. So it should not be called as part of
731 * peStart, as CFG download is happening after peStart.
732 */
733 //limInitMlm(pMac);
734 // Initializations for maintaining peers in IBSS
735 limIbssInit(pMac);
736
737 pmmInitialize(pMac);
738
739
740#if defined WLAN_FEATURE_VOWIFI
741 rrmInitialize(pMac);
742#endif
743#if defined WLAN_FEATURE_VOWIFI_11R
744 limFTOpen(pMac);
745#endif
746
747#ifdef WLAN_FEATURE_P2P
748 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
749#endif
750
751#if 0
752
753 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
754 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
755 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
756
757 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
758 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
759
760 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
761 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
762 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
763
764 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
765
766 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
767
768 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
769 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
770
771 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
772
773
774 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
775
776 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
777#endif
778 MTRACE(limTraceInit(pMac));
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 //Initialize the configurations needed by PE
781 if( eSIR_FAILURE == __limInitConfig(pMac))
782 {
783 //We need to undo everything in limStart
784 limCleanupMlm(pMac);
785 return eSIR_FAILURE;
786 }
787
788 //initialize the TSPEC admission control table.
789 //Note that this was initially done after resume notification from HAL.
790 //Now, DAL is started before PE so this can be done here
791 limAdmitControlInit(pMac);
792 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793
794 return status;
795
796} /*** end limInitialize() ***/
797
798
799
800/**
801 * limCleanup()
802 *
803 *FUNCTION:
804 * This function is called upon reset or persona change
805 * to cleanup LIM state
806 *
807 *LOGIC:
808 * NA
809 *
810 *ASSUMPTIONS:
811 * NA
812 *
813 *NOTE:
814 * NA
815 *
816 * @param pMac - Pointer to Global MAC structure
817 * @return None
818 */
819
820void
821limCleanup(tpAniSirGlobal pMac)
822{
823#ifdef VOSS_ENABLED
824 v_PVOID_t pvosGCTx;
825 VOS_STATUS retStatus;
826#endif
827
828#ifdef WLAN_FEATURE_P2P
829//Before destroying the list making sure all the nodes have been deleted.
830//Which should be the normal case, but a memory leak has been reported.
831
832 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
833
834 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
835 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
836 {
837 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
838 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
839
840 palFreeMemory(pMac, pLimMgmtRegistration);
841 }
842
843 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
844#endif
845
846 limCleanupMlm(pMac);
847 limCleanupLmm(pMac);
848
849 // free up preAuth table
850 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
851 {
852 palFreeMemory(pMac->hHdd, pMac->lim.gLimPreAuthTimerTable.pTable);
853 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
854 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
855 }
856
857 if(NULL != pMac->lim.pDialogueTokenHead)
858 {
859 limDeleteDialogueTokenList(pMac);
860 }
861
862 if(NULL != pMac->lim.pDialogueTokenTail)
863 {
864 palFreeMemory(pMac->hHdd, (void *) pMac->lim.pDialogueTokenTail);
865 pMac->lim.pDialogueTokenTail = NULL;
866 }
867
868 # if 0
869 if (pMac->lim.gpLimStartBssReq != NULL)
870 {
871 palFreeMemory(pMac->hHdd, pMac->lim.gpLimStartBssReq);
872 pMac->lim.gpLimStartBssReq = NULL;
873 }
874 #endif
875
876 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
877 {
878 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmSetKeysReq);
879 pMac->lim.gpLimMlmSetKeysReq = NULL;
880 }
881
882 #if 0
883 if (pMac->lim.gpLimJoinReq != NULL)
884 {
885 palFreeMemory(pMac->hHdd, pMac->lim.gpLimJoinReq);
886 pMac->lim.gpLimJoinReq = NULL;
887 }
888 #endif
889
890 if (pMac->lim.gpLimMlmAuthReq != NULL)
891 {
892 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
893 pMac->lim.gpLimMlmAuthReq = NULL;
894 }
895
Jeff Johnsone7245742012-09-05 17:12:55 -0700896#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 if (pMac->lim.gpLimMlmJoinReq != NULL)
898 {
899 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
900 pMac->lim.gpLimMlmJoinReq = NULL;
901 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700902#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700903
904 #if 0
905 if (pMac->lim.gpLimReassocReq != NULL)
906 {
907 palFreeMemory(pMac->hHdd, pMac->lim.gpLimReassocReq);
908 pMac->lim.gpLimReassocReq = NULL;
909 }
910 #endif
911
912 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
913 {
914 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmRemoveKeyReq);
915 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
916 }
917
Viral Modid86bde22012-12-10 13:09:21 -0800918#ifdef WLAN_FEATURE_P2P
919 if (pMac->lim.gpLimSmeScanReq != NULL)
920 {
921 palFreeMemory(pMac->hHdd, pMac->lim.gpLimSmeScanReq);
922 pMac->lim.gpLimSmeScanReq = NULL;
923 }
924#endif
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 if (pMac->lim.gpLimMlmScanReq != NULL)
927 {
928 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmScanReq);
929 pMac->lim.gpLimMlmScanReq = NULL;
930 }
931
932#if 0
933 if(NULL != pMac->lim.beacon)
934 {
935 palFreeMemory(pMac->hHdd, (void*) pMac->lim.beacon);
936 pMac->lim.beacon = NULL;
937 }
938#endif
939 #if 0
940 if(NULL != pMac->lim.assocReq)
941 {
942 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocReq);
943 pMac->lim.assocReq= NULL;
944 }
945 #endif
946
947#if 0
948 if(NULL != pMac->lim.assocRsp)
949 {
950 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocRsp);
951 pMac->lim.assocRsp= NULL;
952 }
953#endif
954 // Now, finally reset the deferred message queue pointers
955 limResetDeferredMsgQ(pMac);
956
957#ifdef VOSS_ENABLED
958
959 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
960 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
961
962 if ( retStatus != VOS_STATUS_SUCCESS )
963 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out...\n"));)
964#endif
965
966#if defined WLAN_FEATURE_VOWIFI
967 rrmCleanup(pMac);
968#endif
969#if defined WLAN_FEATURE_VOWIFI_11R
970 limFTCleanup(pMac);
971#endif
972
973} /*** end limCleanup() ***/
974
975
976/** -------------------------------------------------------------
977\fn peOpen
978\brief will be called in Open sequence from macOpen
979\param tpAniSirGlobal pMac
980\param tHalOpenParameters *pHalOpenParam
981\return tSirRetStatus
982 -------------------------------------------------------------*/
983
984tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
985{
986 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
987 pMac->lim.maxStation = pMacOpenParam->maxStation;
988
989 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
990 {
991 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!\n"));)
992 return eSIR_FAILURE;
993 }
994
995 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
996 (void **) &pMac->lim.limTimers.gpLimCnfWaitTimer, sizeof(TX_TIMER)*pMac->lim.maxStation))
997 {
998 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
999 return eSIR_FAILURE;
1000 }
1001
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001002#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1004 (void **) &pMac->lim.gpLimAIDpool,
1005 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1)))
1006 {
1007 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1008 return eSIR_FAILURE;
1009 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001010#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1012 (void **) &pMac->lim.gpSession, sizeof(tPESession)* pMac->lim.maxBssId))
1013 {
1014 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
1015 return eSIR_FAILURE;
1016 }
1017
1018 palZeroMemory(pMac->hHdd, pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId);
1019
1020
1021 /*
1022 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1023 (void **) &pMac->dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*pMac->lim.maxStation))
1024 {
1025 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1026 return eSIR_FAILURE;
1027 }
1028
1029 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1030 (void **) &pMac->dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*pMac->lim.maxStation))
1031 {
1032 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1033 return eSIR_FAILURE;
1034 }
1035 */
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1038 (void **) &pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation))
1039 {
1040 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!\n"));)
1041 return eSIR_FAILURE;
1042 }
1043 palZeroMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044
1045#ifdef ANI_PRODUCT_TYPE_AP
1046
1047 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1048 (void **) &pMac->pmm.gPmmTim.pStaInfo, sizeof(*pMac->pmm.gPmmTim.pStaInfo) * pMac->lim.maxStation))
1049 {
1050 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pStaInfo!\n"));)
1051 return eSIR_FAILURE;
1052 }
1053
1054 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1055 (void **) &pMac->pmm.gpPmmStaState, sizeof(tPmmStaState)*pMac->lim.maxStation))
1056 {
1057 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1058 return eSIR_FAILURE;
1059 }
1060
1061 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1062 (void **) &pMac->pmm.gpPmmPSState, sizeof(tANI_U8)*pMac->lim.maxStation))
1063 {
1064 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1065 return eSIR_FAILURE;
1066 }
1067#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001068 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001069
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001070 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1071 {
1072 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!\n"));)
1073 return eSIR_FAILURE;
1074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 return eSIR_SUCCESS;
1076}
1077
1078/** -------------------------------------------------------------
1079\fn peClose
1080\brief will be called in close sequence from macClose
1081\param tpAniSirGlobal pMac
1082\return tSirRetStatus
1083 -------------------------------------------------------------*/
1084
1085tSirRetStatus peClose(tpAniSirGlobal pMac)
1086{
1087 tANI_U8 i;
1088
1089 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1090 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 for(i =0; i < pMac->lim.maxBssId; i++)
1093 {
1094 if(pMac->lim.gpSession[i].valid == TRUE)
1095 {
1096 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1097 }
1098 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001099 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1100 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001101#if 0
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1103 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001104#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1107 pMac->lim.gpSession = NULL;
1108 /*
1109 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1110 pMac->dph.dphHashTable.pHashTable = NULL;
1111 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1112 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1113 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1115 pMac->pmm.gPmmTim.pTim = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001116#ifdef ANI_PRODUCT_TYPE_AP
1117 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pStaInfo);
1118 pMac->pmm.gPmmTim.pStaInfo = NULL;
1119 palFreeMemory(pMac->hHdd, pMac->pmm.gpPmmStaState);
1120 pMac->pmm.gpPmmStaState = NULL;
1121 palFreeMemory(pMac->hHdd, pMac->pmm.gpPmmPSState);
1122 pMac->pmm.gpPmmPSState = NULL;
1123#endif
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001124 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1125 {
1126 return eSIR_FAILURE;
1127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 return eSIR_SUCCESS;
1129}
1130
1131/** -------------------------------------------------------------
1132\fn peStart
1133\brief will be called in start sequence from macStart
1134\param tpAniSirGlobal pMac
1135\return none
1136 -------------------------------------------------------------*/
1137
1138tSirRetStatus peStart(tpAniSirGlobal pMac)
1139{
1140 tSirRetStatus status = eSIR_SUCCESS;
1141
1142 status = limInitialize(pMac);
1143#if defined(ANI_LOGDUMP)
1144 limDumpInit(pMac);
1145#endif //#if defined(ANI_LOGDUMP)
1146
1147 return status;
1148}
1149
1150/** -------------------------------------------------------------
1151\fn peStop
1152\brief will be called in stop sequence from macStop
1153\param tpAniSirGlobal pMac
1154\return none
1155 -------------------------------------------------------------*/
1156
1157void peStop(tpAniSirGlobal pMac)
1158{
1159 limCleanup(pMac);
1160 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1161 return;
1162}
1163
1164/** -------------------------------------------------------------
1165\fn peFreeMsg
1166\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1167\ to free a given PE message on the TX and MC thread.
1168\ This happens when there are messages pending in the PE
1169\ queue when system is being stopped and reset.
1170\param tpAniSirGlobal pMac
1171\param tSirMsgQ pMsg
1172\return none
1173-----------------------------------------------------------------*/
1174v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1175{
1176 if (pMsg != NULL)
1177 {
1178 if (NULL != pMsg->bodyptr)
1179 {
1180 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1181 {
1182 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1183 }
1184 else
1185 {
1186 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1187 }
1188 }
1189 pMsg->bodyptr = 0;
1190 pMsg->bodyval = 0;
1191 pMsg->type = 0;
1192 }
1193 return;
1194}
1195
1196
1197/**
1198 * The function checks if a particular timer should be allowed
1199 * into LIM while device is sleeping
1200 */
1201tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1202{
1203 tANI_U8 retStatus = TRUE;
1204
1205 if(!limIsSystemInActiveState(pMac))
1206 {
1207 switch(pMsg->type)
1208 {
1209 /* Don't allow following timer messages if in sleep */
1210 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1211 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1212 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1213 retStatus = FALSE;
1214 break;
1215 /* May allow following timer messages in sleep mode */
1216 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1217
1218 /* Safe to allow as of today, this triggers background scan
1219 * which will not be started if the device is in power-save mode
1220 * might need to block in the future if we decide to implement
1221 * spectrum management
1222 */
1223 case SIR_LIM_QUIET_TIMEOUT:
1224
1225 /* Safe to allow as of today, this triggers background scan
1226 * which will not be started if the device is in power-save mode
1227 * might need to block in the future if we decide to implement
1228 * spectrum management
1229 */
1230 case SIR_LIM_QUIET_BSS_TIMEOUT:
1231
1232 /* Safe to allow this timermessage, triggers background scan
1233 * which is blocked in sleep mode
1234 */
1235 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1236
1237 /* Safe to allow this timer, since, while in IMPS this timer will not
1238 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1239 * when heart-beat control is handled back to PE, device would have
1240 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1241 */
1242 case SIR_LIM_HEART_BEAT_TIMEOUT:
1243 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1244
1245 /* Safe to allow, PE is not handling this message as of now. May need
1246 * to block it, basically, free the buffer and restart the timer
1247 */
1248 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1249 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001250 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1252 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1253 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1254 retStatus = TRUE;
1255 break;
1256
1257 /* by default allow rest of messages */
1258 default:
1259 retStatus = TRUE;
1260 break;
1261
1262
1263 }
1264 }
1265
1266 return retStatus;
1267
1268}
1269
1270
1271
1272/**
1273 * limPostMsgApi()
1274 *
1275 *FUNCTION:
1276 * This function is called from other thread while posting a
1277 * message to LIM message Queue gSirLimMsgQ.
1278 *
1279 *LOGIC:
1280 * NA
1281 *
1282 *ASSUMPTIONS:
1283 * NA
1284 *
1285 *NOTE:
1286 * NA
1287 *
1288 * @param pMac - Pointer to Global MAC structure
1289 * @param pMsg - Pointer to the message structure
1290 * @return None
1291 */
1292
1293tANI_U32
1294limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1295{
1296#ifdef VOSS_ENABLED
1297 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1298
1299
1300#elif defined(ANI_OS_TYPE_LINUX) || defined(ANI_OS_TYPE_OSX)
1301 return tx_queue_send(&pMac->sys.gSirLimMsgQ, pMsg, TX_WAIT_FOREVER);
1302
1303#else
1304 /* Check if this is a timeout message from a timer
1305 * and if the timeout message is allowed if the device is in power-save state
1306 */
1307 if(!limIsTimerAllowedInPowerSaveState(pMac, pMsg))
1308 {
1309 limLog(pMac, LOGW,
1310 FL("Timeout message %d is not allowed while device is in Power-Save mode\n"),
1311 pMsg->type);
1312
1313 return TX_SUCCESS;
1314 }
1315 if(pMac->gDriverType != eDRIVER_TYPE_MFG)
1316 {
1317 limMessageProcessor(pMac, pMsg);
1318 }
1319
1320 return TX_SUCCESS;
1321
1322#endif
1323} /*** end limPostMsgApi() ***/
1324
1325
1326/*--------------------------------------------------------------------------
1327
1328 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1329
1330 This function can be called by legacy code to post message to voss queues OR
1331 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1332 for dispatching it later.
1333
1334 \param pMac - Pointer to Global MAC structure
1335 \param pMsg - Pointer to the message structure
1336
1337 \return tANI_U32 - TX_SUCCESS for success.
1338
1339 --------------------------------------------------------------------------*/
1340
1341tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1342{
1343 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1344}
1345
1346/*--------------------------------------------------------------------------
1347
1348 \brief peProcessMessages() - Message Processor for PE
1349
1350 Voss calls this function to dispatch the message to PE
1351
1352 \param pMac - Pointer to Global MAC structure
1353 \param pMsg - Pointer to the message structure
1354
1355 \return tANI_U32 - TX_SUCCESS for success.
1356
1357 --------------------------------------------------------------------------*/
1358
1359tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1360{
1361 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1362 {
1363 return eSIR_SUCCESS;
1364 }
1365 /**
1366 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1367 * for all the other cases post it to LIM
1368 */
1369 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1370 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1371 else
1372 limMessageProcessor(pMac, pMsg);
1373 return eSIR_SUCCESS;
1374}
1375
1376
1377#ifdef VOSS_ENABLED
1378
1379// ---------------------------------------------------------------------------
1380/**
1381 * peHandleMgmtFrame
1382 *
1383 * FUNCTION:
1384 * Process the Management frames from TL
1385 *
1386 * LOGIC:
1387 *
1388 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1389 *
1390 * NOTE:
1391 *
1392 * @param pvosGCtx Global Vos Context
1393 * @param vossBuff Packet
1394 * @return None
1395 */
1396
1397VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1398{
1399 tpAniSirGlobal pMac;
1400 tpSirMacMgmtHdr mHdr;
1401 tSirMsgQ msg;
1402 vos_pkt_t *pVosPkt;
1403 VOS_STATUS vosStatus;
1404 v_U8_t *pRxPacketInfo;
1405
1406 pVosPkt = (vos_pkt_t *)vosBuff;
1407 if (NULL == pVosPkt)
1408 {
1409 return VOS_STATUS_E_FAILURE;
1410 }
1411
1412 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1413 if (NULL == pMac)
1414 {
1415 // cannot log a failure without a valid pMac
1416 vos_pkt_return_packet(pVosPkt);
1417 return VOS_STATUS_E_FAILURE;
1418 }
1419
1420 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1421
1422 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1423 {
1424 vos_pkt_return_packet(pVosPkt);
1425 return VOS_STATUS_E_FAILURE;
1426 }
1427
1428
1429 //
1430 // The MPDU header is now present at a certain "offset" in
1431 // the BD and is specified in the BD itself
1432 //
1433 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1434 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1435 {
1436 PELOG1(limLog( pMac, LOG1,
1437 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001438 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001439
Jeff Johnsone7245742012-09-05 17:12:55 -07001440 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1442 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1443 }
1444
1445
1446 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1447 msg.type = SIR_BB_XPORT_MGMT_MSG;
1448 msg.bodyptr = vosBuff;
1449 msg.bodyval = 0;
1450
1451 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1452 &msg,
1453 mHdr->fc.type,
1454 mHdr->fc.subType ))
1455 {
1456 vos_pkt_return_packet(pVosPkt);
1457 limLog( pMac, LOGW,
1458 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG\n" ));
1459 return VOS_STATUS_E_FAILURE;
1460 }
1461
1462 return VOS_STATUS_SUCCESS;
1463}
1464
1465// ---------------------------------------------------------------------------
1466/**
1467 * peRegisterTLHandle
1468 *
1469 * FUNCTION:
1470 * Registers the Handler which, process the Management frames from TL
1471 *
1472 * LOGIC:
1473 *
1474 * ASSUMPTIONS:
1475 *
1476 * NOTE:
1477 *
1478 * @return None
1479 */
1480
1481void peRegisterTLHandle(tpAniSirGlobal pMac)
1482{
1483 v_PVOID_t pvosGCTx;
1484 VOS_STATUS retStatus;
1485
1486 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1487
1488 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1489
1490 if (retStatus != VOS_STATUS_SUCCESS)
1491 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out...\n"));
1492
1493}
1494#endif
1495
1496
1497/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 * limIsSystemInScanState()
1499 *
1500 *FUNCTION:
1501 * This function is called by various MAC software modules to
1502 * determine if System is in Scan/Learn state
1503 *
1504 *LOGIC:
1505 * NA
1506 *
1507 *ASSUMPTIONS:
1508 * NA
1509 *
1510 *NOTE:
1511 *
1512 * @param pMac - Pointer to Global MAC structure
1513 * @return true - System is in Scan/Learn state
1514 * false - System is NOT in Scan/Learn state
1515 */
1516
1517tANI_U8
1518limIsSystemInScanState(tpAniSirGlobal pMac)
1519{
1520 switch (pMac->lim.gLimSmeState)
1521 {
1522 case eLIM_SME_CHANNEL_SCAN_STATE:
1523 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1524 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1525 case eLIM_SME_WT_SCAN_STATE:
1526 // System is in Learn mode
1527 return true;
1528
1529 default:
1530 // System is NOT in Learn mode
1531 return false;
1532 }
1533} /*** end limIsSystemInScanState() ***/
1534
1535
1536
1537/**
1538 * limIsSystemInActiveState()
1539 *
1540 *FUNCTION:
1541 * This function is called by various MAC software modules to
1542 * determine if System is in Active/Wakeup state
1543 *
1544 *LOGIC:
1545 * NA
1546 *
1547 *ASSUMPTIONS:
1548 * NA
1549 *
1550 *NOTE:
1551 *
1552 * @param pMac - Pointer to Global MAC structure
1553 * @return true - System is in Active state
1554 * false - System is not in Active state
1555 */
1556
1557tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1558{
1559 switch (pMac->pmm.gPmmState)
1560 {
1561 case ePMM_STATE_BMPS_WAKEUP:
1562 case ePMM_STATE_IMPS_WAKEUP:
1563 case ePMM_STATE_READY:
1564 // System is in Active mode
1565 return true;
1566 default:
1567 return false;
1568 // System is NOT in Active mode
1569 }
1570}
1571
1572
1573#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
1574/**
1575 * limCheckAndQuietBSS()
1576 *
1577 *FUNCTION:
1578 * This function is called by limSetLearnMode() to check
1579 * if BSS needs to be quieted and call limQuietBSS() to
1580 * send data frame to self for that purpose.
1581 *
1582 *LOGIC:
1583 * NA
1584 *
1585 *ASSUMPTIONS:
1586 * NA
1587 *
1588 *NOTE:
1589 *
1590 * @param pMac - Pointer to Global MAC structure
1591 * @return None
1592 */
1593
1594void
1595limCheckAndQuietBSS(tpAniSirGlobal pMac)
1596{
1597 tANI_U32 dur;
1598
1599 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1600 {
1601 // LIM is in AP role. Quiet the BSS before
1602 // switching to channel to be learned
1603 if (pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration >
1604 LIM_MAX_QUIET_DURATION)
1605 {
1606 // May need to quiet BSS multiple times.
1607 // Quiet for a limit of 32 msecs on Learn
1608 // duration for now.
1609 dur = LIM_MAX_QUIET_DURATION;
1610 }
1611 else
1612 {
1613 dur =
1614 pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration;
1615 }
1616 PELOG3(limLog(pMac, LOG3,
1617 FL("*** Going to quiet BSS for duration=%d msec\n"),
1618 dur);)
1619
1620 limQuietBss(pMac, dur);
1621 }
1622} /*** end limCheckAndQuietBSS() ***/
1623#endif
1624
1625#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1626/**
1627 * limSetLearnMode()
1628 *
1629 *FUNCTION:
1630 * This function is called to setup system into Learn mode
1631 * to collect DFS measurements.
1632 *
1633 *LOGIC:
1634 * NA
1635 *
1636 *ASSUMPTIONS:
1637 * NA
1638 *
1639 *NOTE:
1640 *
1641 * @param pMac - Pointer to Global MAC structure
1642 * @return None
1643 */
1644
1645void
1646limSetLearnMode(tpAniSirGlobal pMac)
1647{
1648 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_LEARN_WAIT_STATE, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN);
1649 return;
1650} /*** end limSetLearnMode() ***/
1651
1652/**
1653 * limContinueChannelLearn()
1654 *
1655 *FUNCTION:
1656 * This function is called to do measurement (learn) on current channel.
1657 *
1658 *LOGIC:
1659 *
1660 *ASSUMPTIONS:
1661 * NA
1662 *
1663 *NOTE:
1664 * NA
1665 *
1666 * @param pMac - Pointer to Global MAC structure
1667 *
1668 * @return None
1669 */
1670
1671void
1672limContinueChannelLearn(tpAniSirGlobal pMac)
1673{
1674 tANI_U8 chanNum;
1675 tSirMacSSid ssId;
1676 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1677
1678 // Time to collect measurements
1679 chanNum = limGetCurrentLearnChannel(pMac);
1680
1681 // Switch channel
1682 pMac->lim.gLimSystemInScanLearnMode = 1;
1683
1684 if (pMac->lim.gpLimMeasReq->measControl.scanType == eSIR_ACTIVE_SCAN)
1685 {
1686 /// Prepare and send Probe Request frame
1687 ssId.length = 0;
1688 /* for learning channel, we don't include any additional IE */
1689 limSendProbeReqMgmtFrame(pMac, &ssId, bssId, chanNum,pMac->lim.gSelfMacAddr, 0 , NULL);
1690 }
1691
1692 // Activate Learn duration timer during which
1693 // DFS measurements are made.
1694 pMac->lim.gLimMeasParams.shortDurationCount++;
1695 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_DURATION_TIMER);
1696
Jeff Johnsone7245742012-09-05 17:12:55 -07001697 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_DURATION_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 if (tx_timer_activate(&pMac->lim.gLimMeasParams.learnDurationTimer)
1699 != TX_SUCCESS)
1700 {
1701 /// Could not activate learn duration timer.
1702 // Log error
1703 limLog(pMac, LOGP, FL("could not activate learn duration timer\n"));
1704
1705 return;
1706 }
1707} /*** end limContinueChannelLearn() ***/
1708
1709
1710/**
1711 * limReEnableLearnMode()
1712 *
1713 *FUNCTION:
1714 * This function is called by various MAC software modules to
1715 * re-enable Learn mode measurements.
1716 *
1717 *LOGIC:
1718 * NA
1719 *
1720 *ASSUMPTIONS:
1721 * NA
1722 *
1723 *NOTE:
1724 *
1725 * @param pMac - Pointer to Global MAC structure
1726 * @return None
1727 */
1728
1729void
1730limReEnableLearnMode(tpAniSirGlobal pMac)
1731{
1732 PELOG4(limLog(pMac, LOG4, FL("quietEnabled = %d\n"),
1733 pMac->lim.gLimSpecMgmt.fQuietEnabled);)
1734
1735 /** Stop measurement temperorily when radar is detected or channel
1736 * switch is running as part of periodic DFS */
1737 if (!pMac->lim.gpLimMeasReq || LIM_IS_RADAR_DETECTED(pMac) ||
1738 (pMac->lim.gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING))
1739 {
1740 return;
1741 }
1742
1743 if (pMac->lim.gLimSpecMgmt.fQuietEnabled)
1744 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001745 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001746#ifdef GEN6_TODO
1747 /* revisit this piece of code to assign the appropriate sessionId below
1748 * priority - HIGH
1749 */
1750 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
1751#endif
1752 if (tx_timer_activate(
1753 &pMac->lim.limTimers.gLimQuietBssTimer)
1754 != TX_SUCCESS)
1755 {
1756 limLog(pMac, LOGP, FL("could not start Quiet Bss timer\n"));
1757 return;
1758 }
1759 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
1760 }
1761 else
1762 {
1763 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_INTERVAL_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07001764 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_INTERVAL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001765#ifdef GEN6_TODO
1766 /* revisit this piece of code to assign the appropriate sessionId below
1767 */
1768 pMac->lim.gLimMeasParams.learnIntervalTimer.sessionId = sessionId;
1769#endif
1770 if (tx_timer_activate(
1771 &pMac->lim.gLimMeasParams.learnIntervalTimer)
1772 != TX_SUCCESS)
1773 {
1774 /// Could not activate Learn Interval timer.
1775 // Log error
1776 limLog(pMac, LOGP, FL("could not start Learn Interval timer\n"));
1777 return;
1778 }
1779 }
1780
1781 PELOG3(limLog(pMac, LOG3, FL("Re-enabled Learn mode Measurements\n"));)
1782 pMac->lim.gLimMeasParams.disableMeasurements = 0;
1783
1784 return;
1785} /*** end limReEnableLearnMode() ***/
1786
1787#endif //#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1788
1789
1790/**
1791*\brief limReceivedHBHandler()
1792*
1793* This function is called by schBeaconProcess() upon
1794* receiving a Beacon on STA. This also gets called upon
1795* receiving Probe Response after heat beat failure is
1796* detected.
1797*
1798* param pMac - global mac structure
1799* param channel - channel number indicated in Beacon, Probe Response
1800* return - none
1801*/
1802
1803
1804void
1805limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1806{
1807 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1808 psessionEntry->LimRxedBeaconCntDuringHB++;
1809
1810 pMac->pmm.inMissedBeaconScenario = FALSE;
1811} /*** end limReceivedHBHandler() ***/
1812
1813
1814
1815#if 0
1816void limResetHBPktCount(tpPESession psessionEntry)
1817{
1818 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1819}
1820#endif
1821
1822
1823/*
1824 * limProcessWdsInfo()
1825 *
1826 *FUNCTION:
1827 * This function is called from schBeaconProcess in BP
1828 *
1829 *PARAMS:
1830 * @param pMac - Pointer to Global MAC structure
1831 * @param propIEInfo - proprietary IE info
1832 *
1833 *LOGIC:
1834 *
1835 *ASSUMPTIONS:
1836 * NA
1837 *
1838 *NOTE:
1839 *
1840 *
1841 *RETURNS:
1842 *
1843 */
1844
1845void limProcessWdsInfo(tpAniSirGlobal pMac,
1846 tSirPropIEStruct propIEInfo)
1847{
1848#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1849 tpSirSmeWdsInfoInd pSirSmeWdsInfoInd;
1850 tANI_U8 *pTemp;
1851 tSirMsgQ mmhMsg;
1852
1853 if (propIEInfo.wdsLength &&
1854 propIEInfo.wdsLength <= ANI_WDS_INFO_MAX_LENGTH)
1855 {
1856 if (pMac->lim.gLimWdsInfo.wdsLength)
1857 {
1858 if ((propIEInfo.wdsLength ==
1859 pMac->lim.gLimWdsInfo.wdsLength) &&
1860 (palEqualMemory( pMac->hHdd,propIEInfo.wdsData,
1861 pMac->lim.gLimWdsInfo.wdsBytes,
1862 pMac->lim.gLimWdsInfo.wdsLength) ))
1863
1864 return; // no difference in WDS info
1865 else
1866 {
1867 PELOG2(limLog(pMac, LOG2,
1868 FL("Cached WDS Info: length %d bytes is: "),
1869 pMac->lim.gLimWdsInfo.wdsLength);
1870 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1871 pMac->lim.gLimWdsInfo.wdsBytes,
1872 pMac->lim.gLimWdsInfo.wdsLength);)
1873
1874 PELOG2(limLog(pMac, LOG2, FL("New WDS Info: length %d bytes is: "),
1875 propIEInfo.wdsLength);
1876 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1877 propIEInfo.wdsData,
1878 propIEInfo.wdsLength);)
1879
1880 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1881 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1882 propIEInfo.wdsData,
1883 propIEInfo.wdsLength);
1884
1885 // send IND to WSM
1886 if (eHAL_STATUS_SUCCESS !=
1887 palAllocateMemory(pMac->hHdd,
1888 (void **) &pSirSmeWdsInfoInd,
1889 sizeof(tSirSmeWdsInfoInd)))
1890 {
1891 // Log error
1892 limLog(pMac, LOGP,
1893 FL("memory allocate failed for WDS_INFO_IND\n"));
1894
1895 return;
1896 }
1897
1898 pSirSmeWdsInfoInd->messageType = eWNI_SME_WDS_INFO_IND;
1899 pSirSmeWdsInfoInd->length = sizeof(tSirSmeWdsInfoInd);
1900
1901 pSirSmeWdsInfoInd->wdsInfo.wdsLength =
1902 pMac->lim.gLimWdsInfo.wdsLength;
1903
1904 palCopyMemory( pMac->hHdd, pSirSmeWdsInfoInd->wdsInfo.wdsBytes,
1905 pMac->lim.gLimWdsInfo.wdsBytes,
1906 pMac->lim.gLimWdsInfo.wdsLength);
1907
1908 pTemp = (tANI_U8 *) pSirSmeWdsInfoInd;
1909
1910 PELOG2(limLog(pMac, LOG2,
1911 FL("eWNI_SME_WDS_INFO_IND length %d bytes is: "),
1912 pSirSmeWdsInfoInd->length);
1913 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pTemp,
1914 pSirSmeWdsInfoInd->length);)
1915
1916 mmhMsg.type = eWNI_SME_WDS_INFO_IND;
1917 mmhMsg.bodyptr = pSirSmeWdsInfoInd;
1918 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001919 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
1921 pMac->lim.gLimNumWdsInfoInd++;
1922 }
1923 }
1924 else
1925 {
1926 // first WDS info
1927 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1928 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1929 propIEInfo.wdsData,
1930 propIEInfo.wdsLength);
1931
1932 PELOG1(limLog(pMac, LOG1, FL("First WDS Info: length %d bytes is:\n"),
1933 pMac->lim.gLimWdsInfo.wdsLength);
1934 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
1935 pMac->lim.gLimWdsInfo.wdsBytes,
1936 pMac->lim.gLimWdsInfo.wdsLength);)
1937
1938 }
1939 }
1940 else
1941 {
1942 PELOG2(limLog(pMac, LOG2,
1943 FL("Illegal WDS length = %d\n"),
1944 propIEInfo.wdsLength);)
1945 }
1946#endif
1947}
1948
1949
1950
1951/**
1952 * limInitWdsInfoParams()
1953 *
1954 *FUNCTION:
1955 * This function is called while processing
1956 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1957 * ind/set related parameters.
1958 *
1959 *LOGIC:
1960 *
1961 *ASSUMPTIONS:
1962 *
1963 *NOTE:
1964 *
1965 * @param pMac Pointer to Global MAC structure
1966 * @return None
1967 */
1968
1969void
1970limInitWdsInfoParams(tpAniSirGlobal pMac)
1971{
1972 pMac->lim.gLimWdsInfo.wdsLength = 0;
1973 pMac->lim.gLimNumWdsInfoInd = 0;
1974 pMac->lim.gLimNumWdsInfoSet = 0;
1975} /*** limInitWdsInfoParams() ***/
1976
1977
1978/** -------------------------------------------------------------
1979\fn limUpdateOverlapStaParam
1980\brief Updates overlap cache and param data structure
1981\param tpAniSirGlobal pMac
1982\param tSirMacAddr bssId
1983\param tpLimProtStaParams pStaParams
1984\return None
1985 -------------------------------------------------------------*/
1986void
1987limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1988{
1989 int i;
1990 if (!pStaParams->numSta)
1991 {
1992 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1993 bssId,
1994 sizeof(tSirMacAddr));
1995 pMac->lim.protStaOverlapCache[0].active = true;
1996
1997 pStaParams->numSta = 1;
1998
1999 return;
2000 }
2001
2002 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
2003 {
2004 if (pMac->lim.protStaOverlapCache[i].active)
2005 {
2006 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
2007 bssId,
2008 sizeof(tSirMacAddr))) {
2009 return; }
2010 }
2011 else
2012 break;
2013 }
2014
2015 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
2016 {
2017 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full\n"));)
2018 }
2019 else
2020 {
2021 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
2022 bssId,
2023 sizeof(tSirMacAddr));
2024 pMac->lim.protStaOverlapCache[i].active = true;
2025
2026 pStaParams->numSta++;
2027 }
2028}
2029
2030
2031/**
2032 * limHandleIBSScoalescing()
2033 *
2034 *FUNCTION:
2035 * This function is called upon receiving Beacon/Probe Response
2036 * while operating in IBSS mode.
2037 *
2038 *LOGIC:
2039 *
2040 *ASSUMPTIONS:
2041 *
2042 *NOTE:
2043 *
2044 * @param pMac - Pointer to Global MAC structure
2045 * @param pBeacon - Parsed Beacon Frame structure
2046 * @param pRxPacketInfo - Pointer to RX packet info structure
2047 *
2048 * @return Status whether to process or ignore received Beacon Frame
2049 */
2050
2051tSirRetStatus
2052limHandleIBSScoalescing(
2053 tpAniSirGlobal pMac,
2054 tpSchBeaconStruct pBeacon,
2055 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
2056{
2057 tpSirMacMgmtHdr pHdr;
2058 tSirRetStatus retCode;
2059
2060 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2061 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
2062 /* Received SSID does not match => Ignore received Beacon frame. */
2063 retCode = eSIR_LIM_IGNORE_BEACON;
2064 else
2065 {
2066 tANI_U32 ieLen;
2067 tANI_U16 tsfLater;
2068 tANI_U8 *pIEs;
2069 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2070 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
2071 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2072 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
2073 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
2074 }
2075 return retCode;
2076} /*** end limHandleIBSScoalescing() ***/
2077
2078
2079
2080/**
2081 * limDetectChangeInApCapabilities()
2082 *
2083 *FUNCTION:
2084 * This function is called while SCH is processing
2085 * received Beacon from AP on STA to detect any
2086 * change in AP's capabilities. If there any change
2087 * is detected, Roaming is informed of such change
2088 * so that it can trigger reassociation.
2089 *
2090 *LOGIC:
2091 *
2092 *ASSUMPTIONS:
2093 *
2094 *NOTE:
2095 * Notification is enabled for STA product only since
2096 * it is not a requirement on BP side.
2097 *
2098 * @param pMac Pointer to Global MAC structure
2099 * @param pBeacon Pointer to parsed Beacon structure
2100 * @return None
2101 */
2102
2103void
2104limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
2105 tpSirProbeRespBeacon pBeacon,
2106 tpPESession psessionEntry)
2107{
2108#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2109 tANI_U8 len;
2110 tSirSmeApNewCaps apNewCaps;
2111 tANI_U8 newChannel;
2112 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
2113 newChannel = (tANI_U8) pBeacon->channelNumber;
2114
2115 if ((psessionEntry->limSentCapsChangeNtf == false) &&
2116 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
2117 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
2118 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
2119 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
2120 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
2121 (newChannel != psessionEntry->currentOperChannel)
2122#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
2123 || (LIM_BSS_CAPS_GET(HCF, psessionEntry->limCurrentBssQosCaps) !=
2124 pBeacon->propIEinfo.hcfEnabled)
2125#endif
2126 )))
2127 {
2128
2129 /**
2130 * BSS capabilities have changed.
2131 * Inform Roaming.
2132 */
2133 len = sizeof(tSirMacCapabilityInfo) +
2134 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
2135 3 * sizeof(tANI_U8) + // reserved fields
2136 pBeacon->ssId.length + 1;
2137
2138 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
2139 psessionEntry->bssId,
2140 sizeof(tSirMacAddr));
2141 if (newChannel != psessionEntry->currentOperChannel)
2142 {
2143 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
2144 "Ignoring beacon!\n"),
2145 psessionEntry->currentOperChannel, newChannel);)
2146 return;
2147 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05302148
2149 /**
2150 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
2151 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
2152 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
2153 * the privacy bit is set in Probe and association responses.
2154 * Due to this anomaly, we detect a change in
2155 * AP capabilities when we receive a beacon after association and
2156 * disconnect from the AP. The following check makes sure that we can
2157 * connect to such APs
2158 */
2159 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
2160 (pBeacon->rsnPresent || pBeacon->wpaPresent))
2161 {
2162 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
2163 " but WPA or RSN IE present, Ignore Beacon!\n"));)
2164 return;
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 else
2167 apNewCaps.channelId = psessionEntry->currentOperChannel;
2168 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
2169 (tANI_U8 *) &pBeacon->ssId,
2170 pBeacon->ssId.length + 1);
2171
2172 psessionEntry->limSentCapsChangeNtf = true;
2173 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2174 (tANI_U32 *) &apNewCaps,
2175 len, psessionEntry->smeSessionId);
2176 }
2177#endif
2178} /*** limDetectChangeInApCapabilities() ***/
2179
2180
2181
2182
2183// ---------------------------------------------------------------------
2184/**
2185 * limUpdateShortSlot
2186 *
2187 * FUNCTION:
2188 * Enable/Disable short slot
2189 *
2190 * LOGIC:
2191 *
2192 * ASSUMPTIONS:
2193 *
2194 * NOTE:
2195 *
2196 * @param enable Flag to enable/disable short slot
2197 * @return None
2198 */
2199
2200tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2201{
2202
2203 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002204 tANI_U32 nShortSlot;
2205 tANI_U32 val = 0;
2206 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207
Jeff Johnsone7245742012-09-05 17:12:55 -07002208 // Check Admin mode first. If it is disabled just return
2209 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2210 != eSIR_SUCCESS)
2211 {
2212 limLog(pMac, LOGP,
2213 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed\n"));
2214 return eSIR_FAILURE;
2215 }
2216 if (val == false)
2217 return eSIR_SUCCESS;
2218
2219 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2220 limGetPhyMode(pMac, &phyMode, psessionEntry);
2221 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2222 return eSIR_SUCCESS;
2223
2224 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2227 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2228 // if no erp present, use short slot based on current ap caps
2229
2230 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2231
2232 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2233 // The difference between the earlier implementation and the new one is only Case4.
2234 /*
2235 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2236 Case1 1 1 1 1 //AP should not advertise this combination.
2237 Case2 1 1 0 0
2238 Case3 1 0 1 1
2239 Case4 1 0 0 0
2240 Case5 0 1 1 1
2241 Case6 0 1 0 0
2242 Case7 0 0 1 1
2243 Case8 0 0 0 0
2244 */
2245 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2246
Jeff Johnsone7245742012-09-05 17:12:55 -07002247 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 {
2249 // Short slot time capability of AP has changed. Adopt to it.
2250 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d\n"), nShortSlot);)
2251 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002252 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2254 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 }
2256 return eSIR_SUCCESS;
2257}
2258
2259
2260#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
2261
2262/**
2263 * limUpdateQuietIEInBeacons()
2264 *
2265 *FUNCTION:
2266 * This function is called by specialBeaconProcessing(),
2267 * when it is time to generate the next beacon.
2268 * If gLimQuietState is not in the INIT state, then it
2269 * means that the next beacon may need to include some
2270 * information about the Quiet BSS IE.
2271 * This function makes that decision based on the current
2272 * state of gLimQuietState
2273 *
2274 *LOGIC:
2275 * This routine invokes schSetFixedBeaconFields() only
2276 * if necessary, as it is expensive to update the fixed
2277 * beacon fields during each beacon interval.
2278 *
2279 *ASSUMPTIONS:
2280 * This Quiet BSS IE will be sent out as part of
2281 * Proprietary IE's. If 802.11H is enabled, this IE
2282 * will be sent out as defined in the 11H spec
2283 *
2284 *NOTE:
2285 *
2286 * @param pMac Pointer to Global MAC structure
2287 * @return true, if the beacon fields need updating
2288 * false, if not
2289 */
2290tANI_BOOLEAN limUpdateQuietIEInBeacons( tpAniSirGlobal pMac )
2291{
2292 tANI_BOOLEAN fUpdateBeaconFields = eANI_BOOLEAN_TRUE;
2293
2294 limLog( pMac, LOG2, FL("Quiet BSS State = %d\n"),
2295 pMac->lim.gLimSpecMgmt.quietState );
2296 switch( pMac->lim.gLimSpecMgmt.quietState )
2297 {
2298 case eLIM_QUIET_BEGIN:
2299 // We need to start broadcasting the Quiet BSS IE
2300 // Transition to eLIM_QUIET_RUNNING
2301 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
2302 break;
2303
2304 case eLIM_QUIET_RUNNING:
2305 // Start down-counting...
2306 pMac->lim.gLimSpecMgmt.quietCount--;
2307 if( pMac->lim.gLimSpecMgmt.quietCount == 0 )
2308 {
2309 //
2310 // We no longer need to broadcast the Quiet BSS IE
2311 //
2312 // NOTE - We still need to call schSetFixedBeaconFields()
2313 // one last time, just to remove the Quiet BSS IE from
2314 // the list of fixed beacon fields
2315 //
2316 // Transition to eLIM_QUIET_END
2317 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2318 limProcessLearnIntervalTimeout(pMac);
2319 }
2320 break;
2321
2322 case eLIM_QUIET_CHANGED:
2323 //
2324 // State possibly changed via setupQuietBss().
2325 // This means, gLimQuietCount has been changed!!
2326 //
2327 // NOTE - We still need to call schSetFixedBeaconFields()
2328 // one last time, just to remove the Quiet BSS IE from
2329 // the list of fixed beacon fields
2330 //
2331
2332 // Transition to eLIM_QUIET_END
2333 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2334 break;
2335
2336 case eLIM_QUIET_INIT:
2337 case eLIM_QUIET_END:
2338 // Transition to eLIM_QUIET_INIT
2339 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
2340 // Fall thru'...
2341 default:
2342 fUpdateBeaconFields = eANI_BOOLEAN_FALSE;
2343 break;
2344 }
2345
2346 return fUpdateBeaconFields;
2347}
2348
2349#endif
2350
2351#if ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK))
2352void limConvertScanDuration(tpAniSirGlobal pMac)
2353{
2354 tpSirSmeMeasurementReq pMeasReq = pMac->lim.gpLimMeasReq;
2355 tpLimScanDurationConvert scanDurConv = &pMac->lim.gLimScanDurationConvert;
2356
2357 /* This is not a good idea to convert {long}shortChannelScanDuration from mS to TICKS *
2358 * The reason is that {long}shortChannelScanDuration is used all over and a lot of code *
2359 * that assumes the old mS definition was never changed to accommodate this new change to TICKS. *
2360 * If optimization is needed, create another set of shadow variables to store the converted *
2361 * values in Ticks, and TU. */
2362 scanDurConv->shortChannelScanDuration_tick =
2363 SYS_MS_TO_TICKS(pMeasReq->measDuration.shortChannelScanDuration +SYS_TICK_DUR_MS-1);
2364
2365 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2366 /* (shortChanneScanDuration * 1000) / 2^10 */
2367 scanDurConv->shortChannelScanDuration_TU = (pMeasReq->measDuration.shortChannelScanDuration * 1000) >> 10;
2368
2369 scanDurConv->longChannelScanDuration_tick =
2370 SYS_MS_TO_TICKS(pMeasReq->measDuration.longChannelScanDuration +SYS_TICK_DUR_MS-1);
2371
2372 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2373 /* (longChanneScanDuration * 1000) / 2^10 */
2374 scanDurConv->longChannelScanDuration_TU = (pMeasReq->measDuration.longChannelScanDuration * 1000) >> 10;
2375}
2376#endif /* ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK)) */
2377
2378
2379#ifdef ANI_PRODUCT_TYPE_AP
2380/**-------------------------------------------------
2381\fn limIsRadarEnabled
2382
2383\brief Checks if radar is enabled
2384\param pMac
2385\return true - if Both 11h and radar enabled
2386 false - if either is not enabled.
2387 --------------------------------------------------*/
2388tANI_BOOLEAN limIsRadarEnabled(tpAniSirGlobal pMac)
2389{
2390 tANI_U32 fEnabled;
2391
2392 if(wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &fEnabled) != eSIR_SUCCESS)
2393 {
2394 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2395 return eANI_BOOLEAN_FALSE;
2396 }
2397
2398 if (!fEnabled)
2399 return eANI_BOOLEAN_FALSE;
2400
2401 if(wlan_cfgGetInt(pMac, WNI_CFG_RDET_FLAG, &fEnabled) != eSIR_SUCCESS)
2402 {
2403 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2404 return eANI_BOOLEAN_FALSE;
2405 }
2406
2407 if (fEnabled)
2408 return eANI_BOOLEAN_TRUE;
2409
2410 return eANI_BOOLEAN_FALSE;
2411}
2412
2413/**---------------------------------------
2414\fn limRadarInit
2415\brief Initialize Radar Interrupt.
2416
2417\param pMac
2418\return None
2419 ----------------------------------------*/
2420void limRadarInit(tpAniSirGlobal pMac)
2421{
2422 tANI_U32 status;
2423 tSirMsgQ msg;
2424
2425 PELOG3(limLog(pMac, LOG3, FL("Radar Interrupt Already configured? %s\n"),
2426 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured?"Yes":"No");)
2427 /** To avoid configuring the radar multiple times */
2428 if (pMac->lim.gLimSpecMgmt.fRadarIntrConfigured)
2429 return;
2430
2431 if (!limIsRadarEnabled(pMac))
2432 return;
2433 // Prepare and post message to HAL Message Queue
2434 msg.type = WDA_INIT_RADAR_IND;
2435 msg.bodyptr = NULL;
2436 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002437 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 status = wdaPostCtrlMsg(pMac, &msg);
2439 if (status != eHAL_STATUS_SUCCESS)
2440 {
2441 limLog(pMac, LOGP,
2442 FL("posting to HAL failed, reason=%d\n"), status);
2443 return;
2444 }
2445 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured = eANI_BOOLEAN_TRUE;
2446} /****** end limRadarInit() ******/
2447
2448#endif
2449
2450
2451/** -----------------------------------------------------------------
2452 \brief limHandleLowRssiInd() - handles low rssi indication
2453
2454 This function process the SIR_HAL_LOW_RSSI_IND message from
2455 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2456
2457 \param pMac - global mac structure
2458
2459 \return
2460
2461 \sa
2462 ----------------------------------------------------------------- */
2463void limHandleLowRssiInd(tpAniSirGlobal pMac)
2464{
2465#if 0 //RSSI related indications will now go to TL and not PE
2466 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2467 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2468 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2469 {
2470 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME \n"));)
2471 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2472 }
2473 else
2474 {
2475 limLog(pMac, LOGE,
2476 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d\n"),
2477 pMac->pmm.gPmmState);
2478 }
2479 return;
2480#endif
2481}
2482
2483
2484/** -----------------------------------------------------------------
2485 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2486
2487 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2488 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2489 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2490
2491 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2492 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2493 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2494 This message can also come from FW anytime after we have entered BMPS.
2495 This means we should handle it in WoWL and UAPSD states as well
2496
2497 \param pMac - global mac structure
2498 \return - none
2499 \sa
2500 ----------------------------------------------------------------- */
2501void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2502{
2503 switch(pMac->pmm.gPmmState)
2504 {
2505 case ePMM_STATE_BMPS_SLEEP:
2506 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2507 case ePMM_STATE_UAPSD_SLEEP:
2508 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2509 case ePMM_STATE_WOWLAN:
2510 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2511 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2512 break;
2513
2514 default:
2515 limLog(pMac, LOGE,
2516 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d\n"),
2517 pMac->pmm.gPmmState);
2518 break;
2519 }
2520 return;
2521}
2522
2523
2524/** -----------------------------------------------------------------
2525 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2526
2527 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2528 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2529 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2530
2531 \param pMac - global mac structure
2532 \return - none
2533 \sa
2534 ----------------------------------------------------------------- */
2535void limHandleMissedBeaconInd(tpAniSirGlobal pMac)
2536{
2537 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2538 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2539 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2540 {
2541 pMac->pmm.inMissedBeaconScenario = TRUE;
2542 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2543 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2544 }
Yathish9f22e662012-12-10 14:21:35 -08002545/* ACTIVE_MODE_HB_OFFLOAD */
2546#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2547 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2548 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2549 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2550 {
2551 pMac->pmm.inMissedBeaconScenario = TRUE;
2552 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure\n"));)
2553 limMissedBeaconInActiveMode(pMac);
2554 }
2555#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 else
2557 {
2558 limLog(pMac, LOGE,
2559 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d\n"),
2560 pMac->pmm.gPmmState);
2561 }
2562 return;
2563}
2564
2565/** -----------------------------------------------------------------
2566 \brief limMicFailureInd() - handles mic failure indication
2567
2568 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2569
2570 \param pMac - global mac structure
2571 \return - none
2572 \sa
2573 ----------------------------------------------------------------- */
2574void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2575{
2576 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2577 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2578 tSirMsgQ mmhMsg;
2579 tpPESession psessionEntry ;
2580 tANI_U8 sessionId;
2581
2582 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2583 {
2584 limLog(pMac, LOGE,
2585 FL("session does not exist for given BSSId\n"));
2586 return;
2587 }
2588
2589 if (eHAL_STATUS_SUCCESS !=
2590 palAllocateMemory(pMac->hHdd,
2591 (void **) &pSirSmeMicFailureInd,
2592 sizeof(tSirSmeMicFailureInd)))
2593 {
2594 // Log error
2595 limLog(pMac, LOGP,
2596 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND\n"));
2597 return;
2598 }
2599
2600 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2601 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2602 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2603
2604 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2605 pSirMicFailureInd->bssId,
2606 sizeof(tSirMacAddr));
2607
2608 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2609 pSirMicFailureInd->info.srcMacAddr,
2610 sizeof(tSirMacAddr));
2611
2612 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2613 pSirMicFailureInd->info.taMacAddr,
2614 sizeof(tSirMacAddr));
2615
2616 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2617 pSirMicFailureInd->info.dstMacAddr,
2618 sizeof(tSirMacAddr));
2619
2620 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2621 pSirMicFailureInd->info.rxMacAddr,
2622 sizeof(tSirMacAddr));
2623
2624 pSirSmeMicFailureInd->info.multicast =
2625 pSirMicFailureInd->info.multicast;
2626
2627 pSirSmeMicFailureInd->info.keyId=
2628 pSirMicFailureInd->info.keyId;
2629
2630 pSirSmeMicFailureInd->info.IV1=
2631 pSirMicFailureInd->info.IV1;
2632
2633 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2634 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2635
2636 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2637 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2638 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002639 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2641 return;
2642}
2643
2644
2645/** -----------------------------------------------------------------
2646 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2647
2648 This function is called before enqueuing the frame to PE queue for further processing.
2649 This prevents unnecessary frames getting into PE Queue and drops them right away.
2650 Frames will be droped in the following scenarios:
2651
2652 - In Scan State, drop the frames which are not marked as scan frames
2653 - In non-Scan state, drop the frames which are marked as scan frames.
2654 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2655 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2656
2657 \param pMac - global mac structure
2658 \return - none
2659 \sa
2660 ----------------------------------------------------------------- */
2661
2662tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2663{
2664 tANI_U32 framelen;
2665 tANI_U8 *pBody;
2666 tSirMacCapabilityInfo capabilityInfo;
2667
2668 /*
2669 *
2670 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2671 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2672 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2673 * other than beacons or probe responses in scan state.
2674 */
2675 if( (subType == SIR_MAC_MGMT_BEACON) ||
2676 (subType == SIR_MAC_MGMT_PROBE_RSP))
2677 {
2678 if(pMac->pmm.inMissedBeaconScenario)
2679 {
Jeff Johnsonab79c8d2012-12-10 14:30:13 -08002680 PELOGE(limLog(pMac, LOGE, FL("Do not drop beacon and probe response - Missed beacon scenario"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 return eMGMT_DROP_NO_DROP;
2682 }
2683 if (limIsSystemInScanState(pMac))
2684 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002685 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 }
2687 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2688 {
2689 return eMGMT_DROP_SCAN_MODE_FRAME;
2690 }
2691 }
2692
2693 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2694 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2695
2696 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2697 * beacons from an infrastructure network
2698 */
2699 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2700 if(!capabilityInfo.ibss)
2701 return eMGMT_DROP_NO_DROP;
2702#if 0
2703 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2704 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2705 return eMGMT_DROP_NO_DROP;
2706#endif
2707
2708 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2709 if( (subType == SIR_MAC_MGMT_BEACON) ||
2710 (subType == SIR_MAC_MGMT_PROBE_RSP))
2711 {
2712 //drop the frame if length is less than 12
2713 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2714 return eMGMT_DROP_INVALID_SIZE;
2715
2716 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2717
2718 //This can be enhanced to even check the SSID before deciding to enque the frame.
2719 if(capabilityInfo.ess)
2720 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2721 }
2722 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2723 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2724 {
2725 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2726 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2727 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2728 }
2729
2730 return eMGMT_DROP_NO_DROP;
2731}
2732
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002733eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2734{
2735 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002736
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002737 if(psPe)
2738 {
2739 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2740 {
2741 status = eHAL_STATUS_SUCCESS;
2742 }
2743 }
2744 return (status);
2745}
2746eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2747{
2748 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2749 if(psPe)
2750 {
2751 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2752 {
2753 status = eHAL_STATUS_SUCCESS;
2754 }
2755 }
2756 return (status);
2757}