blob: a7445f162cb6cd2b91ac23f22ed81a33490ba35e [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"
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include "wniCfgSta.h"
56#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "sirCommon.h"
58#include "sirDebug.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include "cfgApi.h"
60
61#include "schApi.h"
62#include "utilsApi.h"
63#include "limApi.h"
64#include "limGlobal.h"
65#include "limTypes.h"
66#include "limUtils.h"
67#include "limAssocUtils.h"
68#include "limPropExtsUtils.h"
69#include "limSerDesUtils.h"
70#include "limIbssPeerMgmt.h"
71#include "limAdmitControl.h"
72#include "pmmApi.h"
73#include "logDump.h"
74#include "limSendSmeRspMessages.h"
75#include "wmmApsd.h"
76#include "limTrace.h"
77#include "limSession.h"
78#include "wlan_qct_wda.h"
79
80#if defined WLAN_FEATURE_VOWIFI
81#include "rrmApi.h"
82#endif
83
84#include <limFT.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "vos_types.h"
86#include "vos_packet.h"
87#include "wlan_qct_tl.h"
88#include "sysStartup.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089
90
91static void __limInitScanVars(tpAniSirGlobal pMac)
92{
93 pMac->lim.gLimUseScanModeForLearnMode = 1;
94
95 pMac->lim.gLimSystemInScanLearnMode = 0;
96
97 // Scan related globals on STA
98 pMac->lim.gLimReturnAfterFirstMatch = 0;
99 pMac->lim.gLim24Band11dScanDone = 0;
100 pMac->lim.gLim50Band11dScanDone = 0;
101 pMac->lim.gLimReturnUniqueResults = 0;
102
103 // Background Scan related globals on STA
104 pMac->lim.gLimNumOfBackgroundScanSuccess = 0;
105 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure = 0;
106 pMac->lim.gLimNumOfForcedBkgndScan = 0;
107 pMac->lim.gLimBackgroundScanDisable = false; //based on BG timer
108 pMac->lim.gLimForceBackgroundScanDisable = false; //debug control flag
109 pMac->lim.gLimBackgroundScanTerminate = TRUE; //controlled by SME
Jeff Johnson92751692013-03-06 16:00:33 -0800110 pMac->lim.gLimReportBackgroundScanResults = FALSE; //controlled by SME
Jeff Johnson295189b2012-06-20 16:38:30 -0700111
112 pMac->lim.gLimCurrentScanChannelId = 0;
113 pMac->lim.gpLimMlmScanReq = NULL;
Viral Modid440e682013-03-06 02:25:31 -0800114 pMac->lim.gDeferMsgTypeForNOA = 0;
115 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700116 pMac->lim.gLimMlmScanResultLength = 0;
117 pMac->lim.gLimSmeScanResultLength = 0;
118
119 palZeroMemory(pMac->hHdd, pMac->lim.gLimCachedScanHashTable,
120 sizeof(pMac->lim.gLimCachedScanHashTable));
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122 pMac->lim.gLimBackgroundScanChannelId = 0;
123 pMac->lim.gLimBackgroundScanStarted = 0;
124 pMac->lim.gLimRestoreCBNumScanInterval = LIM_RESTORE_CB_NUM_SCAN_INTERVAL_DEFAULT;
125 pMac->lim.gLimRestoreCBCount = 0;
126 palZeroMemory(pMac->hHdd, pMac->lim.gLimLegacyBssidList, sizeof(pMac->lim.gLimLegacyBssidList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700127
128 /* Fill in default values */
129 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = 0;
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131
132 // abort scan is used to abort an on-going scan
133 pMac->lim.abortScan = 0;
134 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
135
136//WLAN_SUSPEND_LINK Related
137 pMac->lim.gpLimSuspendCallback = NULL;
138 pMac->lim.gpLimResumeCallback = NULL;
139//end WLAN_SUSPEND_LINK Related
140}
141
142
143static void __limInitBssVars(tpAniSirGlobal pMac)
144{
145
146 palZeroMemory(pMac->hHdd, (void*)pMac->lim.gpSession, sizeof(*pMac->lim.gpSession)*pMac->lim.maxBssId);
147
148
149 //pMac->lim.gpLimStartBssReq = NULL;
150
Jeff Johnson295189b2012-06-20 16:38:30 -0700151
152
153
154/* These global variables are moved to session table and intialization is done during session creation Oct 9th Review */
155#if 0
156
157 // Place holder for BSS description that we're
158 // currently joined with
159 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentBssId, sizeof(tSirMacAddr));
160 pMac->lim.gLimCurrentChannelId = HAL_INVALID_CHANNEL_ID;
161 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentSSID, sizeof(tSirMacSSid));
162 pMac->lim.gLimCurrentBssCaps = 0;
163 QosCaps is a bit map of various qos capabilities - see defn above
164 pMac->lim.gLimCurrentBssQosCaps = 0;
165 pMac->lim.gLimCurrentBssPropCap = 0;
166 pMac->lim.gLimSentCapsChangeNtf = 0;
167
168 // Place holder for BSS description that
169 // we're currently Reassociating
170 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocBssId, sizeof(tSirMacAddr));
171 pMac->lim.gLimReassocChannelId = 0;
172 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocSSID, sizeof(tSirMacSSid));
173 pMac->lim.gLimReassocBssCaps = 0;
174 pMac->lim.gLimReassocBssQosCaps = 0;
175 pMac->lim.gLimReassocBssPropCap = 0;
176 #endif
177
178 /* This is for testing purposes only, be default should always be off */
179 pMac->lim.gLimForceNoPropIE = 0;
180
181 // pMac->lim.gLimBssIdx = 0;
182
183 pMac->lim.gpLimMlmSetKeysReq = NULL;
184 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
185 // pMac->lim.gLimStaid = 0; //TO SUPPORT BT-AMP
186
187}
188
189
190static void __limInitStatsVars(tpAniSirGlobal pMac)
191{
192 pMac->lim.gLimNumBeaconsRcvd = 0;
193 pMac->lim.gLimNumBeaconsIgnored = 0;
194
195 pMac->lim.gLimNumDeferredMsgs = 0;
196
197 /// Variable to keep track of number of currently associated STAs
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800198 //pMac->lim.gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 pMac->lim.gLimNumOfAniSTAs = 0; // count of ANI peers
200
201 /// This indicates number of RXed Beacons during HB period
202 //pMac->lim.gLimRxedBeaconCntDuringHB = 0;
203
204 // Heart-Beat interval value
205 pMac->lim.gLimHeartBeatCount = 0;
206
207 // Statistics to keep track of no. beacons rcvd in heart beat interval
208 palZeroMemory(pMac->hHdd, pMac->lim.gLimHeartBeatBeaconStats, sizeof(pMac->lim.gLimHeartBeatBeaconStats));
209
210#ifdef WLAN_DEBUG
211 // Debug counters
212 pMac->lim.numTot = 0;
213 pMac->lim.numBbt = 0;
214 pMac->lim.numProtErr = 0;
215 pMac->lim.numLearn = 0;
216 pMac->lim.numLearnIgnore = 0;
217 pMac->lim.numSme = 0;
218 palZeroMemory(pMac->hHdd, pMac->lim.numMAC, sizeof(pMac->lim.numMAC));
219 pMac->lim.gLimNumAssocReqDropInvldState = 0;
220 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
221 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
222 pMac->lim.gLimNumReassocReqDropInvldState = 0;
223 pMac->lim.gLimNumHashMissIgnored = 0;
224 pMac->lim.gLimUnexpBcnCnt = 0;
225 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
226 pMac->lim.gLimNumLinkEsts = 0;
227 pMac->lim.gLimNumRxCleanup = 0;
228 pMac->lim.gLim11bStaAssocRejectCount = 0;
229#endif
230}
231
232
233
234static void __limInitStates(tpAniSirGlobal pMac)
235{
236 // Counts Heartbeat failures
237 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
238 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
239 pMac->lim.gLimHBfailureCntInOtherStates = 0;
240 pMac->lim.gLimRspReqd = 0;
241 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
242
243 /// MLM State visible across all Sirius modules
Jeff Johnsone7245742012-09-05 17:12:55 -0700244 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700245 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
246
247 /// Previous MLM State
248 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
249
250#ifdef GEN4_SCAN
251 // LIM to HAL SCAN Management Message Interface states
252 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
253#endif // GEN4_SCAN
254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 /**
Jeff Johnsone7245742012-09-05 17:12:55 -0700256 * Initialize state to eLIM_SME_OFFLINE_STATE
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700258 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
260 /**
261 * By default assume 'unknown' role. This will be updated
262 * when SME_START_BSS_REQ is received.
263 */
264
265 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11gParams, sizeof(tLimProtStaParams));
266 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11aParams, sizeof(tLimProtStaParams));
267 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapHt20Params, sizeof(tLimProtStaParams));
268 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapNonGfParams, sizeof(tLimProtStaParams));
269 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams));
270 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortSlotParams, sizeof(tLimNoShortSlotParams));
271
272 pMac->lim.gLimPhyMode = 0;
273 pMac->lim.scanStartTime = 0; // used to measure scan time
274
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 palZeroMemory(pMac->hHdd, pMac->lim.gLimMyMacAddr, sizeof(pMac->lim.gLimMyMacAddr));
276 pMac->lim.ackPolicy = 0;
277
278#if 0 /* Moving all these to session specific elements */
279 pMac->lim.gLimQosEnabled = 0; //11E
280 pMac->lim.gLimWmeEnabled = 0; //WME
281 pMac->lim.gLimWsmEnabled = 0; //WSM
282 pMac->lim.gLimHcfEnabled = 0;
283 pMac->lim.gLim11dEnabled = 0;
284#endif
285
286 pMac->lim.gLimProbeRespDisableFlag = 0; // control over probe response
287}
288
289static void __limInitVars(tpAniSirGlobal pMac)
290{
291
Jeff Johnson295189b2012-06-20 16:38:30 -0700292
293 // Place holder for Measurement Req/Rsp/Ind related info
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
295 // WDS info
296 pMac->lim.gLimNumWdsInfoInd = 0;
297 pMac->lim.gLimNumWdsInfoSet = 0;
298 palZeroMemory(pMac->hHdd, &pMac->lim.gLimWdsInfo, sizeof(tSirWdsInfo));
299 /* initialize some parameters */
300 limInitWdsInfoParams(pMac);
301
302 // Deferred Queue Paramters
303 palZeroMemory(pMac->hHdd, &pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq));
304
305 // addts request if any - only one can be outstanding at any time
306 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq));
307 pMac->lim.gLimAddtsSent = 0;
308 pMac->lim.gLimAddtsRspTimerCount = 0;
309
310 //protection related config cache
311 palZeroMemory(pMac->hHdd, &pMac->lim.cfgProtection, sizeof(tCfgProtection));
312 pMac->lim.gLimProtectionControl = 0;
313 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAlternateRadio, sizeof(tSirAlternateRadioInfo));
314 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
315
Jeff Johnsone7245742012-09-05 17:12:55 -0700316#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 // 11h Spectrum Management Related Flag
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
319 pMac->sys.gSysEnableLearnMode = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700320#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 // WMM Related Flag
322 pMac->lim.gUapsdEnable = 0;
323 pMac->lim.gUapsdPerAcBitmask = 0;
324 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
325 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
326
327 // QoS-AC Downgrade: Initially, no AC is admitted
328 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
329 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
330
331 //dialogue token List head/tail for Action frames request sent.
332 pMac->lim.pDialogueTokenHead = NULL;
333 pMac->lim.pDialogueTokenTail = NULL;
334
335 palZeroMemory(pMac->hHdd, &pMac->lim.tspecInfo, sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX);
336
337 // admission control policy information
338 palZeroMemory(pMac->hHdd, &pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo));
339
340 pMac->lim.gLastBeaconDtimCount = 0;
341 pMac->lim.gLastBeaconDtimPeriod = 0;
342
343 //Scan in Power Save Flag
344 pMac->lim.gScanInPowersave = 0;
345}
346
347static void __limInitAssocVars(tpAniSirGlobal pMac)
348{
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800349 tANI_U32 val;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800350#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 palZeroMemory(pMac->hHdd, pMac->lim.gpLimAIDpool,
352 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1));
353 pMac->lim.freeAidHead = 0;
354 pMac->lim.freeAidTail = 0;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800355#endif
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800356 if(wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS)
357 {
358 limLog( pMac, LOGP, FL( "cfg get assoc sta limit failed" ));
359 }
360 pMac->lim.gLimAssocStaLimit = val;
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362 // Place holder for current authentication request
363 // being handled
364 pMac->lim.gpLimMlmAuthReq = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -0700365 //pMac->lim.gpLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
367 /// MAC level Pre-authentication related globals
368 pMac->lim.gLimPreAuthChannelNumber = 0;
369 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
370 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr));
371 pMac->lim.gLimNumPreAuthContexts = 0;
372 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable));
373
374 // Placed holder to deauth reason
375 pMac->lim.gLimDeauthReasonCode = 0;
376
377 // Place holder for Pre-authentication node list
378 pMac->lim.pLimPreAuthList = NULL;
379
380 // Send Disassociate frame threshold parameters
381 pMac->lim.gLimDisassocFrameThreshold = LIM_SEND_DISASSOC_FRAME_THRESHOLD;
382 pMac->lim.gLimDisassocFrameCredit = 0;
383
384 //One cache for each overlap and associated case.
385 palZeroMemory(pMac->hHdd, pMac->lim.protStaOverlapCache, sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE);
386 palZeroMemory(pMac->hHdd, pMac->lim.protStaCache, sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE);
387
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -0700388#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
389 pMac->lim.pSessionEntry = NULL;
390 pMac->lim.reAssocRetryAttempt = 0;
391#endif
392
Jeff Johnson295189b2012-06-20 16:38:30 -0700393}
394
395
396static void __limInitTitanVars(tpAniSirGlobal pMac)
397{
Jeff Johnsone7245742012-09-05 17:12:55 -0700398#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 palZeroMemory(pMac->hHdd, &pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700401 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 // Debug workaround for BEACON's
404 // State change triggered by "dump 222"
405 pMac->lim.gLimScanOverride = 1;
406 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700407 pMac->lim.gLimTitanStaCount = 0;
408 pMac->lim.gLimBlockNonTitanSta = 0;
409}
410
411static void __limInitHTVars(tpAniSirGlobal pMac)
412{
413 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 pMac->lim.gHTShortGI40Mhz = 0;
416 pMac->lim.gHTShortGI20Mhz = 0;
417 pMac->lim.gHTMaxAmsduLength = 0;
418 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
419 pMac->lim.gHTPSMPSupport = 0;
420 pMac->lim.gHTLsigTXOPProtection = 0;
421 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
422 pMac->lim.gHTAMpduDensity = 0;
423
424 pMac->lim.gMaxAmsduSizeEnabled = false;
425 pMac->lim.gHTMaxRxAMpduFactor = 0;
426 pMac->lim.gHTServiceIntervalGranularity = 0;
427 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
429 pMac->lim.gHTPCOActive = 0;
430
431 pMac->lim.gHTPCOPhase = 0;
432 pMac->lim.gHTSecondaryBeacon = 0;
433 pMac->lim.gHTDualCTSProtection = 0;
434 pMac->lim.gHTSTBCBasicMCS = 0;
435 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
436}
437
Jeff Johnson295189b2012-06-20 16:38:30 -0700438static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
439{
Jeff Johnsone7245742012-09-05 17:12:55 -0700440 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 tANI_U16 val16;
442 tANI_U8 val8;
443 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
444 tSirMacHTInfoField1 *pHTInfoField1;
445 tpSirPowerSaveCfg pPowerSaveConfig;
446 tSirMacHTParametersInfo *pAmpduParamInfo;
447
448 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700449 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
450 * and they will be used throughout when there is no session
451 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
454 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700455 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 return eSIR_FAILURE;
457 }
458
459 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
460 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700461 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 return eSIR_FAILURE;
463 }
464 val16 = ( tANI_U16 ) val1;
465 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
466
467 //channel bonding mode could be set to anything from 0 to 4(Titan had these
468 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
469 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
470 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
471 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
472 != eSIR_SUCCESS)
473 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700474 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 return eSIR_FAILURE;
476 }
477
478 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
479 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700480 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 return eSIR_FAILURE;
482 }
483
484 val8 = ( tANI_U8 ) val1;
485 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
486 pHTInfoField1->recommendedTxWidthSet =
487 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
489 != eSIR_SUCCESS)
490 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700491 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 return eSIR_FAILURE;
493 }
494
495 /* WNI_CFG_HEART_BEAT_THRESHOLD */
496
497 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
498 eSIR_SUCCESS )
499 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700500 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 return eSIR_FAILURE;
502 }
503 if(!val1)
504 {
505 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
506 pMac->sys.gSysEnableLinkMonitorMode = 0;
507 }
508 else
509 {
510 //No need to activate the timer during init time.
511 pMac->sys.gSysEnableLinkMonitorMode = 1;
512 }
513
514 /* WNI_CFG_SHORT_GI_20MHZ */
515
516 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
517 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700518 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 return eSIR_FAILURE;
520 }
521 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
522 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700523 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 return eSIR_FAILURE;
525 }
526 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
527 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700528 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 return eSIR_FAILURE;
530 }
531
532 val16 = ( tANI_U16 ) val1;
533 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
534 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
535 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
536
537 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
538 eSIR_SUCCESS)
539 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700540 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 return eSIR_FAILURE;
542 }
543
544 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
545
546 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
547 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700548 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 return eSIR_FAILURE;
550 }
551 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
552 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700553 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 return eSIR_FAILURE;
555 }
556 val16 = ( tANI_U16 ) val1;
557 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
558 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
559 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
560 eSIR_SUCCESS)
561 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700562 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 return eSIR_FAILURE;
564 }
565
566 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
567 limHandleCFGparamUpdate do we want to update this? */
568 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
569 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700570 limLog(pMac, LOGP, FL("cfg get short preamble failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 return eSIR_FAILURE;
572 }
573
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 /* WNI_CFG_MAX_PS_POLL */
575
576 /* Allocate and fill in power save configuration. */
577 if (palAllocateMemory(pMac->hHdd, (void **)&pPowerSaveConfig,
578 sizeof(tSirPowerSaveCfg)) != eHAL_STATUS_SUCCESS)
579 {
580 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700581 "configuration"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 return eSIR_FAILURE;
583 }
584
585 /* This context should be valid if power-save configuration message has been
586 * already dispatched during initialization process. Re-using the present
587 * configuration mask
588 */
589 palCopyMemory(pMac->hHdd, pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg,
590 sizeof(tSirPowerSaveCfg));
591
592 /* Note: it is okay to do this since DAL/HAL is alrady started */
593 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
594 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700595 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 return eSIR_FAILURE;
597 }
598
599 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
600
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700602 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 pMac->lim.gLimBackgroundScanChannelId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700604
605 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
606
607 /* This was initially done after resume notification from HAL. Now, DAL is
608 started before PE so this can be done here */
Jeff Johnsone7245742012-09-05 17:12:55 -0700609 handleHTCapabilityandHTInfo(pMac, NULL);
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800610 if(wlan_cfgGetInt(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,(tANI_U32 *) &pMac->lim.disableLDPCWithTxbfAP) != eSIR_SUCCESS)
611 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700612 limLog(pMac, LOGP, FL("cfg get disableLDPCWithTxbfAP failed"));
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800613 return eSIR_FAILURE;
614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
616 return eSIR_SUCCESS;
617}
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
619/*
620 limStart
621 This function is to replace the __limProcessSmeStartReq since there is no
622 eWNI_SME_START_REQ post to PE.
623*/
624tSirRetStatus limStart(tpAniSirGlobal pMac)
625{
626 tSirResultCodes retCode = eSIR_SUCCESS;
627
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700628 PELOG1(limLog(pMac, LOG1, FL(" enter"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700629
630 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
631 {
632 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
633
Jeff Johnsone7245742012-09-05 17:12:55 -0700634 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700635
636 // By default do not return after first scan match
637 pMac->lim.gLimReturnAfterFirstMatch = 0;
638
639 // Initialize MLM state machine
640 limInitMlm(pMac);
641
642 // By default return unique scan results
643 pMac->lim.gLimReturnUniqueResults = true;
644 pMac->lim.gLimSmeScanResultLength = 0;
645 }
646 else
647 {
648 /**
649 * Should not have received eWNI_SME_START_REQ in states
650 * other than OFFLINE. Return response to host and
651 * log error
652 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700653 limLog(pMac, LOGE, FL("Invalid SME state %X"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 retCode = eSIR_FAILURE;
655 }
656
657 return retCode;
658}
659
660/**
661 * limInitialize()
662 *
663 *FUNCTION:
664 * This function is called from LIM thread entry function.
665 * LIM related global data structures are initialized in this function.
666 *
667 *LOGIC:
668 * NA
669 *
670 *ASSUMPTIONS:
671 * NA
672 *
673 *NOTE:
674 * NA
675 *
676 * @param pMac - Pointer to global MAC structure
677 * @return None
678 */
679
680tSirRetStatus
681limInitialize(tpAniSirGlobal pMac)
682{
683 tSirRetStatus status = eSIR_SUCCESS;
684
685 __limInitAssocVars(pMac);
686 __limInitVars(pMac);
687 __limInitStates(pMac);
688 __limInitStatsVars(pMac);
689 __limInitBssVars(pMac);
690 __limInitScanVars(pMac);
691 __limInitHTVars(pMac);
692 __limInitTitanVars(pMac);
693
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 status = limStart(pMac);
695 if(eSIR_SUCCESS != status)
696 {
697 return status;
698 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700699
700 /*
701 * MLM will be intitalized when 'START' request comes from SME.
702 * limInitMlm calls limCreateTimers, which actually relies on
703 * CFG to be downloaded. So it should not be called as part of
704 * peStart, as CFG download is happening after peStart.
705 */
706 //limInitMlm(pMac);
707 // Initializations for maintaining peers in IBSS
708 limIbssInit(pMac);
709
710 pmmInitialize(pMac);
711
712
713#if defined WLAN_FEATURE_VOWIFI
714 rrmInitialize(pMac);
715#endif
716#if defined WLAN_FEATURE_VOWIFI_11R
717 limFTOpen(pMac);
718#endif
719
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
722#if 0
723
724 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
725 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
726 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
727
728 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
729 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
730
731 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
732 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
733 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
734
735 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
736
737 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
738
739 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
740 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
741
742 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
743
744
745 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
746
747 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
748#endif
749 MTRACE(limTraceInit(pMac));
750
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 //Initialize the configurations needed by PE
752 if( eSIR_FAILURE == __limInitConfig(pMac))
753 {
754 //We need to undo everything in limStart
755 limCleanupMlm(pMac);
756 return eSIR_FAILURE;
757 }
758
759 //initialize the TSPEC admission control table.
760 //Note that this was initially done after resume notification from HAL.
761 //Now, DAL is started before PE so this can be done here
762 limAdmitControlInit(pMac);
763 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764
765 return status;
766
767} /*** end limInitialize() ***/
768
769
770
771/**
772 * limCleanup()
773 *
774 *FUNCTION:
775 * This function is called upon reset or persona change
776 * to cleanup LIM state
777 *
778 *LOGIC:
779 * NA
780 *
781 *ASSUMPTIONS:
782 * NA
783 *
784 *NOTE:
785 * NA
786 *
787 * @param pMac - Pointer to Global MAC structure
788 * @return None
789 */
790
791void
792limCleanup(tpAniSirGlobal pMac)
793{
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 v_PVOID_t pvosGCTx;
795 VOS_STATUS retStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700796
Jeff Johnson295189b2012-06-20 16:38:30 -0700797//Before destroying the list making sure all the nodes have been deleted.
798//Which should be the normal case, but a memory leak has been reported.
799
800 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
801
802 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
803 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
804 {
805 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
806 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
807
808 palFreeMemory(pMac, pLimMgmtRegistration);
809 }
810
811 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700812
813 limCleanupMlm(pMac);
814 limCleanupLmm(pMac);
815
816 // free up preAuth table
817 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
818 {
819 palFreeMemory(pMac->hHdd, pMac->lim.gLimPreAuthTimerTable.pTable);
820 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
821 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
822 }
823
824 if(NULL != pMac->lim.pDialogueTokenHead)
825 {
826 limDeleteDialogueTokenList(pMac);
827 }
828
829 if(NULL != pMac->lim.pDialogueTokenTail)
830 {
831 palFreeMemory(pMac->hHdd, (void *) pMac->lim.pDialogueTokenTail);
832 pMac->lim.pDialogueTokenTail = NULL;
833 }
834
835 # if 0
836 if (pMac->lim.gpLimStartBssReq != NULL)
837 {
838 palFreeMemory(pMac->hHdd, pMac->lim.gpLimStartBssReq);
839 pMac->lim.gpLimStartBssReq = NULL;
840 }
841 #endif
842
843 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
844 {
845 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmSetKeysReq);
846 pMac->lim.gpLimMlmSetKeysReq = NULL;
847 }
848
849 #if 0
850 if (pMac->lim.gpLimJoinReq != NULL)
851 {
852 palFreeMemory(pMac->hHdd, pMac->lim.gpLimJoinReq);
853 pMac->lim.gpLimJoinReq = NULL;
854 }
855 #endif
856
857 if (pMac->lim.gpLimMlmAuthReq != NULL)
858 {
859 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
860 pMac->lim.gpLimMlmAuthReq = NULL;
861 }
862
Jeff Johnsone7245742012-09-05 17:12:55 -0700863#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 if (pMac->lim.gpLimMlmJoinReq != NULL)
865 {
866 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
867 pMac->lim.gpLimMlmJoinReq = NULL;
868 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700870
871 #if 0
872 if (pMac->lim.gpLimReassocReq != NULL)
873 {
874 palFreeMemory(pMac->hHdd, pMac->lim.gpLimReassocReq);
875 pMac->lim.gpLimReassocReq = NULL;
876 }
877 #endif
878
879 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
880 {
881 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmRemoveKeyReq);
882 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
883 }
884
Viral Modid440e682013-03-06 02:25:31 -0800885 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
Viral Modid86bde22012-12-10 13:09:21 -0800886 {
Viral Modid440e682013-03-06 02:25:31 -0800887 palFreeMemory(pMac->hHdd, pMac->lim.gpDefdSmeMsgForNOA);
888 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800889 }
Viral Modid86bde22012-12-10 13:09:21 -0800890
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 if (pMac->lim.gpLimMlmScanReq != NULL)
892 {
893 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmScanReq);
894 pMac->lim.gpLimMlmScanReq = NULL;
895 }
896
897#if 0
898 if(NULL != pMac->lim.beacon)
899 {
900 palFreeMemory(pMac->hHdd, (void*) pMac->lim.beacon);
901 pMac->lim.beacon = NULL;
902 }
903#endif
904 #if 0
905 if(NULL != pMac->lim.assocReq)
906 {
907 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocReq);
908 pMac->lim.assocReq= NULL;
909 }
910 #endif
911
912#if 0
913 if(NULL != pMac->lim.assocRsp)
914 {
915 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocRsp);
916 pMac->lim.assocRsp= NULL;
917 }
918#endif
919 // Now, finally reset the deferred message queue pointers
920 limResetDeferredMsgQ(pMac);
921
Jeff Johnson295189b2012-06-20 16:38:30 -0700922
923 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
924 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
925
926 if ( retStatus != VOS_STATUS_SUCCESS )
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700927 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700928
929#if defined WLAN_FEATURE_VOWIFI
930 rrmCleanup(pMac);
931#endif
932#if defined WLAN_FEATURE_VOWIFI_11R
933 limFTCleanup(pMac);
934#endif
935
936} /*** end limCleanup() ***/
937
938
939/** -------------------------------------------------------------
940\fn peOpen
941\brief will be called in Open sequence from macOpen
942\param tpAniSirGlobal pMac
943\param tHalOpenParameters *pHalOpenParam
944\return tSirRetStatus
945 -------------------------------------------------------------*/
946
947tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
948{
949 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
950 pMac->lim.maxStation = pMacOpenParam->maxStation;
951
952 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
953 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700954 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 return eSIR_FAILURE;
956 }
957
958 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
959 (void **) &pMac->lim.limTimers.gpLimCnfWaitTimer, sizeof(TX_TIMER)*pMac->lim.maxStation))
960 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700961 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 return eSIR_FAILURE;
963 }
964
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800965#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
967 (void **) &pMac->lim.gpLimAIDpool,
968 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1)))
969 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700970 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 return eSIR_FAILURE;
972 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
975 (void **) &pMac->lim.gpSession, sizeof(tPESession)* pMac->lim.maxBssId))
976 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700977 limLog(pMac, LOGE, FL("memory allocate failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 return eSIR_FAILURE;
979 }
980
981 palZeroMemory(pMac->hHdd, pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId);
982
983
984 /*
985 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
986 (void **) &pMac->dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*pMac->lim.maxStation))
987 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700988 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 return eSIR_FAILURE;
990 }
991
992 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
993 (void **) &pMac->dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*pMac->lim.maxStation))
994 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700995 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 return eSIR_FAILURE;
997 }
998 */
999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1001 (void **) &pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation))
1002 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001003 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 return eSIR_FAILURE;
1005 }
1006 palZeroMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001008 pMac->lim.mgmtFrameSessionId = 0xff;
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001009 pMac->lim.deferredMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001010
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001011 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1012 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001013 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!"));)
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001014 return eSIR_FAILURE;
1015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 return eSIR_SUCCESS;
1017}
1018
1019/** -------------------------------------------------------------
1020\fn peClose
1021\brief will be called in close sequence from macClose
1022\param tpAniSirGlobal pMac
1023\return tSirRetStatus
1024 -------------------------------------------------------------*/
1025
1026tSirRetStatus peClose(tpAniSirGlobal pMac)
1027{
1028 tANI_U8 i;
1029
1030 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1031 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 for(i =0; i < pMac->lim.maxBssId; i++)
1034 {
1035 if(pMac->lim.gpSession[i].valid == TRUE)
1036 {
1037 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1038 }
1039 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001040 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1041 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001042#if 0
Jeff Johnsone7245742012-09-05 17:12:55 -07001043 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1044 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001045#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001046
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1048 pMac->lim.gpSession = NULL;
1049 /*
1050 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1051 pMac->dph.dphHashTable.pHashTable = NULL;
1052 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1053 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1054 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1056 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001057 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1058 {
1059 return eSIR_FAILURE;
1060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 return eSIR_SUCCESS;
1062}
1063
1064/** -------------------------------------------------------------
1065\fn peStart
1066\brief will be called in start sequence from macStart
1067\param tpAniSirGlobal pMac
1068\return none
1069 -------------------------------------------------------------*/
1070
1071tSirRetStatus peStart(tpAniSirGlobal pMac)
1072{
1073 tSirRetStatus status = eSIR_SUCCESS;
1074
1075 status = limInitialize(pMac);
1076#if defined(ANI_LOGDUMP)
1077 limDumpInit(pMac);
1078#endif //#if defined(ANI_LOGDUMP)
1079
1080 return status;
1081}
1082
1083/** -------------------------------------------------------------
1084\fn peStop
1085\brief will be called in stop sequence from macStop
1086\param tpAniSirGlobal pMac
1087\return none
1088 -------------------------------------------------------------*/
1089
1090void peStop(tpAniSirGlobal pMac)
1091{
1092 limCleanup(pMac);
1093 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1094 return;
1095}
1096
1097/** -------------------------------------------------------------
1098\fn peFreeMsg
1099\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1100\ to free a given PE message on the TX and MC thread.
1101\ This happens when there are messages pending in the PE
1102\ queue when system is being stopped and reset.
1103\param tpAniSirGlobal pMac
1104\param tSirMsgQ pMsg
1105\return none
1106-----------------------------------------------------------------*/
1107v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1108{
1109 if (pMsg != NULL)
1110 {
1111 if (NULL != pMsg->bodyptr)
1112 {
1113 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1114 {
1115 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1116 }
1117 else
1118 {
1119 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1120 }
1121 }
1122 pMsg->bodyptr = 0;
1123 pMsg->bodyval = 0;
1124 pMsg->type = 0;
1125 }
1126 return;
1127}
1128
1129
1130/**
1131 * The function checks if a particular timer should be allowed
1132 * into LIM while device is sleeping
1133 */
1134tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1135{
1136 tANI_U8 retStatus = TRUE;
1137
1138 if(!limIsSystemInActiveState(pMac))
1139 {
1140 switch(pMsg->type)
1141 {
1142 /* Don't allow following timer messages if in sleep */
1143 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1144 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1145 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1146 retStatus = FALSE;
1147 break;
1148 /* May allow following timer messages in sleep mode */
1149 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1150
1151 /* Safe to allow as of today, this triggers background scan
1152 * which will not be started if the device is in power-save mode
1153 * might need to block in the future if we decide to implement
1154 * spectrum management
1155 */
1156 case SIR_LIM_QUIET_TIMEOUT:
1157
1158 /* Safe to allow as of today, this triggers background scan
1159 * which will not be started if the device is in power-save mode
1160 * might need to block in the future if we decide to implement
1161 * spectrum management
1162 */
1163 case SIR_LIM_QUIET_BSS_TIMEOUT:
1164
1165 /* Safe to allow this timermessage, triggers background scan
1166 * which is blocked in sleep mode
1167 */
1168 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1169
1170 /* Safe to allow this timer, since, while in IMPS this timer will not
1171 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1172 * when heart-beat control is handled back to PE, device would have
1173 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1174 */
1175 case SIR_LIM_HEART_BEAT_TIMEOUT:
1176 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1177
1178 /* Safe to allow, PE is not handling this message as of now. May need
1179 * to block it, basically, free the buffer and restart the timer
1180 */
1181 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1182 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001183 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1185 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1186 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1187 retStatus = TRUE;
1188 break;
1189
1190 /* by default allow rest of messages */
1191 default:
1192 retStatus = TRUE;
1193 break;
1194
1195
1196 }
1197 }
1198
1199 return retStatus;
1200
1201}
1202
1203
1204
1205/**
1206 * limPostMsgApi()
1207 *
1208 *FUNCTION:
1209 * This function is called from other thread while posting a
1210 * message to LIM message Queue gSirLimMsgQ.
1211 *
1212 *LOGIC:
1213 * NA
1214 *
1215 *ASSUMPTIONS:
1216 * NA
1217 *
1218 *NOTE:
1219 * NA
1220 *
1221 * @param pMac - Pointer to Global MAC structure
1222 * @param pMsg - Pointer to the message structure
1223 * @return None
1224 */
1225
1226tANI_U32
1227limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1228{
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1230
1231
Jeff Johnson295189b2012-06-20 16:38:30 -07001232} /*** end limPostMsgApi() ***/
1233
1234
1235/*--------------------------------------------------------------------------
1236
1237 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1238
1239 This function can be called by legacy code to post message to voss queues OR
1240 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1241 for dispatching it later.
1242
1243 \param pMac - Pointer to Global MAC structure
1244 \param pMsg - Pointer to the message structure
1245
1246 \return tANI_U32 - TX_SUCCESS for success.
1247
1248 --------------------------------------------------------------------------*/
1249
1250tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1251{
1252 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1253}
1254
1255/*--------------------------------------------------------------------------
1256
1257 \brief peProcessMessages() - Message Processor for PE
1258
1259 Voss calls this function to dispatch the message to PE
1260
1261 \param pMac - Pointer to Global MAC structure
1262 \param pMsg - Pointer to the message structure
1263
1264 \return tANI_U32 - TX_SUCCESS for success.
1265
1266 --------------------------------------------------------------------------*/
1267
1268tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1269{
1270 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1271 {
1272 return eSIR_SUCCESS;
1273 }
1274 /**
1275 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1276 * for all the other cases post it to LIM
1277 */
1278 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1279 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1280 else
1281 limMessageProcessor(pMac, pMsg);
1282 return eSIR_SUCCESS;
1283}
1284
1285
Jeff Johnson295189b2012-06-20 16:38:30 -07001286
1287// ---------------------------------------------------------------------------
1288/**
1289 * peHandleMgmtFrame
1290 *
1291 * FUNCTION:
1292 * Process the Management frames from TL
1293 *
1294 * LOGIC:
1295 *
1296 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1297 *
1298 * NOTE:
1299 *
1300 * @param pvosGCtx Global Vos Context
1301 * @param vossBuff Packet
1302 * @return None
1303 */
1304
1305VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1306{
1307 tpAniSirGlobal pMac;
1308 tpSirMacMgmtHdr mHdr;
1309 tSirMsgQ msg;
1310 vos_pkt_t *pVosPkt;
1311 VOS_STATUS vosStatus;
1312 v_U8_t *pRxPacketInfo;
1313
1314 pVosPkt = (vos_pkt_t *)vosBuff;
1315 if (NULL == pVosPkt)
1316 {
1317 return VOS_STATUS_E_FAILURE;
1318 }
1319
1320 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1321 if (NULL == pMac)
1322 {
1323 // cannot log a failure without a valid pMac
1324 vos_pkt_return_packet(pVosPkt);
1325 return VOS_STATUS_E_FAILURE;
1326 }
1327
1328 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1329
1330 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1331 {
1332 vos_pkt_return_packet(pVosPkt);
1333 return VOS_STATUS_E_FAILURE;
1334 }
1335
1336
1337 //
1338 // The MPDU header is now present at a certain "offset" in
1339 // the BD and is specified in the BD itself
1340 //
1341 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1342 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1343 {
1344 PELOG1(limLog( pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001345 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001346 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001347
Jeff Johnsone7245742012-09-05 17:12:55 -07001348 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1350 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1351 }
1352
1353
1354 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1355 msg.type = SIR_BB_XPORT_MGMT_MSG;
1356 msg.bodyptr = vosBuff;
1357 msg.bodyval = 0;
1358
1359 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1360 &msg,
1361 mHdr->fc.type,
1362 mHdr->fc.subType ))
1363 {
1364 vos_pkt_return_packet(pVosPkt);
1365 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001366 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 return VOS_STATUS_E_FAILURE;
1368 }
1369
1370 return VOS_STATUS_SUCCESS;
1371}
1372
1373// ---------------------------------------------------------------------------
1374/**
1375 * peRegisterTLHandle
1376 *
1377 * FUNCTION:
1378 * Registers the Handler which, process the Management frames from TL
1379 *
1380 * LOGIC:
1381 *
1382 * ASSUMPTIONS:
1383 *
1384 * NOTE:
1385 *
1386 * @return None
1387 */
1388
1389void peRegisterTLHandle(tpAniSirGlobal pMac)
1390{
1391 v_PVOID_t pvosGCTx;
1392 VOS_STATUS retStatus;
1393
1394 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1395
1396 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1397
1398 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001399 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001400
1401}
Jeff Johnson295189b2012-06-20 16:38:30 -07001402
1403
1404/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 * limIsSystemInScanState()
1406 *
1407 *FUNCTION:
1408 * This function is called by various MAC software modules to
1409 * determine if System is in Scan/Learn state
1410 *
1411 *LOGIC:
1412 * NA
1413 *
1414 *ASSUMPTIONS:
1415 * NA
1416 *
1417 *NOTE:
1418 *
1419 * @param pMac - Pointer to Global MAC structure
1420 * @return true - System is in Scan/Learn state
1421 * false - System is NOT in Scan/Learn state
1422 */
1423
1424tANI_U8
1425limIsSystemInScanState(tpAniSirGlobal pMac)
1426{
1427 switch (pMac->lim.gLimSmeState)
1428 {
1429 case eLIM_SME_CHANNEL_SCAN_STATE:
1430 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1431 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1432 case eLIM_SME_WT_SCAN_STATE:
1433 // System is in Learn mode
1434 return true;
1435
1436 default:
1437 // System is NOT in Learn mode
1438 return false;
1439 }
1440} /*** end limIsSystemInScanState() ***/
1441
1442
1443
1444/**
1445 * limIsSystemInActiveState()
1446 *
1447 *FUNCTION:
1448 * This function is called by various MAC software modules to
1449 * determine if System is in Active/Wakeup state
1450 *
1451 *LOGIC:
1452 * NA
1453 *
1454 *ASSUMPTIONS:
1455 * NA
1456 *
1457 *NOTE:
1458 *
1459 * @param pMac - Pointer to Global MAC structure
1460 * @return true - System is in Active state
1461 * false - System is not in Active state
1462 */
1463
1464tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1465{
1466 switch (pMac->pmm.gPmmState)
1467 {
1468 case ePMM_STATE_BMPS_WAKEUP:
1469 case ePMM_STATE_IMPS_WAKEUP:
1470 case ePMM_STATE_READY:
1471 // System is in Active mode
1472 return true;
1473 default:
1474 return false;
1475 // System is NOT in Active mode
1476 }
1477}
1478
1479
Jeff Johnson295189b2012-06-20 16:38:30 -07001480
Jeff Johnson295189b2012-06-20 16:38:30 -07001481
1482
1483/**
1484*\brief limReceivedHBHandler()
1485*
1486* This function is called by schBeaconProcess() upon
1487* receiving a Beacon on STA. This also gets called upon
1488* receiving Probe Response after heat beat failure is
1489* detected.
1490*
1491* param pMac - global mac structure
1492* param channel - channel number indicated in Beacon, Probe Response
1493* return - none
1494*/
1495
1496
1497void
1498limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1499{
1500 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1501 psessionEntry->LimRxedBeaconCntDuringHB++;
1502
1503 pMac->pmm.inMissedBeaconScenario = FALSE;
1504} /*** end limReceivedHBHandler() ***/
1505
1506
1507
1508#if 0
1509void limResetHBPktCount(tpPESession psessionEntry)
1510{
1511 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1512}
1513#endif
1514
1515
1516/*
1517 * limProcessWdsInfo()
1518 *
1519 *FUNCTION:
1520 * This function is called from schBeaconProcess in BP
1521 *
1522 *PARAMS:
1523 * @param pMac - Pointer to Global MAC structure
1524 * @param propIEInfo - proprietary IE info
1525 *
1526 *LOGIC:
1527 *
1528 *ASSUMPTIONS:
1529 * NA
1530 *
1531 *NOTE:
1532 *
1533 *
1534 *RETURNS:
1535 *
1536 */
1537
1538void limProcessWdsInfo(tpAniSirGlobal pMac,
1539 tSirPropIEStruct propIEInfo)
1540{
Jeff Johnson295189b2012-06-20 16:38:30 -07001541}
1542
1543
1544
1545/**
1546 * limInitWdsInfoParams()
1547 *
1548 *FUNCTION:
1549 * This function is called while processing
1550 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1551 * ind/set related parameters.
1552 *
1553 *LOGIC:
1554 *
1555 *ASSUMPTIONS:
1556 *
1557 *NOTE:
1558 *
1559 * @param pMac Pointer to Global MAC structure
1560 * @return None
1561 */
1562
1563void
1564limInitWdsInfoParams(tpAniSirGlobal pMac)
1565{
1566 pMac->lim.gLimWdsInfo.wdsLength = 0;
1567 pMac->lim.gLimNumWdsInfoInd = 0;
1568 pMac->lim.gLimNumWdsInfoSet = 0;
1569} /*** limInitWdsInfoParams() ***/
1570
1571
1572/** -------------------------------------------------------------
1573\fn limUpdateOverlapStaParam
1574\brief Updates overlap cache and param data structure
1575\param tpAniSirGlobal pMac
1576\param tSirMacAddr bssId
1577\param tpLimProtStaParams pStaParams
1578\return None
1579 -------------------------------------------------------------*/
1580void
1581limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1582{
1583 int i;
1584 if (!pStaParams->numSta)
1585 {
1586 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1587 bssId,
1588 sizeof(tSirMacAddr));
1589 pMac->lim.protStaOverlapCache[0].active = true;
1590
1591 pStaParams->numSta = 1;
1592
1593 return;
1594 }
1595
1596 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1597 {
1598 if (pMac->lim.protStaOverlapCache[i].active)
1599 {
1600 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
1601 bssId,
1602 sizeof(tSirMacAddr))) {
1603 return; }
1604 }
1605 else
1606 break;
1607 }
1608
1609 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1610 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001611 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 }
1613 else
1614 {
1615 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
1616 bssId,
1617 sizeof(tSirMacAddr));
1618 pMac->lim.protStaOverlapCache[i].active = true;
1619
1620 pStaParams->numSta++;
1621 }
1622}
1623
1624
1625/**
1626 * limHandleIBSScoalescing()
1627 *
1628 *FUNCTION:
1629 * This function is called upon receiving Beacon/Probe Response
1630 * while operating in IBSS mode.
1631 *
1632 *LOGIC:
1633 *
1634 *ASSUMPTIONS:
1635 *
1636 *NOTE:
1637 *
1638 * @param pMac - Pointer to Global MAC structure
1639 * @param pBeacon - Parsed Beacon Frame structure
1640 * @param pRxPacketInfo - Pointer to RX packet info structure
1641 *
1642 * @return Status whether to process or ignore received Beacon Frame
1643 */
1644
1645tSirRetStatus
1646limHandleIBSScoalescing(
1647 tpAniSirGlobal pMac,
1648 tpSchBeaconStruct pBeacon,
1649 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1650{
1651 tpSirMacMgmtHdr pHdr;
1652 tSirRetStatus retCode;
1653
1654 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1655 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
1656 /* Received SSID does not match => Ignore received Beacon frame. */
1657 retCode = eSIR_LIM_IGNORE_BEACON;
1658 else
1659 {
1660 tANI_U32 ieLen;
1661 tANI_U16 tsfLater;
1662 tANI_U8 *pIEs;
1663 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1664 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1665 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
1666 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
1667 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1668 }
1669 return retCode;
1670} /*** end limHandleIBSScoalescing() ***/
1671
1672
1673
1674/**
1675 * limDetectChangeInApCapabilities()
1676 *
1677 *FUNCTION:
1678 * This function is called while SCH is processing
1679 * received Beacon from AP on STA to detect any
1680 * change in AP's capabilities. If there any change
1681 * is detected, Roaming is informed of such change
1682 * so that it can trigger reassociation.
1683 *
1684 *LOGIC:
1685 *
1686 *ASSUMPTIONS:
1687 *
1688 *NOTE:
1689 * Notification is enabled for STA product only since
1690 * it is not a requirement on BP side.
1691 *
1692 * @param pMac Pointer to Global MAC structure
1693 * @param pBeacon Pointer to parsed Beacon structure
1694 * @return None
1695 */
1696
1697void
1698limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1699 tpSirProbeRespBeacon pBeacon,
1700 tpPESession psessionEntry)
1701{
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 tANI_U8 len;
1703 tSirSmeApNewCaps apNewCaps;
1704 tANI_U8 newChannel;
1705 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1706 newChannel = (tANI_U8) pBeacon->channelNumber;
1707
1708 if ((psessionEntry->limSentCapsChangeNtf == false) &&
1709 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
1710 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1711 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1712 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1713 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
1714 (newChannel != psessionEntry->currentOperChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 )))
1716 {
1717
1718 /**
1719 * BSS capabilities have changed.
1720 * Inform Roaming.
1721 */
1722 len = sizeof(tSirMacCapabilityInfo) +
1723 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1724 3 * sizeof(tANI_U8) + // reserved fields
1725 pBeacon->ssId.length + 1;
1726
1727 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
1728 psessionEntry->bssId,
1729 sizeof(tSirMacAddr));
1730 if (newChannel != psessionEntry->currentOperChannel)
1731 {
1732 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001733 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 psessionEntry->currentOperChannel, newChannel);)
1735 return;
1736 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301737
1738 /**
1739 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1740 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1741 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1742 * the privacy bit is set in Probe and association responses.
1743 * Due to this anomaly, we detect a change in
1744 * AP capabilities when we receive a beacon after association and
1745 * disconnect from the AP. The following check makes sure that we can
1746 * connect to such APs
1747 */
1748 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1749 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1750 {
1751 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001752 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301753 return;
1754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 else
1756 apNewCaps.channelId = psessionEntry->currentOperChannel;
1757 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
1758 (tANI_U8 *) &pBeacon->ssId,
1759 pBeacon->ssId.length + 1);
1760
1761 psessionEntry->limSentCapsChangeNtf = true;
1762 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1763 (tANI_U32 *) &apNewCaps,
1764 len, psessionEntry->smeSessionId);
1765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001766} /*** limDetectChangeInApCapabilities() ***/
1767
1768
1769
1770
1771// ---------------------------------------------------------------------
1772/**
1773 * limUpdateShortSlot
1774 *
1775 * FUNCTION:
1776 * Enable/Disable short slot
1777 *
1778 * LOGIC:
1779 *
1780 * ASSUMPTIONS:
1781 *
1782 * NOTE:
1783 *
1784 * @param enable Flag to enable/disable short slot
1785 * @return None
1786 */
1787
1788tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1789{
1790
1791 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07001792 tANI_U32 nShortSlot;
1793 tANI_U32 val = 0;
1794 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001795
Jeff Johnsone7245742012-09-05 17:12:55 -07001796 // Check Admin mode first. If it is disabled just return
1797 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
1798 != eSIR_SUCCESS)
1799 {
1800 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001801 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001802 return eSIR_FAILURE;
1803 }
1804 if (val == false)
1805 return eSIR_SUCCESS;
1806
1807 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
1808 limGetPhyMode(pMac, &phyMode, psessionEntry);
1809 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
1810 return eSIR_SUCCESS;
1811
1812 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813
1814 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
1815 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
1816 // if no erp present, use short slot based on current ap caps
1817
1818 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
1819
1820 //Resolution : always use the shortSlot setting the capability info to decide slot time.
1821 // The difference between the earlier implementation and the new one is only Case4.
1822 /*
1823 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1824 Case1 1 1 1 1 //AP should not advertise this combination.
1825 Case2 1 1 0 0
1826 Case3 1 0 1 1
1827 Case4 1 0 0 0
1828 Case5 0 1 1 1
1829 Case6 0 1 0 0
1830 Case7 0 0 1 1
1831 Case8 0 0 0 0
1832 */
1833 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1834
Jeff Johnsone7245742012-09-05 17:12:55 -07001835 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 {
1837 // Short slot time capability of AP has changed. Adopt to it.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001838 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07001840 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
1842 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 }
1844 return eSIR_SUCCESS;
1845}
1846
1847
Jeff Johnson295189b2012-06-20 16:38:30 -07001848
1849
Jeff Johnson295189b2012-06-20 16:38:30 -07001850
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
1852
1853/** -----------------------------------------------------------------
1854 \brief limHandleLowRssiInd() - handles low rssi indication
1855
1856 This function process the SIR_HAL_LOW_RSSI_IND message from
1857 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
1858
1859 \param pMac - global mac structure
1860
1861 \return
1862
1863 \sa
1864 ----------------------------------------------------------------- */
1865void limHandleLowRssiInd(tpAniSirGlobal pMac)
1866{
1867#if 0 //RSSI related indications will now go to TL and not PE
1868 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
1869 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
1870 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
1871 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001872 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
1874 }
1875 else
1876 {
1877 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001878 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 pMac->pmm.gPmmState);
1880 }
1881 return;
1882#endif
1883}
1884
1885
1886/** -----------------------------------------------------------------
1887 \brief limHandleBmpsStatusInd() - handles BMPS status indication
1888
1889 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
1890 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1891 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
1892
1893 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
1894 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
1895 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
1896 This message can also come from FW anytime after we have entered BMPS.
1897 This means we should handle it in WoWL and UAPSD states as well
1898
1899 \param pMac - global mac structure
1900 \return - none
1901 \sa
1902 ----------------------------------------------------------------- */
1903void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
1904{
1905 switch(pMac->pmm.gPmmState)
1906 {
1907 case ePMM_STATE_BMPS_SLEEP:
1908 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
1909 case ePMM_STATE_UAPSD_SLEEP:
1910 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
1911 case ePMM_STATE_WOWLAN:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001912 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
1914 break;
1915
1916 default:
1917 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001918 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 pMac->pmm.gPmmState);
1920 break;
1921 }
1922 return;
1923}
1924
1925
1926/** -----------------------------------------------------------------
1927 \brief limHandleMissedBeaconInd() - handles missed beacon indication
1928
1929 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
1930 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1931 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
1932
1933 \param pMac - global mac structure
1934 \return - none
1935 \sa
1936 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08001937void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07001938{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08001939#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
1940 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
1941 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
1942 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
1943 if (psessionEntry == NULL)
1944 {
1945 limLog(pMac, LOGE,
1946 FL("session does not exist for given BSSIdx:%d"),
1947 pSirMissedBeaconInd->bssIdx);
1948 return;
1949 }
1950#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
1952 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
1953 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
1954 {
1955 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001956 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
1958 }
Yathish9f22e662012-12-10 14:21:35 -08001959/* ACTIVE_MODE_HB_OFFLOAD */
1960#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
1961 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
1962 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
1963 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1964 {
1965 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001966 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08001967 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08001968 }
1969#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 else
1971 {
1972 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001973 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 pMac->pmm.gPmmState);
1975 }
1976 return;
1977}
1978
1979/** -----------------------------------------------------------------
1980 \brief limMicFailureInd() - handles mic failure indication
1981
1982 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
1983
1984 \param pMac - global mac structure
1985 \return - none
1986 \sa
1987 ----------------------------------------------------------------- */
1988void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1989{
1990 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
1991 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
1992 tSirMsgQ mmhMsg;
1993 tpPESession psessionEntry ;
1994 tANI_U8 sessionId;
1995
1996 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
1997 {
1998 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001999 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 return;
2001 }
2002
2003 if (eHAL_STATUS_SUCCESS !=
2004 palAllocateMemory(pMac->hHdd,
2005 (void **) &pSirSmeMicFailureInd,
2006 sizeof(tSirSmeMicFailureInd)))
2007 {
2008 // Log error
2009 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002010 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 return;
2012 }
2013
2014 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2015 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2016 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2017
2018 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2019 pSirMicFailureInd->bssId,
2020 sizeof(tSirMacAddr));
2021
2022 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2023 pSirMicFailureInd->info.srcMacAddr,
2024 sizeof(tSirMacAddr));
2025
2026 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2027 pSirMicFailureInd->info.taMacAddr,
2028 sizeof(tSirMacAddr));
2029
2030 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2031 pSirMicFailureInd->info.dstMacAddr,
2032 sizeof(tSirMacAddr));
2033
2034 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2035 pSirMicFailureInd->info.rxMacAddr,
2036 sizeof(tSirMacAddr));
2037
2038 pSirSmeMicFailureInd->info.multicast =
2039 pSirMicFailureInd->info.multicast;
2040
2041 pSirSmeMicFailureInd->info.keyId=
2042 pSirMicFailureInd->info.keyId;
2043
2044 pSirSmeMicFailureInd->info.IV1=
2045 pSirMicFailureInd->info.IV1;
2046
2047 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2048 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2049
2050 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2051 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2052 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002053 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2055 return;
2056}
2057
2058
2059/** -----------------------------------------------------------------
2060 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2061
2062 This function is called before enqueuing the frame to PE queue for further processing.
2063 This prevents unnecessary frames getting into PE Queue and drops them right away.
2064 Frames will be droped in the following scenarios:
2065
2066 - In Scan State, drop the frames which are not marked as scan frames
2067 - In non-Scan state, drop the frames which are marked as scan frames.
2068 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2069 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2070
2071 \param pMac - global mac structure
2072 \return - none
2073 \sa
2074 ----------------------------------------------------------------- */
2075
2076tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2077{
2078 tANI_U32 framelen;
2079 tANI_U8 *pBody;
2080 tSirMacCapabilityInfo capabilityInfo;
2081
2082 /*
2083 *
2084 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2085 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2086 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2087 * other than beacons or probe responses in scan state.
2088 */
2089 if( (subType == SIR_MAC_MGMT_BEACON) ||
2090 (subType == SIR_MAC_MGMT_PROBE_RSP))
2091 {
2092 if(pMac->pmm.inMissedBeaconScenario)
2093 {
Jeff Johnsonab79c8d2012-12-10 14:30:13 -08002094 PELOGE(limLog(pMac, LOGE, FL("Do not drop beacon and probe response - Missed beacon scenario"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 return eMGMT_DROP_NO_DROP;
2096 }
2097 if (limIsSystemInScanState(pMac))
2098 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002099 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 }
2101 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2102 {
2103 return eMGMT_DROP_SCAN_MODE_FRAME;
2104 }
2105 }
2106
2107 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2108 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2109
2110 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2111 * beacons from an infrastructure network
2112 */
2113 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2114 if(!capabilityInfo.ibss)
2115 return eMGMT_DROP_NO_DROP;
2116#if 0
2117 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2118 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2119 return eMGMT_DROP_NO_DROP;
2120#endif
2121
2122 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2123 if( (subType == SIR_MAC_MGMT_BEACON) ||
2124 (subType == SIR_MAC_MGMT_PROBE_RSP))
2125 {
2126 //drop the frame if length is less than 12
2127 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2128 return eMGMT_DROP_INVALID_SIZE;
2129
2130 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2131
2132 //This can be enhanced to even check the SSID before deciding to enque the frame.
2133 if(capabilityInfo.ess)
2134 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2135 }
2136 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2137 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2138 {
2139 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2140 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2141 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2142 }
2143
2144 return eMGMT_DROP_NO_DROP;
2145}
2146
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002147eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2148{
2149 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002150
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002151 if(psPe)
2152 {
2153 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2154 {
2155 status = eHAL_STATUS_SUCCESS;
2156 }
2157 }
2158 return (status);
2159}
2160eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2161{
2162 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2163 if(psPe)
2164 {
2165 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2166 {
2167 status = eHAL_STATUS_SUCCESS;
2168 }
2169 }
2170 return (status);
2171}