blob: e458129b581bf7ac3047606ee0bc8987a8f7582a [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
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700122#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
123
124 pMac->lim.gLimMlmLfrScanResultLength = 0;
125 pMac->lim.gLimSmeLfrScanResultLength = 0;
126
127 palZeroMemory(pMac->hHdd, pMac->lim.gLimCachedLfrScanHashTable,
128 sizeof(pMac->lim.gLimCachedLfrScanHashTable));
129#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 pMac->lim.gLimBackgroundScanChannelId = 0;
131 pMac->lim.gLimBackgroundScanStarted = 0;
132 pMac->lim.gLimRestoreCBNumScanInterval = LIM_RESTORE_CB_NUM_SCAN_INTERVAL_DEFAULT;
133 pMac->lim.gLimRestoreCBCount = 0;
134 palZeroMemory(pMac->hHdd, pMac->lim.gLimLegacyBssidList, sizeof(pMac->lim.gLimLegacyBssidList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136 /* Fill in default values */
137 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = 0;
138
Jeff Johnson295189b2012-06-20 16:38:30 -0700139
140 // abort scan is used to abort an on-going scan
141 pMac->lim.abortScan = 0;
142 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530143 palZeroMemory(pMac->hHdd, &pMac->lim.dfschannelList, sizeof(tSirDFSChannelList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145//WLAN_SUSPEND_LINK Related
146 pMac->lim.gpLimSuspendCallback = NULL;
147 pMac->lim.gpLimResumeCallback = NULL;
148//end WLAN_SUSPEND_LINK Related
149}
150
151
152static void __limInitBssVars(tpAniSirGlobal pMac)
153{
154
155 palZeroMemory(pMac->hHdd, (void*)pMac->lim.gpSession, sizeof(*pMac->lim.gpSession)*pMac->lim.maxBssId);
156
157
158 //pMac->lim.gpLimStartBssReq = NULL;
159
Jeff Johnson295189b2012-06-20 16:38:30 -0700160
161
162
163/* These global variables are moved to session table and intialization is done during session creation Oct 9th Review */
164#if 0
165
166 // Place holder for BSS description that we're
167 // currently joined with
168 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentBssId, sizeof(tSirMacAddr));
169 pMac->lim.gLimCurrentChannelId = HAL_INVALID_CHANNEL_ID;
170 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentSSID, sizeof(tSirMacSSid));
171 pMac->lim.gLimCurrentBssCaps = 0;
172 QosCaps is a bit map of various qos capabilities - see defn above
173 pMac->lim.gLimCurrentBssQosCaps = 0;
174 pMac->lim.gLimCurrentBssPropCap = 0;
175 pMac->lim.gLimSentCapsChangeNtf = 0;
176
177 // Place holder for BSS description that
178 // we're currently Reassociating
179 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocBssId, sizeof(tSirMacAddr));
180 pMac->lim.gLimReassocChannelId = 0;
181 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocSSID, sizeof(tSirMacSSid));
182 pMac->lim.gLimReassocBssCaps = 0;
183 pMac->lim.gLimReassocBssQosCaps = 0;
184 pMac->lim.gLimReassocBssPropCap = 0;
185 #endif
186
187 /* This is for testing purposes only, be default should always be off */
188 pMac->lim.gLimForceNoPropIE = 0;
189
190 // pMac->lim.gLimBssIdx = 0;
191
192 pMac->lim.gpLimMlmSetKeysReq = NULL;
193 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
194 // pMac->lim.gLimStaid = 0; //TO SUPPORT BT-AMP
195
196}
197
198
199static void __limInitStatsVars(tpAniSirGlobal pMac)
200{
201 pMac->lim.gLimNumBeaconsRcvd = 0;
202 pMac->lim.gLimNumBeaconsIgnored = 0;
203
204 pMac->lim.gLimNumDeferredMsgs = 0;
205
206 /// Variable to keep track of number of currently associated STAs
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800207 //pMac->lim.gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 pMac->lim.gLimNumOfAniSTAs = 0; // count of ANI peers
209
210 /// This indicates number of RXed Beacons during HB period
211 //pMac->lim.gLimRxedBeaconCntDuringHB = 0;
212
213 // Heart-Beat interval value
214 pMac->lim.gLimHeartBeatCount = 0;
215
216 // Statistics to keep track of no. beacons rcvd in heart beat interval
217 palZeroMemory(pMac->hHdd, pMac->lim.gLimHeartBeatBeaconStats, sizeof(pMac->lim.gLimHeartBeatBeaconStats));
218
219#ifdef WLAN_DEBUG
220 // Debug counters
221 pMac->lim.numTot = 0;
222 pMac->lim.numBbt = 0;
223 pMac->lim.numProtErr = 0;
224 pMac->lim.numLearn = 0;
225 pMac->lim.numLearnIgnore = 0;
226 pMac->lim.numSme = 0;
227 palZeroMemory(pMac->hHdd, pMac->lim.numMAC, sizeof(pMac->lim.numMAC));
228 pMac->lim.gLimNumAssocReqDropInvldState = 0;
229 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
230 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
231 pMac->lim.gLimNumReassocReqDropInvldState = 0;
232 pMac->lim.gLimNumHashMissIgnored = 0;
233 pMac->lim.gLimUnexpBcnCnt = 0;
234 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
235 pMac->lim.gLimNumLinkEsts = 0;
236 pMac->lim.gLimNumRxCleanup = 0;
237 pMac->lim.gLim11bStaAssocRejectCount = 0;
238#endif
239}
240
241
242
243static void __limInitStates(tpAniSirGlobal pMac)
244{
245 // Counts Heartbeat failures
246 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
247 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
248 pMac->lim.gLimHBfailureCntInOtherStates = 0;
249 pMac->lim.gLimRspReqd = 0;
250 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
251
252 /// MLM State visible across all Sirius modules
Jeff Johnsone7245742012-09-05 17:12:55 -0700253 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
255
256 /// Previous MLM State
257 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
258
259#ifdef GEN4_SCAN
260 // LIM to HAL SCAN Management Message Interface states
261 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
262#endif // GEN4_SCAN
263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 /**
Jeff Johnsone7245742012-09-05 17:12:55 -0700265 * Initialize state to eLIM_SME_OFFLINE_STATE
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700267 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700268
269 /**
270 * By default assume 'unknown' role. This will be updated
271 * when SME_START_BSS_REQ is received.
272 */
273
274 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11gParams, sizeof(tLimProtStaParams));
275 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11aParams, sizeof(tLimProtStaParams));
276 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapHt20Params, sizeof(tLimProtStaParams));
277 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapNonGfParams, sizeof(tLimProtStaParams));
278 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams));
279 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortSlotParams, sizeof(tLimNoShortSlotParams));
280
281 pMac->lim.gLimPhyMode = 0;
282 pMac->lim.scanStartTime = 0; // used to measure scan time
283
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 palZeroMemory(pMac->hHdd, pMac->lim.gLimMyMacAddr, sizeof(pMac->lim.gLimMyMacAddr));
285 pMac->lim.ackPolicy = 0;
286
287#if 0 /* Moving all these to session specific elements */
288 pMac->lim.gLimQosEnabled = 0; //11E
289 pMac->lim.gLimWmeEnabled = 0; //WME
290 pMac->lim.gLimWsmEnabled = 0; //WSM
291 pMac->lim.gLimHcfEnabled = 0;
292 pMac->lim.gLim11dEnabled = 0;
293#endif
294
295 pMac->lim.gLimProbeRespDisableFlag = 0; // control over probe response
296}
297
298static void __limInitVars(tpAniSirGlobal pMac)
299{
300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301
302 // Place holder for Measurement Req/Rsp/Ind related info
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
304 // WDS info
305 pMac->lim.gLimNumWdsInfoInd = 0;
306 pMac->lim.gLimNumWdsInfoSet = 0;
307 palZeroMemory(pMac->hHdd, &pMac->lim.gLimWdsInfo, sizeof(tSirWdsInfo));
308 /* initialize some parameters */
309 limInitWdsInfoParams(pMac);
310
311 // Deferred Queue Paramters
312 palZeroMemory(pMac->hHdd, &pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq));
313
314 // addts request if any - only one can be outstanding at any time
315 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq));
316 pMac->lim.gLimAddtsSent = 0;
317 pMac->lim.gLimAddtsRspTimerCount = 0;
318
319 //protection related config cache
320 palZeroMemory(pMac->hHdd, &pMac->lim.cfgProtection, sizeof(tCfgProtection));
321 pMac->lim.gLimProtectionControl = 0;
322 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAlternateRadio, sizeof(tSirAlternateRadioInfo));
323 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
324
Jeff Johnsone7245742012-09-05 17:12:55 -0700325#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 // 11h Spectrum Management Related Flag
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
328 pMac->sys.gSysEnableLearnMode = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700329#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 // WMM Related Flag
331 pMac->lim.gUapsdEnable = 0;
332 pMac->lim.gUapsdPerAcBitmask = 0;
333 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
334 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
335
336 // QoS-AC Downgrade: Initially, no AC is admitted
337 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
338 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
339
340 //dialogue token List head/tail for Action frames request sent.
341 pMac->lim.pDialogueTokenHead = NULL;
342 pMac->lim.pDialogueTokenTail = NULL;
343
344 palZeroMemory(pMac->hHdd, &pMac->lim.tspecInfo, sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX);
345
346 // admission control policy information
347 palZeroMemory(pMac->hHdd, &pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo));
348
349 pMac->lim.gLastBeaconDtimCount = 0;
350 pMac->lim.gLastBeaconDtimPeriod = 0;
351
352 //Scan in Power Save Flag
353 pMac->lim.gScanInPowersave = 0;
354}
355
356static void __limInitAssocVars(tpAniSirGlobal pMac)
357{
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800358 tANI_U32 val;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800359#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 palZeroMemory(pMac->hHdd, pMac->lim.gpLimAIDpool,
361 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1));
362 pMac->lim.freeAidHead = 0;
363 pMac->lim.freeAidTail = 0;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800364#endif
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800365 if(wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS)
366 {
367 limLog( pMac, LOGP, FL( "cfg get assoc sta limit failed" ));
368 }
369 pMac->lim.gLimAssocStaLimit = val;
Jeff Johnson295189b2012-06-20 16:38:30 -0700370
371 // Place holder for current authentication request
372 // being handled
373 pMac->lim.gpLimMlmAuthReq = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -0700374 //pMac->lim.gpLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
376 /// MAC level Pre-authentication related globals
377 pMac->lim.gLimPreAuthChannelNumber = 0;
378 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
379 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr));
380 pMac->lim.gLimNumPreAuthContexts = 0;
381 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable));
382
383 // Placed holder to deauth reason
384 pMac->lim.gLimDeauthReasonCode = 0;
385
386 // Place holder for Pre-authentication node list
387 pMac->lim.pLimPreAuthList = NULL;
388
389 // Send Disassociate frame threshold parameters
390 pMac->lim.gLimDisassocFrameThreshold = LIM_SEND_DISASSOC_FRAME_THRESHOLD;
391 pMac->lim.gLimDisassocFrameCredit = 0;
392
393 //One cache for each overlap and associated case.
394 palZeroMemory(pMac->hHdd, pMac->lim.protStaOverlapCache, sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE);
395 palZeroMemory(pMac->hHdd, pMac->lim.protStaCache, sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE);
396
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -0700397#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
398 pMac->lim.pSessionEntry = NULL;
399 pMac->lim.reAssocRetryAttempt = 0;
400#endif
401
Jeff Johnson295189b2012-06-20 16:38:30 -0700402}
403
404
405static void __limInitTitanVars(tpAniSirGlobal pMac)
406{
Jeff Johnsone7245742012-09-05 17:12:55 -0700407#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 palZeroMemory(pMac->hHdd, &pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700410 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
411#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 // Debug workaround for BEACON's
413 // State change triggered by "dump 222"
414 pMac->lim.gLimScanOverride = 1;
415 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 pMac->lim.gLimTitanStaCount = 0;
417 pMac->lim.gLimBlockNonTitanSta = 0;
418}
419
420static void __limInitHTVars(tpAniSirGlobal pMac)
421{
422 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 pMac->lim.gHTShortGI40Mhz = 0;
425 pMac->lim.gHTShortGI20Mhz = 0;
426 pMac->lim.gHTMaxAmsduLength = 0;
427 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
428 pMac->lim.gHTPSMPSupport = 0;
429 pMac->lim.gHTLsigTXOPProtection = 0;
430 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
431 pMac->lim.gHTAMpduDensity = 0;
432
433 pMac->lim.gMaxAmsduSizeEnabled = false;
434 pMac->lim.gHTMaxRxAMpduFactor = 0;
435 pMac->lim.gHTServiceIntervalGranularity = 0;
436 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700437 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
438 pMac->lim.gHTPCOActive = 0;
439
440 pMac->lim.gHTPCOPhase = 0;
441 pMac->lim.gHTSecondaryBeacon = 0;
442 pMac->lim.gHTDualCTSProtection = 0;
443 pMac->lim.gHTSTBCBasicMCS = 0;
444 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
445}
446
Jeff Johnson295189b2012-06-20 16:38:30 -0700447static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
448{
Jeff Johnsone7245742012-09-05 17:12:55 -0700449 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 tANI_U16 val16;
451 tANI_U8 val8;
452 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
453 tSirMacHTInfoField1 *pHTInfoField1;
454 tpSirPowerSaveCfg pPowerSaveConfig;
455 tSirMacHTParametersInfo *pAmpduParamInfo;
456
457 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700458 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
459 * and they will be used throughout when there is no session
460 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
463 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700464 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 return eSIR_FAILURE;
466 }
467
468 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
469 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700470 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return eSIR_FAILURE;
472 }
473 val16 = ( tANI_U16 ) val1;
474 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
475
476 //channel bonding mode could be set to anything from 0 to 4(Titan had these
477 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
478 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
479 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
480 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
481 != eSIR_SUCCESS)
482 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700483 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 return eSIR_FAILURE;
485 }
486
487 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
488 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700489 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 return eSIR_FAILURE;
491 }
492
493 val8 = ( tANI_U8 ) val1;
494 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
495 pHTInfoField1->recommendedTxWidthSet =
496 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
498 != eSIR_SUCCESS)
499 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700500 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 return eSIR_FAILURE;
502 }
503
504 /* WNI_CFG_HEART_BEAT_THRESHOLD */
505
506 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
507 eSIR_SUCCESS )
508 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700509 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 return eSIR_FAILURE;
511 }
512 if(!val1)
513 {
514 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
515 pMac->sys.gSysEnableLinkMonitorMode = 0;
516 }
517 else
518 {
519 //No need to activate the timer during init time.
520 pMac->sys.gSysEnableLinkMonitorMode = 1;
521 }
522
523 /* WNI_CFG_SHORT_GI_20MHZ */
524
525 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
526 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700527 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 return eSIR_FAILURE;
529 }
530 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
531 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700532 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 return eSIR_FAILURE;
534 }
535 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
536 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700537 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 return eSIR_FAILURE;
539 }
540
541 val16 = ( tANI_U16 ) val1;
542 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
543 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
544 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
545
546 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
547 eSIR_SUCCESS)
548 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700549 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 return eSIR_FAILURE;
551 }
552
553 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
554
555 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
556 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700557 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 return eSIR_FAILURE;
559 }
560 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
561 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700562 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 return eSIR_FAILURE;
564 }
565 val16 = ( tANI_U16 ) val1;
566 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
567 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
568 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
569 eSIR_SUCCESS)
570 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700571 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 return eSIR_FAILURE;
573 }
574
575 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
576 limHandleCFGparamUpdate do we want to update this? */
577 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
578 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700579 limLog(pMac, LOGP, FL("cfg get short preamble failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 return eSIR_FAILURE;
581 }
582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 /* WNI_CFG_MAX_PS_POLL */
584
585 /* Allocate and fill in power save configuration. */
586 if (palAllocateMemory(pMac->hHdd, (void **)&pPowerSaveConfig,
587 sizeof(tSirPowerSaveCfg)) != eHAL_STATUS_SUCCESS)
588 {
589 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700590 "configuration"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 return eSIR_FAILURE;
592 }
593
594 /* This context should be valid if power-save configuration message has been
595 * already dispatched during initialization process. Re-using the present
596 * configuration mask
597 */
598 palCopyMemory(pMac->hHdd, pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg,
599 sizeof(tSirPowerSaveCfg));
600
601 /* Note: it is okay to do this since DAL/HAL is alrady started */
602 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
603 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700604 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 return eSIR_FAILURE;
606 }
607
608 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
609
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700611 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 pMac->lim.gLimBackgroundScanChannelId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700613
614 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
615
616 /* This was initially done after resume notification from HAL. Now, DAL is
617 started before PE so this can be done here */
Jeff Johnsone7245742012-09-05 17:12:55 -0700618 handleHTCapabilityandHTInfo(pMac, NULL);
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800619 if(wlan_cfgGetInt(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,(tANI_U32 *) &pMac->lim.disableLDPCWithTxbfAP) != eSIR_SUCCESS)
620 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700621 limLog(pMac, LOGP, FL("cfg get disableLDPCWithTxbfAP failed"));
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800622 return eSIR_FAILURE;
623 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700624
625 return eSIR_SUCCESS;
626}
Jeff Johnson295189b2012-06-20 16:38:30 -0700627
628/*
629 limStart
630 This function is to replace the __limProcessSmeStartReq since there is no
631 eWNI_SME_START_REQ post to PE.
632*/
633tSirRetStatus limStart(tpAniSirGlobal pMac)
634{
635 tSirResultCodes retCode = eSIR_SUCCESS;
636
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700637 PELOG1(limLog(pMac, LOG1, FL(" enter"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700638
639 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
640 {
641 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
642
Jeff Johnsone7245742012-09-05 17:12:55 -0700643 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700644
645 // By default do not return after first scan match
646 pMac->lim.gLimReturnAfterFirstMatch = 0;
647
648 // Initialize MLM state machine
649 limInitMlm(pMac);
650
651 // By default return unique scan results
652 pMac->lim.gLimReturnUniqueResults = true;
653 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700654#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
655 pMac->lim.gLimSmeLfrScanResultLength = 0;
656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 }
658 else
659 {
660 /**
661 * Should not have received eWNI_SME_START_REQ in states
662 * other than OFFLINE. Return response to host and
663 * log error
664 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700665 limLog(pMac, LOGE, FL("Invalid SME state %X"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 retCode = eSIR_FAILURE;
667 }
668
669 return retCode;
670}
671
672/**
673 * limInitialize()
674 *
675 *FUNCTION:
676 * This function is called from LIM thread entry function.
677 * LIM related global data structures are initialized in this function.
678 *
679 *LOGIC:
680 * NA
681 *
682 *ASSUMPTIONS:
683 * NA
684 *
685 *NOTE:
686 * NA
687 *
688 * @param pMac - Pointer to global MAC structure
689 * @return None
690 */
691
692tSirRetStatus
693limInitialize(tpAniSirGlobal pMac)
694{
695 tSirRetStatus status = eSIR_SUCCESS;
696
697 __limInitAssocVars(pMac);
698 __limInitVars(pMac);
699 __limInitStates(pMac);
700 __limInitStatsVars(pMac);
701 __limInitBssVars(pMac);
702 __limInitScanVars(pMac);
703 __limInitHTVars(pMac);
704 __limInitTitanVars(pMac);
705
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 status = limStart(pMac);
707 if(eSIR_SUCCESS != status)
708 {
709 return status;
710 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700711
712 /*
713 * MLM will be intitalized when 'START' request comes from SME.
714 * limInitMlm calls limCreateTimers, which actually relies on
715 * CFG to be downloaded. So it should not be called as part of
716 * peStart, as CFG download is happening after peStart.
717 */
718 //limInitMlm(pMac);
719 // Initializations for maintaining peers in IBSS
720 limIbssInit(pMac);
721
722 pmmInitialize(pMac);
723
724
725#if defined WLAN_FEATURE_VOWIFI
726 rrmInitialize(pMac);
727#endif
728#if defined WLAN_FEATURE_VOWIFI_11R
729 limFTOpen(pMac);
730#endif
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733
734#if 0
735
736 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
737 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
738 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
739
740 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
741 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
742
743 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
744 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
745 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
746
747 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
748
749 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
750
751 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
752 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
753
754 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
755
756
757 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
758
759 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
760#endif
761 MTRACE(limTraceInit(pMac));
762
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 //Initialize the configurations needed by PE
764 if( eSIR_FAILURE == __limInitConfig(pMac))
765 {
766 //We need to undo everything in limStart
767 limCleanupMlm(pMac);
768 return eSIR_FAILURE;
769 }
770
771 //initialize the TSPEC admission control table.
772 //Note that this was initially done after resume notification from HAL.
773 //Now, DAL is started before PE so this can be done here
774 limAdmitControlInit(pMac);
775 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700776
777 return status;
778
779} /*** end limInitialize() ***/
780
781
782
783/**
784 * limCleanup()
785 *
786 *FUNCTION:
787 * This function is called upon reset or persona change
788 * to cleanup LIM state
789 *
790 *LOGIC:
791 * NA
792 *
793 *ASSUMPTIONS:
794 * NA
795 *
796 *NOTE:
797 * NA
798 *
799 * @param pMac - Pointer to Global MAC structure
800 * @return None
801 */
802
803void
804limCleanup(tpAniSirGlobal pMac)
805{
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 v_PVOID_t pvosGCTx;
807 VOS_STATUS retStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809//Before destroying the list making sure all the nodes have been deleted.
810//Which should be the normal case, but a memory leak has been reported.
811
812 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
813
814 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
815 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
816 {
817 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
818 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
819
820 palFreeMemory(pMac, pLimMgmtRegistration);
821 }
822
823 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824
825 limCleanupMlm(pMac);
826 limCleanupLmm(pMac);
827
828 // free up preAuth table
829 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
830 {
831 palFreeMemory(pMac->hHdd, pMac->lim.gLimPreAuthTimerTable.pTable);
832 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
833 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
834 }
835
836 if(NULL != pMac->lim.pDialogueTokenHead)
837 {
838 limDeleteDialogueTokenList(pMac);
839 }
840
841 if(NULL != pMac->lim.pDialogueTokenTail)
842 {
843 palFreeMemory(pMac->hHdd, (void *) pMac->lim.pDialogueTokenTail);
844 pMac->lim.pDialogueTokenTail = NULL;
845 }
846
847 # if 0
848 if (pMac->lim.gpLimStartBssReq != NULL)
849 {
850 palFreeMemory(pMac->hHdd, pMac->lim.gpLimStartBssReq);
851 pMac->lim.gpLimStartBssReq = NULL;
852 }
853 #endif
854
855 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
856 {
857 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmSetKeysReq);
858 pMac->lim.gpLimMlmSetKeysReq = NULL;
859 }
860
861 #if 0
862 if (pMac->lim.gpLimJoinReq != NULL)
863 {
864 palFreeMemory(pMac->hHdd, pMac->lim.gpLimJoinReq);
865 pMac->lim.gpLimJoinReq = NULL;
866 }
867 #endif
868
869 if (pMac->lim.gpLimMlmAuthReq != NULL)
870 {
871 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
872 pMac->lim.gpLimMlmAuthReq = NULL;
873 }
874
Jeff Johnsone7245742012-09-05 17:12:55 -0700875#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 if (pMac->lim.gpLimMlmJoinReq != NULL)
877 {
878 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
879 pMac->lim.gpLimMlmJoinReq = NULL;
880 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700881#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700882
883 #if 0
884 if (pMac->lim.gpLimReassocReq != NULL)
885 {
886 palFreeMemory(pMac->hHdd, pMac->lim.gpLimReassocReq);
887 pMac->lim.gpLimReassocReq = NULL;
888 }
889 #endif
890
891 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
892 {
893 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmRemoveKeyReq);
894 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
895 }
896
Viral Modid440e682013-03-06 02:25:31 -0800897 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
Viral Modid86bde22012-12-10 13:09:21 -0800898 {
Viral Modid440e682013-03-06 02:25:31 -0800899 palFreeMemory(pMac->hHdd, pMac->lim.gpDefdSmeMsgForNOA);
900 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800901 }
Viral Modid86bde22012-12-10 13:09:21 -0800902
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 if (pMac->lim.gpLimMlmScanReq != NULL)
904 {
905 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmScanReq);
906 pMac->lim.gpLimMlmScanReq = NULL;
907 }
908
909#if 0
910 if(NULL != pMac->lim.beacon)
911 {
912 palFreeMemory(pMac->hHdd, (void*) pMac->lim.beacon);
913 pMac->lim.beacon = NULL;
914 }
915#endif
916 #if 0
917 if(NULL != pMac->lim.assocReq)
918 {
919 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocReq);
920 pMac->lim.assocReq= NULL;
921 }
922 #endif
923
924#if 0
925 if(NULL != pMac->lim.assocRsp)
926 {
927 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocRsp);
928 pMac->lim.assocRsp= NULL;
929 }
930#endif
931 // Now, finally reset the deferred message queue pointers
932 limResetDeferredMsgQ(pMac);
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934
935 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
936 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
937
938 if ( retStatus != VOS_STATUS_SUCCESS )
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700939 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700940
941#if defined WLAN_FEATURE_VOWIFI
942 rrmCleanup(pMac);
943#endif
944#if defined WLAN_FEATURE_VOWIFI_11R
945 limFTCleanup(pMac);
946#endif
947
948} /*** end limCleanup() ***/
949
950
951/** -------------------------------------------------------------
952\fn peOpen
953\brief will be called in Open sequence from macOpen
954\param tpAniSirGlobal pMac
955\param tHalOpenParameters *pHalOpenParam
956\return tSirRetStatus
957 -------------------------------------------------------------*/
958
959tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
960{
961 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
962 pMac->lim.maxStation = pMacOpenParam->maxStation;
963
964 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
965 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700966 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 return eSIR_FAILURE;
968 }
969
970 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
971 (void **) &pMac->lim.limTimers.gpLimCnfWaitTimer, sizeof(TX_TIMER)*pMac->lim.maxStation))
972 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700973 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 return eSIR_FAILURE;
975 }
976
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800977#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
979 (void **) &pMac->lim.gpLimAIDpool,
980 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1)))
981 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700982 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 return eSIR_FAILURE;
984 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800985#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
987 (void **) &pMac->lim.gpSession, sizeof(tPESession)* pMac->lim.maxBssId))
988 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700989 limLog(pMac, LOGE, FL("memory allocate failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 return eSIR_FAILURE;
991 }
992
993 palZeroMemory(pMac->hHdd, pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId);
994
995
996 /*
997 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
998 (void **) &pMac->dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*pMac->lim.maxStation))
999 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001000 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 return eSIR_FAILURE;
1002 }
1003
1004 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1005 (void **) &pMac->dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*pMac->lim.maxStation))
1006 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001007 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 return eSIR_FAILURE;
1009 }
1010 */
1011
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1013 (void **) &pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation))
1014 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001015 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 return eSIR_FAILURE;
1017 }
1018 palZeroMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation);
Jeff Johnson295189b2012-06-20 16:38:30 -07001019
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001020 pMac->lim.mgmtFrameSessionId = 0xff;
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001021 pMac->lim.deferredMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001023 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1024 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001025 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!"));)
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001026 return eSIR_FAILURE;
1027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 return eSIR_SUCCESS;
1029}
1030
1031/** -------------------------------------------------------------
1032\fn peClose
1033\brief will be called in close sequence from macClose
1034\param tpAniSirGlobal pMac
1035\return tSirRetStatus
1036 -------------------------------------------------------------*/
1037
1038tSirRetStatus peClose(tpAniSirGlobal pMac)
1039{
1040 tANI_U8 i;
1041
1042 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1043 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001044
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 for(i =0; i < pMac->lim.maxBssId; i++)
1046 {
1047 if(pMac->lim.gpSession[i].valid == TRUE)
1048 {
1049 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1050 }
1051 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001052 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1053 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001054#if 0
Jeff Johnsone7245742012-09-05 17:12:55 -07001055 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1056 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001057#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001058
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1060 pMac->lim.gpSession = NULL;
1061 /*
1062 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1063 pMac->dph.dphHashTable.pHashTable = NULL;
1064 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1065 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1066 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1068 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001069 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1070 {
1071 return eSIR_FAILURE;
1072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 return eSIR_SUCCESS;
1074}
1075
1076/** -------------------------------------------------------------
1077\fn peStart
1078\brief will be called in start sequence from macStart
1079\param tpAniSirGlobal pMac
1080\return none
1081 -------------------------------------------------------------*/
1082
1083tSirRetStatus peStart(tpAniSirGlobal pMac)
1084{
1085 tSirRetStatus status = eSIR_SUCCESS;
1086
1087 status = limInitialize(pMac);
1088#if defined(ANI_LOGDUMP)
1089 limDumpInit(pMac);
1090#endif //#if defined(ANI_LOGDUMP)
1091
1092 return status;
1093}
1094
1095/** -------------------------------------------------------------
1096\fn peStop
1097\brief will be called in stop sequence from macStop
1098\param tpAniSirGlobal pMac
1099\return none
1100 -------------------------------------------------------------*/
1101
1102void peStop(tpAniSirGlobal pMac)
1103{
1104 limCleanup(pMac);
1105 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1106 return;
1107}
1108
1109/** -------------------------------------------------------------
1110\fn peFreeMsg
1111\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1112\ to free a given PE message on the TX and MC thread.
1113\ This happens when there are messages pending in the PE
1114\ queue when system is being stopped and reset.
1115\param tpAniSirGlobal pMac
1116\param tSirMsgQ pMsg
1117\return none
1118-----------------------------------------------------------------*/
1119v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1120{
1121 if (pMsg != NULL)
1122 {
1123 if (NULL != pMsg->bodyptr)
1124 {
1125 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1126 {
1127 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1128 }
1129 else
1130 {
1131 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1132 }
1133 }
1134 pMsg->bodyptr = 0;
1135 pMsg->bodyval = 0;
1136 pMsg->type = 0;
1137 }
1138 return;
1139}
1140
1141
1142/**
1143 * The function checks if a particular timer should be allowed
1144 * into LIM while device is sleeping
1145 */
1146tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1147{
1148 tANI_U8 retStatus = TRUE;
1149
1150 if(!limIsSystemInActiveState(pMac))
1151 {
1152 switch(pMsg->type)
1153 {
1154 /* Don't allow following timer messages if in sleep */
1155 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1156 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1157 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1158 retStatus = FALSE;
1159 break;
1160 /* May allow following timer messages in sleep mode */
1161 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1162
1163 /* Safe to allow as of today, this triggers background scan
1164 * which will not be started if the device is in power-save mode
1165 * might need to block in the future if we decide to implement
1166 * spectrum management
1167 */
1168 case SIR_LIM_QUIET_TIMEOUT:
1169
1170 /* Safe to allow as of today, this triggers background scan
1171 * which will not be started if the device is in power-save mode
1172 * might need to block in the future if we decide to implement
1173 * spectrum management
1174 */
1175 case SIR_LIM_QUIET_BSS_TIMEOUT:
1176
1177 /* Safe to allow this timermessage, triggers background scan
1178 * which is blocked in sleep mode
1179 */
1180 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1181
1182 /* Safe to allow this timer, since, while in IMPS this timer will not
1183 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1184 * when heart-beat control is handled back to PE, device would have
1185 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1186 */
1187 case SIR_LIM_HEART_BEAT_TIMEOUT:
1188 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1189
1190 /* Safe to allow, PE is not handling this message as of now. May need
1191 * to block it, basically, free the buffer and restart the timer
1192 */
1193 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1194 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001195 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1197 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1198 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1199 retStatus = TRUE;
1200 break;
1201
1202 /* by default allow rest of messages */
1203 default:
1204 retStatus = TRUE;
1205 break;
1206
1207
1208 }
1209 }
1210
1211 return retStatus;
1212
1213}
1214
1215
1216
1217/**
1218 * limPostMsgApi()
1219 *
1220 *FUNCTION:
1221 * This function is called from other thread while posting a
1222 * message to LIM message Queue gSirLimMsgQ.
1223 *
1224 *LOGIC:
1225 * NA
1226 *
1227 *ASSUMPTIONS:
1228 * NA
1229 *
1230 *NOTE:
1231 * NA
1232 *
1233 * @param pMac - Pointer to Global MAC structure
1234 * @param pMsg - Pointer to the message structure
1235 * @return None
1236 */
1237
1238tANI_U32
1239limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1240{
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1242
1243
Jeff Johnson295189b2012-06-20 16:38:30 -07001244} /*** end limPostMsgApi() ***/
1245
1246
1247/*--------------------------------------------------------------------------
1248
1249 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1250
1251 This function can be called by legacy code to post message to voss queues OR
1252 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1253 for dispatching it later.
1254
1255 \param pMac - Pointer to Global MAC structure
1256 \param pMsg - Pointer to the message structure
1257
1258 \return tANI_U32 - TX_SUCCESS for success.
1259
1260 --------------------------------------------------------------------------*/
1261
1262tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1263{
1264 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1265}
1266
1267/*--------------------------------------------------------------------------
1268
1269 \brief peProcessMessages() - Message Processor for PE
1270
1271 Voss calls this function to dispatch the message to PE
1272
1273 \param pMac - Pointer to Global MAC structure
1274 \param pMsg - Pointer to the message structure
1275
1276 \return tANI_U32 - TX_SUCCESS for success.
1277
1278 --------------------------------------------------------------------------*/
1279
1280tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1281{
1282 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1283 {
1284 return eSIR_SUCCESS;
1285 }
1286 /**
1287 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1288 * for all the other cases post it to LIM
1289 */
1290 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1291 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1292 else
1293 limMessageProcessor(pMac, pMsg);
1294 return eSIR_SUCCESS;
1295}
1296
1297
Jeff Johnson295189b2012-06-20 16:38:30 -07001298
1299// ---------------------------------------------------------------------------
1300/**
1301 * peHandleMgmtFrame
1302 *
1303 * FUNCTION:
1304 * Process the Management frames from TL
1305 *
1306 * LOGIC:
1307 *
1308 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1309 *
1310 * NOTE:
1311 *
1312 * @param pvosGCtx Global Vos Context
1313 * @param vossBuff Packet
1314 * @return None
1315 */
1316
1317VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1318{
1319 tpAniSirGlobal pMac;
1320 tpSirMacMgmtHdr mHdr;
1321 tSirMsgQ msg;
1322 vos_pkt_t *pVosPkt;
1323 VOS_STATUS vosStatus;
1324 v_U8_t *pRxPacketInfo;
1325
1326 pVosPkt = (vos_pkt_t *)vosBuff;
1327 if (NULL == pVosPkt)
1328 {
1329 return VOS_STATUS_E_FAILURE;
1330 }
1331
1332 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1333 if (NULL == pMac)
1334 {
1335 // cannot log a failure without a valid pMac
1336 vos_pkt_return_packet(pVosPkt);
1337 return VOS_STATUS_E_FAILURE;
1338 }
1339
1340 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1341
1342 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1343 {
1344 vos_pkt_return_packet(pVosPkt);
1345 return VOS_STATUS_E_FAILURE;
1346 }
1347
1348
1349 //
1350 // The MPDU header is now present at a certain "offset" in
1351 // the BD and is specified in the BD itself
1352 //
1353 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1354 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1355 {
1356 PELOG1(limLog( pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001357 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001358 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
Jeff Johnsone7245742012-09-05 17:12:55 -07001360 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1362 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1363 }
1364
1365
1366 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1367 msg.type = SIR_BB_XPORT_MGMT_MSG;
1368 msg.bodyptr = vosBuff;
1369 msg.bodyval = 0;
1370
1371 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1372 &msg,
1373 mHdr->fc.type,
1374 mHdr->fc.subType ))
1375 {
1376 vos_pkt_return_packet(pVosPkt);
1377 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001378 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 return VOS_STATUS_E_FAILURE;
1380 }
1381
1382 return VOS_STATUS_SUCCESS;
1383}
1384
1385// ---------------------------------------------------------------------------
1386/**
1387 * peRegisterTLHandle
1388 *
1389 * FUNCTION:
1390 * Registers the Handler which, process the Management frames from TL
1391 *
1392 * LOGIC:
1393 *
1394 * ASSUMPTIONS:
1395 *
1396 * NOTE:
1397 *
1398 * @return None
1399 */
1400
1401void peRegisterTLHandle(tpAniSirGlobal pMac)
1402{
1403 v_PVOID_t pvosGCTx;
1404 VOS_STATUS retStatus;
1405
1406 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1407
1408 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1409
1410 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001411 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001412
1413}
Jeff Johnson295189b2012-06-20 16:38:30 -07001414
1415
1416/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 * limIsSystemInScanState()
1418 *
1419 *FUNCTION:
1420 * This function is called by various MAC software modules to
1421 * determine if System is in Scan/Learn state
1422 *
1423 *LOGIC:
1424 * NA
1425 *
1426 *ASSUMPTIONS:
1427 * NA
1428 *
1429 *NOTE:
1430 *
1431 * @param pMac - Pointer to Global MAC structure
1432 * @return true - System is in Scan/Learn state
1433 * false - System is NOT in Scan/Learn state
1434 */
1435
1436tANI_U8
1437limIsSystemInScanState(tpAniSirGlobal pMac)
1438{
1439 switch (pMac->lim.gLimSmeState)
1440 {
1441 case eLIM_SME_CHANNEL_SCAN_STATE:
1442 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1443 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1444 case eLIM_SME_WT_SCAN_STATE:
1445 // System is in Learn mode
1446 return true;
1447
1448 default:
1449 // System is NOT in Learn mode
1450 return false;
1451 }
1452} /*** end limIsSystemInScanState() ***/
1453
1454
1455
1456/**
1457 * limIsSystemInActiveState()
1458 *
1459 *FUNCTION:
1460 * This function is called by various MAC software modules to
1461 * determine if System is in Active/Wakeup state
1462 *
1463 *LOGIC:
1464 * NA
1465 *
1466 *ASSUMPTIONS:
1467 * NA
1468 *
1469 *NOTE:
1470 *
1471 * @param pMac - Pointer to Global MAC structure
1472 * @return true - System is in Active state
1473 * false - System is not in Active state
1474 */
1475
1476tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1477{
1478 switch (pMac->pmm.gPmmState)
1479 {
1480 case ePMM_STATE_BMPS_WAKEUP:
1481 case ePMM_STATE_IMPS_WAKEUP:
1482 case ePMM_STATE_READY:
1483 // System is in Active mode
1484 return true;
1485 default:
1486 return false;
1487 // System is NOT in Active mode
1488 }
1489}
1490
1491
Jeff Johnson295189b2012-06-20 16:38:30 -07001492
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
1494
1495/**
1496*\brief limReceivedHBHandler()
1497*
1498* This function is called by schBeaconProcess() upon
1499* receiving a Beacon on STA. This also gets called upon
1500* receiving Probe Response after heat beat failure is
1501* detected.
1502*
1503* param pMac - global mac structure
1504* param channel - channel number indicated in Beacon, Probe Response
1505* return - none
1506*/
1507
1508
1509void
1510limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1511{
1512 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1513 psessionEntry->LimRxedBeaconCntDuringHB++;
1514
1515 pMac->pmm.inMissedBeaconScenario = FALSE;
1516} /*** end limReceivedHBHandler() ***/
1517
1518
1519
1520#if 0
1521void limResetHBPktCount(tpPESession psessionEntry)
1522{
1523 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1524}
1525#endif
1526
1527
1528/*
1529 * limProcessWdsInfo()
1530 *
1531 *FUNCTION:
1532 * This function is called from schBeaconProcess in BP
1533 *
1534 *PARAMS:
1535 * @param pMac - Pointer to Global MAC structure
1536 * @param propIEInfo - proprietary IE info
1537 *
1538 *LOGIC:
1539 *
1540 *ASSUMPTIONS:
1541 * NA
1542 *
1543 *NOTE:
1544 *
1545 *
1546 *RETURNS:
1547 *
1548 */
1549
1550void limProcessWdsInfo(tpAniSirGlobal pMac,
1551 tSirPropIEStruct propIEInfo)
1552{
Jeff Johnson295189b2012-06-20 16:38:30 -07001553}
1554
1555
1556
1557/**
1558 * limInitWdsInfoParams()
1559 *
1560 *FUNCTION:
1561 * This function is called while processing
1562 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1563 * ind/set related parameters.
1564 *
1565 *LOGIC:
1566 *
1567 *ASSUMPTIONS:
1568 *
1569 *NOTE:
1570 *
1571 * @param pMac Pointer to Global MAC structure
1572 * @return None
1573 */
1574
1575void
1576limInitWdsInfoParams(tpAniSirGlobal pMac)
1577{
1578 pMac->lim.gLimWdsInfo.wdsLength = 0;
1579 pMac->lim.gLimNumWdsInfoInd = 0;
1580 pMac->lim.gLimNumWdsInfoSet = 0;
1581} /*** limInitWdsInfoParams() ***/
1582
1583
1584/** -------------------------------------------------------------
1585\fn limUpdateOverlapStaParam
1586\brief Updates overlap cache and param data structure
1587\param tpAniSirGlobal pMac
1588\param tSirMacAddr bssId
1589\param tpLimProtStaParams pStaParams
1590\return None
1591 -------------------------------------------------------------*/
1592void
1593limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1594{
1595 int i;
1596 if (!pStaParams->numSta)
1597 {
1598 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1599 bssId,
1600 sizeof(tSirMacAddr));
1601 pMac->lim.protStaOverlapCache[0].active = true;
1602
1603 pStaParams->numSta = 1;
1604
1605 return;
1606 }
1607
1608 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1609 {
1610 if (pMac->lim.protStaOverlapCache[i].active)
1611 {
1612 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
1613 bssId,
1614 sizeof(tSirMacAddr))) {
1615 return; }
1616 }
1617 else
1618 break;
1619 }
1620
1621 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1622 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001623 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 }
1625 else
1626 {
1627 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
1628 bssId,
1629 sizeof(tSirMacAddr));
1630 pMac->lim.protStaOverlapCache[i].active = true;
1631
1632 pStaParams->numSta++;
1633 }
1634}
1635
1636
1637/**
1638 * limHandleIBSScoalescing()
1639 *
1640 *FUNCTION:
1641 * This function is called upon receiving Beacon/Probe Response
1642 * while operating in IBSS mode.
1643 *
1644 *LOGIC:
1645 *
1646 *ASSUMPTIONS:
1647 *
1648 *NOTE:
1649 *
1650 * @param pMac - Pointer to Global MAC structure
1651 * @param pBeacon - Parsed Beacon Frame structure
1652 * @param pRxPacketInfo - Pointer to RX packet info structure
1653 *
1654 * @return Status whether to process or ignore received Beacon Frame
1655 */
1656
1657tSirRetStatus
1658limHandleIBSScoalescing(
1659 tpAniSirGlobal pMac,
1660 tpSchBeaconStruct pBeacon,
1661 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1662{
1663 tpSirMacMgmtHdr pHdr;
1664 tSirRetStatus retCode;
1665
1666 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1667 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
1668 /* Received SSID does not match => Ignore received Beacon frame. */
1669 retCode = eSIR_LIM_IGNORE_BEACON;
1670 else
1671 {
1672 tANI_U32 ieLen;
1673 tANI_U16 tsfLater;
1674 tANI_U8 *pIEs;
1675 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1676 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1677 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
1678 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
1679 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1680 }
1681 return retCode;
1682} /*** end limHandleIBSScoalescing() ***/
1683
1684
1685
1686/**
1687 * limDetectChangeInApCapabilities()
1688 *
1689 *FUNCTION:
1690 * This function is called while SCH is processing
1691 * received Beacon from AP on STA to detect any
1692 * change in AP's capabilities. If there any change
1693 * is detected, Roaming is informed of such change
1694 * so that it can trigger reassociation.
1695 *
1696 *LOGIC:
1697 *
1698 *ASSUMPTIONS:
1699 *
1700 *NOTE:
1701 * Notification is enabled for STA product only since
1702 * it is not a requirement on BP side.
1703 *
1704 * @param pMac Pointer to Global MAC structure
1705 * @param pBeacon Pointer to parsed Beacon structure
1706 * @return None
1707 */
1708
1709void
1710limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1711 tpSirProbeRespBeacon pBeacon,
1712 tpPESession psessionEntry)
1713{
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 tANI_U8 len;
1715 tSirSmeApNewCaps apNewCaps;
1716 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301717 tSirRetStatus status = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1719 newChannel = (tANI_U8) pBeacon->channelNumber;
1720
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301721 /* Some APs are not setting privacy bit when hidden ssid enabled.
1722 * So LIM was keep on sending eSIR_SME_AP_CAPS_CHANGED event to SME */
1723 if (limIsNullSsid(&pBeacon->ssId) &&
1724 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1725 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))
1726 )
1727 {
1728 /* If Hidden SSID and privacy bit is not matching with the current capability,
1729 * then send unicast probe request to AP and take decision after
1730 * receiving probe response */
1731 if (psessionEntry->fIgnoreCapsChange == true)
1732 {
1733 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1734 return;
1735 }
1736 psessionEntry->fWaitForProbeRsp = true;
1737 limLog(pMac, LOGW, FL("Hidden SSID and privacy bit is not matching,"
1738 "sending directed probe request.. "));
1739 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1740 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1741 psessionEntry->dot11mode, 0, NULL);
1742
1743 if ( status != eSIR_SUCCESS)
1744 {
1745 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1746 }
1747
1748 return;
1749 }
1750 else
1751 {
1752 /* The control will come here if the frame is beacon with broadcast ssid
1753 * or probe response frame */
1754 if (psessionEntry->fWaitForProbeRsp == true)
1755 {
1756 if (((!limIsNullSsid(&pBeacon->ssId)) &&
1757 (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == true)) &&
1758 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) ==
1759 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)))
1760 {
1761 /* Only for probe response frames the control will come here */
1762 /* If beacon with broadcast ssid then fWaitForProbeRsp will be false,
1763 the control wll not come here*/
1764 limLog(pMac, LOGW, FL("Privacy bit in probe response is"
1765 "matching with the current setting,"
1766 "Ignoring subsequent privacy bit capability"
1767 "mismatch"));
1768 psessionEntry->fIgnoreCapsChange = true;
1769 psessionEntry->fWaitForProbeRsp = false;
1770 }
1771 }
1772 }
1773
1774 if ((psessionEntry->limSentCapsChangeNtf == false) &&
1775 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1777 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1778 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1779 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301780 (newChannel != psessionEntry->currentOperChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 )))
1782 {
1783
1784 /**
1785 * BSS capabilities have changed.
1786 * Inform Roaming.
1787 */
1788 len = sizeof(tSirMacCapabilityInfo) +
1789 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1790 3 * sizeof(tANI_U8) + // reserved fields
1791 pBeacon->ssId.length + 1;
1792
1793 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
1794 psessionEntry->bssId,
1795 sizeof(tSirMacAddr));
1796 if (newChannel != psessionEntry->currentOperChannel)
1797 {
1798 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001799 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 psessionEntry->currentOperChannel, newChannel);)
1801 return;
1802 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301803
1804 /**
1805 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1806 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1807 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1808 * the privacy bit is set in Probe and association responses.
1809 * Due to this anomaly, we detect a change in
1810 * AP capabilities when we receive a beacon after association and
1811 * disconnect from the AP. The following check makes sure that we can
1812 * connect to such APs
1813 */
1814 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1815 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1816 {
1817 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001818 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301819 return;
1820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 else
1822 apNewCaps.channelId = psessionEntry->currentOperChannel;
1823 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
1824 (tANI_U8 *) &pBeacon->ssId,
1825 pBeacon->ssId.length + 1);
1826
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301827 psessionEntry->fIgnoreCapsChange = false;
1828 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 psessionEntry->limSentCapsChangeNtf = true;
1830 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1831 (tANI_U32 *) &apNewCaps,
1832 len, psessionEntry->smeSessionId);
1833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001834} /*** limDetectChangeInApCapabilities() ***/
1835
1836
1837
1838
1839// ---------------------------------------------------------------------
1840/**
1841 * limUpdateShortSlot
1842 *
1843 * FUNCTION:
1844 * Enable/Disable short slot
1845 *
1846 * LOGIC:
1847 *
1848 * ASSUMPTIONS:
1849 *
1850 * NOTE:
1851 *
1852 * @param enable Flag to enable/disable short slot
1853 * @return None
1854 */
1855
1856tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1857{
1858
1859 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07001860 tANI_U32 nShortSlot;
1861 tANI_U32 val = 0;
1862 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001863
Jeff Johnsone7245742012-09-05 17:12:55 -07001864 // Check Admin mode first. If it is disabled just return
1865 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
1866 != eSIR_SUCCESS)
1867 {
1868 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001869 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001870 return eSIR_FAILURE;
1871 }
1872 if (val == false)
1873 return eSIR_SUCCESS;
1874
1875 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
1876 limGetPhyMode(pMac, &phyMode, psessionEntry);
1877 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
1878 return eSIR_SUCCESS;
1879
1880 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001881
1882 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
1883 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
1884 // if no erp present, use short slot based on current ap caps
1885
1886 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
1887
1888 //Resolution : always use the shortSlot setting the capability info to decide slot time.
1889 // The difference between the earlier implementation and the new one is only Case4.
1890 /*
1891 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1892 Case1 1 1 1 1 //AP should not advertise this combination.
1893 Case2 1 1 0 0
1894 Case3 1 0 1 1
1895 Case4 1 0 0 0
1896 Case5 0 1 1 1
1897 Case6 0 1 0 0
1898 Case7 0 0 1 1
1899 Case8 0 0 0 0
1900 */
1901 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1902
Jeff Johnsone7245742012-09-05 17:12:55 -07001903 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 {
1905 // Short slot time capability of AP has changed. Adopt to it.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001906 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07001908 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
1910 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 }
1912 return eSIR_SUCCESS;
1913}
1914
1915
Jeff Johnson295189b2012-06-20 16:38:30 -07001916
1917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918
Jeff Johnson295189b2012-06-20 16:38:30 -07001919
1920
1921/** -----------------------------------------------------------------
1922 \brief limHandleLowRssiInd() - handles low rssi indication
1923
1924 This function process the SIR_HAL_LOW_RSSI_IND message from
1925 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
1926
1927 \param pMac - global mac structure
1928
1929 \return
1930
1931 \sa
1932 ----------------------------------------------------------------- */
1933void limHandleLowRssiInd(tpAniSirGlobal pMac)
1934{
1935#if 0 //RSSI related indications will now go to TL and not PE
1936 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
1937 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
1938 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
1939 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001940 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
1942 }
1943 else
1944 {
1945 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001946 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 pMac->pmm.gPmmState);
1948 }
1949 return;
1950#endif
1951}
1952
1953
1954/** -----------------------------------------------------------------
1955 \brief limHandleBmpsStatusInd() - handles BMPS status indication
1956
1957 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
1958 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1959 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
1960
1961 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
1962 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
1963 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
1964 This message can also come from FW anytime after we have entered BMPS.
1965 This means we should handle it in WoWL and UAPSD states as well
1966
1967 \param pMac - global mac structure
1968 \return - none
1969 \sa
1970 ----------------------------------------------------------------- */
1971void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
1972{
1973 switch(pMac->pmm.gPmmState)
1974 {
1975 case ePMM_STATE_BMPS_SLEEP:
1976 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
1977 case ePMM_STATE_UAPSD_SLEEP:
1978 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
1979 case ePMM_STATE_WOWLAN:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001980 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
1982 break;
1983
1984 default:
1985 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001986 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 pMac->pmm.gPmmState);
1988 break;
1989 }
1990 return;
1991}
1992
1993
1994/** -----------------------------------------------------------------
1995 \brief limHandleMissedBeaconInd() - handles missed beacon indication
1996
1997 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
1998 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1999 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2000
2001 \param pMac - global mac structure
2002 \return - none
2003 \sa
2004 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002005void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002006{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002007#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2008 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2009 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2010 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2011 if (psessionEntry == NULL)
2012 {
2013 limLog(pMac, LOGE,
2014 FL("session does not exist for given BSSIdx:%d"),
2015 pSirMissedBeaconInd->bssIdx);
2016 return;
2017 }
2018#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2020 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2021 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2022 {
2023 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002024 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2026 }
Yathish9f22e662012-12-10 14:21:35 -08002027/* ACTIVE_MODE_HB_OFFLOAD */
2028#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2029 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2030 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2031 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2032 {
2033 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002034 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002035 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002036 }
2037#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 else
2039 {
2040 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002041 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 pMac->pmm.gPmmState);
2043 }
2044 return;
2045}
2046
2047/** -----------------------------------------------------------------
2048 \brief limMicFailureInd() - handles mic failure indication
2049
2050 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2051
2052 \param pMac - global mac structure
2053 \return - none
2054 \sa
2055 ----------------------------------------------------------------- */
2056void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2057{
2058 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2059 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2060 tSirMsgQ mmhMsg;
2061 tpPESession psessionEntry ;
2062 tANI_U8 sessionId;
2063
2064 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2065 {
2066 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002067 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 return;
2069 }
2070
2071 if (eHAL_STATUS_SUCCESS !=
2072 palAllocateMemory(pMac->hHdd,
2073 (void **) &pSirSmeMicFailureInd,
2074 sizeof(tSirSmeMicFailureInd)))
2075 {
2076 // Log error
2077 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002078 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 return;
2080 }
2081
2082 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2083 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2084 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2085
2086 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2087 pSirMicFailureInd->bssId,
2088 sizeof(tSirMacAddr));
2089
2090 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2091 pSirMicFailureInd->info.srcMacAddr,
2092 sizeof(tSirMacAddr));
2093
2094 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2095 pSirMicFailureInd->info.taMacAddr,
2096 sizeof(tSirMacAddr));
2097
2098 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2099 pSirMicFailureInd->info.dstMacAddr,
2100 sizeof(tSirMacAddr));
2101
2102 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2103 pSirMicFailureInd->info.rxMacAddr,
2104 sizeof(tSirMacAddr));
2105
2106 pSirSmeMicFailureInd->info.multicast =
2107 pSirMicFailureInd->info.multicast;
2108
2109 pSirSmeMicFailureInd->info.keyId=
2110 pSirMicFailureInd->info.keyId;
2111
2112 pSirSmeMicFailureInd->info.IV1=
2113 pSirMicFailureInd->info.IV1;
2114
2115 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2116 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2117
2118 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2119 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2120 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002121 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2123 return;
2124}
2125
2126
2127/** -----------------------------------------------------------------
2128 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2129
2130 This function is called before enqueuing the frame to PE queue for further processing.
2131 This prevents unnecessary frames getting into PE Queue and drops them right away.
2132 Frames will be droped in the following scenarios:
2133
2134 - In Scan State, drop the frames which are not marked as scan frames
2135 - In non-Scan state, drop the frames which are marked as scan frames.
2136 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2137 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2138
2139 \param pMac - global mac structure
2140 \return - none
2141 \sa
2142 ----------------------------------------------------------------- */
2143
2144tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2145{
2146 tANI_U32 framelen;
2147 tANI_U8 *pBody;
2148 tSirMacCapabilityInfo capabilityInfo;
2149
2150 /*
2151 *
2152 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2153 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2154 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2155 * other than beacons or probe responses in scan state.
2156 */
2157 if( (subType == SIR_MAC_MGMT_BEACON) ||
2158 (subType == SIR_MAC_MGMT_PROBE_RSP))
2159 {
2160 if(pMac->pmm.inMissedBeaconScenario)
2161 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002162 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2163 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 }
2165 if (limIsSystemInScanState(pMac))
2166 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002167 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002169#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2170 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2171 {
2172 return eMGMT_DROP_NO_DROP;
2173 }
2174#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2176 {
2177 return eMGMT_DROP_SCAN_MODE_FRAME;
2178 }
2179 }
2180
2181 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2182 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2183
2184 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2185 * beacons from an infrastructure network
2186 */
2187 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2188 if(!capabilityInfo.ibss)
2189 return eMGMT_DROP_NO_DROP;
2190#if 0
2191 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2192 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2193 return eMGMT_DROP_NO_DROP;
2194#endif
2195
2196 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2197 if( (subType == SIR_MAC_MGMT_BEACON) ||
2198 (subType == SIR_MAC_MGMT_PROBE_RSP))
2199 {
2200 //drop the frame if length is less than 12
2201 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2202 return eMGMT_DROP_INVALID_SIZE;
2203
2204 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2205
2206 //This can be enhanced to even check the SSID before deciding to enque the frame.
2207 if(capabilityInfo.ess)
2208 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2209 }
2210 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2211 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2212 {
2213 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2214 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2215 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2216 }
2217
2218 return eMGMT_DROP_NO_DROP;
2219}
2220
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002221eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2222{
2223 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002224
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002225 if(psPe)
2226 {
2227 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2228 {
2229 status = eHAL_STATUS_SUCCESS;
2230 }
2231 }
2232 return (status);
2233}
2234eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2235{
2236 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2237 if(psPe)
2238 {
2239 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2240 {
2241 status = eHAL_STATUS_SUCCESS;
2242 }
2243 }
2244 return (status);
2245}