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