blob: fae3da2efb60dd95db749810b39cc4a69cf2e347 [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 }
Venkata Prathyusha Kuntupalli22ba5982013-04-24 13:09:20 -07001039 pMac->lim.deauthMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 return eSIR_SUCCESS;
1041}
1042
1043/** -------------------------------------------------------------
1044\fn peClose
1045\brief will be called in close sequence from macClose
1046\param tpAniSirGlobal pMac
1047\return tSirRetStatus
1048 -------------------------------------------------------------*/
1049
1050tSirRetStatus peClose(tpAniSirGlobal pMac)
1051{
1052 tANI_U8 i;
1053
1054 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1055 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001056
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 for(i =0; i < pMac->lim.maxBssId; i++)
1058 {
1059 if(pMac->lim.gpSession[i].valid == TRUE)
1060 {
1061 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1062 }
1063 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001064 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1065 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001066#if 0
Jeff Johnsone7245742012-09-05 17:12:55 -07001067 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1068 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001069#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001070
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1072 pMac->lim.gpSession = NULL;
1073 /*
1074 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1075 pMac->dph.dphHashTable.pHashTable = NULL;
1076 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1077 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1078 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1080 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001081 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1082 {
1083 return eSIR_FAILURE;
1084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 return eSIR_SUCCESS;
1086}
1087
1088/** -------------------------------------------------------------
1089\fn peStart
1090\brief will be called in start sequence from macStart
1091\param tpAniSirGlobal pMac
1092\return none
1093 -------------------------------------------------------------*/
1094
1095tSirRetStatus peStart(tpAniSirGlobal pMac)
1096{
1097 tSirRetStatus status = eSIR_SUCCESS;
1098
1099 status = limInitialize(pMac);
1100#if defined(ANI_LOGDUMP)
1101 limDumpInit(pMac);
1102#endif //#if defined(ANI_LOGDUMP)
1103
1104 return status;
1105}
1106
1107/** -------------------------------------------------------------
1108\fn peStop
1109\brief will be called in stop sequence from macStop
1110\param tpAniSirGlobal pMac
1111\return none
1112 -------------------------------------------------------------*/
1113
1114void peStop(tpAniSirGlobal pMac)
1115{
1116 limCleanup(pMac);
1117 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1118 return;
1119}
1120
1121/** -------------------------------------------------------------
1122\fn peFreeMsg
1123\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1124\ to free a given PE message on the TX and MC thread.
1125\ This happens when there are messages pending in the PE
1126\ queue when system is being stopped and reset.
1127\param tpAniSirGlobal pMac
1128\param tSirMsgQ pMsg
1129\return none
1130-----------------------------------------------------------------*/
1131v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1132{
1133 if (pMsg != NULL)
1134 {
1135 if (NULL != pMsg->bodyptr)
1136 {
1137 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1138 {
1139 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1140 }
1141 else
1142 {
1143 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1144 }
1145 }
1146 pMsg->bodyptr = 0;
1147 pMsg->bodyval = 0;
1148 pMsg->type = 0;
1149 }
1150 return;
1151}
1152
1153
1154/**
1155 * The function checks if a particular timer should be allowed
1156 * into LIM while device is sleeping
1157 */
1158tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1159{
1160 tANI_U8 retStatus = TRUE;
1161
1162 if(!limIsSystemInActiveState(pMac))
1163 {
1164 switch(pMsg->type)
1165 {
1166 /* Don't allow following timer messages if in sleep */
1167 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1168 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1169 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1170 retStatus = FALSE;
1171 break;
1172 /* May allow following timer messages in sleep mode */
1173 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1174
1175 /* Safe to allow as of today, this triggers background scan
1176 * which will not be started if the device is in power-save mode
1177 * might need to block in the future if we decide to implement
1178 * spectrum management
1179 */
1180 case SIR_LIM_QUIET_TIMEOUT:
1181
1182 /* Safe to allow as of today, this triggers background scan
1183 * which will not be started if the device is in power-save mode
1184 * might need to block in the future if we decide to implement
1185 * spectrum management
1186 */
1187 case SIR_LIM_QUIET_BSS_TIMEOUT:
1188
1189 /* Safe to allow this timermessage, triggers background scan
1190 * which is blocked in sleep mode
1191 */
1192 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1193
1194 /* Safe to allow this timer, since, while in IMPS this timer will not
1195 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1196 * when heart-beat control is handled back to PE, device would have
1197 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1198 */
1199 case SIR_LIM_HEART_BEAT_TIMEOUT:
1200 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1201
1202 /* Safe to allow, PE is not handling this message as of now. May need
1203 * to block it, basically, free the buffer and restart the timer
1204 */
1205 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1206 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001207 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1209 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1210 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1211 retStatus = TRUE;
1212 break;
1213
1214 /* by default allow rest of messages */
1215 default:
1216 retStatus = TRUE;
1217 break;
1218
1219
1220 }
1221 }
1222
1223 return retStatus;
1224
1225}
1226
1227
1228
1229/**
1230 * limPostMsgApi()
1231 *
1232 *FUNCTION:
1233 * This function is called from other thread while posting a
1234 * message to LIM message Queue gSirLimMsgQ.
1235 *
1236 *LOGIC:
1237 * NA
1238 *
1239 *ASSUMPTIONS:
1240 * NA
1241 *
1242 *NOTE:
1243 * NA
1244 *
1245 * @param pMac - Pointer to Global MAC structure
1246 * @param pMsg - Pointer to the message structure
1247 * @return None
1248 */
1249
1250tANI_U32
1251limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1252{
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1254
1255
Jeff Johnson295189b2012-06-20 16:38:30 -07001256} /*** end limPostMsgApi() ***/
1257
1258
1259/*--------------------------------------------------------------------------
1260
1261 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1262
1263 This function can be called by legacy code to post message to voss queues OR
1264 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1265 for dispatching it later.
1266
1267 \param pMac - Pointer to Global MAC structure
1268 \param pMsg - Pointer to the message structure
1269
1270 \return tANI_U32 - TX_SUCCESS for success.
1271
1272 --------------------------------------------------------------------------*/
1273
1274tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1275{
1276 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1277}
1278
1279/*--------------------------------------------------------------------------
1280
1281 \brief peProcessMessages() - Message Processor for PE
1282
1283 Voss calls this function to dispatch the message to PE
1284
1285 \param pMac - Pointer to Global MAC structure
1286 \param pMsg - Pointer to the message structure
1287
1288 \return tANI_U32 - TX_SUCCESS for success.
1289
1290 --------------------------------------------------------------------------*/
1291
1292tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1293{
1294 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1295 {
1296 return eSIR_SUCCESS;
1297 }
1298 /**
1299 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1300 * for all the other cases post it to LIM
1301 */
1302 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1303 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1304 else
1305 limMessageProcessor(pMac, pMsg);
1306 return eSIR_SUCCESS;
1307}
1308
1309
Jeff Johnson295189b2012-06-20 16:38:30 -07001310
1311// ---------------------------------------------------------------------------
1312/**
1313 * peHandleMgmtFrame
1314 *
1315 * FUNCTION:
1316 * Process the Management frames from TL
1317 *
1318 * LOGIC:
1319 *
1320 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1321 *
1322 * NOTE:
1323 *
1324 * @param pvosGCtx Global Vos Context
1325 * @param vossBuff Packet
1326 * @return None
1327 */
1328
1329VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1330{
1331 tpAniSirGlobal pMac;
1332 tpSirMacMgmtHdr mHdr;
1333 tSirMsgQ msg;
1334 vos_pkt_t *pVosPkt;
1335 VOS_STATUS vosStatus;
1336 v_U8_t *pRxPacketInfo;
1337
1338 pVosPkt = (vos_pkt_t *)vosBuff;
1339 if (NULL == pVosPkt)
1340 {
1341 return VOS_STATUS_E_FAILURE;
1342 }
1343
1344 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1345 if (NULL == pMac)
1346 {
1347 // cannot log a failure without a valid pMac
1348 vos_pkt_return_packet(pVosPkt);
1349 return VOS_STATUS_E_FAILURE;
1350 }
1351
1352 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1353
1354 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1355 {
1356 vos_pkt_return_packet(pVosPkt);
1357 return VOS_STATUS_E_FAILURE;
1358 }
1359
1360
1361 //
1362 // The MPDU header is now present at a certain "offset" in
1363 // the BD and is specified in the BD itself
1364 //
1365 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1366 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1367 {
1368 PELOG1(limLog( pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001369 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001370 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001371
Jeff Johnsone7245742012-09-05 17:12:55 -07001372 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1374 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1375 }
1376
1377
1378 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1379 msg.type = SIR_BB_XPORT_MGMT_MSG;
1380 msg.bodyptr = vosBuff;
1381 msg.bodyval = 0;
1382
1383 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1384 &msg,
1385 mHdr->fc.type,
1386 mHdr->fc.subType ))
1387 {
1388 vos_pkt_return_packet(pVosPkt);
1389 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001390 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 return VOS_STATUS_E_FAILURE;
1392 }
1393
1394 return VOS_STATUS_SUCCESS;
1395}
1396
1397// ---------------------------------------------------------------------------
1398/**
1399 * peRegisterTLHandle
1400 *
1401 * FUNCTION:
1402 * Registers the Handler which, process the Management frames from TL
1403 *
1404 * LOGIC:
1405 *
1406 * ASSUMPTIONS:
1407 *
1408 * NOTE:
1409 *
1410 * @return None
1411 */
1412
1413void peRegisterTLHandle(tpAniSirGlobal pMac)
1414{
1415 v_PVOID_t pvosGCTx;
1416 VOS_STATUS retStatus;
1417
1418 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1419
1420 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1421
1422 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001423 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001424
1425}
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
1427
1428/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 * limIsSystemInScanState()
1430 *
1431 *FUNCTION:
1432 * This function is called by various MAC software modules to
1433 * determine if System is in Scan/Learn state
1434 *
1435 *LOGIC:
1436 * NA
1437 *
1438 *ASSUMPTIONS:
1439 * NA
1440 *
1441 *NOTE:
1442 *
1443 * @param pMac - Pointer to Global MAC structure
1444 * @return true - System is in Scan/Learn state
1445 * false - System is NOT in Scan/Learn state
1446 */
1447
1448tANI_U8
1449limIsSystemInScanState(tpAniSirGlobal pMac)
1450{
1451 switch (pMac->lim.gLimSmeState)
1452 {
1453 case eLIM_SME_CHANNEL_SCAN_STATE:
1454 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1455 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1456 case eLIM_SME_WT_SCAN_STATE:
1457 // System is in Learn mode
1458 return true;
1459
1460 default:
1461 // System is NOT in Learn mode
1462 return false;
1463 }
1464} /*** end limIsSystemInScanState() ***/
1465
1466
1467
1468/**
1469 * limIsSystemInActiveState()
1470 *
1471 *FUNCTION:
1472 * This function is called by various MAC software modules to
1473 * determine if System is in Active/Wakeup state
1474 *
1475 *LOGIC:
1476 * NA
1477 *
1478 *ASSUMPTIONS:
1479 * NA
1480 *
1481 *NOTE:
1482 *
1483 * @param pMac - Pointer to Global MAC structure
1484 * @return true - System is in Active state
1485 * false - System is not in Active state
1486 */
1487
1488tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1489{
1490 switch (pMac->pmm.gPmmState)
1491 {
1492 case ePMM_STATE_BMPS_WAKEUP:
1493 case ePMM_STATE_IMPS_WAKEUP:
1494 case ePMM_STATE_READY:
1495 // System is in Active mode
1496 return true;
1497 default:
1498 return false;
1499 // System is NOT in Active mode
1500 }
1501}
1502
1503
Jeff Johnson295189b2012-06-20 16:38:30 -07001504
Jeff Johnson295189b2012-06-20 16:38:30 -07001505
1506
1507/**
1508*\brief limReceivedHBHandler()
1509*
1510* This function is called by schBeaconProcess() upon
1511* receiving a Beacon on STA. This also gets called upon
1512* receiving Probe Response after heat beat failure is
1513* detected.
1514*
1515* param pMac - global mac structure
1516* param channel - channel number indicated in Beacon, Probe Response
1517* return - none
1518*/
1519
1520
1521void
1522limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1523{
1524 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1525 psessionEntry->LimRxedBeaconCntDuringHB++;
1526
1527 pMac->pmm.inMissedBeaconScenario = FALSE;
1528} /*** end limReceivedHBHandler() ***/
1529
1530
1531
1532#if 0
1533void limResetHBPktCount(tpPESession psessionEntry)
1534{
1535 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1536}
1537#endif
1538
1539
1540/*
1541 * limProcessWdsInfo()
1542 *
1543 *FUNCTION:
1544 * This function is called from schBeaconProcess in BP
1545 *
1546 *PARAMS:
1547 * @param pMac - Pointer to Global MAC structure
1548 * @param propIEInfo - proprietary IE info
1549 *
1550 *LOGIC:
1551 *
1552 *ASSUMPTIONS:
1553 * NA
1554 *
1555 *NOTE:
1556 *
1557 *
1558 *RETURNS:
1559 *
1560 */
1561
1562void limProcessWdsInfo(tpAniSirGlobal pMac,
1563 tSirPropIEStruct propIEInfo)
1564{
Jeff Johnson295189b2012-06-20 16:38:30 -07001565}
1566
1567
1568
1569/**
1570 * limInitWdsInfoParams()
1571 *
1572 *FUNCTION:
1573 * This function is called while processing
1574 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1575 * ind/set related parameters.
1576 *
1577 *LOGIC:
1578 *
1579 *ASSUMPTIONS:
1580 *
1581 *NOTE:
1582 *
1583 * @param pMac Pointer to Global MAC structure
1584 * @return None
1585 */
1586
1587void
1588limInitWdsInfoParams(tpAniSirGlobal pMac)
1589{
1590 pMac->lim.gLimWdsInfo.wdsLength = 0;
1591 pMac->lim.gLimNumWdsInfoInd = 0;
1592 pMac->lim.gLimNumWdsInfoSet = 0;
1593} /*** limInitWdsInfoParams() ***/
1594
1595
1596/** -------------------------------------------------------------
1597\fn limUpdateOverlapStaParam
1598\brief Updates overlap cache and param data structure
1599\param tpAniSirGlobal pMac
1600\param tSirMacAddr bssId
1601\param tpLimProtStaParams pStaParams
1602\return None
1603 -------------------------------------------------------------*/
1604void
1605limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1606{
1607 int i;
1608 if (!pStaParams->numSta)
1609 {
1610 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1611 bssId,
1612 sizeof(tSirMacAddr));
1613 pMac->lim.protStaOverlapCache[0].active = true;
1614
1615 pStaParams->numSta = 1;
1616
1617 return;
1618 }
1619
1620 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1621 {
1622 if (pMac->lim.protStaOverlapCache[i].active)
1623 {
1624 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
1625 bssId,
1626 sizeof(tSirMacAddr))) {
1627 return; }
1628 }
1629 else
1630 break;
1631 }
1632
1633 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1634 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001635 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 }
1637 else
1638 {
1639 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
1640 bssId,
1641 sizeof(tSirMacAddr));
1642 pMac->lim.protStaOverlapCache[i].active = true;
1643
1644 pStaParams->numSta++;
1645 }
1646}
1647
1648
1649/**
1650 * limHandleIBSScoalescing()
1651 *
1652 *FUNCTION:
1653 * This function is called upon receiving Beacon/Probe Response
1654 * while operating in IBSS mode.
1655 *
1656 *LOGIC:
1657 *
1658 *ASSUMPTIONS:
1659 *
1660 *NOTE:
1661 *
1662 * @param pMac - Pointer to Global MAC structure
1663 * @param pBeacon - Parsed Beacon Frame structure
1664 * @param pRxPacketInfo - Pointer to RX packet info structure
1665 *
1666 * @return Status whether to process or ignore received Beacon Frame
1667 */
1668
1669tSirRetStatus
1670limHandleIBSScoalescing(
1671 tpAniSirGlobal pMac,
1672 tpSchBeaconStruct pBeacon,
1673 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1674{
1675 tpSirMacMgmtHdr pHdr;
1676 tSirRetStatus retCode;
1677
1678 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1679 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
1680 /* Received SSID does not match => Ignore received Beacon frame. */
1681 retCode = eSIR_LIM_IGNORE_BEACON;
1682 else
1683 {
1684 tANI_U32 ieLen;
1685 tANI_U16 tsfLater;
1686 tANI_U8 *pIEs;
1687 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1688 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1689 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
1690 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
1691 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1692 }
1693 return retCode;
1694} /*** end limHandleIBSScoalescing() ***/
1695
1696
1697
1698/**
1699 * limDetectChangeInApCapabilities()
1700 *
1701 *FUNCTION:
1702 * This function is called while SCH is processing
1703 * received Beacon from AP on STA to detect any
1704 * change in AP's capabilities. If there any change
1705 * is detected, Roaming is informed of such change
1706 * so that it can trigger reassociation.
1707 *
1708 *LOGIC:
1709 *
1710 *ASSUMPTIONS:
1711 *
1712 *NOTE:
1713 * Notification is enabled for STA product only since
1714 * it is not a requirement on BP side.
1715 *
1716 * @param pMac Pointer to Global MAC structure
1717 * @param pBeacon Pointer to parsed Beacon structure
1718 * @return None
1719 */
1720
1721void
1722limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1723 tpSirProbeRespBeacon pBeacon,
1724 tpPESession psessionEntry)
1725{
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 tANI_U8 len;
1727 tSirSmeApNewCaps apNewCaps;
1728 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301729 tSirRetStatus status = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1731 newChannel = (tANI_U8) pBeacon->channelNumber;
1732
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301733 /* Some APs are not setting privacy bit when hidden ssid enabled.
1734 * So LIM was keep on sending eSIR_SME_AP_CAPS_CHANGED event to SME */
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301735 if ((limIsNullSsid(&pBeacon->ssId) &&
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301736 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301737 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))) ||
1738 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1739 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps))
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301740 )
1741 {
1742 /* If Hidden SSID and privacy bit is not matching with the current capability,
1743 * then send unicast probe request to AP and take decision after
1744 * receiving probe response */
1745 if (psessionEntry->fIgnoreCapsChange == true)
1746 {
1747 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1748 return;
1749 }
1750 psessionEntry->fWaitForProbeRsp = true;
1751 limLog(pMac, LOGW, FL("Hidden SSID and privacy bit is not matching,"
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301752 " Or Short preamble bit is not matching ,"
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301753 "sending directed probe request.. "));
1754 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1755 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1756 psessionEntry->dot11mode, 0, NULL);
1757
1758 if ( status != eSIR_SUCCESS)
1759 {
1760 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1761 }
1762
1763 return;
1764 }
1765 else
1766 {
1767 /* The control will come here if the frame is beacon with broadcast ssid
1768 * or probe response frame */
1769 if (psessionEntry->fWaitForProbeRsp == true)
1770 {
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301771 if ((((!limIsNullSsid(&pBeacon->ssId)) &&
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301772 (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == true)) &&
1773 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) ==
madan mohan koyyalamudi1388b2f2013-06-19 18:58:59 +05301774 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))) &&
1775 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) ==
1776 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps))
1777 )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301778 {
1779 /* Only for probe response frames the control will come here */
1780 /* If beacon with broadcast ssid then fWaitForProbeRsp will be false,
1781 the control wll not come here*/
1782 limLog(pMac, LOGW, FL("Privacy bit in probe response is"
1783 "matching with the current setting,"
1784 "Ignoring subsequent privacy bit capability"
1785 "mismatch"));
1786 psessionEntry->fIgnoreCapsChange = true;
1787 psessionEntry->fWaitForProbeRsp = false;
1788 }
1789 }
1790 }
1791
1792 if ((psessionEntry->limSentCapsChangeNtf == false) &&
1793 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1795 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1796 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1797 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301798 (newChannel != psessionEntry->currentOperChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 )))
1800 {
1801
1802 /**
1803 * BSS capabilities have changed.
1804 * Inform Roaming.
1805 */
1806 len = sizeof(tSirMacCapabilityInfo) +
1807 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1808 3 * sizeof(tANI_U8) + // reserved fields
1809 pBeacon->ssId.length + 1;
1810
1811 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
1812 psessionEntry->bssId,
1813 sizeof(tSirMacAddr));
1814 if (newChannel != psessionEntry->currentOperChannel)
1815 {
1816 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001817 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 psessionEntry->currentOperChannel, newChannel);)
1819 return;
1820 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301821
1822 /**
1823 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1824 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1825 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1826 * the privacy bit is set in Probe and association responses.
1827 * Due to this anomaly, we detect a change in
1828 * AP capabilities when we receive a beacon after association and
1829 * disconnect from the AP. The following check makes sure that we can
1830 * connect to such APs
1831 */
1832 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1833 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1834 {
1835 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001836 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301837 return;
1838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 else
1840 apNewCaps.channelId = psessionEntry->currentOperChannel;
1841 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
1842 (tANI_U8 *) &pBeacon->ssId,
1843 pBeacon->ssId.length + 1);
1844
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301845 psessionEntry->fIgnoreCapsChange = false;
1846 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 psessionEntry->limSentCapsChangeNtf = true;
1848 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1849 (tANI_U32 *) &apNewCaps,
1850 len, psessionEntry->smeSessionId);
1851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001852} /*** limDetectChangeInApCapabilities() ***/
1853
1854
1855
1856
1857// ---------------------------------------------------------------------
1858/**
1859 * limUpdateShortSlot
1860 *
1861 * FUNCTION:
1862 * Enable/Disable short slot
1863 *
1864 * LOGIC:
1865 *
1866 * ASSUMPTIONS:
1867 *
1868 * NOTE:
1869 *
1870 * @param enable Flag to enable/disable short slot
1871 * @return None
1872 */
1873
1874tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1875{
1876
1877 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07001878 tANI_U32 nShortSlot;
1879 tANI_U32 val = 0;
1880 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881
Jeff Johnsone7245742012-09-05 17:12:55 -07001882 // Check Admin mode first. If it is disabled just return
1883 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
1884 != eSIR_SUCCESS)
1885 {
1886 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001887 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001888 return eSIR_FAILURE;
1889 }
1890 if (val == false)
1891 return eSIR_SUCCESS;
1892
1893 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
1894 limGetPhyMode(pMac, &phyMode, psessionEntry);
1895 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
1896 return eSIR_SUCCESS;
1897
1898 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001899
1900 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
1901 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
1902 // if no erp present, use short slot based on current ap caps
1903
1904 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
1905
1906 //Resolution : always use the shortSlot setting the capability info to decide slot time.
1907 // The difference between the earlier implementation and the new one is only Case4.
1908 /*
1909 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1910 Case1 1 1 1 1 //AP should not advertise this combination.
1911 Case2 1 1 0 0
1912 Case3 1 0 1 1
1913 Case4 1 0 0 0
1914 Case5 0 1 1 1
1915 Case6 0 1 0 0
1916 Case7 0 0 1 1
1917 Case8 0 0 0 0
1918 */
1919 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1920
Jeff Johnsone7245742012-09-05 17:12:55 -07001921 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 {
1923 // Short slot time capability of AP has changed. Adopt to it.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001924 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07001926 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
1928 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 }
1930 return eSIR_SUCCESS;
1931}
1932
1933
Jeff Johnson295189b2012-06-20 16:38:30 -07001934
1935
Jeff Johnson295189b2012-06-20 16:38:30 -07001936
Jeff Johnson295189b2012-06-20 16:38:30 -07001937
1938
1939/** -----------------------------------------------------------------
1940 \brief limHandleLowRssiInd() - handles low rssi indication
1941
1942 This function process the SIR_HAL_LOW_RSSI_IND message from
1943 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
1944
1945 \param pMac - global mac structure
1946
1947 \return
1948
1949 \sa
1950 ----------------------------------------------------------------- */
1951void limHandleLowRssiInd(tpAniSirGlobal pMac)
1952{
1953#if 0 //RSSI related indications will now go to TL and not PE
1954 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
1955 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
1956 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
1957 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001958 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
1960 }
1961 else
1962 {
1963 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001964 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 pMac->pmm.gPmmState);
1966 }
1967 return;
1968#endif
1969}
1970
1971
1972/** -----------------------------------------------------------------
1973 \brief limHandleBmpsStatusInd() - handles BMPS status indication
1974
1975 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
1976 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
1977 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
1978
1979 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
1980 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
1981 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
1982 This message can also come from FW anytime after we have entered BMPS.
1983 This means we should handle it in WoWL and UAPSD states as well
1984
1985 \param pMac - global mac structure
1986 \return - none
1987 \sa
1988 ----------------------------------------------------------------- */
1989void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
1990{
1991 switch(pMac->pmm.gPmmState)
1992 {
1993 case ePMM_STATE_BMPS_SLEEP:
1994 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
1995 case ePMM_STATE_UAPSD_SLEEP:
1996 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
1997 case ePMM_STATE_WOWLAN:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001998 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2000 break;
2001
2002 default:
2003 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002004 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 pMac->pmm.gPmmState);
2006 break;
2007 }
2008 return;
2009}
2010
2011
2012/** -----------------------------------------------------------------
2013 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2014
2015 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2016 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2017 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2018
2019 \param pMac - global mac structure
2020 \return - none
2021 \sa
2022 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002023void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002024{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002025#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2026 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2027 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2028 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2029 if (psessionEntry == NULL)
2030 {
2031 limLog(pMac, LOGE,
2032 FL("session does not exist for given BSSIdx:%d"),
2033 pSirMissedBeaconInd->bssIdx);
2034 return;
2035 }
2036#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2038 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2039 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2040 {
2041 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002042 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2044 }
Yathish9f22e662012-12-10 14:21:35 -08002045/* ACTIVE_MODE_HB_OFFLOAD */
2046#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2047 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2048 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2049 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2050 {
2051 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002052 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002053 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002054 }
2055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 else
2057 {
2058 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002059 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 pMac->pmm.gPmmState);
2061 }
2062 return;
2063}
2064
2065/** -----------------------------------------------------------------
2066 \brief limMicFailureInd() - handles mic failure indication
2067
2068 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2069
2070 \param pMac - global mac structure
2071 \return - none
2072 \sa
2073 ----------------------------------------------------------------- */
2074void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2075{
2076 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2077 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2078 tSirMsgQ mmhMsg;
2079 tpPESession psessionEntry ;
2080 tANI_U8 sessionId;
2081
2082 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2083 {
2084 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002085 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 return;
2087 }
2088
2089 if (eHAL_STATUS_SUCCESS !=
2090 palAllocateMemory(pMac->hHdd,
2091 (void **) &pSirSmeMicFailureInd,
2092 sizeof(tSirSmeMicFailureInd)))
2093 {
2094 // Log error
2095 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002096 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 return;
2098 }
2099
2100 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2101 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2102 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2103
2104 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2105 pSirMicFailureInd->bssId,
2106 sizeof(tSirMacAddr));
2107
2108 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2109 pSirMicFailureInd->info.srcMacAddr,
2110 sizeof(tSirMacAddr));
2111
2112 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2113 pSirMicFailureInd->info.taMacAddr,
2114 sizeof(tSirMacAddr));
2115
2116 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2117 pSirMicFailureInd->info.dstMacAddr,
2118 sizeof(tSirMacAddr));
2119
2120 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2121 pSirMicFailureInd->info.rxMacAddr,
2122 sizeof(tSirMacAddr));
2123
2124 pSirSmeMicFailureInd->info.multicast =
2125 pSirMicFailureInd->info.multicast;
2126
2127 pSirSmeMicFailureInd->info.keyId=
2128 pSirMicFailureInd->info.keyId;
2129
2130 pSirSmeMicFailureInd->info.IV1=
2131 pSirMicFailureInd->info.IV1;
2132
2133 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2134 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2135
2136 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2137 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2138 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002139 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2141 return;
2142}
2143
2144
2145/** -----------------------------------------------------------------
2146 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2147
2148 This function is called before enqueuing the frame to PE queue for further processing.
2149 This prevents unnecessary frames getting into PE Queue and drops them right away.
2150 Frames will be droped in the following scenarios:
2151
2152 - In Scan State, drop the frames which are not marked as scan frames
2153 - In non-Scan state, drop the frames which are marked as scan frames.
2154 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2155 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2156
2157 \param pMac - global mac structure
2158 \return - none
2159 \sa
2160 ----------------------------------------------------------------- */
2161
2162tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2163{
2164 tANI_U32 framelen;
2165 tANI_U8 *pBody;
2166 tSirMacCapabilityInfo capabilityInfo;
2167
2168 /*
2169 *
2170 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2171 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2172 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2173 * other than beacons or probe responses in scan state.
2174 */
2175 if( (subType == SIR_MAC_MGMT_BEACON) ||
2176 (subType == SIR_MAC_MGMT_PROBE_RSP))
2177 {
2178 if(pMac->pmm.inMissedBeaconScenario)
2179 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002180 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2181 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 }
2183 if (limIsSystemInScanState(pMac))
2184 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002185 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002187#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2188 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2189 {
2190 return eMGMT_DROP_NO_DROP;
2191 }
2192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2194 {
2195 return eMGMT_DROP_SCAN_MODE_FRAME;
2196 }
2197 }
2198
2199 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2200 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2201
2202 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2203 * beacons from an infrastructure network
2204 */
2205 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2206 if(!capabilityInfo.ibss)
2207 return eMGMT_DROP_NO_DROP;
2208#if 0
2209 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2210 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2211 return eMGMT_DROP_NO_DROP;
2212#endif
2213
2214 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2215 if( (subType == SIR_MAC_MGMT_BEACON) ||
2216 (subType == SIR_MAC_MGMT_PROBE_RSP))
2217 {
2218 //drop the frame if length is less than 12
2219 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2220 return eMGMT_DROP_INVALID_SIZE;
2221
2222 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2223
2224 //This can be enhanced to even check the SSID before deciding to enque the frame.
2225 if(capabilityInfo.ess)
2226 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2227 }
2228 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2229 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2230 {
2231 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2232 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2233 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2234 }
2235
2236 return eMGMT_DROP_NO_DROP;
2237}
2238
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002239eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2240{
2241 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002243 if(psPe)
2244 {
2245 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2246 {
2247 status = eHAL_STATUS_SUCCESS;
2248 }
2249 }
2250 return (status);
2251}
2252eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2253{
2254 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2255 if(psPe)
2256 {
2257 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2258 {
2259 status = eHAL_STATUS_SUCCESS;
2260 }
2261 }
2262 return (status);
2263}