blob: aac103b2657e041cc51befa6a71ba626d24bff28 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. 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
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
Jeff Johnson295189b2012-06-20 16:38:30 -0700392}
393
394
395static void __limInitTitanVars(tpAniSirGlobal pMac)
396{
Jeff Johnsone7245742012-09-05 17:12:55 -0700397#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 palZeroMemory(pMac->hHdd, &pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700400 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 // Debug workaround for BEACON's
403 // State change triggered by "dump 222"
404 pMac->lim.gLimScanOverride = 1;
405 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 pMac->lim.gLimTitanStaCount = 0;
407 pMac->lim.gLimBlockNonTitanSta = 0;
408}
409
410static void __limInitHTVars(tpAniSirGlobal pMac)
411{
412 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 pMac->lim.gHTShortGI40Mhz = 0;
415 pMac->lim.gHTShortGI20Mhz = 0;
416 pMac->lim.gHTMaxAmsduLength = 0;
417 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
418 pMac->lim.gHTPSMPSupport = 0;
419 pMac->lim.gHTLsigTXOPProtection = 0;
420 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
421 pMac->lim.gHTAMpduDensity = 0;
422
423 pMac->lim.gMaxAmsduSizeEnabled = false;
424 pMac->lim.gHTMaxRxAMpduFactor = 0;
425 pMac->lim.gHTServiceIntervalGranularity = 0;
426 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700427 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
428 pMac->lim.gHTPCOActive = 0;
429
430 pMac->lim.gHTPCOPhase = 0;
431 pMac->lim.gHTSecondaryBeacon = 0;
432 pMac->lim.gHTDualCTSProtection = 0;
433 pMac->lim.gHTSTBCBasicMCS = 0;
434 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
435}
436
437#if defined( FEATURE_WLAN_INTEGRATED_SOC )
438static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
439{
Jeff Johnsone7245742012-09-05 17:12:55 -0700440 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 tANI_U16 val16;
442 tANI_U8 val8;
443 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
444 tSirMacHTInfoField1 *pHTInfoField1;
445 tpSirPowerSaveCfg pPowerSaveConfig;
446 tSirMacHTParametersInfo *pAmpduParamInfo;
447
448 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700449 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
450 * and they will be used throughout when there is no session
451 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
454 {
455 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG\n"));)
456 return eSIR_FAILURE;
457 }
458
459 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
460 {
461 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG\n"));)
462 return eSIR_FAILURE;
463 }
464 val16 = ( tANI_U16 ) val1;
465 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
466
467 //channel bonding mode could be set to anything from 0 to 4(Titan had these
468 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
469 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
470 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
471 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
472 != eSIR_SUCCESS)
473 {
474 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG\n"));)
475 return eSIR_FAILURE;
476 }
477
478 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
479 {
480 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG\n"));)
481 return eSIR_FAILURE;
482 }
483
484 val8 = ( tANI_U8 ) val1;
485 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
486 pHTInfoField1->recommendedTxWidthSet =
487 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
489 != eSIR_SUCCESS)
490 {
491 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field\n"));)
492 return eSIR_FAILURE;
493 }
494
495 /* WNI_CFG_HEART_BEAT_THRESHOLD */
496
497 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
498 eSIR_SUCCESS )
499 {
500 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG\n"));)
501 return eSIR_FAILURE;
502 }
503 if(!val1)
504 {
505 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
506 pMac->sys.gSysEnableLinkMonitorMode = 0;
507 }
508 else
509 {
510 //No need to activate the timer during init time.
511 pMac->sys.gSysEnableLinkMonitorMode = 1;
512 }
513
514 /* WNI_CFG_SHORT_GI_20MHZ */
515
516 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
517 {
518 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG\n"));)
519 return eSIR_FAILURE;
520 }
521 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
522 {
523 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG\n"));)
524 return eSIR_FAILURE;
525 }
526 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
527 {
528 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG\n"));)
529 return eSIR_FAILURE;
530 }
531
532 val16 = ( tANI_U16 ) val1;
533 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
534 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
535 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
536
537 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
538 eSIR_SUCCESS)
539 {
540 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG\n"));)
541 return eSIR_FAILURE;
542 }
543
544 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
545
546 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
547 {
548 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG\n"));)
549 return eSIR_FAILURE;
550 }
551 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
552 {
553 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG\n"));)
554 return eSIR_FAILURE;
555 }
556 val16 = ( tANI_U16 ) val1;
557 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
558 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
559 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
560 eSIR_SUCCESS)
561 {
562 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG\n"));)
563 return eSIR_FAILURE;
564 }
565
566 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
567 limHandleCFGparamUpdate do we want to update this? */
568 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
569 {
570 limLog(pMac, LOGP, FL("cfg get short preamble failed\n"));
571 return eSIR_FAILURE;
572 }
573
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 /* WNI_CFG_MAX_PS_POLL */
575
576 /* Allocate and fill in power save configuration. */
577 if (palAllocateMemory(pMac->hHdd, (void **)&pPowerSaveConfig,
578 sizeof(tSirPowerSaveCfg)) != eHAL_STATUS_SUCCESS)
579 {
580 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
581 "configuration\n"));)
582 return eSIR_FAILURE;
583 }
584
585 /* This context should be valid if power-save configuration message has been
586 * already dispatched during initialization process. Re-using the present
587 * configuration mask
588 */
589 palCopyMemory(pMac->hHdd, pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg,
590 sizeof(tSirPowerSaveCfg));
591
592 /* Note: it is okay to do this since DAL/HAL is alrady started */
593 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
594 {
595 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed \n"));)
596 return eSIR_FAILURE;
597 }
598
599 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
600
601#if (WNI_POLARIS_FW_PRODUCT == WLAN_STA) || defined(ANI_AP_CLIENT_SDK)
602 PELOG1(limLog(pMac, LOG1,
603 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel\n"));)
604 pMac->lim.gLimBackgroundScanChannelId = 0;
605#endif
606
607 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
608
609 /* This was initially done after resume notification from HAL. Now, DAL is
610 started before PE so this can be done here */
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 handleHTCapabilityandHTInfo(pMac, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700612
613 return eSIR_SUCCESS;
614}
615#endif /* FEATURE_WLAN_INTEGRATED_SOC */
616
617/*
618 limStart
619 This function is to replace the __limProcessSmeStartReq since there is no
620 eWNI_SME_START_REQ post to PE.
621*/
622tSirRetStatus limStart(tpAniSirGlobal pMac)
623{
624 tSirResultCodes retCode = eSIR_SUCCESS;
625
626 PELOG1(limLog(pMac, LOG1, FL(" enter\n"));)
627
628 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
629 {
630 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
631
Jeff Johnsone7245742012-09-05 17:12:55 -0700632 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700633
634 // By default do not return after first scan match
635 pMac->lim.gLimReturnAfterFirstMatch = 0;
636
637 // Initialize MLM state machine
638 limInitMlm(pMac);
639
640 // By default return unique scan results
641 pMac->lim.gLimReturnUniqueResults = true;
642 pMac->lim.gLimSmeScanResultLength = 0;
643 }
644 else
645 {
646 /**
647 * Should not have received eWNI_SME_START_REQ in states
648 * other than OFFLINE. Return response to host and
649 * log error
650 */
651 limLog(pMac, LOGE, FL("Invalid SME state %X\n"),pMac->lim.gLimSmeState );
652 retCode = eSIR_FAILURE;
653 }
654
655 return retCode;
656}
657
658/**
659 * limInitialize()
660 *
661 *FUNCTION:
662 * This function is called from LIM thread entry function.
663 * LIM related global data structures are initialized in this function.
664 *
665 *LOGIC:
666 * NA
667 *
668 *ASSUMPTIONS:
669 * NA
670 *
671 *NOTE:
672 * NA
673 *
674 * @param pMac - Pointer to global MAC structure
675 * @return None
676 */
677
678tSirRetStatus
679limInitialize(tpAniSirGlobal pMac)
680{
681 tSirRetStatus status = eSIR_SUCCESS;
682
683 __limInitAssocVars(pMac);
684 __limInitVars(pMac);
685 __limInitStates(pMac);
686 __limInitStatsVars(pMac);
687 __limInitBssVars(pMac);
688 __limInitScanVars(pMac);
689 __limInitHTVars(pMac);
690 __limInitTitanVars(pMac);
691
692#if defined( FEATURE_WLAN_INTEGRATED_SOC )
693 status = limStart(pMac);
694 if(eSIR_SUCCESS != status)
695 {
696 return status;
697 }
698#endif /* FEATURE_WLAN_INTEGRATED_SOC */
699
700 /*
701 * MLM will be intitalized when 'START' request comes from SME.
702 * limInitMlm calls limCreateTimers, which actually relies on
703 * CFG to be downloaded. So it should not be called as part of
704 * peStart, as CFG download is happening after peStart.
705 */
706 //limInitMlm(pMac);
707 // Initializations for maintaining peers in IBSS
708 limIbssInit(pMac);
709
710 pmmInitialize(pMac);
711
712
713#if defined WLAN_FEATURE_VOWIFI
714 rrmInitialize(pMac);
715#endif
716#if defined WLAN_FEATURE_VOWIFI_11R
717 limFTOpen(pMac);
718#endif
719
720#ifdef WLAN_FEATURE_P2P
721 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
722#endif
723
724#if 0
725
726 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
727 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
728 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
729
730 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
731 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
732
733 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
734 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
735 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
736
737 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
738
739 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
740
741 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
742 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
743
744 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
745
746
747 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
748
749 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
750#endif
751 MTRACE(limTraceInit(pMac));
752
753#if defined( FEATURE_WLAN_INTEGRATED_SOC )
754 //Initialize the configurations needed by PE
755 if( eSIR_FAILURE == __limInitConfig(pMac))
756 {
757 //We need to undo everything in limStart
758 limCleanupMlm(pMac);
759 return eSIR_FAILURE;
760 }
761
762 //initialize the TSPEC admission control table.
763 //Note that this was initially done after resume notification from HAL.
764 //Now, DAL is started before PE so this can be done here
765 limAdmitControlInit(pMac);
766 limRegisterHalIndCallBack(pMac);
767#endif /*FEATURE_WLAN_INTEGRATED_SOC*/
768
769 return status;
770
771} /*** end limInitialize() ***/
772
773
774
775/**
776 * limCleanup()
777 *
778 *FUNCTION:
779 * This function is called upon reset or persona change
780 * to cleanup LIM state
781 *
782 *LOGIC:
783 * NA
784 *
785 *ASSUMPTIONS:
786 * NA
787 *
788 *NOTE:
789 * NA
790 *
791 * @param pMac - Pointer to Global MAC structure
792 * @return None
793 */
794
795void
796limCleanup(tpAniSirGlobal pMac)
797{
798#ifdef VOSS_ENABLED
799 v_PVOID_t pvosGCTx;
800 VOS_STATUS retStatus;
801#endif
802
803#ifdef WLAN_FEATURE_P2P
804//Before destroying the list making sure all the nodes have been deleted.
805//Which should be the normal case, but a memory leak has been reported.
806
807 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
808
809 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
810 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
811 {
812 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
813 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
814
815 palFreeMemory(pMac, pLimMgmtRegistration);
816 }
817
818 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
819#endif
820
821 limCleanupMlm(pMac);
822 limCleanupLmm(pMac);
823
824 // free up preAuth table
825 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
826 {
827 palFreeMemory(pMac->hHdd, pMac->lim.gLimPreAuthTimerTable.pTable);
828 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
829 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
830 }
831
832 if(NULL != pMac->lim.pDialogueTokenHead)
833 {
834 limDeleteDialogueTokenList(pMac);
835 }
836
837 if(NULL != pMac->lim.pDialogueTokenTail)
838 {
839 palFreeMemory(pMac->hHdd, (void *) pMac->lim.pDialogueTokenTail);
840 pMac->lim.pDialogueTokenTail = NULL;
841 }
842
843 # if 0
844 if (pMac->lim.gpLimStartBssReq != NULL)
845 {
846 palFreeMemory(pMac->hHdd, pMac->lim.gpLimStartBssReq);
847 pMac->lim.gpLimStartBssReq = NULL;
848 }
849 #endif
850
851 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
852 {
853 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmSetKeysReq);
854 pMac->lim.gpLimMlmSetKeysReq = NULL;
855 }
856
857 #if 0
858 if (pMac->lim.gpLimJoinReq != NULL)
859 {
860 palFreeMemory(pMac->hHdd, pMac->lim.gpLimJoinReq);
861 pMac->lim.gpLimJoinReq = NULL;
862 }
863 #endif
864
865 if (pMac->lim.gpLimMlmAuthReq != NULL)
866 {
867 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
868 pMac->lim.gpLimMlmAuthReq = NULL;
869 }
870
Jeff Johnsone7245742012-09-05 17:12:55 -0700871#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 if (pMac->lim.gpLimMlmJoinReq != NULL)
873 {
874 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
875 pMac->lim.gpLimMlmJoinReq = NULL;
876 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700877#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
879 #if 0
880 if (pMac->lim.gpLimReassocReq != NULL)
881 {
882 palFreeMemory(pMac->hHdd, pMac->lim.gpLimReassocReq);
883 pMac->lim.gpLimReassocReq = NULL;
884 }
885 #endif
886
887 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
888 {
889 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmRemoveKeyReq);
890 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
891 }
892
893 if (pMac->lim.gpLimMlmScanReq != NULL)
894 {
895 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmScanReq);
896 pMac->lim.gpLimMlmScanReq = NULL;
897 }
898
899#if 0
900 if(NULL != pMac->lim.beacon)
901 {
902 palFreeMemory(pMac->hHdd, (void*) pMac->lim.beacon);
903 pMac->lim.beacon = NULL;
904 }
905#endif
906 #if 0
907 if(NULL != pMac->lim.assocReq)
908 {
909 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocReq);
910 pMac->lim.assocReq= NULL;
911 }
912 #endif
913
914#if 0
915 if(NULL != pMac->lim.assocRsp)
916 {
917 palFreeMemory(pMac->hHdd, (void*) pMac->lim.assocRsp);
918 pMac->lim.assocRsp= NULL;
919 }
920#endif
921 // Now, finally reset the deferred message queue pointers
922 limResetDeferredMsgQ(pMac);
923
924#ifdef VOSS_ENABLED
925
926 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
927 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
928
929 if ( retStatus != VOS_STATUS_SUCCESS )
930 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out...\n"));)
931#endif
932
933#if defined WLAN_FEATURE_VOWIFI
934 rrmCleanup(pMac);
935#endif
936#if defined WLAN_FEATURE_VOWIFI_11R
937 limFTCleanup(pMac);
938#endif
939
940} /*** end limCleanup() ***/
941
942
943/** -------------------------------------------------------------
944\fn peOpen
945\brief will be called in Open sequence from macOpen
946\param tpAniSirGlobal pMac
947\param tHalOpenParameters *pHalOpenParam
948\return tSirRetStatus
949 -------------------------------------------------------------*/
950
951tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
952{
953 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
954 pMac->lim.maxStation = pMacOpenParam->maxStation;
955
956 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
957 {
958 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!\n"));)
959 return eSIR_FAILURE;
960 }
961
962 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
963 (void **) &pMac->lim.limTimers.gpLimCnfWaitTimer, sizeof(TX_TIMER)*pMac->lim.maxStation))
964 {
965 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
966 return eSIR_FAILURE;
967 }
968
969 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
970 (void **) &pMac->lim.gpLimAIDpool,
971 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1)))
972 {
973 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
974 return eSIR_FAILURE;
975 }
976
977 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
978 (void **) &pMac->lim.gpSession, sizeof(tPESession)* pMac->lim.maxBssId))
979 {
980 limLog(pMac, LOGE, FL("memory allocate failed!\n"));
981 return eSIR_FAILURE;
982 }
983
984 palZeroMemory(pMac->hHdd, pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId);
985
986
987 /*
988 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
989 (void **) &pMac->dph.dphHashTable.pHashTable, sizeof(tpDphHashNode)*pMac->lim.maxStation))
990 {
991 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
992 return eSIR_FAILURE;
993 }
994
995 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
996 (void **) &pMac->dph.dphHashTable.pDphNodeArray, sizeof(tDphHashNode)*pMac->lim.maxStation))
997 {
998 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
999 return eSIR_FAILURE;
1000 }
1001 */
1002
1003#ifdef WLAN_SOFTAP_FEATURE
1004 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1005 (void **) &pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation))
1006 {
1007 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!\n"));)
1008 return eSIR_FAILURE;
1009 }
1010 palZeroMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation);
1011#endif
1012
1013#ifdef ANI_PRODUCT_TYPE_AP
1014
1015 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1016 (void **) &pMac->pmm.gPmmTim.pStaInfo, sizeof(*pMac->pmm.gPmmTim.pStaInfo) * pMac->lim.maxStation))
1017 {
1018 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pStaInfo!\n"));)
1019 return eSIR_FAILURE;
1020 }
1021
1022 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1023 (void **) &pMac->pmm.gpPmmStaState, sizeof(tPmmStaState)*pMac->lim.maxStation))
1024 {
1025 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1026 return eSIR_FAILURE;
1027 }
1028
1029 if (eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1030 (void **) &pMac->pmm.gpPmmPSState, sizeof(tANI_U8)*pMac->lim.maxStation))
1031 {
1032 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!\n"));)
1033 return eSIR_FAILURE;
1034 }
1035#endif
1036
Jeff Johnsone7245742012-09-05 17:12:55 -07001037#ifdef WLAN_FEATURE_P2P
1038 pMac->lim.actionFrameSessionId = 0xff;
1039#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001040
1041 return eSIR_SUCCESS;
1042}
1043
1044/** -------------------------------------------------------------
1045\fn peClose
1046\brief will be called in close sequence from macClose
1047\param tpAniSirGlobal pMac
1048\return tSirRetStatus
1049 -------------------------------------------------------------*/
1050
1051tSirRetStatus peClose(tpAniSirGlobal pMac)
1052{
1053 tANI_U8 i;
1054
1055 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1056 return eSIR_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001057
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 for(i =0; i < pMac->lim.maxBssId; i++)
1059 {
1060 if(pMac->lim.gpSession[i].valid == TRUE)
1061 {
1062 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1063 }
1064 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001065 palFreeMemory(pMac->hHdd, pMac->lim.limTimers.gpLimCnfWaitTimer);
1066 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
1067 palFreeMemory(pMac->hHdd, pMac->lim.gpLimAIDpool);
1068 pMac->lim.gpLimAIDpool = NULL;
1069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 palFreeMemory(pMac->hHdd, pMac->lim.gpSession);
1071 pMac->lim.gpSession = NULL;
1072 /*
1073 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pHashTable);
1074 pMac->dph.dphHashTable.pHashTable = NULL;
1075 palFreeMemory(pMac->hHdd, pMac->dph.dphHashTable.pDphNodeArray);
1076 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1077 */
1078#ifdef WLAN_SOFTAP_FEATURE
1079 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pTim);
1080 pMac->pmm.gPmmTim.pTim = NULL;
1081#endif
1082#ifdef ANI_PRODUCT_TYPE_AP
1083 palFreeMemory(pMac->hHdd, pMac->pmm.gPmmTim.pStaInfo);
1084 pMac->pmm.gPmmTim.pStaInfo = NULL;
1085 palFreeMemory(pMac->hHdd, pMac->pmm.gpPmmStaState);
1086 pMac->pmm.gpPmmStaState = NULL;
1087 palFreeMemory(pMac->hHdd, pMac->pmm.gpPmmPSState);
1088 pMac->pmm.gpPmmPSState = NULL;
1089#endif
1090
1091 return eSIR_SUCCESS;
1092}
1093
1094/** -------------------------------------------------------------
1095\fn peStart
1096\brief will be called in start sequence from macStart
1097\param tpAniSirGlobal pMac
1098\return none
1099 -------------------------------------------------------------*/
1100
1101tSirRetStatus peStart(tpAniSirGlobal pMac)
1102{
1103 tSirRetStatus status = eSIR_SUCCESS;
1104
1105 status = limInitialize(pMac);
1106#if defined(ANI_LOGDUMP)
1107 limDumpInit(pMac);
1108#endif //#if defined(ANI_LOGDUMP)
1109
1110 return status;
1111}
1112
1113/** -------------------------------------------------------------
1114\fn peStop
1115\brief will be called in stop sequence from macStop
1116\param tpAniSirGlobal pMac
1117\return none
1118 -------------------------------------------------------------*/
1119
1120void peStop(tpAniSirGlobal pMac)
1121{
1122 limCleanup(pMac);
1123 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1124 return;
1125}
1126
1127/** -------------------------------------------------------------
1128\fn peFreeMsg
1129\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1130\ to free a given PE message on the TX and MC thread.
1131\ This happens when there are messages pending in the PE
1132\ queue when system is being stopped and reset.
1133\param tpAniSirGlobal pMac
1134\param tSirMsgQ pMsg
1135\return none
1136-----------------------------------------------------------------*/
1137v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1138{
1139 if (pMsg != NULL)
1140 {
1141 if (NULL != pMsg->bodyptr)
1142 {
1143 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1144 {
1145 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1146 }
1147 else
1148 {
1149 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1150 }
1151 }
1152 pMsg->bodyptr = 0;
1153 pMsg->bodyval = 0;
1154 pMsg->type = 0;
1155 }
1156 return;
1157}
1158
1159
1160/**
1161 * The function checks if a particular timer should be allowed
1162 * into LIM while device is sleeping
1163 */
1164tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1165{
1166 tANI_U8 retStatus = TRUE;
1167
1168 if(!limIsSystemInActiveState(pMac))
1169 {
1170 switch(pMsg->type)
1171 {
1172 /* Don't allow following timer messages if in sleep */
1173 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1174 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1175 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1176 retStatus = FALSE;
1177 break;
1178 /* May allow following timer messages in sleep mode */
1179 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1180
1181 /* Safe to allow as of today, this triggers background scan
1182 * which will not be started if the device is in power-save mode
1183 * might need to block in the future if we decide to implement
1184 * spectrum management
1185 */
1186 case SIR_LIM_QUIET_TIMEOUT:
1187
1188 /* Safe to allow as of today, this triggers background scan
1189 * which will not be started if the device is in power-save mode
1190 * might need to block in the future if we decide to implement
1191 * spectrum management
1192 */
1193 case SIR_LIM_QUIET_BSS_TIMEOUT:
1194
1195 /* Safe to allow this timermessage, triggers background scan
1196 * which is blocked in sleep mode
1197 */
1198 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1199
1200 /* Safe to allow this timer, since, while in IMPS this timer will not
1201 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1202 * when heart-beat control is handled back to PE, device would have
1203 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1204 */
1205 case SIR_LIM_HEART_BEAT_TIMEOUT:
1206 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1207
1208 /* Safe to allow, PE is not handling this message as of now. May need
1209 * to block it, basically, free the buffer and restart the timer
1210 */
1211 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1212 case SIR_LIM_JOIN_FAIL_TIMEOUT:
1213 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1214 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1215 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1216 retStatus = TRUE;
1217 break;
1218
1219 /* by default allow rest of messages */
1220 default:
1221 retStatus = TRUE;
1222 break;
1223
1224
1225 }
1226 }
1227
1228 return retStatus;
1229
1230}
1231
1232
1233
1234/**
1235 * limPostMsgApi()
1236 *
1237 *FUNCTION:
1238 * This function is called from other thread while posting a
1239 * message to LIM message Queue gSirLimMsgQ.
1240 *
1241 *LOGIC:
1242 * NA
1243 *
1244 *ASSUMPTIONS:
1245 * NA
1246 *
1247 *NOTE:
1248 * NA
1249 *
1250 * @param pMac - Pointer to Global MAC structure
1251 * @param pMsg - Pointer to the message structure
1252 * @return None
1253 */
1254
1255tANI_U32
1256limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1257{
1258#ifdef VOSS_ENABLED
1259 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1260
1261
1262#elif defined(ANI_OS_TYPE_LINUX) || defined(ANI_OS_TYPE_OSX)
1263 return tx_queue_send(&pMac->sys.gSirLimMsgQ, pMsg, TX_WAIT_FOREVER);
1264
1265#else
1266 /* Check if this is a timeout message from a timer
1267 * and if the timeout message is allowed if the device is in power-save state
1268 */
1269 if(!limIsTimerAllowedInPowerSaveState(pMac, pMsg))
1270 {
1271 limLog(pMac, LOGW,
1272 FL("Timeout message %d is not allowed while device is in Power-Save mode\n"),
1273 pMsg->type);
1274
1275 return TX_SUCCESS;
1276 }
1277 if(pMac->gDriverType != eDRIVER_TYPE_MFG)
1278 {
1279 limMessageProcessor(pMac, pMsg);
1280 }
1281
1282 return TX_SUCCESS;
1283
1284#endif
1285} /*** end limPostMsgApi() ***/
1286
1287
1288/*--------------------------------------------------------------------------
1289
1290 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1291
1292 This function can be called by legacy code to post message to voss queues OR
1293 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1294 for dispatching it later.
1295
1296 \param pMac - Pointer to Global MAC structure
1297 \param pMsg - Pointer to the message structure
1298
1299 \return tANI_U32 - TX_SUCCESS for success.
1300
1301 --------------------------------------------------------------------------*/
1302
1303tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1304{
1305 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1306}
1307
1308/*--------------------------------------------------------------------------
1309
1310 \brief peProcessMessages() - Message Processor for PE
1311
1312 Voss calls this function to dispatch the message to PE
1313
1314 \param pMac - Pointer to Global MAC structure
1315 \param pMsg - Pointer to the message structure
1316
1317 \return tANI_U32 - TX_SUCCESS for success.
1318
1319 --------------------------------------------------------------------------*/
1320
1321tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1322{
1323 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1324 {
1325 return eSIR_SUCCESS;
1326 }
1327 /**
1328 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1329 * for all the other cases post it to LIM
1330 */
1331 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1332 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1333 else
1334 limMessageProcessor(pMac, pMsg);
1335 return eSIR_SUCCESS;
1336}
1337
1338
1339#ifdef VOSS_ENABLED
1340
1341// ---------------------------------------------------------------------------
1342/**
1343 * peHandleMgmtFrame
1344 *
1345 * FUNCTION:
1346 * Process the Management frames from TL
1347 *
1348 * LOGIC:
1349 *
1350 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1351 *
1352 * NOTE:
1353 *
1354 * @param pvosGCtx Global Vos Context
1355 * @param vossBuff Packet
1356 * @return None
1357 */
1358
1359VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1360{
1361 tpAniSirGlobal pMac;
1362 tpSirMacMgmtHdr mHdr;
1363 tSirMsgQ msg;
1364 vos_pkt_t *pVosPkt;
1365 VOS_STATUS vosStatus;
1366 v_U8_t *pRxPacketInfo;
1367
1368 pVosPkt = (vos_pkt_t *)vosBuff;
1369 if (NULL == pVosPkt)
1370 {
1371 return VOS_STATUS_E_FAILURE;
1372 }
1373
1374 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1375 if (NULL == pMac)
1376 {
1377 // cannot log a failure without a valid pMac
1378 vos_pkt_return_packet(pVosPkt);
1379 return VOS_STATUS_E_FAILURE;
1380 }
1381
1382 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1383
1384 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1385 {
1386 vos_pkt_return_packet(pVosPkt);
1387 return VOS_STATUS_E_FAILURE;
1388 }
1389
1390
1391 //
1392 // The MPDU header is now present at a certain "offset" in
1393 // the BD and is specified in the BD itself
1394 //
1395 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1396 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1397 {
1398 PELOG1(limLog( pMac, LOG1,
1399 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001400 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001401
Jeff Johnsone7245742012-09-05 17:12:55 -07001402 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1404 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1405 }
1406
1407
1408 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1409 msg.type = SIR_BB_XPORT_MGMT_MSG;
1410 msg.bodyptr = vosBuff;
1411 msg.bodyval = 0;
1412
1413 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1414 &msg,
1415 mHdr->fc.type,
1416 mHdr->fc.subType ))
1417 {
1418 vos_pkt_return_packet(pVosPkt);
1419 limLog( pMac, LOGW,
1420 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG\n" ));
1421 return VOS_STATUS_E_FAILURE;
1422 }
1423
1424 return VOS_STATUS_SUCCESS;
1425}
1426
1427// ---------------------------------------------------------------------------
1428/**
1429 * peRegisterTLHandle
1430 *
1431 * FUNCTION:
1432 * Registers the Handler which, process the Management frames from TL
1433 *
1434 * LOGIC:
1435 *
1436 * ASSUMPTIONS:
1437 *
1438 * NOTE:
1439 *
1440 * @return None
1441 */
1442
1443void peRegisterTLHandle(tpAniSirGlobal pMac)
1444{
1445 v_PVOID_t pvosGCTx;
1446 VOS_STATUS retStatus;
1447
1448 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1449
1450 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1451
1452 if (retStatus != VOS_STATUS_SUCCESS)
1453 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out...\n"));
1454
1455}
1456#endif
1457
1458
1459/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 * limIsSystemInScanState()
1461 *
1462 *FUNCTION:
1463 * This function is called by various MAC software modules to
1464 * determine if System is in Scan/Learn state
1465 *
1466 *LOGIC:
1467 * NA
1468 *
1469 *ASSUMPTIONS:
1470 * NA
1471 *
1472 *NOTE:
1473 *
1474 * @param pMac - Pointer to Global MAC structure
1475 * @return true - System is in Scan/Learn state
1476 * false - System is NOT in Scan/Learn state
1477 */
1478
1479tANI_U8
1480limIsSystemInScanState(tpAniSirGlobal pMac)
1481{
1482 switch (pMac->lim.gLimSmeState)
1483 {
1484 case eLIM_SME_CHANNEL_SCAN_STATE:
1485 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1486 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1487 case eLIM_SME_WT_SCAN_STATE:
1488 // System is in Learn mode
1489 return true;
1490
1491 default:
1492 // System is NOT in Learn mode
1493 return false;
1494 }
1495} /*** end limIsSystemInScanState() ***/
1496
1497
1498
1499/**
1500 * limIsSystemInActiveState()
1501 *
1502 *FUNCTION:
1503 * This function is called by various MAC software modules to
1504 * determine if System is in Active/Wakeup state
1505 *
1506 *LOGIC:
1507 * NA
1508 *
1509 *ASSUMPTIONS:
1510 * NA
1511 *
1512 *NOTE:
1513 *
1514 * @param pMac - Pointer to Global MAC structure
1515 * @return true - System is in Active state
1516 * false - System is not in Active state
1517 */
1518
1519tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1520{
1521 switch (pMac->pmm.gPmmState)
1522 {
1523 case ePMM_STATE_BMPS_WAKEUP:
1524 case ePMM_STATE_IMPS_WAKEUP:
1525 case ePMM_STATE_READY:
1526 // System is in Active mode
1527 return true;
1528 default:
1529 return false;
1530 // System is NOT in Active mode
1531 }
1532}
1533
1534
1535#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
1536/**
1537 * limCheckAndQuietBSS()
1538 *
1539 *FUNCTION:
1540 * This function is called by limSetLearnMode() to check
1541 * if BSS needs to be quieted and call limQuietBSS() to
1542 * send data frame to self for that purpose.
1543 *
1544 *LOGIC:
1545 * NA
1546 *
1547 *ASSUMPTIONS:
1548 * NA
1549 *
1550 *NOTE:
1551 *
1552 * @param pMac - Pointer to Global MAC structure
1553 * @return None
1554 */
1555
1556void
1557limCheckAndQuietBSS(tpAniSirGlobal pMac)
1558{
1559 tANI_U32 dur;
1560
1561 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1562 {
1563 // LIM is in AP role. Quiet the BSS before
1564 // switching to channel to be learned
1565 if (pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration >
1566 LIM_MAX_QUIET_DURATION)
1567 {
1568 // May need to quiet BSS multiple times.
1569 // Quiet for a limit of 32 msecs on Learn
1570 // duration for now.
1571 dur = LIM_MAX_QUIET_DURATION;
1572 }
1573 else
1574 {
1575 dur =
1576 pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration;
1577 }
1578 PELOG3(limLog(pMac, LOG3,
1579 FL("*** Going to quiet BSS for duration=%d msec\n"),
1580 dur);)
1581
1582 limQuietBss(pMac, dur);
1583 }
1584} /*** end limCheckAndQuietBSS() ***/
1585#endif
1586
1587#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1588/**
1589 * limSetLearnMode()
1590 *
1591 *FUNCTION:
1592 * This function is called to setup system into Learn mode
1593 * to collect DFS measurements.
1594 *
1595 *LOGIC:
1596 * NA
1597 *
1598 *ASSUMPTIONS:
1599 * NA
1600 *
1601 *NOTE:
1602 *
1603 * @param pMac - Pointer to Global MAC structure
1604 * @return None
1605 */
1606
1607void
1608limSetLearnMode(tpAniSirGlobal pMac)
1609{
1610 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_LEARN_WAIT_STATE, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN);
1611 return;
1612} /*** end limSetLearnMode() ***/
1613
1614/**
1615 * limContinueChannelLearn()
1616 *
1617 *FUNCTION:
1618 * This function is called to do measurement (learn) on current channel.
1619 *
1620 *LOGIC:
1621 *
1622 *ASSUMPTIONS:
1623 * NA
1624 *
1625 *NOTE:
1626 * NA
1627 *
1628 * @param pMac - Pointer to Global MAC structure
1629 *
1630 * @return None
1631 */
1632
1633void
1634limContinueChannelLearn(tpAniSirGlobal pMac)
1635{
1636 tANI_U8 chanNum;
1637 tSirMacSSid ssId;
1638 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1639
1640 // Time to collect measurements
1641 chanNum = limGetCurrentLearnChannel(pMac);
1642
1643 // Switch channel
1644 pMac->lim.gLimSystemInScanLearnMode = 1;
1645
1646 if (pMac->lim.gpLimMeasReq->measControl.scanType == eSIR_ACTIVE_SCAN)
1647 {
1648 /// Prepare and send Probe Request frame
1649 ssId.length = 0;
1650 /* for learning channel, we don't include any additional IE */
1651 limSendProbeReqMgmtFrame(pMac, &ssId, bssId, chanNum,pMac->lim.gSelfMacAddr, 0 , NULL);
1652 }
1653
1654 // Activate Learn duration timer during which
1655 // DFS measurements are made.
1656 pMac->lim.gLimMeasParams.shortDurationCount++;
1657 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_DURATION_TIMER);
1658
Jeff Johnsone7245742012-09-05 17:12:55 -07001659 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_DURATION_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 if (tx_timer_activate(&pMac->lim.gLimMeasParams.learnDurationTimer)
1661 != TX_SUCCESS)
1662 {
1663 /// Could not activate learn duration timer.
1664 // Log error
1665 limLog(pMac, LOGP, FL("could not activate learn duration timer\n"));
1666
1667 return;
1668 }
1669} /*** end limContinueChannelLearn() ***/
1670
1671
1672/**
1673 * limReEnableLearnMode()
1674 *
1675 *FUNCTION:
1676 * This function is called by various MAC software modules to
1677 * re-enable Learn mode measurements.
1678 *
1679 *LOGIC:
1680 * NA
1681 *
1682 *ASSUMPTIONS:
1683 * NA
1684 *
1685 *NOTE:
1686 *
1687 * @param pMac - Pointer to Global MAC structure
1688 * @return None
1689 */
1690
1691void
1692limReEnableLearnMode(tpAniSirGlobal pMac)
1693{
1694 PELOG4(limLog(pMac, LOG4, FL("quietEnabled = %d\n"),
1695 pMac->lim.gLimSpecMgmt.fQuietEnabled);)
1696
1697 /** Stop measurement temperorily when radar is detected or channel
1698 * switch is running as part of periodic DFS */
1699 if (!pMac->lim.gpLimMeasReq || LIM_IS_RADAR_DETECTED(pMac) ||
1700 (pMac->lim.gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING))
1701 {
1702 return;
1703 }
1704
1705 if (pMac->lim.gLimSpecMgmt.fQuietEnabled)
1706 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001707 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001708#ifdef GEN6_TODO
1709 /* revisit this piece of code to assign the appropriate sessionId below
1710 * priority - HIGH
1711 */
1712 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
1713#endif
1714 if (tx_timer_activate(
1715 &pMac->lim.limTimers.gLimQuietBssTimer)
1716 != TX_SUCCESS)
1717 {
1718 limLog(pMac, LOGP, FL("could not start Quiet Bss timer\n"));
1719 return;
1720 }
1721 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
1722 }
1723 else
1724 {
1725 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_INTERVAL_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07001726 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_INTERVAL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001727#ifdef GEN6_TODO
1728 /* revisit this piece of code to assign the appropriate sessionId below
1729 */
1730 pMac->lim.gLimMeasParams.learnIntervalTimer.sessionId = sessionId;
1731#endif
1732 if (tx_timer_activate(
1733 &pMac->lim.gLimMeasParams.learnIntervalTimer)
1734 != TX_SUCCESS)
1735 {
1736 /// Could not activate Learn Interval timer.
1737 // Log error
1738 limLog(pMac, LOGP, FL("could not start Learn Interval timer\n"));
1739 return;
1740 }
1741 }
1742
1743 PELOG3(limLog(pMac, LOG3, FL("Re-enabled Learn mode Measurements\n"));)
1744 pMac->lim.gLimMeasParams.disableMeasurements = 0;
1745
1746 return;
1747} /*** end limReEnableLearnMode() ***/
1748
1749#endif //#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1750
1751
1752/**
1753*\brief limReceivedHBHandler()
1754*
1755* This function is called by schBeaconProcess() upon
1756* receiving a Beacon on STA. This also gets called upon
1757* receiving Probe Response after heat beat failure is
1758* detected.
1759*
1760* param pMac - global mac structure
1761* param channel - channel number indicated in Beacon, Probe Response
1762* return - none
1763*/
1764
1765
1766void
1767limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1768{
1769 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1770 psessionEntry->LimRxedBeaconCntDuringHB++;
1771
1772 pMac->pmm.inMissedBeaconScenario = FALSE;
1773} /*** end limReceivedHBHandler() ***/
1774
1775
1776
1777#if 0
1778void limResetHBPktCount(tpPESession psessionEntry)
1779{
1780 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1781}
1782#endif
1783
1784
1785/*
1786 * limProcessWdsInfo()
1787 *
1788 *FUNCTION:
1789 * This function is called from schBeaconProcess in BP
1790 *
1791 *PARAMS:
1792 * @param pMac - Pointer to Global MAC structure
1793 * @param propIEInfo - proprietary IE info
1794 *
1795 *LOGIC:
1796 *
1797 *ASSUMPTIONS:
1798 * NA
1799 *
1800 *NOTE:
1801 *
1802 *
1803 *RETURNS:
1804 *
1805 */
1806
1807void limProcessWdsInfo(tpAniSirGlobal pMac,
1808 tSirPropIEStruct propIEInfo)
1809{
1810#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1811 tpSirSmeWdsInfoInd pSirSmeWdsInfoInd;
1812 tANI_U8 *pTemp;
1813 tSirMsgQ mmhMsg;
1814
1815 if (propIEInfo.wdsLength &&
1816 propIEInfo.wdsLength <= ANI_WDS_INFO_MAX_LENGTH)
1817 {
1818 if (pMac->lim.gLimWdsInfo.wdsLength)
1819 {
1820 if ((propIEInfo.wdsLength ==
1821 pMac->lim.gLimWdsInfo.wdsLength) &&
1822 (palEqualMemory( pMac->hHdd,propIEInfo.wdsData,
1823 pMac->lim.gLimWdsInfo.wdsBytes,
1824 pMac->lim.gLimWdsInfo.wdsLength) ))
1825
1826 return; // no difference in WDS info
1827 else
1828 {
1829 PELOG2(limLog(pMac, LOG2,
1830 FL("Cached WDS Info: length %d bytes is: "),
1831 pMac->lim.gLimWdsInfo.wdsLength);
1832 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1833 pMac->lim.gLimWdsInfo.wdsBytes,
1834 pMac->lim.gLimWdsInfo.wdsLength);)
1835
1836 PELOG2(limLog(pMac, LOG2, FL("New WDS Info: length %d bytes is: "),
1837 propIEInfo.wdsLength);
1838 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1839 propIEInfo.wdsData,
1840 propIEInfo.wdsLength);)
1841
1842 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1843 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1844 propIEInfo.wdsData,
1845 propIEInfo.wdsLength);
1846
1847 // send IND to WSM
1848 if (eHAL_STATUS_SUCCESS !=
1849 palAllocateMemory(pMac->hHdd,
1850 (void **) &pSirSmeWdsInfoInd,
1851 sizeof(tSirSmeWdsInfoInd)))
1852 {
1853 // Log error
1854 limLog(pMac, LOGP,
1855 FL("memory allocate failed for WDS_INFO_IND\n"));
1856
1857 return;
1858 }
1859
1860 pSirSmeWdsInfoInd->messageType = eWNI_SME_WDS_INFO_IND;
1861 pSirSmeWdsInfoInd->length = sizeof(tSirSmeWdsInfoInd);
1862
1863 pSirSmeWdsInfoInd->wdsInfo.wdsLength =
1864 pMac->lim.gLimWdsInfo.wdsLength;
1865
1866 palCopyMemory( pMac->hHdd, pSirSmeWdsInfoInd->wdsInfo.wdsBytes,
1867 pMac->lim.gLimWdsInfo.wdsBytes,
1868 pMac->lim.gLimWdsInfo.wdsLength);
1869
1870 pTemp = (tANI_U8 *) pSirSmeWdsInfoInd;
1871
1872 PELOG2(limLog(pMac, LOG2,
1873 FL("eWNI_SME_WDS_INFO_IND length %d bytes is: "),
1874 pSirSmeWdsInfoInd->length);
1875 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pTemp,
1876 pSirSmeWdsInfoInd->length);)
1877
1878 mmhMsg.type = eWNI_SME_WDS_INFO_IND;
1879 mmhMsg.bodyptr = pSirSmeWdsInfoInd;
1880 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001881 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
1883 pMac->lim.gLimNumWdsInfoInd++;
1884 }
1885 }
1886 else
1887 {
1888 // first WDS info
1889 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1890 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1891 propIEInfo.wdsData,
1892 propIEInfo.wdsLength);
1893
1894 PELOG1(limLog(pMac, LOG1, FL("First WDS Info: length %d bytes is:\n"),
1895 pMac->lim.gLimWdsInfo.wdsLength);
1896 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
1897 pMac->lim.gLimWdsInfo.wdsBytes,
1898 pMac->lim.gLimWdsInfo.wdsLength);)
1899
1900 }
1901 }
1902 else
1903 {
1904 PELOG2(limLog(pMac, LOG2,
1905 FL("Illegal WDS length = %d\n"),
1906 propIEInfo.wdsLength);)
1907 }
1908#endif
1909}
1910
1911
1912
1913/**
1914 * limInitWdsInfoParams()
1915 *
1916 *FUNCTION:
1917 * This function is called while processing
1918 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1919 * ind/set related parameters.
1920 *
1921 *LOGIC:
1922 *
1923 *ASSUMPTIONS:
1924 *
1925 *NOTE:
1926 *
1927 * @param pMac Pointer to Global MAC structure
1928 * @return None
1929 */
1930
1931void
1932limInitWdsInfoParams(tpAniSirGlobal pMac)
1933{
1934 pMac->lim.gLimWdsInfo.wdsLength = 0;
1935 pMac->lim.gLimNumWdsInfoInd = 0;
1936 pMac->lim.gLimNumWdsInfoSet = 0;
1937} /*** limInitWdsInfoParams() ***/
1938
1939
1940/** -------------------------------------------------------------
1941\fn limUpdateOverlapStaParam
1942\brief Updates overlap cache and param data structure
1943\param tpAniSirGlobal pMac
1944\param tSirMacAddr bssId
1945\param tpLimProtStaParams pStaParams
1946\return None
1947 -------------------------------------------------------------*/
1948void
1949limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1950{
1951 int i;
1952 if (!pStaParams->numSta)
1953 {
1954 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1955 bssId,
1956 sizeof(tSirMacAddr));
1957 pMac->lim.protStaOverlapCache[0].active = true;
1958
1959 pStaParams->numSta = 1;
1960
1961 return;
1962 }
1963
1964 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1965 {
1966 if (pMac->lim.protStaOverlapCache[i].active)
1967 {
1968 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
1969 bssId,
1970 sizeof(tSirMacAddr))) {
1971 return; }
1972 }
1973 else
1974 break;
1975 }
1976
1977 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1978 {
1979 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full\n"));)
1980 }
1981 else
1982 {
1983 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
1984 bssId,
1985 sizeof(tSirMacAddr));
1986 pMac->lim.protStaOverlapCache[i].active = true;
1987
1988 pStaParams->numSta++;
1989 }
1990}
1991
1992
1993/**
1994 * limHandleIBSScoalescing()
1995 *
1996 *FUNCTION:
1997 * This function is called upon receiving Beacon/Probe Response
1998 * while operating in IBSS mode.
1999 *
2000 *LOGIC:
2001 *
2002 *ASSUMPTIONS:
2003 *
2004 *NOTE:
2005 *
2006 * @param pMac - Pointer to Global MAC structure
2007 * @param pBeacon - Parsed Beacon Frame structure
2008 * @param pRxPacketInfo - Pointer to RX packet info structure
2009 *
2010 * @return Status whether to process or ignore received Beacon Frame
2011 */
2012
2013tSirRetStatus
2014limHandleIBSScoalescing(
2015 tpAniSirGlobal pMac,
2016 tpSchBeaconStruct pBeacon,
2017 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
2018{
2019 tpSirMacMgmtHdr pHdr;
2020 tSirRetStatus retCode;
2021
2022 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2023 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
2024 /* Received SSID does not match => Ignore received Beacon frame. */
2025 retCode = eSIR_LIM_IGNORE_BEACON;
2026 else
2027 {
2028 tANI_U32 ieLen;
2029 tANI_U16 tsfLater;
2030 tANI_U8 *pIEs;
2031 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2032 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
2033 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2034 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
2035 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
2036 }
2037 return retCode;
2038} /*** end limHandleIBSScoalescing() ***/
2039
2040
2041
2042/**
2043 * limDetectChangeInApCapabilities()
2044 *
2045 *FUNCTION:
2046 * This function is called while SCH is processing
2047 * received Beacon from AP on STA to detect any
2048 * change in AP's capabilities. If there any change
2049 * is detected, Roaming is informed of such change
2050 * so that it can trigger reassociation.
2051 *
2052 *LOGIC:
2053 *
2054 *ASSUMPTIONS:
2055 *
2056 *NOTE:
2057 * Notification is enabled for STA product only since
2058 * it is not a requirement on BP side.
2059 *
2060 * @param pMac Pointer to Global MAC structure
2061 * @param pBeacon Pointer to parsed Beacon structure
2062 * @return None
2063 */
2064
2065void
2066limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
2067 tpSirProbeRespBeacon pBeacon,
2068 tpPESession psessionEntry)
2069{
2070#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2071 tANI_U8 len;
2072 tSirSmeApNewCaps apNewCaps;
2073 tANI_U8 newChannel;
2074 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
2075 newChannel = (tANI_U8) pBeacon->channelNumber;
2076
2077 if ((psessionEntry->limSentCapsChangeNtf == false) &&
2078 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
2079 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
2080 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
2081 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
2082 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
2083 (newChannel != psessionEntry->currentOperChannel)
2084#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
2085 || (LIM_BSS_CAPS_GET(HCF, psessionEntry->limCurrentBssQosCaps) !=
2086 pBeacon->propIEinfo.hcfEnabled)
2087#endif
2088 )))
2089 {
2090
2091 /**
2092 * BSS capabilities have changed.
2093 * Inform Roaming.
2094 */
2095 len = sizeof(tSirMacCapabilityInfo) +
2096 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
2097 3 * sizeof(tANI_U8) + // reserved fields
2098 pBeacon->ssId.length + 1;
2099
2100 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
2101 psessionEntry->bssId,
2102 sizeof(tSirMacAddr));
2103 if (newChannel != psessionEntry->currentOperChannel)
2104 {
2105 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
2106 "Ignoring beacon!\n"),
2107 psessionEntry->currentOperChannel, newChannel);)
2108 return;
2109 }
2110 else
2111 apNewCaps.channelId = psessionEntry->currentOperChannel;
2112 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
2113 (tANI_U8 *) &pBeacon->ssId,
2114 pBeacon->ssId.length + 1);
2115
2116 psessionEntry->limSentCapsChangeNtf = true;
2117 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2118 (tANI_U32 *) &apNewCaps,
2119 len, psessionEntry->smeSessionId);
2120 }
2121#endif
2122} /*** limDetectChangeInApCapabilities() ***/
2123
2124
2125
2126
2127// ---------------------------------------------------------------------
2128/**
2129 * limUpdateShortSlot
2130 *
2131 * FUNCTION:
2132 * Enable/Disable short slot
2133 *
2134 * LOGIC:
2135 *
2136 * ASSUMPTIONS:
2137 *
2138 * NOTE:
2139 *
2140 * @param enable Flag to enable/disable short slot
2141 * @return None
2142 */
2143
2144tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2145{
2146
2147 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002148 tANI_U32 nShortSlot;
2149 tANI_U32 val = 0;
2150 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002151
Jeff Johnsone7245742012-09-05 17:12:55 -07002152 // Check Admin mode first. If it is disabled just return
2153 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2154 != eSIR_SUCCESS)
2155 {
2156 limLog(pMac, LOGP,
2157 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed\n"));
2158 return eSIR_FAILURE;
2159 }
2160 if (val == false)
2161 return eSIR_SUCCESS;
2162
2163 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2164 limGetPhyMode(pMac, &phyMode, psessionEntry);
2165 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2166 return eSIR_SUCCESS;
2167
2168 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002169
2170 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2171 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2172 // if no erp present, use short slot based on current ap caps
2173
2174 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2175
2176 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2177 // The difference between the earlier implementation and the new one is only Case4.
2178 /*
2179 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2180 Case1 1 1 1 1 //AP should not advertise this combination.
2181 Case2 1 1 0 0
2182 Case3 1 0 1 1
2183 Case4 1 0 0 0
2184 Case5 0 1 1 1
2185 Case6 0 1 0 0
2186 Case7 0 0 1 1
2187 Case8 0 0 0 0
2188 */
2189 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2190
Jeff Johnsone7245742012-09-05 17:12:55 -07002191 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 {
2193 // Short slot time capability of AP has changed. Adopt to it.
2194 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d\n"), nShortSlot);)
2195 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002196 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2198 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 }
2200 return eSIR_SUCCESS;
2201}
2202
2203
2204#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
2205
2206/**
2207 * limUpdateQuietIEInBeacons()
2208 *
2209 *FUNCTION:
2210 * This function is called by specialBeaconProcessing(),
2211 * when it is time to generate the next beacon.
2212 * If gLimQuietState is not in the INIT state, then it
2213 * means that the next beacon may need to include some
2214 * information about the Quiet BSS IE.
2215 * This function makes that decision based on the current
2216 * state of gLimQuietState
2217 *
2218 *LOGIC:
2219 * This routine invokes schSetFixedBeaconFields() only
2220 * if necessary, as it is expensive to update the fixed
2221 * beacon fields during each beacon interval.
2222 *
2223 *ASSUMPTIONS:
2224 * This Quiet BSS IE will be sent out as part of
2225 * Proprietary IE's. If 802.11H is enabled, this IE
2226 * will be sent out as defined in the 11H spec
2227 *
2228 *NOTE:
2229 *
2230 * @param pMac Pointer to Global MAC structure
2231 * @return true, if the beacon fields need updating
2232 * false, if not
2233 */
2234tANI_BOOLEAN limUpdateQuietIEInBeacons( tpAniSirGlobal pMac )
2235{
2236 tANI_BOOLEAN fUpdateBeaconFields = eANI_BOOLEAN_TRUE;
2237
2238 limLog( pMac, LOG2, FL("Quiet BSS State = %d\n"),
2239 pMac->lim.gLimSpecMgmt.quietState );
2240 switch( pMac->lim.gLimSpecMgmt.quietState )
2241 {
2242 case eLIM_QUIET_BEGIN:
2243 // We need to start broadcasting the Quiet BSS IE
2244 // Transition to eLIM_QUIET_RUNNING
2245 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
2246 break;
2247
2248 case eLIM_QUIET_RUNNING:
2249 // Start down-counting...
2250 pMac->lim.gLimSpecMgmt.quietCount--;
2251 if( pMac->lim.gLimSpecMgmt.quietCount == 0 )
2252 {
2253 //
2254 // We no longer need to broadcast the Quiet BSS IE
2255 //
2256 // NOTE - We still need to call schSetFixedBeaconFields()
2257 // one last time, just to remove the Quiet BSS IE from
2258 // the list of fixed beacon fields
2259 //
2260 // Transition to eLIM_QUIET_END
2261 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2262 limProcessLearnIntervalTimeout(pMac);
2263 }
2264 break;
2265
2266 case eLIM_QUIET_CHANGED:
2267 //
2268 // State possibly changed via setupQuietBss().
2269 // This means, gLimQuietCount has been changed!!
2270 //
2271 // NOTE - We still need to call schSetFixedBeaconFields()
2272 // one last time, just to remove the Quiet BSS IE from
2273 // the list of fixed beacon fields
2274 //
2275
2276 // Transition to eLIM_QUIET_END
2277 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2278 break;
2279
2280 case eLIM_QUIET_INIT:
2281 case eLIM_QUIET_END:
2282 // Transition to eLIM_QUIET_INIT
2283 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
2284 // Fall thru'...
2285 default:
2286 fUpdateBeaconFields = eANI_BOOLEAN_FALSE;
2287 break;
2288 }
2289
2290 return fUpdateBeaconFields;
2291}
2292
2293#endif
2294
2295#if ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK))
2296void limConvertScanDuration(tpAniSirGlobal pMac)
2297{
2298 tpSirSmeMeasurementReq pMeasReq = pMac->lim.gpLimMeasReq;
2299 tpLimScanDurationConvert scanDurConv = &pMac->lim.gLimScanDurationConvert;
2300
2301 /* This is not a good idea to convert {long}shortChannelScanDuration from mS to TICKS *
2302 * The reason is that {long}shortChannelScanDuration is used all over and a lot of code *
2303 * that assumes the old mS definition was never changed to accommodate this new change to TICKS. *
2304 * If optimization is needed, create another set of shadow variables to store the converted *
2305 * values in Ticks, and TU. */
2306 scanDurConv->shortChannelScanDuration_tick =
2307 SYS_MS_TO_TICKS(pMeasReq->measDuration.shortChannelScanDuration +SYS_TICK_DUR_MS-1);
2308
2309 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2310 /* (shortChanneScanDuration * 1000) / 2^10 */
2311 scanDurConv->shortChannelScanDuration_TU = (pMeasReq->measDuration.shortChannelScanDuration * 1000) >> 10;
2312
2313 scanDurConv->longChannelScanDuration_tick =
2314 SYS_MS_TO_TICKS(pMeasReq->measDuration.longChannelScanDuration +SYS_TICK_DUR_MS-1);
2315
2316 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2317 /* (longChanneScanDuration * 1000) / 2^10 */
2318 scanDurConv->longChannelScanDuration_TU = (pMeasReq->measDuration.longChannelScanDuration * 1000) >> 10;
2319}
2320#endif /* ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK)) */
2321
2322
2323#ifdef ANI_PRODUCT_TYPE_AP
2324/**-------------------------------------------------
2325\fn limIsRadarEnabled
2326
2327\brief Checks if radar is enabled
2328\param pMac
2329\return true - if Both 11h and radar enabled
2330 false - if either is not enabled.
2331 --------------------------------------------------*/
2332tANI_BOOLEAN limIsRadarEnabled(tpAniSirGlobal pMac)
2333{
2334 tANI_U32 fEnabled;
2335
2336 if(wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &fEnabled) != eSIR_SUCCESS)
2337 {
2338 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2339 return eANI_BOOLEAN_FALSE;
2340 }
2341
2342 if (!fEnabled)
2343 return eANI_BOOLEAN_FALSE;
2344
2345 if(wlan_cfgGetInt(pMac, WNI_CFG_RDET_FLAG, &fEnabled) != eSIR_SUCCESS)
2346 {
2347 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2348 return eANI_BOOLEAN_FALSE;
2349 }
2350
2351 if (fEnabled)
2352 return eANI_BOOLEAN_TRUE;
2353
2354 return eANI_BOOLEAN_FALSE;
2355}
2356
2357/**---------------------------------------
2358\fn limRadarInit
2359\brief Initialize Radar Interrupt.
2360
2361\param pMac
2362\return None
2363 ----------------------------------------*/
2364void limRadarInit(tpAniSirGlobal pMac)
2365{
2366 tANI_U32 status;
2367 tSirMsgQ msg;
2368
2369 PELOG3(limLog(pMac, LOG3, FL("Radar Interrupt Already configured? %s\n"),
2370 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured?"Yes":"No");)
2371 /** To avoid configuring the radar multiple times */
2372 if (pMac->lim.gLimSpecMgmt.fRadarIntrConfigured)
2373 return;
2374
2375 if (!limIsRadarEnabled(pMac))
2376 return;
2377 // Prepare and post message to HAL Message Queue
2378 msg.type = WDA_INIT_RADAR_IND;
2379 msg.bodyptr = NULL;
2380 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002381 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 status = wdaPostCtrlMsg(pMac, &msg);
2383 if (status != eHAL_STATUS_SUCCESS)
2384 {
2385 limLog(pMac, LOGP,
2386 FL("posting to HAL failed, reason=%d\n"), status);
2387 return;
2388 }
2389 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured = eANI_BOOLEAN_TRUE;
2390} /****** end limRadarInit() ******/
2391
2392#endif
2393
2394
2395/** -----------------------------------------------------------------
2396 \brief limHandleLowRssiInd() - handles low rssi indication
2397
2398 This function process the SIR_HAL_LOW_RSSI_IND message from
2399 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2400
2401 \param pMac - global mac structure
2402
2403 \return
2404
2405 \sa
2406 ----------------------------------------------------------------- */
2407void limHandleLowRssiInd(tpAniSirGlobal pMac)
2408{
2409#if 0 //RSSI related indications will now go to TL and not PE
2410 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2411 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2412 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2413 {
2414 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME \n"));)
2415 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2416 }
2417 else
2418 {
2419 limLog(pMac, LOGE,
2420 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d\n"),
2421 pMac->pmm.gPmmState);
2422 }
2423 return;
2424#endif
2425}
2426
2427
2428/** -----------------------------------------------------------------
2429 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2430
2431 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2432 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2433 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2434
2435 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2436 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2437 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2438 This message can also come from FW anytime after we have entered BMPS.
2439 This means we should handle it in WoWL and UAPSD states as well
2440
2441 \param pMac - global mac structure
2442 \return - none
2443 \sa
2444 ----------------------------------------------------------------- */
2445void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2446{
2447 switch(pMac->pmm.gPmmState)
2448 {
2449 case ePMM_STATE_BMPS_SLEEP:
2450 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2451 case ePMM_STATE_UAPSD_SLEEP:
2452 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2453 case ePMM_STATE_WOWLAN:
2454 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2455 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2456 break;
2457
2458 default:
2459 limLog(pMac, LOGE,
2460 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d\n"),
2461 pMac->pmm.gPmmState);
2462 break;
2463 }
2464 return;
2465}
2466
2467
2468/** -----------------------------------------------------------------
2469 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2470
2471 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2472 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2473 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2474
2475 \param pMac - global mac structure
2476 \return - none
2477 \sa
2478 ----------------------------------------------------------------- */
2479void limHandleMissedBeaconInd(tpAniSirGlobal pMac)
2480{
2481 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2482 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2483 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2484 {
2485 pMac->pmm.inMissedBeaconScenario = TRUE;
2486 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2487 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2488 }
2489 else
2490 {
2491 limLog(pMac, LOGE,
2492 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d\n"),
2493 pMac->pmm.gPmmState);
2494 }
2495 return;
2496}
2497
2498/** -----------------------------------------------------------------
2499 \brief limMicFailureInd() - handles mic failure indication
2500
2501 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2502
2503 \param pMac - global mac structure
2504 \return - none
2505 \sa
2506 ----------------------------------------------------------------- */
2507void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2508{
2509 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2510 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2511 tSirMsgQ mmhMsg;
2512 tpPESession psessionEntry ;
2513 tANI_U8 sessionId;
2514
2515 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2516 {
2517 limLog(pMac, LOGE,
2518 FL("session does not exist for given BSSId\n"));
2519 return;
2520 }
2521
2522 if (eHAL_STATUS_SUCCESS !=
2523 palAllocateMemory(pMac->hHdd,
2524 (void **) &pSirSmeMicFailureInd,
2525 sizeof(tSirSmeMicFailureInd)))
2526 {
2527 // Log error
2528 limLog(pMac, LOGP,
2529 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND\n"));
2530 return;
2531 }
2532
2533 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2534 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2535 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2536
2537 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2538 pSirMicFailureInd->bssId,
2539 sizeof(tSirMacAddr));
2540
2541 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2542 pSirMicFailureInd->info.srcMacAddr,
2543 sizeof(tSirMacAddr));
2544
2545 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2546 pSirMicFailureInd->info.taMacAddr,
2547 sizeof(tSirMacAddr));
2548
2549 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2550 pSirMicFailureInd->info.dstMacAddr,
2551 sizeof(tSirMacAddr));
2552
2553 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2554 pSirMicFailureInd->info.rxMacAddr,
2555 sizeof(tSirMacAddr));
2556
2557 pSirSmeMicFailureInd->info.multicast =
2558 pSirMicFailureInd->info.multicast;
2559
2560 pSirSmeMicFailureInd->info.keyId=
2561 pSirMicFailureInd->info.keyId;
2562
2563 pSirSmeMicFailureInd->info.IV1=
2564 pSirMicFailureInd->info.IV1;
2565
2566 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2567 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2568
2569 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2570 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2571 mmhMsg.bodyval = 0;
2572 MTRACE(macTraceMsgTx(pMac, 0, mmhMsg.type));
2573 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2574 return;
2575}
2576
2577
2578/** -----------------------------------------------------------------
2579 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2580
2581 This function is called before enqueuing the frame to PE queue for further processing.
2582 This prevents unnecessary frames getting into PE Queue and drops them right away.
2583 Frames will be droped in the following scenarios:
2584
2585 - In Scan State, drop the frames which are not marked as scan frames
2586 - In non-Scan state, drop the frames which are marked as scan frames.
2587 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2588 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2589
2590 \param pMac - global mac structure
2591 \return - none
2592 \sa
2593 ----------------------------------------------------------------- */
2594
2595tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2596{
2597 tANI_U32 framelen;
2598 tANI_U8 *pBody;
2599 tSirMacCapabilityInfo capabilityInfo;
2600
2601 /*
2602 *
2603 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2604 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2605 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2606 * other than beacons or probe responses in scan state.
2607 */
2608 if( (subType == SIR_MAC_MGMT_BEACON) ||
2609 (subType == SIR_MAC_MGMT_PROBE_RSP))
2610 {
2611 if(pMac->pmm.inMissedBeaconScenario)
2612 {
2613 PELOGE(limLog(pMac, LOGE, FL("Do not drop beacon and probe response - Missed beacon sceanrio"));)
2614 return eMGMT_DROP_NO_DROP;
2615 }
2616 if (limIsSystemInScanState(pMac))
2617 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002618 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 }
2620 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2621 {
2622 return eMGMT_DROP_SCAN_MODE_FRAME;
2623 }
2624 }
2625
2626 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2627 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2628
2629 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2630 * beacons from an infrastructure network
2631 */
2632 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2633 if(!capabilityInfo.ibss)
2634 return eMGMT_DROP_NO_DROP;
2635#if 0
2636 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2637 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2638 return eMGMT_DROP_NO_DROP;
2639#endif
2640
2641 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2642 if( (subType == SIR_MAC_MGMT_BEACON) ||
2643 (subType == SIR_MAC_MGMT_PROBE_RSP))
2644 {
2645 //drop the frame if length is less than 12
2646 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2647 return eMGMT_DROP_INVALID_SIZE;
2648
2649 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2650
2651 //This can be enhanced to even check the SSID before deciding to enque the frame.
2652 if(capabilityInfo.ess)
2653 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2654 }
2655 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2656 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2657 {
2658 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2659 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2660 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2661 }
2662
2663 return eMGMT_DROP_NO_DROP;
2664}
2665
2666