blob: a0ba77a0ef952a190fd3ece3bd6906414310d878 [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 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530624#ifdef FEATURE_WLAN_TDLS
625 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_BUF_STA_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSBufStaEnabled) != eSIR_SUCCESS)
626 {
627 limLog(pMac, LOGP, FL("cfg get LimTDLSBufStaEnabled failed"));
628 return eSIR_FAILURE;
629 }
630 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_QOS_WMM_UAPSD_MASK,(tANI_U32 *) &pMac->lim.gLimTDLSUapsdMask) != eSIR_SUCCESS)
631 {
632 limLog(pMac, LOGP, FL("cfg get LimTDLSUapsdMask failed"));
633 return eSIR_FAILURE;
634 }
635#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 return eSIR_SUCCESS;
637}
Jeff Johnson295189b2012-06-20 16:38:30 -0700638
639/*
640 limStart
641 This function is to replace the __limProcessSmeStartReq since there is no
642 eWNI_SME_START_REQ post to PE.
643*/
644tSirRetStatus limStart(tpAniSirGlobal pMac)
645{
646 tSirResultCodes retCode = eSIR_SUCCESS;
647
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700648 PELOG1(limLog(pMac, LOG1, FL(" enter"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700649
650 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
651 {
652 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
653
Jeff Johnsone7245742012-09-05 17:12:55 -0700654 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700655
656 // By default do not return after first scan match
657 pMac->lim.gLimReturnAfterFirstMatch = 0;
658
659 // Initialize MLM state machine
660 limInitMlm(pMac);
661
662 // By default return unique scan results
663 pMac->lim.gLimReturnUniqueResults = true;
664 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700665#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
666 pMac->lim.gLimSmeLfrScanResultLength = 0;
667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 }
669 else
670 {
671 /**
672 * Should not have received eWNI_SME_START_REQ in states
673 * other than OFFLINE. Return response to host and
674 * log error
675 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700676 limLog(pMac, LOGE, FL("Invalid SME state %X"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 retCode = eSIR_FAILURE;
678 }
679
680 return retCode;
681}
682
683/**
684 * limInitialize()
685 *
686 *FUNCTION:
687 * This function is called from LIM thread entry function.
688 * LIM related global data structures are initialized in this function.
689 *
690 *LOGIC:
691 * NA
692 *
693 *ASSUMPTIONS:
694 * NA
695 *
696 *NOTE:
697 * NA
698 *
699 * @param pMac - Pointer to global MAC structure
700 * @return None
701 */
702
703tSirRetStatus
704limInitialize(tpAniSirGlobal pMac)
705{
706 tSirRetStatus status = eSIR_SUCCESS;
707
708 __limInitAssocVars(pMac);
709 __limInitVars(pMac);
710 __limInitStates(pMac);
711 __limInitStatsVars(pMac);
712 __limInitBssVars(pMac);
713 __limInitScanVars(pMac);
714 __limInitHTVars(pMac);
715 __limInitTitanVars(pMac);
716
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 status = limStart(pMac);
718 if(eSIR_SUCCESS != status)
719 {
720 return status;
721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
723 /*
724 * MLM will be intitalized when 'START' request comes from SME.
725 * limInitMlm calls limCreateTimers, which actually relies on
726 * CFG to be downloaded. So it should not be called as part of
727 * peStart, as CFG download is happening after peStart.
728 */
729 //limInitMlm(pMac);
730 // Initializations for maintaining peers in IBSS
731 limIbssInit(pMac);
732
733 pmmInitialize(pMac);
734
735
736#if defined WLAN_FEATURE_VOWIFI
737 rrmInitialize(pMac);
738#endif
739#if defined WLAN_FEATURE_VOWIFI_11R
740 limFTOpen(pMac);
741#endif
742
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744
745#if 0
746
747 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
748 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
749 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
750
751 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
752 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
753
754 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
755 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
756 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
757
758 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
759
760 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
761
762 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
763 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
764
765 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
766
767
768 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
769
770 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
771#endif
772 MTRACE(limTraceInit(pMac));
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 //Initialize the configurations needed by PE
775 if( eSIR_FAILURE == __limInitConfig(pMac))
776 {
777 //We need to undo everything in limStart
778 limCleanupMlm(pMac);
779 return eSIR_FAILURE;
780 }
781
782 //initialize the TSPEC admission control table.
783 //Note that this was initially done after resume notification from HAL.
784 //Now, DAL is started before PE so this can be done here
785 limAdmitControlInit(pMac);
786 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700787
788 return status;
789
790} /*** end limInitialize() ***/
791
792
793
794/**
795 * limCleanup()
796 *
797 *FUNCTION:
798 * This function is called upon reset or persona change
799 * to cleanup LIM state
800 *
801 *LOGIC:
802 * NA
803 *
804 *ASSUMPTIONS:
805 * NA
806 *
807 *NOTE:
808 * NA
809 *
810 * @param pMac - Pointer to Global MAC structure
811 * @return None
812 */
813
814void
815limCleanup(tpAniSirGlobal pMac)
816{
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 v_PVOID_t pvosGCTx;
818 VOS_STATUS retStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700819
Jeff Johnson295189b2012-06-20 16:38:30 -0700820//Before destroying the list making sure all the nodes have been deleted.
821//Which should be the normal case, but a memory leak has been reported.
822
823 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
824
825 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
826 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
827 {
828 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
829 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
830
831 palFreeMemory(pMac, pLimMgmtRegistration);
832 }
833
834 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 limCleanupMlm(pMac);
837 limCleanupLmm(pMac);
838
839 // free up preAuth table
840 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
841 {
842 palFreeMemory(pMac->hHdd, pMac->lim.gLimPreAuthTimerTable.pTable);
843 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
844 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
845 }
846
847 if(NULL != pMac->lim.pDialogueTokenHead)
848 {
849 limDeleteDialogueTokenList(pMac);
850 }
851
852 if(NULL != pMac->lim.pDialogueTokenTail)
853 {
854 palFreeMemory(pMac->hHdd, (void *) pMac->lim.pDialogueTokenTail);
855 pMac->lim.pDialogueTokenTail = NULL;
856 }
857
858 # if 0
859 if (pMac->lim.gpLimStartBssReq != NULL)
860 {
861 palFreeMemory(pMac->hHdd, pMac->lim.gpLimStartBssReq);
862 pMac->lim.gpLimStartBssReq = NULL;
863 }
864 #endif
865
866 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
867 {
868 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmSetKeysReq);
869 pMac->lim.gpLimMlmSetKeysReq = NULL;
870 }
871
872 #if 0
873 if (pMac->lim.gpLimJoinReq != NULL)
874 {
875 palFreeMemory(pMac->hHdd, pMac->lim.gpLimJoinReq);
876 pMac->lim.gpLimJoinReq = NULL;
877 }
878 #endif
879
880 if (pMac->lim.gpLimMlmAuthReq != NULL)
881 {
882 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
883 pMac->lim.gpLimMlmAuthReq = NULL;
884 }
885
Jeff Johnsone7245742012-09-05 17:12:55 -0700886#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 if (pMac->lim.gpLimMlmJoinReq != NULL)
888 {
889 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
890 pMac->lim.gpLimMlmJoinReq = NULL;
891 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700892#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700893
894 #if 0
895 if (pMac->lim.gpLimReassocReq != NULL)
896 {
897 palFreeMemory(pMac->hHdd, pMac->lim.gpLimReassocReq);
898 pMac->lim.gpLimReassocReq = NULL;
899 }
900 #endif
901
902 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
903 {
904 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmRemoveKeyReq);
905 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
906 }
907
Viral Modid440e682013-03-06 02:25:31 -0800908 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
Viral Modid86bde22012-12-10 13:09:21 -0800909 {
Viral Modid440e682013-03-06 02:25:31 -0800910 palFreeMemory(pMac->hHdd, pMac->lim.gpDefdSmeMsgForNOA);
911 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800912 }
Viral Modid86bde22012-12-10 13:09:21 -0800913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 if (pMac->lim.gpLimMlmScanReq != NULL)
915 {
916 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmScanReq);
917 pMac->lim.gpLimMlmScanReq = NULL;
918 }
919
920#if 0
921 if(NULL != pMac->lim.beacon)
922 {
923 palFreeMemory(pMac->hHdd, (void*) pMac->lim.beacon);
924 pMac->lim.beacon = NULL;
925 }
926#endif
927 #if 0
928 if(NULL != pMac->lim.assocReq)
929 {
930 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocReq);
931 pMac->lim.assocReq= NULL;
932 }
933 #endif
934
935#if 0
936 if(NULL != pMac->lim.assocRsp)
937 {
938 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocRsp);
939 pMac->lim.assocRsp= NULL;
940 }
941#endif
942 // Now, finally reset the deferred message queue pointers
943 limResetDeferredMsgQ(pMac);
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945
946 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
947 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
948
949 if ( retStatus != VOS_STATUS_SUCCESS )
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700950 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700951
952#if defined WLAN_FEATURE_VOWIFI
953 rrmCleanup(pMac);
954#endif
955#if defined WLAN_FEATURE_VOWIFI_11R
956 limFTCleanup(pMac);
957#endif
958
959} /*** end limCleanup() ***/
960
961
962/** -------------------------------------------------------------
963\fn peOpen
964\brief will be called in Open sequence from macOpen
965\param tpAniSirGlobal pMac
966\param tHalOpenParameters *pHalOpenParam
967\return tSirRetStatus
968 -------------------------------------------------------------*/
969
970tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
971{
972 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
973 pMac->lim.maxStation = pMacOpenParam->maxStation;
974
975 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
976 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700977 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 return eSIR_FAILURE;
979 }
980
981 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
982 (void **) &pMac->lim.limTimers.gpLimCnfWaitTimer, sizeof(TX_TIMER)*pMac->lim.maxStation))
983 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700984 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 return eSIR_FAILURE;
986 }
987
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800988#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
990 (void **) &pMac->lim.gpLimAIDpool,
991 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1)))
992 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700993 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 return eSIR_FAILURE;
995 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800996#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
998 (void **) &pMac->lim.gpSession, sizeof(tPESession)* pMac->lim.maxBssId))
999 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001000 limLog(pMac, LOGE, FL("memory allocate failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 return eSIR_FAILURE;
1002 }
1003
1004 palZeroMemory(pMac->hHdd, pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId);
1005
1006
1007 /*
1008 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1009 (void **) &pMac->dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*pMac->lim.maxStation))
1010 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001011 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 return eSIR_FAILURE;
1013 }
1014
1015 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1016 (void **) &pMac->dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*pMac->lim.maxStation))
1017 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001018 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 return eSIR_FAILURE;
1020 }
1021 */
1022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1024 (void **) &pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation))
1025 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001026 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 return eSIR_FAILURE;
1028 }
1029 palZeroMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001031 pMac->lim.mgmtFrameSessionId = 0xff;
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001032 pMac->lim.deferredMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001033
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001034 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1035 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001036 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!"));)
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001037 return eSIR_FAILURE;
1038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 return eSIR_SUCCESS;
1040}
1041
1042/** -------------------------------------------------------------
1043\fn peClose
1044\brief will be called in close sequence from macClose
1045\param tpAniSirGlobal pMac
1046\return tSirRetStatus
1047 -------------------------------------------------------------*/
1048
1049tSirRetStatus peClose(tpAniSirGlobal pMac)
1050{
1051 tANI_U8 i;
1052
1053 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1054 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 for(i =0; i < pMac->lim.maxBssId; i++)
1057 {
1058 if(pMac->lim.gpSession[i].valid == TRUE)
1059 {
1060 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1061 }
1062 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001063 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1064 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001065#if 0
Jeff Johnsone7245742012-09-05 17:12:55 -07001066 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1067 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001068#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1071 pMac->lim.gpSession = NULL;
1072 /*
1073 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1074 pMac->dph.dphHashTable.pHashTable = NULL;
1075 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1076 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1077 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1079 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001080 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1081 {
1082 return eSIR_FAILURE;
1083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 return eSIR_SUCCESS;
1085}
1086
1087/** -------------------------------------------------------------
1088\fn peStart
1089\brief will be called in start sequence from macStart
1090\param tpAniSirGlobal pMac
1091\return none
1092 -------------------------------------------------------------*/
1093
1094tSirRetStatus peStart(tpAniSirGlobal pMac)
1095{
1096 tSirRetStatus status = eSIR_SUCCESS;
1097
1098 status = limInitialize(pMac);
1099#if defined(ANI_LOGDUMP)
1100 limDumpInit(pMac);
1101#endif //#if defined(ANI_LOGDUMP)
1102
1103 return status;
1104}
1105
1106/** -------------------------------------------------------------
1107\fn peStop
1108\brief will be called in stop sequence from macStop
1109\param tpAniSirGlobal pMac
1110\return none
1111 -------------------------------------------------------------*/
1112
1113void peStop(tpAniSirGlobal pMac)
1114{
1115 limCleanup(pMac);
1116 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1117 return;
1118}
1119
1120/** -------------------------------------------------------------
1121\fn peFreeMsg
1122\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1123\ to free a given PE message on the TX and MC thread.
1124\ This happens when there are messages pending in the PE
1125\ queue when system is being stopped and reset.
1126\param tpAniSirGlobal pMac
1127\param tSirMsgQ pMsg
1128\return none
1129-----------------------------------------------------------------*/
1130v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1131{
1132 if (pMsg != NULL)
1133 {
1134 if (NULL != pMsg->bodyptr)
1135 {
1136 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1137 {
1138 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1139 }
1140 else
1141 {
1142 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1143 }
1144 }
1145 pMsg->bodyptr = 0;
1146 pMsg->bodyval = 0;
1147 pMsg->type = 0;
1148 }
1149 return;
1150}
1151
1152
1153/**
1154 * The function checks if a particular timer should be allowed
1155 * into LIM while device is sleeping
1156 */
1157tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1158{
1159 tANI_U8 retStatus = TRUE;
1160
1161 if(!limIsSystemInActiveState(pMac))
1162 {
1163 switch(pMsg->type)
1164 {
1165 /* Don't allow following timer messages if in sleep */
1166 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1167 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1168 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1169 retStatus = FALSE;
1170 break;
1171 /* May allow following timer messages in sleep mode */
1172 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1173
1174 /* Safe to allow as of today, this triggers background scan
1175 * which will not be started if the device is in power-save mode
1176 * might need to block in the future if we decide to implement
1177 * spectrum management
1178 */
1179 case SIR_LIM_QUIET_TIMEOUT:
1180
1181 /* Safe to allow as of today, this triggers background scan
1182 * which will not be started if the device is in power-save mode
1183 * might need to block in the future if we decide to implement
1184 * spectrum management
1185 */
1186 case SIR_LIM_QUIET_BSS_TIMEOUT:
1187
1188 /* Safe to allow this timermessage, triggers background scan
1189 * which is blocked in sleep mode
1190 */
1191 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1192
1193 /* Safe to allow this timer, since, while in IMPS this timer will not
1194 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1195 * when heart-beat control is handled back to PE, device would have
1196 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1197 */
1198 case SIR_LIM_HEART_BEAT_TIMEOUT:
1199 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1200
1201 /* Safe to allow, PE is not handling this message as of now. May need
1202 * to block it, basically, free the buffer and restart the timer
1203 */
1204 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1205 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001206 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1208 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1209 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1210 retStatus = TRUE;
1211 break;
1212
1213 /* by default allow rest of messages */
1214 default:
1215 retStatus = TRUE;
1216 break;
1217
1218
1219 }
1220 }
1221
1222 return retStatus;
1223
1224}
1225
1226
1227
1228/**
1229 * limPostMsgApi()
1230 *
1231 *FUNCTION:
1232 * This function is called from other thread while posting a
1233 * message to LIM message Queue gSirLimMsgQ.
1234 *
1235 *LOGIC:
1236 * NA
1237 *
1238 *ASSUMPTIONS:
1239 * NA
1240 *
1241 *NOTE:
1242 * NA
1243 *
1244 * @param pMac - Pointer to Global MAC structure
1245 * @param pMsg - Pointer to the message structure
1246 * @return None
1247 */
1248
1249tANI_U32
1250limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1251{
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1253
1254
Jeff Johnson295189b2012-06-20 16:38:30 -07001255} /*** end limPostMsgApi() ***/
1256
1257
1258/*--------------------------------------------------------------------------
1259
1260 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1261
1262 This function can be called by legacy code to post message to voss queues OR
1263 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1264 for dispatching it later.
1265
1266 \param pMac - Pointer to Global MAC structure
1267 \param pMsg - Pointer to the message structure
1268
1269 \return tANI_U32 - TX_SUCCESS for success.
1270
1271 --------------------------------------------------------------------------*/
1272
1273tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1274{
1275 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1276}
1277
1278/*--------------------------------------------------------------------------
1279
1280 \brief peProcessMessages() - Message Processor for PE
1281
1282 Voss calls this function to dispatch the message to PE
1283
1284 \param pMac - Pointer to Global MAC structure
1285 \param pMsg - Pointer to the message structure
1286
1287 \return tANI_U32 - TX_SUCCESS for success.
1288
1289 --------------------------------------------------------------------------*/
1290
1291tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1292{
1293 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1294 {
1295 return eSIR_SUCCESS;
1296 }
1297 /**
1298 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1299 * for all the other cases post it to LIM
1300 */
1301 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1302 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1303 else
1304 limMessageProcessor(pMac, pMsg);
1305 return eSIR_SUCCESS;
1306}
1307
1308
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
1310// ---------------------------------------------------------------------------
1311/**
1312 * peHandleMgmtFrame
1313 *
1314 * FUNCTION:
1315 * Process the Management frames from TL
1316 *
1317 * LOGIC:
1318 *
1319 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1320 *
1321 * NOTE:
1322 *
1323 * @param pvosGCtx Global Vos Context
1324 * @param vossBuff Packet
1325 * @return None
1326 */
1327
1328VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1329{
1330 tpAniSirGlobal pMac;
1331 tpSirMacMgmtHdr mHdr;
1332 tSirMsgQ msg;
1333 vos_pkt_t *pVosPkt;
1334 VOS_STATUS vosStatus;
1335 v_U8_t *pRxPacketInfo;
1336
1337 pVosPkt = (vos_pkt_t *)vosBuff;
1338 if (NULL == pVosPkt)
1339 {
1340 return VOS_STATUS_E_FAILURE;
1341 }
1342
1343 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1344 if (NULL == pMac)
1345 {
1346 // cannot log a failure without a valid pMac
1347 vos_pkt_return_packet(pVosPkt);
1348 return VOS_STATUS_E_FAILURE;
1349 }
1350
1351 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1352
1353 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1354 {
1355 vos_pkt_return_packet(pVosPkt);
1356 return VOS_STATUS_E_FAILURE;
1357 }
1358
1359
1360 //
1361 // The MPDU header is now present at a certain "offset" in
1362 // the BD and is specified in the BD itself
1363 //
1364 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1365 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1366 {
1367 PELOG1(limLog( pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001368 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001369 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001370
Jeff Johnsone7245742012-09-05 17:12:55 -07001371 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1373 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1374 }
1375
1376
1377 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1378 msg.type = SIR_BB_XPORT_MGMT_MSG;
1379 msg.bodyptr = vosBuff;
1380 msg.bodyval = 0;
1381
1382 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1383 &msg,
1384 mHdr->fc.type,
1385 mHdr->fc.subType ))
1386 {
1387 vos_pkt_return_packet(pVosPkt);
1388 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001389 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 return VOS_STATUS_E_FAILURE;
1391 }
1392
1393 return VOS_STATUS_SUCCESS;
1394}
1395
1396// ---------------------------------------------------------------------------
1397/**
1398 * peRegisterTLHandle
1399 *
1400 * FUNCTION:
1401 * Registers the Handler which, process the Management frames from TL
1402 *
1403 * LOGIC:
1404 *
1405 * ASSUMPTIONS:
1406 *
1407 * NOTE:
1408 *
1409 * @return None
1410 */
1411
1412void peRegisterTLHandle(tpAniSirGlobal pMac)
1413{
1414 v_PVOID_t pvosGCTx;
1415 VOS_STATUS retStatus;
1416
1417 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1418
1419 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1420
1421 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001422 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001423
1424}
Jeff Johnson295189b2012-06-20 16:38:30 -07001425
1426
1427/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 * limIsSystemInScanState()
1429 *
1430 *FUNCTION:
1431 * This function is called by various MAC software modules to
1432 * determine if System is in Scan/Learn state
1433 *
1434 *LOGIC:
1435 * NA
1436 *
1437 *ASSUMPTIONS:
1438 * NA
1439 *
1440 *NOTE:
1441 *
1442 * @param pMac - Pointer to Global MAC structure
1443 * @return true - System is in Scan/Learn state
1444 * false - System is NOT in Scan/Learn state
1445 */
1446
1447tANI_U8
1448limIsSystemInScanState(tpAniSirGlobal pMac)
1449{
1450 switch (pMac->lim.gLimSmeState)
1451 {
1452 case eLIM_SME_CHANNEL_SCAN_STATE:
1453 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1454 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1455 case eLIM_SME_WT_SCAN_STATE:
1456 // System is in Learn mode
1457 return true;
1458
1459 default:
1460 // System is NOT in Learn mode
1461 return false;
1462 }
1463} /*** end limIsSystemInScanState() ***/
1464
1465
1466
1467/**
1468 * limIsSystemInActiveState()
1469 *
1470 *FUNCTION:
1471 * This function is called by various MAC software modules to
1472 * determine if System is in Active/Wakeup state
1473 *
1474 *LOGIC:
1475 * NA
1476 *
1477 *ASSUMPTIONS:
1478 * NA
1479 *
1480 *NOTE:
1481 *
1482 * @param pMac - Pointer to Global MAC structure
1483 * @return true - System is in Active state
1484 * false - System is not in Active state
1485 */
1486
1487tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1488{
1489 switch (pMac->pmm.gPmmState)
1490 {
1491 case ePMM_STATE_BMPS_WAKEUP:
1492 case ePMM_STATE_IMPS_WAKEUP:
1493 case ePMM_STATE_READY:
1494 // System is in Active mode
1495 return true;
1496 default:
1497 return false;
1498 // System is NOT in Active mode
1499 }
1500}
1501
1502
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
Jeff Johnson295189b2012-06-20 16:38:30 -07001504
1505
1506/**
1507*\brief limReceivedHBHandler()
1508*
1509* This function is called by schBeaconProcess() upon
1510* receiving a Beacon on STA. This also gets called upon
1511* receiving Probe Response after heat beat failure is
1512* detected.
1513*
1514* param pMac - global mac structure
1515* param channel - channel number indicated in Beacon, Probe Response
1516* return - none
1517*/
1518
1519
1520void
1521limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1522{
1523 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1524 psessionEntry->LimRxedBeaconCntDuringHB++;
1525
1526 pMac->pmm.inMissedBeaconScenario = FALSE;
1527} /*** end limReceivedHBHandler() ***/
1528
1529
1530
1531#if 0
1532void limResetHBPktCount(tpPESession psessionEntry)
1533{
1534 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1535}
1536#endif
1537
1538
1539/*
1540 * limProcessWdsInfo()
1541 *
1542 *FUNCTION:
1543 * This function is called from schBeaconProcess in BP
1544 *
1545 *PARAMS:
1546 * @param pMac - Pointer to Global MAC structure
1547 * @param propIEInfo - proprietary IE info
1548 *
1549 *LOGIC:
1550 *
1551 *ASSUMPTIONS:
1552 * NA
1553 *
1554 *NOTE:
1555 *
1556 *
1557 *RETURNS:
1558 *
1559 */
1560
1561void limProcessWdsInfo(tpAniSirGlobal pMac,
1562 tSirPropIEStruct propIEInfo)
1563{
Jeff Johnson295189b2012-06-20 16:38:30 -07001564}
1565
1566
1567
1568/**
1569 * limInitWdsInfoParams()
1570 *
1571 *FUNCTION:
1572 * This function is called while processing
1573 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1574 * ind/set related parameters.
1575 *
1576 *LOGIC:
1577 *
1578 *ASSUMPTIONS:
1579 *
1580 *NOTE:
1581 *
1582 * @param pMac Pointer to Global MAC structure
1583 * @return None
1584 */
1585
1586void
1587limInitWdsInfoParams(tpAniSirGlobal pMac)
1588{
1589 pMac->lim.gLimWdsInfo.wdsLength = 0;
1590 pMac->lim.gLimNumWdsInfoInd = 0;
1591 pMac->lim.gLimNumWdsInfoSet = 0;
1592} /*** limInitWdsInfoParams() ***/
1593
1594
1595/** -------------------------------------------------------------
1596\fn limUpdateOverlapStaParam
1597\brief Updates overlap cache and param data structure
1598\param tpAniSirGlobal pMac
1599\param tSirMacAddr bssId
1600\param tpLimProtStaParams pStaParams
1601\return None
1602 -------------------------------------------------------------*/
1603void
1604limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1605{
1606 int i;
1607 if (!pStaParams->numSta)
1608 {
1609 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1610 bssId,
1611 sizeof(tSirMacAddr));
1612 pMac->lim.protStaOverlapCache[0].active = true;
1613
1614 pStaParams->numSta = 1;
1615
1616 return;
1617 }
1618
1619 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1620 {
1621 if (pMac->lim.protStaOverlapCache[i].active)
1622 {
1623 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
1624 bssId,
1625 sizeof(tSirMacAddr))) {
1626 return; }
1627 }
1628 else
1629 break;
1630 }
1631
1632 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1633 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001634 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636 else
1637 {
1638 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
1639 bssId,
1640 sizeof(tSirMacAddr));
1641 pMac->lim.protStaOverlapCache[i].active = true;
1642
1643 pStaParams->numSta++;
1644 }
1645}
1646
1647
1648/**
1649 * limHandleIBSScoalescing()
1650 *
1651 *FUNCTION:
1652 * This function is called upon receiving Beacon/Probe Response
1653 * while operating in IBSS mode.
1654 *
1655 *LOGIC:
1656 *
1657 *ASSUMPTIONS:
1658 *
1659 *NOTE:
1660 *
1661 * @param pMac - Pointer to Global MAC structure
1662 * @param pBeacon - Parsed Beacon Frame structure
1663 * @param pRxPacketInfo - Pointer to RX packet info structure
1664 *
1665 * @return Status whether to process or ignore received Beacon Frame
1666 */
1667
1668tSirRetStatus
1669limHandleIBSScoalescing(
1670 tpAniSirGlobal pMac,
1671 tpSchBeaconStruct pBeacon,
1672 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1673{
1674 tpSirMacMgmtHdr pHdr;
1675 tSirRetStatus retCode;
1676
1677 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1678 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
1679 /* Received SSID does not match => Ignore received Beacon frame. */
1680 retCode = eSIR_LIM_IGNORE_BEACON;
1681 else
1682 {
1683 tANI_U32 ieLen;
1684 tANI_U16 tsfLater;
1685 tANI_U8 *pIEs;
1686 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1687 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1688 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
1689 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
1690 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1691 }
1692 return retCode;
1693} /*** end limHandleIBSScoalescing() ***/
1694
1695
1696
1697/**
1698 * limDetectChangeInApCapabilities()
1699 *
1700 *FUNCTION:
1701 * This function is called while SCH is processing
1702 * received Beacon from AP on STA to detect any
1703 * change in AP's capabilities. If there any change
1704 * is detected, Roaming is informed of such change
1705 * so that it can trigger reassociation.
1706 *
1707 *LOGIC:
1708 *
1709 *ASSUMPTIONS:
1710 *
1711 *NOTE:
1712 * Notification is enabled for STA product only since
1713 * it is not a requirement on BP side.
1714 *
1715 * @param pMac Pointer to Global MAC structure
1716 * @param pBeacon Pointer to parsed Beacon structure
1717 * @return None
1718 */
1719
1720void
1721limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1722 tpSirProbeRespBeacon pBeacon,
1723 tpPESession psessionEntry)
1724{
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 tANI_U8 len;
1726 tSirSmeApNewCaps apNewCaps;
1727 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301728 tSirRetStatus status = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1730 newChannel = (tANI_U8) pBeacon->channelNumber;
1731
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301732 /* Some APs are not setting privacy bit when hidden ssid enabled.
1733 * So LIM was keep on sending eSIR_SME_AP_CAPS_CHANGED event to SME */
1734 if (limIsNullSsid(&pBeacon->ssId) &&
1735 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1736 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))
1737 )
1738 {
1739 /* If Hidden SSID and privacy bit is not matching with the current capability,
1740 * then send unicast probe request to AP and take decision after
1741 * receiving probe response */
1742 if (psessionEntry->fIgnoreCapsChange == true)
1743 {
1744 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1745 return;
1746 }
1747 psessionEntry->fWaitForProbeRsp = true;
1748 limLog(pMac, LOGW, FL("Hidden SSID and privacy bit is not matching,"
1749 "sending directed probe request.. "));
1750 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1751 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1752 psessionEntry->dot11mode, 0, NULL);
1753
1754 if ( status != eSIR_SUCCESS)
1755 {
1756 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1757 }
1758
1759 return;
1760 }
1761 else
1762 {
1763 /* The control will come here if the frame is beacon with broadcast ssid
1764 * or probe response frame */
1765 if (psessionEntry->fWaitForProbeRsp == true)
1766 {
1767 if (((!limIsNullSsid(&pBeacon->ssId)) &&
1768 (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == true)) &&
1769 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) ==
1770 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)))
1771 {
1772 /* Only for probe response frames the control will come here */
1773 /* If beacon with broadcast ssid then fWaitForProbeRsp will be false,
1774 the control wll not come here*/
1775 limLog(pMac, LOGW, FL("Privacy bit in probe response is"
1776 "matching with the current setting,"
1777 "Ignoring subsequent privacy bit capability"
1778 "mismatch"));
1779 psessionEntry->fIgnoreCapsChange = true;
1780 psessionEntry->fWaitForProbeRsp = false;
1781 }
1782 }
1783 }
1784
1785 if ((psessionEntry->limSentCapsChangeNtf == false) &&
1786 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1788 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1789 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1790 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301791 (newChannel != psessionEntry->currentOperChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 )))
1793 {
1794
1795 /**
1796 * BSS capabilities have changed.
1797 * Inform Roaming.
1798 */
1799 len = sizeof(tSirMacCapabilityInfo) +
1800 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1801 3 * sizeof(tANI_U8) + // reserved fields
1802 pBeacon->ssId.length + 1;
1803
1804 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
1805 psessionEntry->bssId,
1806 sizeof(tSirMacAddr));
1807 if (newChannel != psessionEntry->currentOperChannel)
1808 {
1809 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001810 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 psessionEntry->currentOperChannel, newChannel);)
1812 return;
1813 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301814
1815 /**
1816 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1817 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1818 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1819 * the privacy bit is set in Probe and association responses.
1820 * Due to this anomaly, we detect a change in
1821 * AP capabilities when we receive a beacon after association and
1822 * disconnect from the AP. The following check makes sure that we can
1823 * connect to such APs
1824 */
1825 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1826 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1827 {
1828 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001829 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301830 return;
1831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 else
1833 apNewCaps.channelId = psessionEntry->currentOperChannel;
1834 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
1835 (tANI_U8 *) &pBeacon->ssId,
1836 pBeacon->ssId.length + 1);
1837
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301838 psessionEntry->fIgnoreCapsChange = false;
1839 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 psessionEntry->limSentCapsChangeNtf = true;
1841 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1842 (tANI_U32 *) &apNewCaps,
1843 len, psessionEntry->smeSessionId);
1844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001845} /*** limDetectChangeInApCapabilities() ***/
1846
1847
1848
1849
1850// ---------------------------------------------------------------------
1851/**
1852 * limUpdateShortSlot
1853 *
1854 * FUNCTION:
1855 * Enable/Disable short slot
1856 *
1857 * LOGIC:
1858 *
1859 * ASSUMPTIONS:
1860 *
1861 * NOTE:
1862 *
1863 * @param enable Flag to enable/disable short slot
1864 * @return None
1865 */
1866
1867tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1868{
1869
1870 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07001871 tANI_U32 nShortSlot;
1872 tANI_U32 val = 0;
1873 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874
Jeff Johnsone7245742012-09-05 17:12:55 -07001875 // Check Admin mode first. If it is disabled just return
1876 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
1877 != eSIR_SUCCESS)
1878 {
1879 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001880 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001881 return eSIR_FAILURE;
1882 }
1883 if (val == false)
1884 return eSIR_SUCCESS;
1885
1886 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
1887 limGetPhyMode(pMac, &phyMode, psessionEntry);
1888 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
1889 return eSIR_SUCCESS;
1890
1891 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001892
1893 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
1894 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
1895 // if no erp present, use short slot based on current ap caps
1896
1897 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
1898
1899 //Resolution : always use the shortSlot setting the capability info to decide slot time.
1900 // The difference between the earlier implementation and the new one is only Case4.
1901 /*
1902 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1903 Case1 1 1 1 1 //AP should not advertise this combination.
1904 Case2 1 1 0 0
1905 Case3 1 0 1 1
1906 Case4 1 0 0 0
1907 Case5 0 1 1 1
1908 Case6 0 1 0 0
1909 Case7 0 0 1 1
1910 Case8 0 0 0 0
1911 */
1912 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1913
Jeff Johnsone7245742012-09-05 17:12:55 -07001914 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 {
1916 // Short slot time capability of AP has changed. Adopt to it.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001917 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07001919 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
1921 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 }
1923 return eSIR_SUCCESS;
1924}
1925
1926
Jeff Johnson295189b2012-06-20 16:38:30 -07001927
1928
Jeff Johnson295189b2012-06-20 16:38:30 -07001929
Jeff Johnson295189b2012-06-20 16:38:30 -07001930
1931
1932/** -----------------------------------------------------------------
1933 \brief limHandleLowRssiInd() - handles low rssi indication
1934
1935 This function process the SIR_HAL_LOW_RSSI_IND message from
1936 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
1937
1938 \param pMac - global mac structure
1939
1940 \return
1941
1942 \sa
1943 ----------------------------------------------------------------- */
1944void limHandleLowRssiInd(tpAniSirGlobal pMac)
1945{
1946#if 0 //RSSI related indications will now go to TL and not PE
1947 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
1948 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
1949 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
1950 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001951 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
1953 }
1954 else
1955 {
1956 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001957 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 pMac->pmm.gPmmState);
1959 }
1960 return;
1961#endif
1962}
1963
1964
1965/** -----------------------------------------------------------------
1966 \brief limHandleBmpsStatusInd() - handles BMPS status indication
1967
1968 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
1969 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1970 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
1971
1972 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
1973 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
1974 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
1975 This message can also come from FW anytime after we have entered BMPS.
1976 This means we should handle it in WoWL and UAPSD states as well
1977
1978 \param pMac - global mac structure
1979 \return - none
1980 \sa
1981 ----------------------------------------------------------------- */
1982void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
1983{
1984 switch(pMac->pmm.gPmmState)
1985 {
1986 case ePMM_STATE_BMPS_SLEEP:
1987 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
1988 case ePMM_STATE_UAPSD_SLEEP:
1989 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
1990 case ePMM_STATE_WOWLAN:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001991 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
1993 break;
1994
1995 default:
1996 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001997 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 pMac->pmm.gPmmState);
1999 break;
2000 }
2001 return;
2002}
2003
2004
2005/** -----------------------------------------------------------------
2006 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2007
2008 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2009 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2010 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2011
2012 \param pMac - global mac structure
2013 \return - none
2014 \sa
2015 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002016void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002017{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002018#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2019 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2020 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2021 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2022 if (psessionEntry == NULL)
2023 {
2024 limLog(pMac, LOGE,
2025 FL("session does not exist for given BSSIdx:%d"),
2026 pSirMissedBeaconInd->bssIdx);
2027 return;
2028 }
2029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2031 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2032 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2033 {
2034 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002035 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2037 }
Yathish9f22e662012-12-10 14:21:35 -08002038/* ACTIVE_MODE_HB_OFFLOAD */
2039#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2040 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2041 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2042 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2043 {
2044 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002045 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002046 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002047 }
2048#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 else
2050 {
2051 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002052 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 pMac->pmm.gPmmState);
2054 }
2055 return;
2056}
2057
2058/** -----------------------------------------------------------------
2059 \brief limMicFailureInd() - handles mic failure indication
2060
2061 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2062
2063 \param pMac - global mac structure
2064 \return - none
2065 \sa
2066 ----------------------------------------------------------------- */
2067void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2068{
2069 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2070 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2071 tSirMsgQ mmhMsg;
2072 tpPESession psessionEntry ;
2073 tANI_U8 sessionId;
2074
2075 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2076 {
2077 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002078 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 return;
2080 }
2081
2082 if (eHAL_STATUS_SUCCESS !=
2083 palAllocateMemory(pMac->hHdd,
2084 (void **) &pSirSmeMicFailureInd,
2085 sizeof(tSirSmeMicFailureInd)))
2086 {
2087 // Log error
2088 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002089 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 return;
2091 }
2092
2093 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2094 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2095 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2096
2097 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2098 pSirMicFailureInd->bssId,
2099 sizeof(tSirMacAddr));
2100
2101 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2102 pSirMicFailureInd->info.srcMacAddr,
2103 sizeof(tSirMacAddr));
2104
2105 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2106 pSirMicFailureInd->info.taMacAddr,
2107 sizeof(tSirMacAddr));
2108
2109 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2110 pSirMicFailureInd->info.dstMacAddr,
2111 sizeof(tSirMacAddr));
2112
2113 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2114 pSirMicFailureInd->info.rxMacAddr,
2115 sizeof(tSirMacAddr));
2116
2117 pSirSmeMicFailureInd->info.multicast =
2118 pSirMicFailureInd->info.multicast;
2119
2120 pSirSmeMicFailureInd->info.keyId=
2121 pSirMicFailureInd->info.keyId;
2122
2123 pSirSmeMicFailureInd->info.IV1=
2124 pSirMicFailureInd->info.IV1;
2125
2126 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2127 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2128
2129 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2130 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2131 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002132 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2134 return;
2135}
2136
2137
2138/** -----------------------------------------------------------------
2139 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2140
2141 This function is called before enqueuing the frame to PE queue for further processing.
2142 This prevents unnecessary frames getting into PE Queue and drops them right away.
2143 Frames will be droped in the following scenarios:
2144
2145 - In Scan State, drop the frames which are not marked as scan frames
2146 - In non-Scan state, drop the frames which are marked as scan frames.
2147 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2148 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2149
2150 \param pMac - global mac structure
2151 \return - none
2152 \sa
2153 ----------------------------------------------------------------- */
2154
2155tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2156{
2157 tANI_U32 framelen;
2158 tANI_U8 *pBody;
2159 tSirMacCapabilityInfo capabilityInfo;
2160
2161 /*
2162 *
2163 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2164 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2165 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2166 * other than beacons or probe responses in scan state.
2167 */
2168 if( (subType == SIR_MAC_MGMT_BEACON) ||
2169 (subType == SIR_MAC_MGMT_PROBE_RSP))
2170 {
2171 if(pMac->pmm.inMissedBeaconScenario)
2172 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002173 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2174 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 }
2176 if (limIsSystemInScanState(pMac))
2177 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002178 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002180#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2181 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2182 {
2183 return eMGMT_DROP_NO_DROP;
2184 }
2185#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2187 {
2188 return eMGMT_DROP_SCAN_MODE_FRAME;
2189 }
2190 }
2191
2192 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2193 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2194
2195 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2196 * beacons from an infrastructure network
2197 */
2198 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2199 if(!capabilityInfo.ibss)
2200 return eMGMT_DROP_NO_DROP;
2201#if 0
2202 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2203 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2204 return eMGMT_DROP_NO_DROP;
2205#endif
2206
2207 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2208 if( (subType == SIR_MAC_MGMT_BEACON) ||
2209 (subType == SIR_MAC_MGMT_PROBE_RSP))
2210 {
2211 //drop the frame if length is less than 12
2212 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2213 return eMGMT_DROP_INVALID_SIZE;
2214
2215 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2216
2217 //This can be enhanced to even check the SSID before deciding to enque the frame.
2218 if(capabilityInfo.ess)
2219 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2220 }
2221 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2222 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2223 {
2224 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2225 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2226 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2227 }
2228
2229 return eMGMT_DROP_NO_DROP;
2230}
2231
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002232eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2233{
2234 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002236 if(psPe)
2237 {
2238 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2239 {
2240 status = eHAL_STATUS_SUCCESS;
2241 }
2242 }
2243 return (status);
2244}
2245eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2246{
2247 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2248 if(psPe)
2249 {
2250 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2251 {
2252 status = eHAL_STATUS_SUCCESS;
2253 }
2254 }
2255 return (status);
2256}