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