blob: 43a535911807ea70396e2f15c7e7f685b0166572 [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 */
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301734 if ((limIsNullSsid(&pBeacon->ssId) &&
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301735 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301736 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))) ||
1737 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1738 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps))
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301739 )
1740 {
1741 /* If Hidden SSID and privacy bit is not matching with the current capability,
1742 * then send unicast probe request to AP and take decision after
1743 * receiving probe response */
1744 if (psessionEntry->fIgnoreCapsChange == true)
1745 {
1746 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1747 return;
1748 }
1749 psessionEntry->fWaitForProbeRsp = true;
1750 limLog(pMac, LOGW, FL("Hidden SSID and privacy bit is not matching,"
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301751 " Or Short preamble bit is not matching ,"
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301752 "sending directed probe request.. "));
1753 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1754 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1755 psessionEntry->dot11mode, 0, NULL);
1756
1757 if ( status != eSIR_SUCCESS)
1758 {
1759 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1760 }
1761
1762 return;
1763 }
1764 else
1765 {
1766 /* The control will come here if the frame is beacon with broadcast ssid
1767 * or probe response frame */
1768 if (psessionEntry->fWaitForProbeRsp == true)
1769 {
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301770 if ((((!limIsNullSsid(&pBeacon->ssId)) &&
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301771 (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == true)) &&
1772 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) ==
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301773 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))) &&
1774 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) ==
1775 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps))
1776 )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301777 {
1778 /* Only for probe response frames the control will come here */
1779 /* If beacon with broadcast ssid then fWaitForProbeRsp will be false,
1780 the control wll not come here*/
1781 limLog(pMac, LOGW, FL("Privacy bit in probe response is"
1782 "matching with the current setting,"
1783 "Ignoring subsequent privacy bit capability"
1784 "mismatch"));
1785 psessionEntry->fIgnoreCapsChange = true;
1786 psessionEntry->fWaitForProbeRsp = false;
1787 }
1788 }
1789 }
1790
1791 if ((psessionEntry->limSentCapsChangeNtf == false) &&
1792 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1794 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1795 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1796 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301797 (newChannel != psessionEntry->currentOperChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 )))
1799 {
1800
1801 /**
1802 * BSS capabilities have changed.
1803 * Inform Roaming.
1804 */
1805 len = sizeof(tSirMacCapabilityInfo) +
1806 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1807 3 * sizeof(tANI_U8) + // reserved fields
1808 pBeacon->ssId.length + 1;
1809
1810 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
1811 psessionEntry->bssId,
1812 sizeof(tSirMacAddr));
1813 if (newChannel != psessionEntry->currentOperChannel)
1814 {
1815 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001816 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 psessionEntry->currentOperChannel, newChannel);)
1818 return;
1819 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301820
1821 /**
1822 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1823 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1824 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1825 * the privacy bit is set in Probe and association responses.
1826 * Due to this anomaly, we detect a change in
1827 * AP capabilities when we receive a beacon after association and
1828 * disconnect from the AP. The following check makes sure that we can
1829 * connect to such APs
1830 */
1831 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1832 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1833 {
1834 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001835 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301836 return;
1837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 else
1839 apNewCaps.channelId = psessionEntry->currentOperChannel;
1840 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
1841 (tANI_U8 *) &pBeacon->ssId,
1842 pBeacon->ssId.length + 1);
1843
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301844 psessionEntry->fIgnoreCapsChange = false;
1845 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 psessionEntry->limSentCapsChangeNtf = true;
1847 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1848 (tANI_U32 *) &apNewCaps,
1849 len, psessionEntry->smeSessionId);
1850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001851} /*** limDetectChangeInApCapabilities() ***/
1852
1853
1854
1855
1856// ---------------------------------------------------------------------
1857/**
1858 * limUpdateShortSlot
1859 *
1860 * FUNCTION:
1861 * Enable/Disable short slot
1862 *
1863 * LOGIC:
1864 *
1865 * ASSUMPTIONS:
1866 *
1867 * NOTE:
1868 *
1869 * @param enable Flag to enable/disable short slot
1870 * @return None
1871 */
1872
1873tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1874{
1875
1876 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07001877 tANI_U32 nShortSlot;
1878 tANI_U32 val = 0;
1879 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001880
Jeff Johnsone7245742012-09-05 17:12:55 -07001881 // Check Admin mode first. If it is disabled just return
1882 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
1883 != eSIR_SUCCESS)
1884 {
1885 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001886 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001887 return eSIR_FAILURE;
1888 }
1889 if (val == false)
1890 return eSIR_SUCCESS;
1891
1892 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
1893 limGetPhyMode(pMac, &phyMode, psessionEntry);
1894 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
1895 return eSIR_SUCCESS;
1896
1897 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
1899 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
1900 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
1901 // if no erp present, use short slot based on current ap caps
1902
1903 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
1904
1905 //Resolution : always use the shortSlot setting the capability info to decide slot time.
1906 // The difference between the earlier implementation and the new one is only Case4.
1907 /*
1908 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1909 Case1 1 1 1 1 //AP should not advertise this combination.
1910 Case2 1 1 0 0
1911 Case3 1 0 1 1
1912 Case4 1 0 0 0
1913 Case5 0 1 1 1
1914 Case6 0 1 0 0
1915 Case7 0 0 1 1
1916 Case8 0 0 0 0
1917 */
1918 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1919
Jeff Johnsone7245742012-09-05 17:12:55 -07001920 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 {
1922 // Short slot time capability of AP has changed. Adopt to it.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001923 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07001925 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
1927 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
1929 return eSIR_SUCCESS;
1930}
1931
1932
Jeff Johnson295189b2012-06-20 16:38:30 -07001933
1934
Jeff Johnson295189b2012-06-20 16:38:30 -07001935
Jeff Johnson295189b2012-06-20 16:38:30 -07001936
1937
1938/** -----------------------------------------------------------------
1939 \brief limHandleLowRssiInd() - handles low rssi indication
1940
1941 This function process the SIR_HAL_LOW_RSSI_IND message from
1942 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
1943
1944 \param pMac - global mac structure
1945
1946 \return
1947
1948 \sa
1949 ----------------------------------------------------------------- */
1950void limHandleLowRssiInd(tpAniSirGlobal pMac)
1951{
1952#if 0 //RSSI related indications will now go to TL and not PE
1953 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
1954 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
1955 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
1956 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001957 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
1959 }
1960 else
1961 {
1962 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001963 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 pMac->pmm.gPmmState);
1965 }
1966 return;
1967#endif
1968}
1969
1970
1971/** -----------------------------------------------------------------
1972 \brief limHandleBmpsStatusInd() - handles BMPS status indication
1973
1974 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
1975 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1976 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
1977
1978 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
1979 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
1980 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
1981 This message can also come from FW anytime after we have entered BMPS.
1982 This means we should handle it in WoWL and UAPSD states as well
1983
1984 \param pMac - global mac structure
1985 \return - none
1986 \sa
1987 ----------------------------------------------------------------- */
1988void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
1989{
1990 switch(pMac->pmm.gPmmState)
1991 {
1992 case ePMM_STATE_BMPS_SLEEP:
1993 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
1994 case ePMM_STATE_UAPSD_SLEEP:
1995 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
1996 case ePMM_STATE_WOWLAN:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001997 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
1999 break;
2000
2001 default:
2002 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002003 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 pMac->pmm.gPmmState);
2005 break;
2006 }
2007 return;
2008}
2009
2010
2011/** -----------------------------------------------------------------
2012 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2013
2014 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2015 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2016 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2017
2018 \param pMac - global mac structure
2019 \return - none
2020 \sa
2021 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002022void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002023{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002024#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2025 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2026 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2027 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2028 if (psessionEntry == NULL)
2029 {
2030 limLog(pMac, LOGE,
2031 FL("session does not exist for given BSSIdx:%d"),
2032 pSirMissedBeaconInd->bssIdx);
2033 return;
2034 }
2035#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2037 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2038 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2039 {
2040 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002041 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2043 }
Yathish9f22e662012-12-10 14:21:35 -08002044/* ACTIVE_MODE_HB_OFFLOAD */
2045#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2046 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2047 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2048 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2049 {
2050 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002051 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002052 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002053 }
2054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 else
2056 {
2057 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002058 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 pMac->pmm.gPmmState);
2060 }
2061 return;
2062}
2063
2064/** -----------------------------------------------------------------
2065 \brief limMicFailureInd() - handles mic failure indication
2066
2067 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2068
2069 \param pMac - global mac structure
2070 \return - none
2071 \sa
2072 ----------------------------------------------------------------- */
2073void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2074{
2075 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2076 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2077 tSirMsgQ mmhMsg;
2078 tpPESession psessionEntry ;
2079 tANI_U8 sessionId;
2080
2081 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2082 {
2083 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002084 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 return;
2086 }
2087
2088 if (eHAL_STATUS_SUCCESS !=
2089 palAllocateMemory(pMac->hHdd,
2090 (void **) &pSirSmeMicFailureInd,
2091 sizeof(tSirSmeMicFailureInd)))
2092 {
2093 // Log error
2094 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002095 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 return;
2097 }
2098
2099 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2100 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2101 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2102
2103 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2104 pSirMicFailureInd->bssId,
2105 sizeof(tSirMacAddr));
2106
2107 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2108 pSirMicFailureInd->info.srcMacAddr,
2109 sizeof(tSirMacAddr));
2110
2111 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2112 pSirMicFailureInd->info.taMacAddr,
2113 sizeof(tSirMacAddr));
2114
2115 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2116 pSirMicFailureInd->info.dstMacAddr,
2117 sizeof(tSirMacAddr));
2118
2119 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2120 pSirMicFailureInd->info.rxMacAddr,
2121 sizeof(tSirMacAddr));
2122
2123 pSirSmeMicFailureInd->info.multicast =
2124 pSirMicFailureInd->info.multicast;
2125
2126 pSirSmeMicFailureInd->info.keyId=
2127 pSirMicFailureInd->info.keyId;
2128
2129 pSirSmeMicFailureInd->info.IV1=
2130 pSirMicFailureInd->info.IV1;
2131
2132 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2133 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2134
2135 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2136 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2137 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002138 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2140 return;
2141}
2142
2143
2144/** -----------------------------------------------------------------
2145 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2146
2147 This function is called before enqueuing the frame to PE queue for further processing.
2148 This prevents unnecessary frames getting into PE Queue and drops them right away.
2149 Frames will be droped in the following scenarios:
2150
2151 - In Scan State, drop the frames which are not marked as scan frames
2152 - In non-Scan state, drop the frames which are marked as scan frames.
2153 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2154 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2155
2156 \param pMac - global mac structure
2157 \return - none
2158 \sa
2159 ----------------------------------------------------------------- */
2160
2161tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2162{
2163 tANI_U32 framelen;
2164 tANI_U8 *pBody;
2165 tSirMacCapabilityInfo capabilityInfo;
2166
2167 /*
2168 *
2169 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2170 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2171 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2172 * other than beacons or probe responses in scan state.
2173 */
2174 if( (subType == SIR_MAC_MGMT_BEACON) ||
2175 (subType == SIR_MAC_MGMT_PROBE_RSP))
2176 {
2177 if(pMac->pmm.inMissedBeaconScenario)
2178 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002179 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2180 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 }
2182 if (limIsSystemInScanState(pMac))
2183 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002184 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002186#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2187 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2188 {
2189 return eMGMT_DROP_NO_DROP;
2190 }
2191#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2193 {
2194 return eMGMT_DROP_SCAN_MODE_FRAME;
2195 }
2196 }
2197
2198 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2199 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2200
2201 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2202 * beacons from an infrastructure network
2203 */
2204 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2205 if(!capabilityInfo.ibss)
2206 return eMGMT_DROP_NO_DROP;
2207#if 0
2208 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2209 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2210 return eMGMT_DROP_NO_DROP;
2211#endif
2212
2213 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2214 if( (subType == SIR_MAC_MGMT_BEACON) ||
2215 (subType == SIR_MAC_MGMT_PROBE_RSP))
2216 {
2217 //drop the frame if length is less than 12
2218 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2219 return eMGMT_DROP_INVALID_SIZE;
2220
2221 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2222
2223 //This can be enhanced to even check the SSID before deciding to enque the frame.
2224 if(capabilityInfo.ess)
2225 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2226 }
2227 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2228 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2229 {
2230 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2231 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2232 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2233 }
2234
2235 return eMGMT_DROP_NO_DROP;
2236}
2237
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002238eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2239{
2240 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002241
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002242 if(psPe)
2243 {
2244 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2245 {
2246 status = eHAL_STATUS_SUCCESS;
2247 }
2248 }
2249 return (status);
2250}
2251eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2252{
2253 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2254 if(psPe)
2255 {
2256 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2257 {
2258 status = eHAL_STATUS_SUCCESS;
2259 }
2260 }
2261 return (status);
2262}