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