blob: 071b9cb4d6c66a75f2955a3ccfe615c99157559a [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"
55#ifdef ANI_PRODUCT_TYPE_AP
56#include "wniCfgAp.h"
57#else
58#include "wniCfgSta.h"
59#include "wniApi.h"
60#endif
61#include "sirCommon.h"
62#include "sirDebug.h"
63#include "aniParam.h"
64#include "cfgApi.h"
65
66#include "schApi.h"
67#include "utilsApi.h"
68#include "limApi.h"
69#include "limGlobal.h"
70#include "limTypes.h"
71#include "limUtils.h"
72#include "limAssocUtils.h"
73#include "limPropExtsUtils.h"
74#include "limSerDesUtils.h"
75#include "limIbssPeerMgmt.h"
76#include "limAdmitControl.h"
77#include "pmmApi.h"
78#include "logDump.h"
79#include "limSendSmeRspMessages.h"
80#include "wmmApsd.h"
81#include "limTrace.h"
82#include "limSession.h"
83#include "wlan_qct_wda.h"
84
85#if defined WLAN_FEATURE_VOWIFI
86#include "rrmApi.h"
87#endif
88
89#include <limFT.h>
90
91#ifdef VOSS_ENABLED
92#include "vos_types.h"
93#include "vos_packet.h"
94#include "wlan_qct_tl.h"
95#include "sysStartup.h"
96#endif
97
98
99static void __limInitScanVars(tpAniSirGlobal pMac)
100{
101 pMac->lim.gLimUseScanModeForLearnMode = 1;
102
103 pMac->lim.gLimSystemInScanLearnMode = 0;
104
105 // Scan related globals on STA
106 pMac->lim.gLimReturnAfterFirstMatch = 0;
107 pMac->lim.gLim24Band11dScanDone = 0;
108 pMac->lim.gLim50Band11dScanDone = 0;
109 pMac->lim.gLimReturnUniqueResults = 0;
110
111 // Background Scan related globals on STA
112 pMac->lim.gLimNumOfBackgroundScanSuccess = 0;
113 pMac->lim.gLimNumOfConsecutiveBkgndScanFailure = 0;
114 pMac->lim.gLimNumOfForcedBkgndScan = 0;
115 pMac->lim.gLimBackgroundScanDisable = false; //based on BG timer
116 pMac->lim.gLimForceBackgroundScanDisable = false; //debug control flag
117 pMac->lim.gLimBackgroundScanTerminate = TRUE; //controlled by SME
118 pMac->lim.gLimReportBackgroundScanResults = FALSE; //controlled by SME
119
120 pMac->lim.gLimCurrentScanChannelId = 0;
121 pMac->lim.gpLimMlmScanReq = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800122#ifdef WLAN_FEATURE_P2P
123 pMac->lim.gpLimSmeScanReq = NULL;
124#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700125 pMac->lim.gLimMlmScanResultLength = 0;
126 pMac->lim.gLimSmeScanResultLength = 0;
127
128 palZeroMemory(pMac->hHdd, pMac->lim.gLimCachedScanHashTable,
129 sizeof(pMac->lim.gLimCachedScanHashTable));
130
131#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
132 pMac->lim.gLimBackgroundScanChannelId = 0;
133 pMac->lim.gLimBackgroundScanStarted = 0;
134 pMac->lim.gLimRestoreCBNumScanInterval = LIM_RESTORE_CB_NUM_SCAN_INTERVAL_DEFAULT;
135 pMac->lim.gLimRestoreCBCount = 0;
136 palZeroMemory(pMac->hHdd, pMac->lim.gLimLegacyBssidList, sizeof(pMac->lim.gLimLegacyBssidList));
137#endif
138
139 /* Fill in default values */
140 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = 0;
141
142#ifdef ANI_AP_SDK
143 palZeroMemory(pMac->hHdd, &pMac->lim.gLimScanDurationConvert, sizeof(tLimScanDurationConvert)); /* Used to store converted scan duration values in TU and TICKS */
144#endif /* ANI_AP_SDK */
145
146 // abort scan is used to abort an on-going scan
147 pMac->lim.abortScan = 0;
148 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
149
150//WLAN_SUSPEND_LINK Related
151 pMac->lim.gpLimSuspendCallback = NULL;
152 pMac->lim.gpLimResumeCallback = NULL;
153//end WLAN_SUSPEND_LINK Related
154}
155
156
157static void __limInitBssVars(tpAniSirGlobal pMac)
158{
159
160 palZeroMemory(pMac->hHdd, (void*)pMac->lim.gpSession, sizeof(*pMac->lim.gpSession)*pMac->lim.maxBssId);
161
162
163 //pMac->lim.gpLimStartBssReq = NULL;
164
165#if defined(ANI_PRODUCT_TYPE_AP)
166 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNeighborBssList, sizeof(tSirMultipleNeighborBssInfo));
167#endif
168
169
170
171/* These global variables are moved to session table and intialization is done during session creation Oct 9th Review */
172#if 0
173
174 // Place holder for BSS description that we're
175 // currently joined with
176 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentBssId, sizeof(tSirMacAddr));
177 pMac->lim.gLimCurrentChannelId = HAL_INVALID_CHANNEL_ID;
178 palZeroMemory(pMac->hHdd, &pMac->lim.gLimCurrentSSID, sizeof(tSirMacSSid));
179 pMac->lim.gLimCurrentBssCaps = 0;
180 QosCaps is a bit map of various qos capabilities - see defn above
181 pMac->lim.gLimCurrentBssQosCaps = 0;
182 pMac->lim.gLimCurrentBssPropCap = 0;
183 pMac->lim.gLimSentCapsChangeNtf = 0;
184
185 // Place holder for BSS description that
186 // we're currently Reassociating
187 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocBssId, sizeof(tSirMacAddr));
188 pMac->lim.gLimReassocChannelId = 0;
189 palZeroMemory(pMac->hHdd, &pMac->lim.gLimReassocSSID, sizeof(tSirMacSSid));
190 pMac->lim.gLimReassocBssCaps = 0;
191 pMac->lim.gLimReassocBssQosCaps = 0;
192 pMac->lim.gLimReassocBssPropCap = 0;
193 #endif
194
195 /* This is for testing purposes only, be default should always be off */
196 pMac->lim.gLimForceNoPropIE = 0;
197
198 // pMac->lim.gLimBssIdx = 0;
199
200 pMac->lim.gpLimMlmSetKeysReq = NULL;
201 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
202 // pMac->lim.gLimStaid = 0; //TO SUPPORT BT-AMP
203
204}
205
206
207static void __limInitStatsVars(tpAniSirGlobal pMac)
208{
209 pMac->lim.gLimNumBeaconsRcvd = 0;
210 pMac->lim.gLimNumBeaconsIgnored = 0;
211
212 pMac->lim.gLimNumDeferredMsgs = 0;
213
214 /// Variable to keep track of number of currently associated STAs
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800215 //pMac->lim.gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 pMac->lim.gLimNumOfAniSTAs = 0; // count of ANI peers
217
218 /// This indicates number of RXed Beacons during HB period
219 //pMac->lim.gLimRxedBeaconCntDuringHB = 0;
220
221 // Heart-Beat interval value
222 pMac->lim.gLimHeartBeatCount = 0;
223
224 // Statistics to keep track of no. beacons rcvd in heart beat interval
225 palZeroMemory(pMac->hHdd, pMac->lim.gLimHeartBeatBeaconStats, sizeof(pMac->lim.gLimHeartBeatBeaconStats));
226
227#ifdef WLAN_DEBUG
228 // Debug counters
229 pMac->lim.numTot = 0;
230 pMac->lim.numBbt = 0;
231 pMac->lim.numProtErr = 0;
232 pMac->lim.numLearn = 0;
233 pMac->lim.numLearnIgnore = 0;
234 pMac->lim.numSme = 0;
235 palZeroMemory(pMac->hHdd, pMac->lim.numMAC, sizeof(pMac->lim.numMAC));
236 pMac->lim.gLimNumAssocReqDropInvldState = 0;
237 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
238 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
239 pMac->lim.gLimNumReassocReqDropInvldState = 0;
240 pMac->lim.gLimNumHashMissIgnored = 0;
241 pMac->lim.gLimUnexpBcnCnt = 0;
242 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
243 pMac->lim.gLimNumLinkEsts = 0;
244 pMac->lim.gLimNumRxCleanup = 0;
245 pMac->lim.gLim11bStaAssocRejectCount = 0;
246#endif
247}
248
249
250
251static void __limInitStates(tpAniSirGlobal pMac)
252{
253 // Counts Heartbeat failures
254 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
255 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
256 pMac->lim.gLimHBfailureCntInOtherStates = 0;
257 pMac->lim.gLimRspReqd = 0;
258 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
259
260 /// MLM State visible across all Sirius modules
Jeff Johnsone7245742012-09-05 17:12:55 -0700261 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
263
264 /// Previous MLM State
265 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
266
267#ifdef GEN4_SCAN
268 // LIM to HAL SCAN Management Message Interface states
269 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
270#endif // GEN4_SCAN
271
272#ifdef FEATURE_WLAN_INTEGRATED_SOC
273 /**
Jeff Johnsone7245742012-09-05 17:12:55 -0700274 * Initialize state to eLIM_SME_OFFLINE_STATE
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700276 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700277#else
278 /**
279 * Initialize state to suspended state and wait for
280 * HAL to send LIM_RESUME_ACTIVITY_NTF message.
281 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700282 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 pMac->lim.gLimSmeState = eLIM_SME_SUSPEND_STATE;
284#endif /* FEATURE_WLAN_INTEGRATED_SOC */
285
286 /**
287 * By default assume 'unknown' role. This will be updated
288 * when SME_START_BSS_REQ is received.
289 */
290
291 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11gParams, sizeof(tLimProtStaParams));
292 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlap11aParams, sizeof(tLimProtStaParams));
293 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapHt20Params, sizeof(tLimProtStaParams));
294 palZeroMemory(pMac->hHdd, &pMac->lim.gLimOverlapNonGfParams, sizeof(tLimProtStaParams));
295 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams));
296 palZeroMemory(pMac->hHdd, &pMac->lim.gLimNoShortSlotParams, sizeof(tLimNoShortSlotParams));
297
298 pMac->lim.gLimPhyMode = 0;
299 pMac->lim.scanStartTime = 0; // used to measure scan time
300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 palZeroMemory(pMac->hHdd, pMac->lim.gLimMyMacAddr, sizeof(pMac->lim.gLimMyMacAddr));
302 pMac->lim.ackPolicy = 0;
303
304#if 0 /* Moving all these to session specific elements */
305 pMac->lim.gLimQosEnabled = 0; //11E
306 pMac->lim.gLimWmeEnabled = 0; //WME
307 pMac->lim.gLimWsmEnabled = 0; //WSM
308 pMac->lim.gLimHcfEnabled = 0;
309 pMac->lim.gLim11dEnabled = 0;
310#endif
311
312 pMac->lim.gLimProbeRespDisableFlag = 0; // control over probe response
313}
314
315static void __limInitVars(tpAniSirGlobal pMac)
316{
317
318#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
319 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAlternateRadioList, sizeof(tSirMultipleAlternateRadioInfo));
320#endif
321
322 // Place holder for Measurement Req/Rsp/Ind related info
323#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
324 pMac->lim.gpLimMeasReq = NULL;
325 palZeroMemory(pMac->hHdd, &pMac->lim.gLimMeasParams, sizeof(tLimMeasParams));
326 pMac->lim.gpLimMeasData = NULL;
327#endif
328
329 // WDS info
330 pMac->lim.gLimNumWdsInfoInd = 0;
331 pMac->lim.gLimNumWdsInfoSet = 0;
332 palZeroMemory(pMac->hHdd, &pMac->lim.gLimWdsInfo, sizeof(tSirWdsInfo));
333 /* initialize some parameters */
334 limInitWdsInfoParams(pMac);
335
336 // Deferred Queue Paramters
337 palZeroMemory(pMac->hHdd, &pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq));
338
339 // addts request if any - only one can be outstanding at any time
340 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq));
341 pMac->lim.gLimAddtsSent = 0;
342 pMac->lim.gLimAddtsRspTimerCount = 0;
343
344 //protection related config cache
345 palZeroMemory(pMac->hHdd, &pMac->lim.cfgProtection, sizeof(tCfgProtection));
346 pMac->lim.gLimProtectionControl = 0;
347 palZeroMemory(pMac->hHdd, &pMac->lim.gLimAlternateRadio, sizeof(tSirAlternateRadioInfo));
348 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
349
Jeff Johnsone7245742012-09-05 17:12:55 -0700350#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 // 11h Spectrum Management Related Flag
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
353 pMac->sys.gSysEnableLearnMode = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700354#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 // WMM Related Flag
356 pMac->lim.gUapsdEnable = 0;
357 pMac->lim.gUapsdPerAcBitmask = 0;
358 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
359 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
360
361 // QoS-AC Downgrade: Initially, no AC is admitted
362 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
363 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
364
365 //dialogue token List head/tail for Action frames request sent.
366 pMac->lim.pDialogueTokenHead = NULL;
367 pMac->lim.pDialogueTokenTail = NULL;
368
369 palZeroMemory(pMac->hHdd, &pMac->lim.tspecInfo, sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX);
370
371 // admission control policy information
372 palZeroMemory(pMac->hHdd, &pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo));
373
374 pMac->lim.gLastBeaconDtimCount = 0;
375 pMac->lim.gLastBeaconDtimPeriod = 0;
376
377 //Scan in Power Save Flag
378 pMac->lim.gScanInPowersave = 0;
379}
380
381static void __limInitAssocVars(tpAniSirGlobal pMac)
382{
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800383 tANI_U32 val;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800384#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 palZeroMemory(pMac->hHdd, pMac->lim.gpLimAIDpool,
386 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1));
387 pMac->lim.freeAidHead = 0;
388 pMac->lim.freeAidTail = 0;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800389#endif
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800390 if(wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS)
391 {
392 limLog( pMac, LOGP, FL( "cfg get assoc sta limit failed" ));
393 }
394 pMac->lim.gLimAssocStaLimit = val;
Jeff Johnson295189b2012-06-20 16:38:30 -0700395
396 // Place holder for current authentication request
397 // being handled
398 pMac->lim.gpLimMlmAuthReq = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -0700399 //pMac->lim.gpLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700400
401 /// MAC level Pre-authentication related globals
402 pMac->lim.gLimPreAuthChannelNumber = 0;
403 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
404 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr));
405 pMac->lim.gLimNumPreAuthContexts = 0;
406 palZeroMemory(pMac->hHdd, &pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable));
407
408 // Placed holder to deauth reason
409 pMac->lim.gLimDeauthReasonCode = 0;
410
411 // Place holder for Pre-authentication node list
412 pMac->lim.pLimPreAuthList = NULL;
413
414 // Send Disassociate frame threshold parameters
415 pMac->lim.gLimDisassocFrameThreshold = LIM_SEND_DISASSOC_FRAME_THRESHOLD;
416 pMac->lim.gLimDisassocFrameCredit = 0;
417
418 //One cache for each overlap and associated case.
419 palZeroMemory(pMac->hHdd, pMac->lim.protStaOverlapCache, sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE);
420 palZeroMemory(pMac->hHdd, pMac->lim.protStaCache, sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE);
421
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -0700422#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
423 pMac->lim.pSessionEntry = NULL;
424 pMac->lim.reAssocRetryAttempt = 0;
425#endif
426
Jeff Johnson295189b2012-06-20 16:38:30 -0700427}
428
429
430static void __limInitTitanVars(tpAniSirGlobal pMac)
431{
Jeff Johnsone7245742012-09-05 17:12:55 -0700432#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 palZeroMemory(pMac->hHdd, &pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700435 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
436#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700437 // Debug workaround for BEACON's
438 // State change triggered by "dump 222"
439 pMac->lim.gLimScanOverride = 1;
440 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 pMac->lim.gLimTitanStaCount = 0;
442 pMac->lim.gLimBlockNonTitanSta = 0;
443}
444
445static void __limInitHTVars(tpAniSirGlobal pMac)
446{
447 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 pMac->lim.gHTShortGI40Mhz = 0;
450 pMac->lim.gHTShortGI20Mhz = 0;
451 pMac->lim.gHTMaxAmsduLength = 0;
452 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
453 pMac->lim.gHTPSMPSupport = 0;
454 pMac->lim.gHTLsigTXOPProtection = 0;
455 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
456 pMac->lim.gHTAMpduDensity = 0;
457
458 pMac->lim.gMaxAmsduSizeEnabled = false;
459 pMac->lim.gHTMaxRxAMpduFactor = 0;
460 pMac->lim.gHTServiceIntervalGranularity = 0;
461 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
463 pMac->lim.gHTPCOActive = 0;
464
465 pMac->lim.gHTPCOPhase = 0;
466 pMac->lim.gHTSecondaryBeacon = 0;
467 pMac->lim.gHTDualCTSProtection = 0;
468 pMac->lim.gHTSTBCBasicMCS = 0;
469 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
470}
471
472#if defined( FEATURE_WLAN_INTEGRATED_SOC )
473static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
474{
Jeff Johnsone7245742012-09-05 17:12:55 -0700475 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 tANI_U16 val16;
477 tANI_U8 val8;
478 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
479 tSirMacHTInfoField1 *pHTInfoField1;
480 tpSirPowerSaveCfg pPowerSaveConfig;
481 tSirMacHTParametersInfo *pAmpduParamInfo;
482
483 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700484 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
485 * and they will be used throughout when there is no session
486 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700487
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
489 {
490 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG\n"));)
491 return eSIR_FAILURE;
492 }
493
494 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
495 {
496 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG\n"));)
497 return eSIR_FAILURE;
498 }
499 val16 = ( tANI_U16 ) val1;
500 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
501
502 //channel bonding mode could be set to anything from 0 to 4(Titan had these
503 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
504 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
505 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
506 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
507 != eSIR_SUCCESS)
508 {
509 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG\n"));)
510 return eSIR_FAILURE;
511 }
512
513 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
514 {
515 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG\n"));)
516 return eSIR_FAILURE;
517 }
518
519 val8 = ( tANI_U8 ) val1;
520 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
521 pHTInfoField1->recommendedTxWidthSet =
522 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
524 != eSIR_SUCCESS)
525 {
526 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field\n"));)
527 return eSIR_FAILURE;
528 }
529
530 /* WNI_CFG_HEART_BEAT_THRESHOLD */
531
532 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
533 eSIR_SUCCESS )
534 {
535 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG\n"));)
536 return eSIR_FAILURE;
537 }
538 if(!val1)
539 {
540 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
541 pMac->sys.gSysEnableLinkMonitorMode = 0;
542 }
543 else
544 {
545 //No need to activate the timer during init time.
546 pMac->sys.gSysEnableLinkMonitorMode = 1;
547 }
548
549 /* WNI_CFG_SHORT_GI_20MHZ */
550
551 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
552 {
553 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG\n"));)
554 return eSIR_FAILURE;
555 }
556 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
557 {
558 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG\n"));)
559 return eSIR_FAILURE;
560 }
561 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
562 {
563 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG\n"));)
564 return eSIR_FAILURE;
565 }
566
567 val16 = ( tANI_U16 ) val1;
568 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
569 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
570 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
571
572 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
573 eSIR_SUCCESS)
574 {
575 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG\n"));)
576 return eSIR_FAILURE;
577 }
578
579 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
580
581 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
582 {
583 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG\n"));)
584 return eSIR_FAILURE;
585 }
586 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
587 {
588 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG\n"));)
589 return eSIR_FAILURE;
590 }
591 val16 = ( tANI_U16 ) val1;
592 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
593 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
594 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
595 eSIR_SUCCESS)
596 {
597 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG\n"));)
598 return eSIR_FAILURE;
599 }
600
601 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
602 limHandleCFGparamUpdate do we want to update this? */
603 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
604 {
605 limLog(pMac, LOGP, FL("cfg get short preamble failed\n"));
606 return eSIR_FAILURE;
607 }
608
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 /* WNI_CFG_MAX_PS_POLL */
610
611 /* Allocate and fill in power save configuration. */
612 if (palAllocateMemory(pMac->hHdd, (void **)&pPowerSaveConfig,
613 sizeof(tSirPowerSaveCfg)) != eHAL_STATUS_SUCCESS)
614 {
615 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
616 "configuration\n"));)
617 return eSIR_FAILURE;
618 }
619
620 /* This context should be valid if power-save configuration message has been
621 * already dispatched during initialization process. Re-using the present
622 * configuration mask
623 */
624 palCopyMemory(pMac->hHdd, pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg,
625 sizeof(tSirPowerSaveCfg));
626
627 /* Note: it is okay to do this since DAL/HAL is alrady started */
628 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
629 {
630 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed \n"));)
631 return eSIR_FAILURE;
632 }
633
634 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
635
636#if (WNI_POLARIS_FW_PRODUCT == WLAN_STA) || defined(ANI_AP_CLIENT_SDK)
637 PELOG1(limLog(pMac, LOG1,
638 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel\n"));)
639 pMac->lim.gLimBackgroundScanChannelId = 0;
640#endif
641
642 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
643
644 /* This was initially done after resume notification from HAL. Now, DAL is
645 started before PE so this can be done here */
Jeff Johnsone7245742012-09-05 17:12:55 -0700646 handleHTCapabilityandHTInfo(pMac, NULL);
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800647 if(wlan_cfgGetInt(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,(tANI_U32 *) &pMac->lim.disableLDPCWithTxbfAP) != eSIR_SUCCESS)
648 {
649 limLog(pMac, LOGP, FL("cfg get disableLDPCWithTxbfAP failed\n"));
650 return eSIR_FAILURE;
651 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
653 return eSIR_SUCCESS;
654}
655#endif /* FEATURE_WLAN_INTEGRATED_SOC */
656
657/*
658 limStart
659 This function is to replace the __limProcessSmeStartReq since there is no
660 eWNI_SME_START_REQ post to PE.
661*/
662tSirRetStatus limStart(tpAniSirGlobal pMac)
663{
664 tSirResultCodes retCode = eSIR_SUCCESS;
665
666 PELOG1(limLog(pMac, LOG1, FL(" enter\n"));)
667
668 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
669 {
670 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
671
Jeff Johnsone7245742012-09-05 17:12:55 -0700672 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 // By default do not return after first scan match
675 pMac->lim.gLimReturnAfterFirstMatch = 0;
676
677 // Initialize MLM state machine
678 limInitMlm(pMac);
679
680 // By default return unique scan results
681 pMac->lim.gLimReturnUniqueResults = true;
682 pMac->lim.gLimSmeScanResultLength = 0;
683 }
684 else
685 {
686 /**
687 * Should not have received eWNI_SME_START_REQ in states
688 * other than OFFLINE. Return response to host and
689 * log error
690 */
691 limLog(pMac, LOGE, FL("Invalid SME state %X\n"),pMac->lim.gLimSmeState );
692 retCode = eSIR_FAILURE;
693 }
694
695 return retCode;
696}
697
698/**
699 * limInitialize()
700 *
701 *FUNCTION:
702 * This function is called from LIM thread entry function.
703 * LIM related global data structures are initialized in this function.
704 *
705 *LOGIC:
706 * NA
707 *
708 *ASSUMPTIONS:
709 * NA
710 *
711 *NOTE:
712 * NA
713 *
714 * @param pMac - Pointer to global MAC structure
715 * @return None
716 */
717
718tSirRetStatus
719limInitialize(tpAniSirGlobal pMac)
720{
721 tSirRetStatus status = eSIR_SUCCESS;
722
723 __limInitAssocVars(pMac);
724 __limInitVars(pMac);
725 __limInitStates(pMac);
726 __limInitStatsVars(pMac);
727 __limInitBssVars(pMac);
728 __limInitScanVars(pMac);
729 __limInitHTVars(pMac);
730 __limInitTitanVars(pMac);
731
732#if defined( FEATURE_WLAN_INTEGRATED_SOC )
733 status = limStart(pMac);
734 if(eSIR_SUCCESS != status)
735 {
736 return status;
737 }
738#endif /* FEATURE_WLAN_INTEGRATED_SOC */
739
740 /*
741 * MLM will be intitalized when 'START' request comes from SME.
742 * limInitMlm calls limCreateTimers, which actually relies on
743 * CFG to be downloaded. So it should not be called as part of
744 * peStart, as CFG download is happening after peStart.
745 */
746 //limInitMlm(pMac);
747 // Initializations for maintaining peers in IBSS
748 limIbssInit(pMac);
749
750 pmmInitialize(pMac);
751
752
753#if defined WLAN_FEATURE_VOWIFI
754 rrmInitialize(pMac);
755#endif
756#if defined WLAN_FEATURE_VOWIFI_11R
757 limFTOpen(pMac);
758#endif
759
760#ifdef WLAN_FEATURE_P2P
761 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
762#endif
763
764#if 0
765
766 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
767 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
768 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
769
770 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
771 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
772
773 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
774 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
775 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
776
777 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
778
779 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
780
781 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
782 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
783
784 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
785
786
787 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
788
789 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
790#endif
791 MTRACE(limTraceInit(pMac));
792
793#if defined( FEATURE_WLAN_INTEGRATED_SOC )
794 //Initialize the configurations needed by PE
795 if( eSIR_FAILURE == __limInitConfig(pMac))
796 {
797 //We need to undo everything in limStart
798 limCleanupMlm(pMac);
799 return eSIR_FAILURE;
800 }
801
802 //initialize the TSPEC admission control table.
803 //Note that this was initially done after resume notification from HAL.
804 //Now, DAL is started before PE so this can be done here
805 limAdmitControlInit(pMac);
806 limRegisterHalIndCallBack(pMac);
807#endif /*FEATURE_WLAN_INTEGRATED_SOC*/
808
809 return status;
810
811} /*** end limInitialize() ***/
812
813
814
815/**
816 * limCleanup()
817 *
818 *FUNCTION:
819 * This function is called upon reset or persona change
820 * to cleanup LIM state
821 *
822 *LOGIC:
823 * NA
824 *
825 *ASSUMPTIONS:
826 * NA
827 *
828 *NOTE:
829 * NA
830 *
831 * @param pMac - Pointer to Global MAC structure
832 * @return None
833 */
834
835void
836limCleanup(tpAniSirGlobal pMac)
837{
838#ifdef VOSS_ENABLED
839 v_PVOID_t pvosGCTx;
840 VOS_STATUS retStatus;
841#endif
842
843#ifdef WLAN_FEATURE_P2P
844//Before destroying the list making sure all the nodes have been deleted.
845//Which should be the normal case, but a memory leak has been reported.
846
847 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
848
849 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
850 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
851 {
852 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
853 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
854
855 palFreeMemory(pMac, pLimMgmtRegistration);
856 }
857
858 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
859#endif
860
861 limCleanupMlm(pMac);
862 limCleanupLmm(pMac);
863
864 // free up preAuth table
865 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
866 {
867 palFreeMemory(pMac->hHdd, pMac->lim.gLimPreAuthTimerTable.pTable);
868 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
869 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
870 }
871
872 if(NULL != pMac->lim.pDialogueTokenHead)
873 {
874 limDeleteDialogueTokenList(pMac);
875 }
876
877 if(NULL != pMac->lim.pDialogueTokenTail)
878 {
879 palFreeMemory(pMac->hHdd, (void *) pMac->lim.pDialogueTokenTail);
880 pMac->lim.pDialogueTokenTail = NULL;
881 }
882
883 # if 0
884 if (pMac->lim.gpLimStartBssReq != NULL)
885 {
886 palFreeMemory(pMac->hHdd, pMac->lim.gpLimStartBssReq);
887 pMac->lim.gpLimStartBssReq = NULL;
888 }
889 #endif
890
891 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
892 {
893 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmSetKeysReq);
894 pMac->lim.gpLimMlmSetKeysReq = NULL;
895 }
896
897 #if 0
898 if (pMac->lim.gpLimJoinReq != NULL)
899 {
900 palFreeMemory(pMac->hHdd, pMac->lim.gpLimJoinReq);
901 pMac->lim.gpLimJoinReq = NULL;
902 }
903 #endif
904
905 if (pMac->lim.gpLimMlmAuthReq != NULL)
906 {
907 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
908 pMac->lim.gpLimMlmAuthReq = NULL;
909 }
910
Jeff Johnsone7245742012-09-05 17:12:55 -0700911#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 if (pMac->lim.gpLimMlmJoinReq != NULL)
913 {
914 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
915 pMac->lim.gpLimMlmJoinReq = NULL;
916 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700918
919 #if 0
920 if (pMac->lim.gpLimReassocReq != NULL)
921 {
922 palFreeMemory(pMac->hHdd, pMac->lim.gpLimReassocReq);
923 pMac->lim.gpLimReassocReq = NULL;
924 }
925 #endif
926
927 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
928 {
929 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmRemoveKeyReq);
930 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
931 }
932
Viral Modid86bde22012-12-10 13:09:21 -0800933#ifdef WLAN_FEATURE_P2P
934 if (pMac->lim.gpLimSmeScanReq != NULL)
935 {
936 palFreeMemory(pMac->hHdd, pMac->lim.gpLimSmeScanReq);
937 pMac->lim.gpLimSmeScanReq = NULL;
938 }
939#endif
940
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 if (pMac->lim.gpLimMlmScanReq != NULL)
942 {
943 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmScanReq);
944 pMac->lim.gpLimMlmScanReq = NULL;
945 }
946
947#if 0
948 if(NULL != pMac->lim.beacon)
949 {
950 palFreeMemory(pMac->hHdd, (void*) pMac->lim.beacon);
951 pMac->lim.beacon = NULL;
952 }
953#endif
954 #if 0
955 if(NULL != pMac->lim.assocReq)
956 {
957 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocReq);
958 pMac->lim.assocReq= NULL;
959 }
960 #endif
961
962#if 0
963 if(NULL != pMac->lim.assocRsp)
964 {
965 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocRsp);
966 pMac->lim.assocRsp= NULL;
967 }
968#endif
969 // Now, finally reset the deferred message queue pointers
970 limResetDeferredMsgQ(pMac);
971
972#ifdef VOSS_ENABLED
973
974 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
975 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
976
977 if ( retStatus != VOS_STATUS_SUCCESS )
978 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out...\n"));)
979#endif
980
981#if defined WLAN_FEATURE_VOWIFI
982 rrmCleanup(pMac);
983#endif
984#if defined WLAN_FEATURE_VOWIFI_11R
985 limFTCleanup(pMac);
986#endif
987
988} /*** end limCleanup() ***/
989
990
991/** -------------------------------------------------------------
992\fn peOpen
993\brief will be called in Open sequence from macOpen
994\param tpAniSirGlobal pMac
995\param tHalOpenParameters *pHalOpenParam
996\return tSirRetStatus
997 -------------------------------------------------------------*/
998
999tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
1000{
1001 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
1002 pMac->lim.maxStation = pMacOpenParam->maxStation;
1003
1004 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
1005 {
1006 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!\n"));)
1007 return eSIR_FAILURE;
1008 }
1009
1010 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1011 (void **) &pMac->lim.limTimers.gpLimCnfWaitTimer, sizeof(TX_TIMER)*pMac->lim.maxStation))
1012 {
1013 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1014 return eSIR_FAILURE;
1015 }
1016
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001017#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1019 (void **) &pMac->lim.gpLimAIDpool,
1020 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1)))
1021 {
1022 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1023 return eSIR_FAILURE;
1024 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001025#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1027 (void **) &pMac->lim.gpSession, sizeof(tPESession)* pMac->lim.maxBssId))
1028 {
1029 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
1030 return eSIR_FAILURE;
1031 }
1032
1033 palZeroMemory(pMac->hHdd, pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId);
1034
1035
1036 /*
1037 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1038 (void **) &pMac->dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*pMac->lim.maxStation))
1039 {
1040 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1041 return eSIR_FAILURE;
1042 }
1043
1044 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1045 (void **) &pMac->dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*pMac->lim.maxStation))
1046 {
1047 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1048 return eSIR_FAILURE;
1049 }
1050 */
1051
1052#ifdef WLAN_SOFTAP_FEATURE
1053 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1054 (void **) &pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation))
1055 {
1056 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!\n"));)
1057 return eSIR_FAILURE;
1058 }
1059 palZeroMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation);
1060#endif
1061
1062#ifdef ANI_PRODUCT_TYPE_AP
1063
1064 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1065 (void **) &pMac->pmm.gPmmTim.pStaInfo, sizeof(*pMac->pmm.gPmmTim.pStaInfo) * pMac->lim.maxStation))
1066 {
1067 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pStaInfo!\n"));)
1068 return eSIR_FAILURE;
1069 }
1070
1071 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1072 (void **) &pMac->pmm.gpPmmStaState, sizeof(tPmmStaState)*pMac->lim.maxStation))
1073 {
1074 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1075 return eSIR_FAILURE;
1076 }
1077
1078 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1079 (void **) &pMac->pmm.gpPmmPSState, sizeof(tANI_U8)*pMac->lim.maxStation))
1080 {
1081 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1082 return eSIR_FAILURE;
1083 }
1084#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001085 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001086
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001087 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1088 {
1089 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!\n"));)
1090 return eSIR_FAILURE;
1091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 return eSIR_SUCCESS;
1093}
1094
1095/** -------------------------------------------------------------
1096\fn peClose
1097\brief will be called in close sequence from macClose
1098\param tpAniSirGlobal pMac
1099\return tSirRetStatus
1100 -------------------------------------------------------------*/
1101
1102tSirRetStatus peClose(tpAniSirGlobal pMac)
1103{
1104 tANI_U8 i;
1105
1106 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1107 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001108
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 for(i =0; i < pMac->lim.maxBssId; i++)
1110 {
1111 if(pMac->lim.gpSession[i].valid == TRUE)
1112 {
1113 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1114 }
1115 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001116 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1117 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001118#if 0
Jeff Johnsone7245742012-09-05 17:12:55 -07001119 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1120 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001121#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001122
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1124 pMac->lim.gpSession = NULL;
1125 /*
1126 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1127 pMac->dph.dphHashTable.pHashTable = NULL;
1128 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1129 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1130 */
1131#ifdef WLAN_SOFTAP_FEATURE
1132 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1133 pMac->pmm.gPmmTim.pTim = NULL;
1134#endif
1135#ifdef ANI_PRODUCT_TYPE_AP
1136 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pStaInfo);
1137 pMac->pmm.gPmmTim.pStaInfo = NULL;
1138 palFreeMemory(pMac->hHdd, pMac->pmm.gpPmmStaState);
1139 pMac->pmm.gpPmmStaState = NULL;
1140 palFreeMemory(pMac->hHdd, pMac->pmm.gpPmmPSState);
1141 pMac->pmm.gpPmmPSState = NULL;
1142#endif
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001143 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1144 {
1145 return eSIR_FAILURE;
1146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 return eSIR_SUCCESS;
1148}
1149
1150/** -------------------------------------------------------------
1151\fn peStart
1152\brief will be called in start sequence from macStart
1153\param tpAniSirGlobal pMac
1154\return none
1155 -------------------------------------------------------------*/
1156
1157tSirRetStatus peStart(tpAniSirGlobal pMac)
1158{
1159 tSirRetStatus status = eSIR_SUCCESS;
1160
1161 status = limInitialize(pMac);
1162#if defined(ANI_LOGDUMP)
1163 limDumpInit(pMac);
1164#endif //#if defined(ANI_LOGDUMP)
1165
1166 return status;
1167}
1168
1169/** -------------------------------------------------------------
1170\fn peStop
1171\brief will be called in stop sequence from macStop
1172\param tpAniSirGlobal pMac
1173\return none
1174 -------------------------------------------------------------*/
1175
1176void peStop(tpAniSirGlobal pMac)
1177{
1178 limCleanup(pMac);
1179 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1180 return;
1181}
1182
1183/** -------------------------------------------------------------
1184\fn peFreeMsg
1185\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1186\ to free a given PE message on the TX and MC thread.
1187\ This happens when there are messages pending in the PE
1188\ queue when system is being stopped and reset.
1189\param tpAniSirGlobal pMac
1190\param tSirMsgQ pMsg
1191\return none
1192-----------------------------------------------------------------*/
1193v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1194{
1195 if (pMsg != NULL)
1196 {
1197 if (NULL != pMsg->bodyptr)
1198 {
1199 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1200 {
1201 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1202 }
1203 else
1204 {
1205 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1206 }
1207 }
1208 pMsg->bodyptr = 0;
1209 pMsg->bodyval = 0;
1210 pMsg->type = 0;
1211 }
1212 return;
1213}
1214
1215
1216/**
1217 * The function checks if a particular timer should be allowed
1218 * into LIM while device is sleeping
1219 */
1220tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1221{
1222 tANI_U8 retStatus = TRUE;
1223
1224 if(!limIsSystemInActiveState(pMac))
1225 {
1226 switch(pMsg->type)
1227 {
1228 /* Don't allow following timer messages if in sleep */
1229 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1230 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1231 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1232 retStatus = FALSE;
1233 break;
1234 /* May allow following timer messages in sleep mode */
1235 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1236
1237 /* Safe to allow as of today, this triggers background scan
1238 * which will not be started if the device is in power-save mode
1239 * might need to block in the future if we decide to implement
1240 * spectrum management
1241 */
1242 case SIR_LIM_QUIET_TIMEOUT:
1243
1244 /* Safe to allow as of today, this triggers background scan
1245 * which will not be started if the device is in power-save mode
1246 * might need to block in the future if we decide to implement
1247 * spectrum management
1248 */
1249 case SIR_LIM_QUIET_BSS_TIMEOUT:
1250
1251 /* Safe to allow this timermessage, triggers background scan
1252 * which is blocked in sleep mode
1253 */
1254 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1255
1256 /* Safe to allow this timer, since, while in IMPS this timer will not
1257 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1258 * when heart-beat control is handled back to PE, device would have
1259 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1260 */
1261 case SIR_LIM_HEART_BEAT_TIMEOUT:
1262 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1263
1264 /* Safe to allow, PE is not handling this message as of now. May need
1265 * to block it, basically, free the buffer and restart the timer
1266 */
1267 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1268 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001269 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1271 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1272 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1273 retStatus = TRUE;
1274 break;
1275
1276 /* by default allow rest of messages */
1277 default:
1278 retStatus = TRUE;
1279 break;
1280
1281
1282 }
1283 }
1284
1285 return retStatus;
1286
1287}
1288
1289
1290
1291/**
1292 * limPostMsgApi()
1293 *
1294 *FUNCTION:
1295 * This function is called from other thread while posting a
1296 * message to LIM message Queue gSirLimMsgQ.
1297 *
1298 *LOGIC:
1299 * NA
1300 *
1301 *ASSUMPTIONS:
1302 * NA
1303 *
1304 *NOTE:
1305 * NA
1306 *
1307 * @param pMac - Pointer to Global MAC structure
1308 * @param pMsg - Pointer to the message structure
1309 * @return None
1310 */
1311
1312tANI_U32
1313limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1314{
1315#ifdef VOSS_ENABLED
1316 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1317
1318
1319#elif defined(ANI_OS_TYPE_LINUX) || defined(ANI_OS_TYPE_OSX)
1320 return tx_queue_send(&pMac->sys.gSirLimMsgQ, pMsg, TX_WAIT_FOREVER);
1321
1322#else
1323 /* Check if this is a timeout message from a timer
1324 * and if the timeout message is allowed if the device is in power-save state
1325 */
1326 if(!limIsTimerAllowedInPowerSaveState(pMac, pMsg))
1327 {
1328 limLog(pMac, LOGW,
1329 FL("Timeout message %d is not allowed while device is in Power-Save mode\n"),
1330 pMsg->type);
1331
1332 return TX_SUCCESS;
1333 }
1334 if(pMac->gDriverType != eDRIVER_TYPE_MFG)
1335 {
1336 limMessageProcessor(pMac, pMsg);
1337 }
1338
1339 return TX_SUCCESS;
1340
1341#endif
1342} /*** end limPostMsgApi() ***/
1343
1344
1345/*--------------------------------------------------------------------------
1346
1347 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1348
1349 This function can be called by legacy code to post message to voss queues OR
1350 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1351 for dispatching it later.
1352
1353 \param pMac - Pointer to Global MAC structure
1354 \param pMsg - Pointer to the message structure
1355
1356 \return tANI_U32 - TX_SUCCESS for success.
1357
1358 --------------------------------------------------------------------------*/
1359
1360tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1361{
1362 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1363}
1364
1365/*--------------------------------------------------------------------------
1366
1367 \brief peProcessMessages() - Message Processor for PE
1368
1369 Voss calls this function to dispatch the message to PE
1370
1371 \param pMac - Pointer to Global MAC structure
1372 \param pMsg - Pointer to the message structure
1373
1374 \return tANI_U32 - TX_SUCCESS for success.
1375
1376 --------------------------------------------------------------------------*/
1377
1378tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1379{
1380 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1381 {
1382 return eSIR_SUCCESS;
1383 }
1384 /**
1385 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1386 * for all the other cases post it to LIM
1387 */
1388 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1389 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1390 else
1391 limMessageProcessor(pMac, pMsg);
1392 return eSIR_SUCCESS;
1393}
1394
1395
1396#ifdef VOSS_ENABLED
1397
1398// ---------------------------------------------------------------------------
1399/**
1400 * peHandleMgmtFrame
1401 *
1402 * FUNCTION:
1403 * Process the Management frames from TL
1404 *
1405 * LOGIC:
1406 *
1407 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1408 *
1409 * NOTE:
1410 *
1411 * @param pvosGCtx Global Vos Context
1412 * @param vossBuff Packet
1413 * @return None
1414 */
1415
1416VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1417{
1418 tpAniSirGlobal pMac;
1419 tpSirMacMgmtHdr mHdr;
1420 tSirMsgQ msg;
1421 vos_pkt_t *pVosPkt;
1422 VOS_STATUS vosStatus;
1423 v_U8_t *pRxPacketInfo;
1424
1425 pVosPkt = (vos_pkt_t *)vosBuff;
1426 if (NULL == pVosPkt)
1427 {
1428 return VOS_STATUS_E_FAILURE;
1429 }
1430
1431 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1432 if (NULL == pMac)
1433 {
1434 // cannot log a failure without a valid pMac
1435 vos_pkt_return_packet(pVosPkt);
1436 return VOS_STATUS_E_FAILURE;
1437 }
1438
1439 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1440
1441 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1442 {
1443 vos_pkt_return_packet(pVosPkt);
1444 return VOS_STATUS_E_FAILURE;
1445 }
1446
1447
1448 //
1449 // The MPDU header is now present at a certain "offset" in
1450 // the BD and is specified in the BD itself
1451 //
1452 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1453 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1454 {
1455 PELOG1(limLog( pMac, LOG1,
1456 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001457 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001458
Jeff Johnsone7245742012-09-05 17:12:55 -07001459 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1461 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1462 }
1463
1464
1465 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1466 msg.type = SIR_BB_XPORT_MGMT_MSG;
1467 msg.bodyptr = vosBuff;
1468 msg.bodyval = 0;
1469
1470 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1471 &msg,
1472 mHdr->fc.type,
1473 mHdr->fc.subType ))
1474 {
1475 vos_pkt_return_packet(pVosPkt);
1476 limLog( pMac, LOGW,
1477 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG\n" ));
1478 return VOS_STATUS_E_FAILURE;
1479 }
1480
1481 return VOS_STATUS_SUCCESS;
1482}
1483
1484// ---------------------------------------------------------------------------
1485/**
1486 * peRegisterTLHandle
1487 *
1488 * FUNCTION:
1489 * Registers the Handler which, process the Management frames from TL
1490 *
1491 * LOGIC:
1492 *
1493 * ASSUMPTIONS:
1494 *
1495 * NOTE:
1496 *
1497 * @return None
1498 */
1499
1500void peRegisterTLHandle(tpAniSirGlobal pMac)
1501{
1502 v_PVOID_t pvosGCTx;
1503 VOS_STATUS retStatus;
1504
1505 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1506
1507 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1508
1509 if (retStatus != VOS_STATUS_SUCCESS)
1510 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out...\n"));
1511
1512}
1513#endif
1514
1515
1516/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 * limIsSystemInScanState()
1518 *
1519 *FUNCTION:
1520 * This function is called by various MAC software modules to
1521 * determine if System is in Scan/Learn state
1522 *
1523 *LOGIC:
1524 * NA
1525 *
1526 *ASSUMPTIONS:
1527 * NA
1528 *
1529 *NOTE:
1530 *
1531 * @param pMac - Pointer to Global MAC structure
1532 * @return true - System is in Scan/Learn state
1533 * false - System is NOT in Scan/Learn state
1534 */
1535
1536tANI_U8
1537limIsSystemInScanState(tpAniSirGlobal pMac)
1538{
1539 switch (pMac->lim.gLimSmeState)
1540 {
1541 case eLIM_SME_CHANNEL_SCAN_STATE:
1542 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1543 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1544 case eLIM_SME_WT_SCAN_STATE:
1545 // System is in Learn mode
1546 return true;
1547
1548 default:
1549 // System is NOT in Learn mode
1550 return false;
1551 }
1552} /*** end limIsSystemInScanState() ***/
1553
1554
1555
1556/**
1557 * limIsSystemInActiveState()
1558 *
1559 *FUNCTION:
1560 * This function is called by various MAC software modules to
1561 * determine if System is in Active/Wakeup state
1562 *
1563 *LOGIC:
1564 * NA
1565 *
1566 *ASSUMPTIONS:
1567 * NA
1568 *
1569 *NOTE:
1570 *
1571 * @param pMac - Pointer to Global MAC structure
1572 * @return true - System is in Active state
1573 * false - System is not in Active state
1574 */
1575
1576tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1577{
1578 switch (pMac->pmm.gPmmState)
1579 {
1580 case ePMM_STATE_BMPS_WAKEUP:
1581 case ePMM_STATE_IMPS_WAKEUP:
1582 case ePMM_STATE_READY:
1583 // System is in Active mode
1584 return true;
1585 default:
1586 return false;
1587 // System is NOT in Active mode
1588 }
1589}
1590
1591
1592#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
1593/**
1594 * limCheckAndQuietBSS()
1595 *
1596 *FUNCTION:
1597 * This function is called by limSetLearnMode() to check
1598 * if BSS needs to be quieted and call limQuietBSS() to
1599 * send data frame to self for that purpose.
1600 *
1601 *LOGIC:
1602 * NA
1603 *
1604 *ASSUMPTIONS:
1605 * NA
1606 *
1607 *NOTE:
1608 *
1609 * @param pMac - Pointer to Global MAC structure
1610 * @return None
1611 */
1612
1613void
1614limCheckAndQuietBSS(tpAniSirGlobal pMac)
1615{
1616 tANI_U32 dur;
1617
1618 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1619 {
1620 // LIM is in AP role. Quiet the BSS before
1621 // switching to channel to be learned
1622 if (pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration >
1623 LIM_MAX_QUIET_DURATION)
1624 {
1625 // May need to quiet BSS multiple times.
1626 // Quiet for a limit of 32 msecs on Learn
1627 // duration for now.
1628 dur = LIM_MAX_QUIET_DURATION;
1629 }
1630 else
1631 {
1632 dur =
1633 pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration;
1634 }
1635 PELOG3(limLog(pMac, LOG3,
1636 FL("*** Going to quiet BSS for duration=%d msec\n"),
1637 dur);)
1638
1639 limQuietBss(pMac, dur);
1640 }
1641} /*** end limCheckAndQuietBSS() ***/
1642#endif
1643
1644#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1645/**
1646 * limSetLearnMode()
1647 *
1648 *FUNCTION:
1649 * This function is called to setup system into Learn mode
1650 * to collect DFS measurements.
1651 *
1652 *LOGIC:
1653 * NA
1654 *
1655 *ASSUMPTIONS:
1656 * NA
1657 *
1658 *NOTE:
1659 *
1660 * @param pMac - Pointer to Global MAC structure
1661 * @return None
1662 */
1663
1664void
1665limSetLearnMode(tpAniSirGlobal pMac)
1666{
1667 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_LEARN_WAIT_STATE, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN);
1668 return;
1669} /*** end limSetLearnMode() ***/
1670
1671/**
1672 * limContinueChannelLearn()
1673 *
1674 *FUNCTION:
1675 * This function is called to do measurement (learn) on current channel.
1676 *
1677 *LOGIC:
1678 *
1679 *ASSUMPTIONS:
1680 * NA
1681 *
1682 *NOTE:
1683 * NA
1684 *
1685 * @param pMac - Pointer to Global MAC structure
1686 *
1687 * @return None
1688 */
1689
1690void
1691limContinueChannelLearn(tpAniSirGlobal pMac)
1692{
1693 tANI_U8 chanNum;
1694 tSirMacSSid ssId;
1695 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1696
1697 // Time to collect measurements
1698 chanNum = limGetCurrentLearnChannel(pMac);
1699
1700 // Switch channel
1701 pMac->lim.gLimSystemInScanLearnMode = 1;
1702
1703 if (pMac->lim.gpLimMeasReq->measControl.scanType == eSIR_ACTIVE_SCAN)
1704 {
1705 /// Prepare and send Probe Request frame
1706 ssId.length = 0;
1707 /* for learning channel, we don't include any additional IE */
1708 limSendProbeReqMgmtFrame(pMac, &ssId, bssId, chanNum,pMac->lim.gSelfMacAddr, 0 , NULL);
1709 }
1710
1711 // Activate Learn duration timer during which
1712 // DFS measurements are made.
1713 pMac->lim.gLimMeasParams.shortDurationCount++;
1714 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_DURATION_TIMER);
1715
Jeff Johnsone7245742012-09-05 17:12:55 -07001716 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_DURATION_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 if (tx_timer_activate(&pMac->lim.gLimMeasParams.learnDurationTimer)
1718 != TX_SUCCESS)
1719 {
1720 /// Could not activate learn duration timer.
1721 // Log error
1722 limLog(pMac, LOGP, FL("could not activate learn duration timer\n"));
1723
1724 return;
1725 }
1726} /*** end limContinueChannelLearn() ***/
1727
1728
1729/**
1730 * limReEnableLearnMode()
1731 *
1732 *FUNCTION:
1733 * This function is called by various MAC software modules to
1734 * re-enable Learn mode measurements.
1735 *
1736 *LOGIC:
1737 * NA
1738 *
1739 *ASSUMPTIONS:
1740 * NA
1741 *
1742 *NOTE:
1743 *
1744 * @param pMac - Pointer to Global MAC structure
1745 * @return None
1746 */
1747
1748void
1749limReEnableLearnMode(tpAniSirGlobal pMac)
1750{
1751 PELOG4(limLog(pMac, LOG4, FL("quietEnabled = %d\n"),
1752 pMac->lim.gLimSpecMgmt.fQuietEnabled);)
1753
1754 /** Stop measurement temperorily when radar is detected or channel
1755 * switch is running as part of periodic DFS */
1756 if (!pMac->lim.gpLimMeasReq || LIM_IS_RADAR_DETECTED(pMac) ||
1757 (pMac->lim.gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING))
1758 {
1759 return;
1760 }
1761
1762 if (pMac->lim.gLimSpecMgmt.fQuietEnabled)
1763 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001764 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001765#ifdef GEN6_TODO
1766 /* revisit this piece of code to assign the appropriate sessionId below
1767 * priority - HIGH
1768 */
1769 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
1770#endif
1771 if (tx_timer_activate(
1772 &pMac->lim.limTimers.gLimQuietBssTimer)
1773 != TX_SUCCESS)
1774 {
1775 limLog(pMac, LOGP, FL("could not start Quiet Bss timer\n"));
1776 return;
1777 }
1778 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
1779 }
1780 else
1781 {
1782 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_INTERVAL_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07001783 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_INTERVAL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001784#ifdef GEN6_TODO
1785 /* revisit this piece of code to assign the appropriate sessionId below
1786 */
1787 pMac->lim.gLimMeasParams.learnIntervalTimer.sessionId = sessionId;
1788#endif
1789 if (tx_timer_activate(
1790 &pMac->lim.gLimMeasParams.learnIntervalTimer)
1791 != TX_SUCCESS)
1792 {
1793 /// Could not activate Learn Interval timer.
1794 // Log error
1795 limLog(pMac, LOGP, FL("could not start Learn Interval timer\n"));
1796 return;
1797 }
1798 }
1799
1800 PELOG3(limLog(pMac, LOG3, FL("Re-enabled Learn mode Measurements\n"));)
1801 pMac->lim.gLimMeasParams.disableMeasurements = 0;
1802
1803 return;
1804} /*** end limReEnableLearnMode() ***/
1805
1806#endif //#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1807
1808
1809/**
1810*\brief limReceivedHBHandler()
1811*
1812* This function is called by schBeaconProcess() upon
1813* receiving a Beacon on STA. This also gets called upon
1814* receiving Probe Response after heat beat failure is
1815* detected.
1816*
1817* param pMac - global mac structure
1818* param channel - channel number indicated in Beacon, Probe Response
1819* return - none
1820*/
1821
1822
1823void
1824limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1825{
1826 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1827 psessionEntry->LimRxedBeaconCntDuringHB++;
1828
1829 pMac->pmm.inMissedBeaconScenario = FALSE;
1830} /*** end limReceivedHBHandler() ***/
1831
1832
1833
1834#if 0
1835void limResetHBPktCount(tpPESession psessionEntry)
1836{
1837 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1838}
1839#endif
1840
1841
1842/*
1843 * limProcessWdsInfo()
1844 *
1845 *FUNCTION:
1846 * This function is called from schBeaconProcess in BP
1847 *
1848 *PARAMS:
1849 * @param pMac - Pointer to Global MAC structure
1850 * @param propIEInfo - proprietary IE info
1851 *
1852 *LOGIC:
1853 *
1854 *ASSUMPTIONS:
1855 * NA
1856 *
1857 *NOTE:
1858 *
1859 *
1860 *RETURNS:
1861 *
1862 */
1863
1864void limProcessWdsInfo(tpAniSirGlobal pMac,
1865 tSirPropIEStruct propIEInfo)
1866{
1867#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1868 tpSirSmeWdsInfoInd pSirSmeWdsInfoInd;
1869 tANI_U8 *pTemp;
1870 tSirMsgQ mmhMsg;
1871
1872 if (propIEInfo.wdsLength &&
1873 propIEInfo.wdsLength <= ANI_WDS_INFO_MAX_LENGTH)
1874 {
1875 if (pMac->lim.gLimWdsInfo.wdsLength)
1876 {
1877 if ((propIEInfo.wdsLength ==
1878 pMac->lim.gLimWdsInfo.wdsLength) &&
1879 (palEqualMemory( pMac->hHdd,propIEInfo.wdsData,
1880 pMac->lim.gLimWdsInfo.wdsBytes,
1881 pMac->lim.gLimWdsInfo.wdsLength) ))
1882
1883 return; // no difference in WDS info
1884 else
1885 {
1886 PELOG2(limLog(pMac, LOG2,
1887 FL("Cached WDS Info: length %d bytes is: "),
1888 pMac->lim.gLimWdsInfo.wdsLength);
1889 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1890 pMac->lim.gLimWdsInfo.wdsBytes,
1891 pMac->lim.gLimWdsInfo.wdsLength);)
1892
1893 PELOG2(limLog(pMac, LOG2, FL("New WDS Info: length %d bytes is: "),
1894 propIEInfo.wdsLength);
1895 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1896 propIEInfo.wdsData,
1897 propIEInfo.wdsLength);)
1898
1899 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1900 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1901 propIEInfo.wdsData,
1902 propIEInfo.wdsLength);
1903
1904 // send IND to WSM
1905 if (eHAL_STATUS_SUCCESS !=
1906 palAllocateMemory(pMac->hHdd,
1907 (void **) &pSirSmeWdsInfoInd,
1908 sizeof(tSirSmeWdsInfoInd)))
1909 {
1910 // Log error
1911 limLog(pMac, LOGP,
1912 FL("memory allocate failed for WDS_INFO_IND\n"));
1913
1914 return;
1915 }
1916
1917 pSirSmeWdsInfoInd->messageType = eWNI_SME_WDS_INFO_IND;
1918 pSirSmeWdsInfoInd->length = sizeof(tSirSmeWdsInfoInd);
1919
1920 pSirSmeWdsInfoInd->wdsInfo.wdsLength =
1921 pMac->lim.gLimWdsInfo.wdsLength;
1922
1923 palCopyMemory( pMac->hHdd, pSirSmeWdsInfoInd->wdsInfo.wdsBytes,
1924 pMac->lim.gLimWdsInfo.wdsBytes,
1925 pMac->lim.gLimWdsInfo.wdsLength);
1926
1927 pTemp = (tANI_U8 *) pSirSmeWdsInfoInd;
1928
1929 PELOG2(limLog(pMac, LOG2,
1930 FL("eWNI_SME_WDS_INFO_IND length %d bytes is: "),
1931 pSirSmeWdsInfoInd->length);
1932 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pTemp,
1933 pSirSmeWdsInfoInd->length);)
1934
1935 mmhMsg.type = eWNI_SME_WDS_INFO_IND;
1936 mmhMsg.bodyptr = pSirSmeWdsInfoInd;
1937 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001938 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
1940 pMac->lim.gLimNumWdsInfoInd++;
1941 }
1942 }
1943 else
1944 {
1945 // first WDS info
1946 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1947 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1948 propIEInfo.wdsData,
1949 propIEInfo.wdsLength);
1950
1951 PELOG1(limLog(pMac, LOG1, FL("First WDS Info: length %d bytes is:\n"),
1952 pMac->lim.gLimWdsInfo.wdsLength);
1953 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
1954 pMac->lim.gLimWdsInfo.wdsBytes,
1955 pMac->lim.gLimWdsInfo.wdsLength);)
1956
1957 }
1958 }
1959 else
1960 {
1961 PELOG2(limLog(pMac, LOG2,
1962 FL("Illegal WDS length = %d\n"),
1963 propIEInfo.wdsLength);)
1964 }
1965#endif
1966}
1967
1968
1969
1970/**
1971 * limInitWdsInfoParams()
1972 *
1973 *FUNCTION:
1974 * This function is called while processing
1975 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1976 * ind/set related parameters.
1977 *
1978 *LOGIC:
1979 *
1980 *ASSUMPTIONS:
1981 *
1982 *NOTE:
1983 *
1984 * @param pMac Pointer to Global MAC structure
1985 * @return None
1986 */
1987
1988void
1989limInitWdsInfoParams(tpAniSirGlobal pMac)
1990{
1991 pMac->lim.gLimWdsInfo.wdsLength = 0;
1992 pMac->lim.gLimNumWdsInfoInd = 0;
1993 pMac->lim.gLimNumWdsInfoSet = 0;
1994} /*** limInitWdsInfoParams() ***/
1995
1996
1997/** -------------------------------------------------------------
1998\fn limUpdateOverlapStaParam
1999\brief Updates overlap cache and param data structure
2000\param tpAniSirGlobal pMac
2001\param tSirMacAddr bssId
2002\param tpLimProtStaParams pStaParams
2003\return None
2004 -------------------------------------------------------------*/
2005void
2006limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
2007{
2008 int i;
2009 if (!pStaParams->numSta)
2010 {
2011 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
2012 bssId,
2013 sizeof(tSirMacAddr));
2014 pMac->lim.protStaOverlapCache[0].active = true;
2015
2016 pStaParams->numSta = 1;
2017
2018 return;
2019 }
2020
2021 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
2022 {
2023 if (pMac->lim.protStaOverlapCache[i].active)
2024 {
2025 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
2026 bssId,
2027 sizeof(tSirMacAddr))) {
2028 return; }
2029 }
2030 else
2031 break;
2032 }
2033
2034 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
2035 {
2036 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full\n"));)
2037 }
2038 else
2039 {
2040 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
2041 bssId,
2042 sizeof(tSirMacAddr));
2043 pMac->lim.protStaOverlapCache[i].active = true;
2044
2045 pStaParams->numSta++;
2046 }
2047}
2048
2049
2050/**
2051 * limHandleIBSScoalescing()
2052 *
2053 *FUNCTION:
2054 * This function is called upon receiving Beacon/Probe Response
2055 * while operating in IBSS mode.
2056 *
2057 *LOGIC:
2058 *
2059 *ASSUMPTIONS:
2060 *
2061 *NOTE:
2062 *
2063 * @param pMac - Pointer to Global MAC structure
2064 * @param pBeacon - Parsed Beacon Frame structure
2065 * @param pRxPacketInfo - Pointer to RX packet info structure
2066 *
2067 * @return Status whether to process or ignore received Beacon Frame
2068 */
2069
2070tSirRetStatus
2071limHandleIBSScoalescing(
2072 tpAniSirGlobal pMac,
2073 tpSchBeaconStruct pBeacon,
2074 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
2075{
2076 tpSirMacMgmtHdr pHdr;
2077 tSirRetStatus retCode;
2078
2079 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2080 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
2081 /* Received SSID does not match => Ignore received Beacon frame. */
2082 retCode = eSIR_LIM_IGNORE_BEACON;
2083 else
2084 {
2085 tANI_U32 ieLen;
2086 tANI_U16 tsfLater;
2087 tANI_U8 *pIEs;
2088 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2089 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
2090 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2091 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
2092 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
2093 }
2094 return retCode;
2095} /*** end limHandleIBSScoalescing() ***/
2096
2097
2098
2099/**
2100 * limDetectChangeInApCapabilities()
2101 *
2102 *FUNCTION:
2103 * This function is called while SCH is processing
2104 * received Beacon from AP on STA to detect any
2105 * change in AP's capabilities. If there any change
2106 * is detected, Roaming is informed of such change
2107 * so that it can trigger reassociation.
2108 *
2109 *LOGIC:
2110 *
2111 *ASSUMPTIONS:
2112 *
2113 *NOTE:
2114 * Notification is enabled for STA product only since
2115 * it is not a requirement on BP side.
2116 *
2117 * @param pMac Pointer to Global MAC structure
2118 * @param pBeacon Pointer to parsed Beacon structure
2119 * @return None
2120 */
2121
2122void
2123limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
2124 tpSirProbeRespBeacon pBeacon,
2125 tpPESession psessionEntry)
2126{
2127#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2128 tANI_U8 len;
2129 tSirSmeApNewCaps apNewCaps;
2130 tANI_U8 newChannel;
2131 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
2132 newChannel = (tANI_U8) pBeacon->channelNumber;
2133
2134 if ((psessionEntry->limSentCapsChangeNtf == false) &&
2135 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
2136 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
2137 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
2138 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
2139 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
2140 (newChannel != psessionEntry->currentOperChannel)
2141#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
2142 || (LIM_BSS_CAPS_GET(HCF, psessionEntry->limCurrentBssQosCaps) !=
2143 pBeacon->propIEinfo.hcfEnabled)
2144#endif
2145 )))
2146 {
2147
2148 /**
2149 * BSS capabilities have changed.
2150 * Inform Roaming.
2151 */
2152 len = sizeof(tSirMacCapabilityInfo) +
2153 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
2154 3 * sizeof(tANI_U8) + // reserved fields
2155 pBeacon->ssId.length + 1;
2156
2157 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
2158 psessionEntry->bssId,
2159 sizeof(tSirMacAddr));
2160 if (newChannel != psessionEntry->currentOperChannel)
2161 {
2162 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
2163 "Ignoring beacon!\n"),
2164 psessionEntry->currentOperChannel, newChannel);)
2165 return;
2166 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05302167
2168 /**
2169 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
2170 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
2171 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
2172 * the privacy bit is set in Probe and association responses.
2173 * Due to this anomaly, we detect a change in
2174 * AP capabilities when we receive a beacon after association and
2175 * disconnect from the AP. The following check makes sure that we can
2176 * connect to such APs
2177 */
2178 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
2179 (pBeacon->rsnPresent || pBeacon->wpaPresent))
2180 {
2181 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
2182 " but WPA or RSN IE present, Ignore Beacon!\n"));)
2183 return;
2184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 else
2186 apNewCaps.channelId = psessionEntry->currentOperChannel;
2187 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
2188 (tANI_U8 *) &pBeacon->ssId,
2189 pBeacon->ssId.length + 1);
2190
2191 psessionEntry->limSentCapsChangeNtf = true;
2192 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2193 (tANI_U32 *) &apNewCaps,
2194 len, psessionEntry->smeSessionId);
2195 }
2196#endif
2197} /*** limDetectChangeInApCapabilities() ***/
2198
2199
2200
2201
2202// ---------------------------------------------------------------------
2203/**
2204 * limUpdateShortSlot
2205 *
2206 * FUNCTION:
2207 * Enable/Disable short slot
2208 *
2209 * LOGIC:
2210 *
2211 * ASSUMPTIONS:
2212 *
2213 * NOTE:
2214 *
2215 * @param enable Flag to enable/disable short slot
2216 * @return None
2217 */
2218
2219tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2220{
2221
2222 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002223 tANI_U32 nShortSlot;
2224 tANI_U32 val = 0;
2225 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
Jeff Johnsone7245742012-09-05 17:12:55 -07002227 // Check Admin mode first. If it is disabled just return
2228 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2229 != eSIR_SUCCESS)
2230 {
2231 limLog(pMac, LOGP,
2232 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed\n"));
2233 return eSIR_FAILURE;
2234 }
2235 if (val == false)
2236 return eSIR_SUCCESS;
2237
2238 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2239 limGetPhyMode(pMac, &phyMode, psessionEntry);
2240 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2241 return eSIR_SUCCESS;
2242
2243 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002244
2245 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2246 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2247 // if no erp present, use short slot based on current ap caps
2248
2249 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2250
2251 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2252 // The difference between the earlier implementation and the new one is only Case4.
2253 /*
2254 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2255 Case1 1 1 1 1 //AP should not advertise this combination.
2256 Case2 1 1 0 0
2257 Case3 1 0 1 1
2258 Case4 1 0 0 0
2259 Case5 0 1 1 1
2260 Case6 0 1 0 0
2261 Case7 0 0 1 1
2262 Case8 0 0 0 0
2263 */
2264 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2265
Jeff Johnsone7245742012-09-05 17:12:55 -07002266 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 {
2268 // Short slot time capability of AP has changed. Adopt to it.
2269 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d\n"), nShortSlot);)
2270 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002271 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2273 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 }
2275 return eSIR_SUCCESS;
2276}
2277
2278
2279#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
2280
2281/**
2282 * limUpdateQuietIEInBeacons()
2283 *
2284 *FUNCTION:
2285 * This function is called by specialBeaconProcessing(),
2286 * when it is time to generate the next beacon.
2287 * If gLimQuietState is not in the INIT state, then it
2288 * means that the next beacon may need to include some
2289 * information about the Quiet BSS IE.
2290 * This function makes that decision based on the current
2291 * state of gLimQuietState
2292 *
2293 *LOGIC:
2294 * This routine invokes schSetFixedBeaconFields() only
2295 * if necessary, as it is expensive to update the fixed
2296 * beacon fields during each beacon interval.
2297 *
2298 *ASSUMPTIONS:
2299 * This Quiet BSS IE will be sent out as part of
2300 * Proprietary IE's. If 802.11H is enabled, this IE
2301 * will be sent out as defined in the 11H spec
2302 *
2303 *NOTE:
2304 *
2305 * @param pMac Pointer to Global MAC structure
2306 * @return true, if the beacon fields need updating
2307 * false, if not
2308 */
2309tANI_BOOLEAN limUpdateQuietIEInBeacons( tpAniSirGlobal pMac )
2310{
2311 tANI_BOOLEAN fUpdateBeaconFields = eANI_BOOLEAN_TRUE;
2312
2313 limLog( pMac, LOG2, FL("Quiet BSS State = %d\n"),
2314 pMac->lim.gLimSpecMgmt.quietState );
2315 switch( pMac->lim.gLimSpecMgmt.quietState )
2316 {
2317 case eLIM_QUIET_BEGIN:
2318 // We need to start broadcasting the Quiet BSS IE
2319 // Transition to eLIM_QUIET_RUNNING
2320 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
2321 break;
2322
2323 case eLIM_QUIET_RUNNING:
2324 // Start down-counting...
2325 pMac->lim.gLimSpecMgmt.quietCount--;
2326 if( pMac->lim.gLimSpecMgmt.quietCount == 0 )
2327 {
2328 //
2329 // We no longer need to broadcast the Quiet BSS IE
2330 //
2331 // NOTE - We still need to call schSetFixedBeaconFields()
2332 // one last time, just to remove the Quiet BSS IE from
2333 // the list of fixed beacon fields
2334 //
2335 // Transition to eLIM_QUIET_END
2336 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2337 limProcessLearnIntervalTimeout(pMac);
2338 }
2339 break;
2340
2341 case eLIM_QUIET_CHANGED:
2342 //
2343 // State possibly changed via setupQuietBss().
2344 // This means, gLimQuietCount has been changed!!
2345 //
2346 // NOTE - We still need to call schSetFixedBeaconFields()
2347 // one last time, just to remove the Quiet BSS IE from
2348 // the list of fixed beacon fields
2349 //
2350
2351 // Transition to eLIM_QUIET_END
2352 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2353 break;
2354
2355 case eLIM_QUIET_INIT:
2356 case eLIM_QUIET_END:
2357 // Transition to eLIM_QUIET_INIT
2358 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
2359 // Fall thru'...
2360 default:
2361 fUpdateBeaconFields = eANI_BOOLEAN_FALSE;
2362 break;
2363 }
2364
2365 return fUpdateBeaconFields;
2366}
2367
2368#endif
2369
2370#if ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK))
2371void limConvertScanDuration(tpAniSirGlobal pMac)
2372{
2373 tpSirSmeMeasurementReq pMeasReq = pMac->lim.gpLimMeasReq;
2374 tpLimScanDurationConvert scanDurConv = &pMac->lim.gLimScanDurationConvert;
2375
2376 /* This is not a good idea to convert {long}shortChannelScanDuration from mS to TICKS *
2377 * The reason is that {long}shortChannelScanDuration is used all over and a lot of code *
2378 * that assumes the old mS definition was never changed to accommodate this new change to TICKS. *
2379 * If optimization is needed, create another set of shadow variables to store the converted *
2380 * values in Ticks, and TU. */
2381 scanDurConv->shortChannelScanDuration_tick =
2382 SYS_MS_TO_TICKS(pMeasReq->measDuration.shortChannelScanDuration +SYS_TICK_DUR_MS-1);
2383
2384 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2385 /* (shortChanneScanDuration * 1000) / 2^10 */
2386 scanDurConv->shortChannelScanDuration_TU = (pMeasReq->measDuration.shortChannelScanDuration * 1000) >> 10;
2387
2388 scanDurConv->longChannelScanDuration_tick =
2389 SYS_MS_TO_TICKS(pMeasReq->measDuration.longChannelScanDuration +SYS_TICK_DUR_MS-1);
2390
2391 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2392 /* (longChanneScanDuration * 1000) / 2^10 */
2393 scanDurConv->longChannelScanDuration_TU = (pMeasReq->measDuration.longChannelScanDuration * 1000) >> 10;
2394}
2395#endif /* ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK)) */
2396
2397
2398#ifdef ANI_PRODUCT_TYPE_AP
2399/**-------------------------------------------------
2400\fn limIsRadarEnabled
2401
2402\brief Checks if radar is enabled
2403\param pMac
2404\return true - if Both 11h and radar enabled
2405 false - if either is not enabled.
2406 --------------------------------------------------*/
2407tANI_BOOLEAN limIsRadarEnabled(tpAniSirGlobal pMac)
2408{
2409 tANI_U32 fEnabled;
2410
2411 if(wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &fEnabled) != eSIR_SUCCESS)
2412 {
2413 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2414 return eANI_BOOLEAN_FALSE;
2415 }
2416
2417 if (!fEnabled)
2418 return eANI_BOOLEAN_FALSE;
2419
2420 if(wlan_cfgGetInt(pMac, WNI_CFG_RDET_FLAG, &fEnabled) != eSIR_SUCCESS)
2421 {
2422 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2423 return eANI_BOOLEAN_FALSE;
2424 }
2425
2426 if (fEnabled)
2427 return eANI_BOOLEAN_TRUE;
2428
2429 return eANI_BOOLEAN_FALSE;
2430}
2431
2432/**---------------------------------------
2433\fn limRadarInit
2434\brief Initialize Radar Interrupt.
2435
2436\param pMac
2437\return None
2438 ----------------------------------------*/
2439void limRadarInit(tpAniSirGlobal pMac)
2440{
2441 tANI_U32 status;
2442 tSirMsgQ msg;
2443
2444 PELOG3(limLog(pMac, LOG3, FL("Radar Interrupt Already configured? %s\n"),
2445 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured?"Yes":"No");)
2446 /** To avoid configuring the radar multiple times */
2447 if (pMac->lim.gLimSpecMgmt.fRadarIntrConfigured)
2448 return;
2449
2450 if (!limIsRadarEnabled(pMac))
2451 return;
2452 // Prepare and post message to HAL Message Queue
2453 msg.type = WDA_INIT_RADAR_IND;
2454 msg.bodyptr = NULL;
2455 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002456 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 status = wdaPostCtrlMsg(pMac, &msg);
2458 if (status != eHAL_STATUS_SUCCESS)
2459 {
2460 limLog(pMac, LOGP,
2461 FL("posting to HAL failed, reason=%d\n"), status);
2462 return;
2463 }
2464 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured = eANI_BOOLEAN_TRUE;
2465} /****** end limRadarInit() ******/
2466
2467#endif
2468
2469
2470/** -----------------------------------------------------------------
2471 \brief limHandleLowRssiInd() - handles low rssi indication
2472
2473 This function process the SIR_HAL_LOW_RSSI_IND message from
2474 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2475
2476 \param pMac - global mac structure
2477
2478 \return
2479
2480 \sa
2481 ----------------------------------------------------------------- */
2482void limHandleLowRssiInd(tpAniSirGlobal pMac)
2483{
2484#if 0 //RSSI related indications will now go to TL and not PE
2485 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2486 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2487 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2488 {
2489 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME \n"));)
2490 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2491 }
2492 else
2493 {
2494 limLog(pMac, LOGE,
2495 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d\n"),
2496 pMac->pmm.gPmmState);
2497 }
2498 return;
2499#endif
2500}
2501
2502
2503/** -----------------------------------------------------------------
2504 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2505
2506 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2507 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2508 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2509
2510 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2511 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2512 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2513 This message can also come from FW anytime after we have entered BMPS.
2514 This means we should handle it in WoWL and UAPSD states as well
2515
2516 \param pMac - global mac structure
2517 \return - none
2518 \sa
2519 ----------------------------------------------------------------- */
2520void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2521{
2522 switch(pMac->pmm.gPmmState)
2523 {
2524 case ePMM_STATE_BMPS_SLEEP:
2525 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2526 case ePMM_STATE_UAPSD_SLEEP:
2527 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2528 case ePMM_STATE_WOWLAN:
2529 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2530 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2531 break;
2532
2533 default:
2534 limLog(pMac, LOGE,
2535 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d\n"),
2536 pMac->pmm.gPmmState);
2537 break;
2538 }
2539 return;
2540}
2541
2542
2543/** -----------------------------------------------------------------
2544 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2545
2546 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2547 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2548 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2549
2550 \param pMac - global mac structure
2551 \return - none
2552 \sa
2553 ----------------------------------------------------------------- */
2554void limHandleMissedBeaconInd(tpAniSirGlobal pMac)
2555{
2556 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2557 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2558 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2559 {
2560 pMac->pmm.inMissedBeaconScenario = TRUE;
2561 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2562 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2563 }
Yathish9f22e662012-12-10 14:21:35 -08002564/* ACTIVE_MODE_HB_OFFLOAD */
2565#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2566 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2567 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2568 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2569 {
2570 pMac->pmm.inMissedBeaconScenario = TRUE;
2571 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure\n"));)
2572 limMissedBeaconInActiveMode(pMac);
2573 }
2574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 else
2576 {
2577 limLog(pMac, LOGE,
2578 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d\n"),
2579 pMac->pmm.gPmmState);
2580 }
2581 return;
2582}
2583
2584/** -----------------------------------------------------------------
2585 \brief limMicFailureInd() - handles mic failure indication
2586
2587 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2588
2589 \param pMac - global mac structure
2590 \return - none
2591 \sa
2592 ----------------------------------------------------------------- */
2593void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2594{
2595 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2596 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2597 tSirMsgQ mmhMsg;
2598 tpPESession psessionEntry ;
2599 tANI_U8 sessionId;
2600
2601 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2602 {
2603 limLog(pMac, LOGE,
2604 FL("session does not exist for given BSSId\n"));
2605 return;
2606 }
2607
2608 if (eHAL_STATUS_SUCCESS !=
2609 palAllocateMemory(pMac->hHdd,
2610 (void **) &pSirSmeMicFailureInd,
2611 sizeof(tSirSmeMicFailureInd)))
2612 {
2613 // Log error
2614 limLog(pMac, LOGP,
2615 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND\n"));
2616 return;
2617 }
2618
2619 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2620 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2621 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2622
2623 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2624 pSirMicFailureInd->bssId,
2625 sizeof(tSirMacAddr));
2626
2627 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2628 pSirMicFailureInd->info.srcMacAddr,
2629 sizeof(tSirMacAddr));
2630
2631 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2632 pSirMicFailureInd->info.taMacAddr,
2633 sizeof(tSirMacAddr));
2634
2635 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2636 pSirMicFailureInd->info.dstMacAddr,
2637 sizeof(tSirMacAddr));
2638
2639 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2640 pSirMicFailureInd->info.rxMacAddr,
2641 sizeof(tSirMacAddr));
2642
2643 pSirSmeMicFailureInd->info.multicast =
2644 pSirMicFailureInd->info.multicast;
2645
2646 pSirSmeMicFailureInd->info.keyId=
2647 pSirMicFailureInd->info.keyId;
2648
2649 pSirSmeMicFailureInd->info.IV1=
2650 pSirMicFailureInd->info.IV1;
2651
2652 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2653 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2654
2655 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2656 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2657 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002658 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2660 return;
2661}
2662
2663
2664/** -----------------------------------------------------------------
2665 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2666
2667 This function is called before enqueuing the frame to PE queue for further processing.
2668 This prevents unnecessary frames getting into PE Queue and drops them right away.
2669 Frames will be droped in the following scenarios:
2670
2671 - In Scan State, drop the frames which are not marked as scan frames
2672 - In non-Scan state, drop the frames which are marked as scan frames.
2673 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2674 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2675
2676 \param pMac - global mac structure
2677 \return - none
2678 \sa
2679 ----------------------------------------------------------------- */
2680
2681tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2682{
2683 tANI_U32 framelen;
2684 tANI_U8 *pBody;
2685 tSirMacCapabilityInfo capabilityInfo;
2686
2687 /*
2688 *
2689 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2690 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2691 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2692 * other than beacons or probe responses in scan state.
2693 */
2694 if( (subType == SIR_MAC_MGMT_BEACON) ||
2695 (subType == SIR_MAC_MGMT_PROBE_RSP))
2696 {
2697 if(pMac->pmm.inMissedBeaconScenario)
2698 {
Jeff Johnsonab79c8d2012-12-10 14:30:13 -08002699 PELOGE(limLog(pMac, LOGE, FL("Do not drop beacon and probe response - Missed beacon scenario"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 return eMGMT_DROP_NO_DROP;
2701 }
2702 if (limIsSystemInScanState(pMac))
2703 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002704 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 }
2706 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2707 {
2708 return eMGMT_DROP_SCAN_MODE_FRAME;
2709 }
2710 }
2711
2712 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2713 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2714
2715 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2716 * beacons from an infrastructure network
2717 */
2718 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2719 if(!capabilityInfo.ibss)
2720 return eMGMT_DROP_NO_DROP;
2721#if 0
2722 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2723 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2724 return eMGMT_DROP_NO_DROP;
2725#endif
2726
2727 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2728 if( (subType == SIR_MAC_MGMT_BEACON) ||
2729 (subType == SIR_MAC_MGMT_PROBE_RSP))
2730 {
2731 //drop the frame if length is less than 12
2732 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2733 return eMGMT_DROP_INVALID_SIZE;
2734
2735 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2736
2737 //This can be enhanced to even check the SSID before deciding to enque the frame.
2738 if(capabilityInfo.ess)
2739 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2740 }
2741 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2742 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2743 {
2744 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2745 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2746 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2747 }
2748
2749 return eMGMT_DROP_NO_DROP;
2750}
2751
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002752eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2753{
2754 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002755
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002756 if(psPe)
2757 {
2758 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2759 {
2760 status = eHAL_STATUS_SUCCESS;
2761 }
2762 }
2763 return (status);
2764}
2765eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2766{
2767 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2768 if(psPe)
2769 {
2770 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2771 {
2772 status = eHAL_STATUS_SUCCESS;
2773 }
2774 }
2775 return (status);
2776}