blob: c352d7eb6e12b894da36e302f8f656f6b55922a5 [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:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001218 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1220 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1221 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1222 retStatus = TRUE;
1223 break;
1224
1225 /* by default allow rest of messages */
1226 default:
1227 retStatus = TRUE;
1228 break;
1229
1230
1231 }
1232 }
1233
1234 return retStatus;
1235
1236}
1237
1238
1239
1240/**
1241 * limPostMsgApi()
1242 *
1243 *FUNCTION:
1244 * This function is called from other thread while posting a
1245 * message to LIM message Queue gSirLimMsgQ.
1246 *
1247 *LOGIC:
1248 * NA
1249 *
1250 *ASSUMPTIONS:
1251 * NA
1252 *
1253 *NOTE:
1254 * NA
1255 *
1256 * @param pMac - Pointer to Global MAC structure
1257 * @param pMsg - Pointer to the message structure
1258 * @return None
1259 */
1260
1261tANI_U32
1262limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1263{
1264#ifdef VOSS_ENABLED
1265 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1266
1267
1268#elif defined(ANI_OS_TYPE_LINUX) || defined(ANI_OS_TYPE_OSX)
1269 return tx_queue_send(&pMac->sys.gSirLimMsgQ, pMsg, TX_WAIT_FOREVER);
1270
1271#else
1272 /* Check if this is a timeout message from a timer
1273 * and if the timeout message is allowed if the device is in power-save state
1274 */
1275 if(!limIsTimerAllowedInPowerSaveState(pMac, pMsg))
1276 {
1277 limLog(pMac, LOGW,
1278 FL("Timeout message %d is not allowed while device is in Power-Save mode\n"),
1279 pMsg->type);
1280
1281 return TX_SUCCESS;
1282 }
1283 if(pMac->gDriverType != eDRIVER_TYPE_MFG)
1284 {
1285 limMessageProcessor(pMac, pMsg);
1286 }
1287
1288 return TX_SUCCESS;
1289
1290#endif
1291} /*** end limPostMsgApi() ***/
1292
1293
1294/*--------------------------------------------------------------------------
1295
1296 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1297
1298 This function can be called by legacy code to post message to voss queues OR
1299 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1300 for dispatching it later.
1301
1302 \param pMac - Pointer to Global MAC structure
1303 \param pMsg - Pointer to the message structure
1304
1305 \return tANI_U32 - TX_SUCCESS for success.
1306
1307 --------------------------------------------------------------------------*/
1308
1309tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1310{
1311 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1312}
1313
1314/*--------------------------------------------------------------------------
1315
1316 \brief peProcessMessages() - Message Processor for PE
1317
1318 Voss calls this function to dispatch the message to PE
1319
1320 \param pMac - Pointer to Global MAC structure
1321 \param pMsg - Pointer to the message structure
1322
1323 \return tANI_U32 - TX_SUCCESS for success.
1324
1325 --------------------------------------------------------------------------*/
1326
1327tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1328{
1329 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1330 {
1331 return eSIR_SUCCESS;
1332 }
1333 /**
1334 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1335 * for all the other cases post it to LIM
1336 */
1337 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1338 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1339 else
1340 limMessageProcessor(pMac, pMsg);
1341 return eSIR_SUCCESS;
1342}
1343
1344
1345#ifdef VOSS_ENABLED
1346
1347// ---------------------------------------------------------------------------
1348/**
1349 * peHandleMgmtFrame
1350 *
1351 * FUNCTION:
1352 * Process the Management frames from TL
1353 *
1354 * LOGIC:
1355 *
1356 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1357 *
1358 * NOTE:
1359 *
1360 * @param pvosGCtx Global Vos Context
1361 * @param vossBuff Packet
1362 * @return None
1363 */
1364
1365VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1366{
1367 tpAniSirGlobal pMac;
1368 tpSirMacMgmtHdr mHdr;
1369 tSirMsgQ msg;
1370 vos_pkt_t *pVosPkt;
1371 VOS_STATUS vosStatus;
1372 v_U8_t *pRxPacketInfo;
1373
1374 pVosPkt = (vos_pkt_t *)vosBuff;
1375 if (NULL == pVosPkt)
1376 {
1377 return VOS_STATUS_E_FAILURE;
1378 }
1379
1380 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1381 if (NULL == pMac)
1382 {
1383 // cannot log a failure without a valid pMac
1384 vos_pkt_return_packet(pVosPkt);
1385 return VOS_STATUS_E_FAILURE;
1386 }
1387
1388 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1389
1390 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1391 {
1392 vos_pkt_return_packet(pVosPkt);
1393 return VOS_STATUS_E_FAILURE;
1394 }
1395
1396
1397 //
1398 // The MPDU header is now present at a certain "offset" in
1399 // the BD and is specified in the BD itself
1400 //
1401 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1402 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1403 {
1404 PELOG1(limLog( pMac, LOG1,
1405 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001406 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
Jeff Johnsone7245742012-09-05 17:12:55 -07001408 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1410 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1411 }
1412
1413
1414 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1415 msg.type = SIR_BB_XPORT_MGMT_MSG;
1416 msg.bodyptr = vosBuff;
1417 msg.bodyval = 0;
1418
1419 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1420 &msg,
1421 mHdr->fc.type,
1422 mHdr->fc.subType ))
1423 {
1424 vos_pkt_return_packet(pVosPkt);
1425 limLog( pMac, LOGW,
1426 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG\n" ));
1427 return VOS_STATUS_E_FAILURE;
1428 }
1429
1430 return VOS_STATUS_SUCCESS;
1431}
1432
1433// ---------------------------------------------------------------------------
1434/**
1435 * peRegisterTLHandle
1436 *
1437 * FUNCTION:
1438 * Registers the Handler which, process the Management frames from TL
1439 *
1440 * LOGIC:
1441 *
1442 * ASSUMPTIONS:
1443 *
1444 * NOTE:
1445 *
1446 * @return None
1447 */
1448
1449void peRegisterTLHandle(tpAniSirGlobal pMac)
1450{
1451 v_PVOID_t pvosGCTx;
1452 VOS_STATUS retStatus;
1453
1454 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1455
1456 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1457
1458 if (retStatus != VOS_STATUS_SUCCESS)
1459 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out...\n"));
1460
1461}
1462#endif
1463
1464
1465/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 * limIsSystemInScanState()
1467 *
1468 *FUNCTION:
1469 * This function is called by various MAC software modules to
1470 * determine if System is in Scan/Learn state
1471 *
1472 *LOGIC:
1473 * NA
1474 *
1475 *ASSUMPTIONS:
1476 * NA
1477 *
1478 *NOTE:
1479 *
1480 * @param pMac - Pointer to Global MAC structure
1481 * @return true - System is in Scan/Learn state
1482 * false - System is NOT in Scan/Learn state
1483 */
1484
1485tANI_U8
1486limIsSystemInScanState(tpAniSirGlobal pMac)
1487{
1488 switch (pMac->lim.gLimSmeState)
1489 {
1490 case eLIM_SME_CHANNEL_SCAN_STATE:
1491 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1492 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1493 case eLIM_SME_WT_SCAN_STATE:
1494 // System is in Learn mode
1495 return true;
1496
1497 default:
1498 // System is NOT in Learn mode
1499 return false;
1500 }
1501} /*** end limIsSystemInScanState() ***/
1502
1503
1504
1505/**
1506 * limIsSystemInActiveState()
1507 *
1508 *FUNCTION:
1509 * This function is called by various MAC software modules to
1510 * determine if System is in Active/Wakeup state
1511 *
1512 *LOGIC:
1513 * NA
1514 *
1515 *ASSUMPTIONS:
1516 * NA
1517 *
1518 *NOTE:
1519 *
1520 * @param pMac - Pointer to Global MAC structure
1521 * @return true - System is in Active state
1522 * false - System is not in Active state
1523 */
1524
1525tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1526{
1527 switch (pMac->pmm.gPmmState)
1528 {
1529 case ePMM_STATE_BMPS_WAKEUP:
1530 case ePMM_STATE_IMPS_WAKEUP:
1531 case ePMM_STATE_READY:
1532 // System is in Active mode
1533 return true;
1534 default:
1535 return false;
1536 // System is NOT in Active mode
1537 }
1538}
1539
1540
1541#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
1542/**
1543 * limCheckAndQuietBSS()
1544 *
1545 *FUNCTION:
1546 * This function is called by limSetLearnMode() to check
1547 * if BSS needs to be quieted and call limQuietBSS() to
1548 * send data frame to self for that purpose.
1549 *
1550 *LOGIC:
1551 * NA
1552 *
1553 *ASSUMPTIONS:
1554 * NA
1555 *
1556 *NOTE:
1557 *
1558 * @param pMac - Pointer to Global MAC structure
1559 * @return None
1560 */
1561
1562void
1563limCheckAndQuietBSS(tpAniSirGlobal pMac)
1564{
1565 tANI_U32 dur;
1566
1567 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1568 {
1569 // LIM is in AP role. Quiet the BSS before
1570 // switching to channel to be learned
1571 if (pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration >
1572 LIM_MAX_QUIET_DURATION)
1573 {
1574 // May need to quiet BSS multiple times.
1575 // Quiet for a limit of 32 msecs on Learn
1576 // duration for now.
1577 dur = LIM_MAX_QUIET_DURATION;
1578 }
1579 else
1580 {
1581 dur =
1582 pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration;
1583 }
1584 PELOG3(limLog(pMac, LOG3,
1585 FL("*** Going to quiet BSS for duration=%d msec\n"),
1586 dur);)
1587
1588 limQuietBss(pMac, dur);
1589 }
1590} /*** end limCheckAndQuietBSS() ***/
1591#endif
1592
1593#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1594/**
1595 * limSetLearnMode()
1596 *
1597 *FUNCTION:
1598 * This function is called to setup system into Learn mode
1599 * to collect DFS measurements.
1600 *
1601 *LOGIC:
1602 * NA
1603 *
1604 *ASSUMPTIONS:
1605 * NA
1606 *
1607 *NOTE:
1608 *
1609 * @param pMac - Pointer to Global MAC structure
1610 * @return None
1611 */
1612
1613void
1614limSetLearnMode(tpAniSirGlobal pMac)
1615{
1616 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_LEARN_WAIT_STATE, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN);
1617 return;
1618} /*** end limSetLearnMode() ***/
1619
1620/**
1621 * limContinueChannelLearn()
1622 *
1623 *FUNCTION:
1624 * This function is called to do measurement (learn) on current channel.
1625 *
1626 *LOGIC:
1627 *
1628 *ASSUMPTIONS:
1629 * NA
1630 *
1631 *NOTE:
1632 * NA
1633 *
1634 * @param pMac - Pointer to Global MAC structure
1635 *
1636 * @return None
1637 */
1638
1639void
1640limContinueChannelLearn(tpAniSirGlobal pMac)
1641{
1642 tANI_U8 chanNum;
1643 tSirMacSSid ssId;
1644 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1645
1646 // Time to collect measurements
1647 chanNum = limGetCurrentLearnChannel(pMac);
1648
1649 // Switch channel
1650 pMac->lim.gLimSystemInScanLearnMode = 1;
1651
1652 if (pMac->lim.gpLimMeasReq->measControl.scanType == eSIR_ACTIVE_SCAN)
1653 {
1654 /// Prepare and send Probe Request frame
1655 ssId.length = 0;
1656 /* for learning channel, we don't include any additional IE */
1657 limSendProbeReqMgmtFrame(pMac, &ssId, bssId, chanNum,pMac->lim.gSelfMacAddr, 0 , NULL);
1658 }
1659
1660 // Activate Learn duration timer during which
1661 // DFS measurements are made.
1662 pMac->lim.gLimMeasParams.shortDurationCount++;
1663 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_DURATION_TIMER);
1664
Jeff Johnsone7245742012-09-05 17:12:55 -07001665 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_DURATION_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 if (tx_timer_activate(&pMac->lim.gLimMeasParams.learnDurationTimer)
1667 != TX_SUCCESS)
1668 {
1669 /// Could not activate learn duration timer.
1670 // Log error
1671 limLog(pMac, LOGP, FL("could not activate learn duration timer\n"));
1672
1673 return;
1674 }
1675} /*** end limContinueChannelLearn() ***/
1676
1677
1678/**
1679 * limReEnableLearnMode()
1680 *
1681 *FUNCTION:
1682 * This function is called by various MAC software modules to
1683 * re-enable Learn mode measurements.
1684 *
1685 *LOGIC:
1686 * NA
1687 *
1688 *ASSUMPTIONS:
1689 * NA
1690 *
1691 *NOTE:
1692 *
1693 * @param pMac - Pointer to Global MAC structure
1694 * @return None
1695 */
1696
1697void
1698limReEnableLearnMode(tpAniSirGlobal pMac)
1699{
1700 PELOG4(limLog(pMac, LOG4, FL("quietEnabled = %d\n"),
1701 pMac->lim.gLimSpecMgmt.fQuietEnabled);)
1702
1703 /** Stop measurement temperorily when radar is detected or channel
1704 * switch is running as part of periodic DFS */
1705 if (!pMac->lim.gpLimMeasReq || LIM_IS_RADAR_DETECTED(pMac) ||
1706 (pMac->lim.gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING))
1707 {
1708 return;
1709 }
1710
1711 if (pMac->lim.gLimSpecMgmt.fQuietEnabled)
1712 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001713 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001714#ifdef GEN6_TODO
1715 /* revisit this piece of code to assign the appropriate sessionId below
1716 * priority - HIGH
1717 */
1718 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
1719#endif
1720 if (tx_timer_activate(
1721 &pMac->lim.limTimers.gLimQuietBssTimer)
1722 != TX_SUCCESS)
1723 {
1724 limLog(pMac, LOGP, FL("could not start Quiet Bss timer\n"));
1725 return;
1726 }
1727 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
1728 }
1729 else
1730 {
1731 limDeactivateAndChangeTimer(pMac, eLIM_LEARN_INTERVAL_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -07001732 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_LEARN_INTERVAL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07001733#ifdef GEN6_TODO
1734 /* revisit this piece of code to assign the appropriate sessionId below
1735 */
1736 pMac->lim.gLimMeasParams.learnIntervalTimer.sessionId = sessionId;
1737#endif
1738 if (tx_timer_activate(
1739 &pMac->lim.gLimMeasParams.learnIntervalTimer)
1740 != TX_SUCCESS)
1741 {
1742 /// Could not activate Learn Interval timer.
1743 // Log error
1744 limLog(pMac, LOGP, FL("could not start Learn Interval timer\n"));
1745 return;
1746 }
1747 }
1748
1749 PELOG3(limLog(pMac, LOG3, FL("Re-enabled Learn mode Measurements\n"));)
1750 pMac->lim.gLimMeasParams.disableMeasurements = 0;
1751
1752 return;
1753} /*** end limReEnableLearnMode() ***/
1754
1755#endif //#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
1756
1757
1758/**
1759*\brief limReceivedHBHandler()
1760*
1761* This function is called by schBeaconProcess() upon
1762* receiving a Beacon on STA. This also gets called upon
1763* receiving Probe Response after heat beat failure is
1764* detected.
1765*
1766* param pMac - global mac structure
1767* param channel - channel number indicated in Beacon, Probe Response
1768* return - none
1769*/
1770
1771
1772void
1773limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1774{
1775 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1776 psessionEntry->LimRxedBeaconCntDuringHB++;
1777
1778 pMac->pmm.inMissedBeaconScenario = FALSE;
1779} /*** end limReceivedHBHandler() ***/
1780
1781
1782
1783#if 0
1784void limResetHBPktCount(tpPESession psessionEntry)
1785{
1786 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1787}
1788#endif
1789
1790
1791/*
1792 * limProcessWdsInfo()
1793 *
1794 *FUNCTION:
1795 * This function is called from schBeaconProcess in BP
1796 *
1797 *PARAMS:
1798 * @param pMac - Pointer to Global MAC structure
1799 * @param propIEInfo - proprietary IE info
1800 *
1801 *LOGIC:
1802 *
1803 *ASSUMPTIONS:
1804 * NA
1805 *
1806 *NOTE:
1807 *
1808 *
1809 *RETURNS:
1810 *
1811 */
1812
1813void limProcessWdsInfo(tpAniSirGlobal pMac,
1814 tSirPropIEStruct propIEInfo)
1815{
1816#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1817 tpSirSmeWdsInfoInd pSirSmeWdsInfoInd;
1818 tANI_U8 *pTemp;
1819 tSirMsgQ mmhMsg;
1820
1821 if (propIEInfo.wdsLength &&
1822 propIEInfo.wdsLength <= ANI_WDS_INFO_MAX_LENGTH)
1823 {
1824 if (pMac->lim.gLimWdsInfo.wdsLength)
1825 {
1826 if ((propIEInfo.wdsLength ==
1827 pMac->lim.gLimWdsInfo.wdsLength) &&
1828 (palEqualMemory( pMac->hHdd,propIEInfo.wdsData,
1829 pMac->lim.gLimWdsInfo.wdsBytes,
1830 pMac->lim.gLimWdsInfo.wdsLength) ))
1831
1832 return; // no difference in WDS info
1833 else
1834 {
1835 PELOG2(limLog(pMac, LOG2,
1836 FL("Cached WDS Info: length %d bytes is: "),
1837 pMac->lim.gLimWdsInfo.wdsLength);
1838 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1839 pMac->lim.gLimWdsInfo.wdsBytes,
1840 pMac->lim.gLimWdsInfo.wdsLength);)
1841
1842 PELOG2(limLog(pMac, LOG2, FL("New WDS Info: length %d bytes is: "),
1843 propIEInfo.wdsLength);
1844 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
1845 propIEInfo.wdsData,
1846 propIEInfo.wdsLength);)
1847
1848 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1849 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1850 propIEInfo.wdsData,
1851 propIEInfo.wdsLength);
1852
1853 // send IND to WSM
1854 if (eHAL_STATUS_SUCCESS !=
1855 palAllocateMemory(pMac->hHdd,
1856 (void **) &pSirSmeWdsInfoInd,
1857 sizeof(tSirSmeWdsInfoInd)))
1858 {
1859 // Log error
1860 limLog(pMac, LOGP,
1861 FL("memory allocate failed for WDS_INFO_IND\n"));
1862
1863 return;
1864 }
1865
1866 pSirSmeWdsInfoInd->messageType = eWNI_SME_WDS_INFO_IND;
1867 pSirSmeWdsInfoInd->length = sizeof(tSirSmeWdsInfoInd);
1868
1869 pSirSmeWdsInfoInd->wdsInfo.wdsLength =
1870 pMac->lim.gLimWdsInfo.wdsLength;
1871
1872 palCopyMemory( pMac->hHdd, pSirSmeWdsInfoInd->wdsInfo.wdsBytes,
1873 pMac->lim.gLimWdsInfo.wdsBytes,
1874 pMac->lim.gLimWdsInfo.wdsLength);
1875
1876 pTemp = (tANI_U8 *) pSirSmeWdsInfoInd;
1877
1878 PELOG2(limLog(pMac, LOG2,
1879 FL("eWNI_SME_WDS_INFO_IND length %d bytes is: "),
1880 pSirSmeWdsInfoInd->length);
1881 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pTemp,
1882 pSirSmeWdsInfoInd->length);)
1883
1884 mmhMsg.type = eWNI_SME_WDS_INFO_IND;
1885 mmhMsg.bodyptr = pSirSmeWdsInfoInd;
1886 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001887 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
1889 pMac->lim.gLimNumWdsInfoInd++;
1890 }
1891 }
1892 else
1893 {
1894 // first WDS info
1895 pMac->lim.gLimWdsInfo.wdsLength = propIEInfo.wdsLength;
1896 palCopyMemory( pMac->hHdd, pMac->lim.gLimWdsInfo.wdsBytes,
1897 propIEInfo.wdsData,
1898 propIEInfo.wdsLength);
1899
1900 PELOG1(limLog(pMac, LOG1, FL("First WDS Info: length %d bytes is:\n"),
1901 pMac->lim.gLimWdsInfo.wdsLength);
1902 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
1903 pMac->lim.gLimWdsInfo.wdsBytes,
1904 pMac->lim.gLimWdsInfo.wdsLength);)
1905
1906 }
1907 }
1908 else
1909 {
1910 PELOG2(limLog(pMac, LOG2,
1911 FL("Illegal WDS length = %d\n"),
1912 propIEInfo.wdsLength);)
1913 }
1914#endif
1915}
1916
1917
1918
1919/**
1920 * limInitWdsInfoParams()
1921 *
1922 *FUNCTION:
1923 * This function is called while processing
1924 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1925 * ind/set related parameters.
1926 *
1927 *LOGIC:
1928 *
1929 *ASSUMPTIONS:
1930 *
1931 *NOTE:
1932 *
1933 * @param pMac Pointer to Global MAC structure
1934 * @return None
1935 */
1936
1937void
1938limInitWdsInfoParams(tpAniSirGlobal pMac)
1939{
1940 pMac->lim.gLimWdsInfo.wdsLength = 0;
1941 pMac->lim.gLimNumWdsInfoInd = 0;
1942 pMac->lim.gLimNumWdsInfoSet = 0;
1943} /*** limInitWdsInfoParams() ***/
1944
1945
1946/** -------------------------------------------------------------
1947\fn limUpdateOverlapStaParam
1948\brief Updates overlap cache and param data structure
1949\param tpAniSirGlobal pMac
1950\param tSirMacAddr bssId
1951\param tpLimProtStaParams pStaParams
1952\return None
1953 -------------------------------------------------------------*/
1954void
1955limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1956{
1957 int i;
1958 if (!pStaParams->numSta)
1959 {
1960 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[0].addr,
1961 bssId,
1962 sizeof(tSirMacAddr));
1963 pMac->lim.protStaOverlapCache[0].active = true;
1964
1965 pStaParams->numSta = 1;
1966
1967 return;
1968 }
1969
1970 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1971 {
1972 if (pMac->lim.protStaOverlapCache[i].active)
1973 {
1974 if (palEqualMemory( pMac->hHdd,pMac->lim.protStaOverlapCache[i].addr,
1975 bssId,
1976 sizeof(tSirMacAddr))) {
1977 return; }
1978 }
1979 else
1980 break;
1981 }
1982
1983 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1984 {
1985 PELOG1(limLog(pMac, LOG1, FL("Overlap cache is full\n"));)
1986 }
1987 else
1988 {
1989 palCopyMemory( pMac->hHdd, pMac->lim.protStaOverlapCache[i].addr,
1990 bssId,
1991 sizeof(tSirMacAddr));
1992 pMac->lim.protStaOverlapCache[i].active = true;
1993
1994 pStaParams->numSta++;
1995 }
1996}
1997
1998
1999/**
2000 * limHandleIBSScoalescing()
2001 *
2002 *FUNCTION:
2003 * This function is called upon receiving Beacon/Probe Response
2004 * while operating in IBSS mode.
2005 *
2006 *LOGIC:
2007 *
2008 *ASSUMPTIONS:
2009 *
2010 *NOTE:
2011 *
2012 * @param pMac - Pointer to Global MAC structure
2013 * @param pBeacon - Parsed Beacon Frame structure
2014 * @param pRxPacketInfo - Pointer to RX packet info structure
2015 *
2016 * @return Status whether to process or ignore received Beacon Frame
2017 */
2018
2019tSirRetStatus
2020limHandleIBSScoalescing(
2021 tpAniSirGlobal pMac,
2022 tpSchBeaconStruct pBeacon,
2023 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
2024{
2025 tpSirMacMgmtHdr pHdr;
2026 tSirRetStatus retCode;
2027
2028 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2029 if ( (!pBeacon->capabilityInfo.ibss) || (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) )
2030 /* Received SSID does not match => Ignore received Beacon frame. */
2031 retCode = eSIR_LIM_IGNORE_BEACON;
2032 else
2033 {
2034 tANI_U32 ieLen;
2035 tANI_U16 tsfLater;
2036 tANI_U8 *pIEs;
2037 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2038 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
2039 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2040 PELOG3(limLog(pMac, LOG3, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);)
2041 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
2042 }
2043 return retCode;
2044} /*** end limHandleIBSScoalescing() ***/
2045
2046
2047
2048/**
2049 * limDetectChangeInApCapabilities()
2050 *
2051 *FUNCTION:
2052 * This function is called while SCH is processing
2053 * received Beacon from AP on STA to detect any
2054 * change in AP's capabilities. If there any change
2055 * is detected, Roaming is informed of such change
2056 * so that it can trigger reassociation.
2057 *
2058 *LOGIC:
2059 *
2060 *ASSUMPTIONS:
2061 *
2062 *NOTE:
2063 * Notification is enabled for STA product only since
2064 * it is not a requirement on BP side.
2065 *
2066 * @param pMac Pointer to Global MAC structure
2067 * @param pBeacon Pointer to parsed Beacon structure
2068 * @return None
2069 */
2070
2071void
2072limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
2073 tpSirProbeRespBeacon pBeacon,
2074 tpPESession psessionEntry)
2075{
2076#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2077 tANI_U8 len;
2078 tSirSmeApNewCaps apNewCaps;
2079 tANI_U8 newChannel;
2080 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
2081 newChannel = (tANI_U8) pBeacon->channelNumber;
2082
2083 if ((psessionEntry->limSentCapsChangeNtf == false) &&
2084 (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
2085 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
2086 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) != SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
2087 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) != SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
2088 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) != SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
2089 (newChannel != psessionEntry->currentOperChannel)
2090#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
2091 || (LIM_BSS_CAPS_GET(HCF, psessionEntry->limCurrentBssQosCaps) !=
2092 pBeacon->propIEinfo.hcfEnabled)
2093#endif
2094 )))
2095 {
2096
2097 /**
2098 * BSS capabilities have changed.
2099 * Inform Roaming.
2100 */
2101 len = sizeof(tSirMacCapabilityInfo) +
2102 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
2103 3 * sizeof(tANI_U8) + // reserved fields
2104 pBeacon->ssId.length + 1;
2105
2106 palCopyMemory( pMac->hHdd, apNewCaps.bssId,
2107 psessionEntry->bssId,
2108 sizeof(tSirMacAddr));
2109 if (newChannel != psessionEntry->currentOperChannel)
2110 {
2111 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
2112 "Ignoring beacon!\n"),
2113 psessionEntry->currentOperChannel, newChannel);)
2114 return;
2115 }
2116 else
2117 apNewCaps.channelId = psessionEntry->currentOperChannel;
2118 palCopyMemory( pMac->hHdd, (tANI_U8 *) &apNewCaps.ssId,
2119 (tANI_U8 *) &pBeacon->ssId,
2120 pBeacon->ssId.length + 1);
2121
2122 psessionEntry->limSentCapsChangeNtf = true;
2123 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2124 (tANI_U32 *) &apNewCaps,
2125 len, psessionEntry->smeSessionId);
2126 }
2127#endif
2128} /*** limDetectChangeInApCapabilities() ***/
2129
2130
2131
2132
2133// ---------------------------------------------------------------------
2134/**
2135 * limUpdateShortSlot
2136 *
2137 * FUNCTION:
2138 * Enable/Disable short slot
2139 *
2140 * LOGIC:
2141 *
2142 * ASSUMPTIONS:
2143 *
2144 * NOTE:
2145 *
2146 * @param enable Flag to enable/disable short slot
2147 * @return None
2148 */
2149
2150tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2151{
2152
2153 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002154 tANI_U32 nShortSlot;
2155 tANI_U32 val = 0;
2156 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002157
Jeff Johnsone7245742012-09-05 17:12:55 -07002158 // Check Admin mode first. If it is disabled just return
2159 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2160 != eSIR_SUCCESS)
2161 {
2162 limLog(pMac, LOGP,
2163 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed\n"));
2164 return eSIR_FAILURE;
2165 }
2166 if (val == false)
2167 return eSIR_SUCCESS;
2168
2169 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2170 limGetPhyMode(pMac, &phyMode, psessionEntry);
2171 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2172 return eSIR_SUCCESS;
2173
2174 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002175
2176 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2177 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2178 // if no erp present, use short slot based on current ap caps
2179
2180 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2181
2182 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2183 // The difference between the earlier implementation and the new one is only Case4.
2184 /*
2185 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2186 Case1 1 1 1 1 //AP should not advertise this combination.
2187 Case2 1 1 0 0
2188 Case3 1 0 1 1
2189 Case4 1 0 0 0
2190 Case5 0 1 1 1
2191 Case6 0 1 0 0
2192 Case7 0 0 1 1
2193 Case8 0 0 0 0
2194 */
2195 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2196
Jeff Johnsone7245742012-09-05 17:12:55 -07002197 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 {
2199 // Short slot time capability of AP has changed. Adopt to it.
2200 PELOG1(limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d\n"), nShortSlot);)
2201 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002202 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2204 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 }
2206 return eSIR_SUCCESS;
2207}
2208
2209
2210#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
2211
2212/**
2213 * limUpdateQuietIEInBeacons()
2214 *
2215 *FUNCTION:
2216 * This function is called by specialBeaconProcessing(),
2217 * when it is time to generate the next beacon.
2218 * If gLimQuietState is not in the INIT state, then it
2219 * means that the next beacon may need to include some
2220 * information about the Quiet BSS IE.
2221 * This function makes that decision based on the current
2222 * state of gLimQuietState
2223 *
2224 *LOGIC:
2225 * This routine invokes schSetFixedBeaconFields() only
2226 * if necessary, as it is expensive to update the fixed
2227 * beacon fields during each beacon interval.
2228 *
2229 *ASSUMPTIONS:
2230 * This Quiet BSS IE will be sent out as part of
2231 * Proprietary IE's. If 802.11H is enabled, this IE
2232 * will be sent out as defined in the 11H spec
2233 *
2234 *NOTE:
2235 *
2236 * @param pMac Pointer to Global MAC structure
2237 * @return true, if the beacon fields need updating
2238 * false, if not
2239 */
2240tANI_BOOLEAN limUpdateQuietIEInBeacons( tpAniSirGlobal pMac )
2241{
2242 tANI_BOOLEAN fUpdateBeaconFields = eANI_BOOLEAN_TRUE;
2243
2244 limLog( pMac, LOG2, FL("Quiet BSS State = %d\n"),
2245 pMac->lim.gLimSpecMgmt.quietState );
2246 switch( pMac->lim.gLimSpecMgmt.quietState )
2247 {
2248 case eLIM_QUIET_BEGIN:
2249 // We need to start broadcasting the Quiet BSS IE
2250 // Transition to eLIM_QUIET_RUNNING
2251 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
2252 break;
2253
2254 case eLIM_QUIET_RUNNING:
2255 // Start down-counting...
2256 pMac->lim.gLimSpecMgmt.quietCount--;
2257 if( pMac->lim.gLimSpecMgmt.quietCount == 0 )
2258 {
2259 //
2260 // We no longer need to broadcast the Quiet BSS IE
2261 //
2262 // NOTE - We still need to call schSetFixedBeaconFields()
2263 // one last time, just to remove the Quiet BSS IE from
2264 // the list of fixed beacon fields
2265 //
2266 // Transition to eLIM_QUIET_END
2267 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2268 limProcessLearnIntervalTimeout(pMac);
2269 }
2270 break;
2271
2272 case eLIM_QUIET_CHANGED:
2273 //
2274 // State possibly changed via setupQuietBss().
2275 // This means, gLimQuietCount has been changed!!
2276 //
2277 // NOTE - We still need to call schSetFixedBeaconFields()
2278 // one last time, just to remove the Quiet BSS IE from
2279 // the list of fixed beacon fields
2280 //
2281
2282 // Transition to eLIM_QUIET_END
2283 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_END;
2284 break;
2285
2286 case eLIM_QUIET_INIT:
2287 case eLIM_QUIET_END:
2288 // Transition to eLIM_QUIET_INIT
2289 pMac->lim.gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
2290 // Fall thru'...
2291 default:
2292 fUpdateBeaconFields = eANI_BOOLEAN_FALSE;
2293 break;
2294 }
2295
2296 return fUpdateBeaconFields;
2297}
2298
2299#endif
2300
2301#if ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK))
2302void limConvertScanDuration(tpAniSirGlobal pMac)
2303{
2304 tpSirSmeMeasurementReq pMeasReq = pMac->lim.gpLimMeasReq;
2305 tpLimScanDurationConvert scanDurConv = &pMac->lim.gLimScanDurationConvert;
2306
2307 /* This is not a good idea to convert {long}shortChannelScanDuration from mS to TICKS *
2308 * The reason is that {long}shortChannelScanDuration is used all over and a lot of code *
2309 * that assumes the old mS definition was never changed to accommodate this new change to TICKS. *
2310 * If optimization is needed, create another set of shadow variables to store the converted *
2311 * values in Ticks, and TU. */
2312 scanDurConv->shortChannelScanDuration_tick =
2313 SYS_MS_TO_TICKS(pMeasReq->measDuration.shortChannelScanDuration +SYS_TICK_DUR_MS-1);
2314
2315 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2316 /* (shortChanneScanDuration * 1000) / 2^10 */
2317 scanDurConv->shortChannelScanDuration_TU = (pMeasReq->measDuration.shortChannelScanDuration * 1000) >> 10;
2318
2319 scanDurConv->longChannelScanDuration_tick =
2320 SYS_MS_TO_TICKS(pMeasReq->measDuration.longChannelScanDuration +SYS_TICK_DUR_MS-1);
2321
2322 /* convert shortChannelScanDuration to TU also for CB scan, used to set gLimQuietDuration */
2323 /* (longChanneScanDuration * 1000) / 2^10 */
2324 scanDurConv->longChannelScanDuration_TU = (pMeasReq->measDuration.longChannelScanDuration * 1000) >> 10;
2325}
2326#endif /* ((defined ANI_PRODUCT_TYPE_AP) && (defined ANI_AP_SDK)) */
2327
2328
2329#ifdef ANI_PRODUCT_TYPE_AP
2330/**-------------------------------------------------
2331\fn limIsRadarEnabled
2332
2333\brief Checks if radar is enabled
2334\param pMac
2335\return true - if Both 11h and radar enabled
2336 false - if either is not enabled.
2337 --------------------------------------------------*/
2338tANI_BOOLEAN limIsRadarEnabled(tpAniSirGlobal pMac)
2339{
2340 tANI_U32 fEnabled;
2341
2342 if(wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &fEnabled) != eSIR_SUCCESS)
2343 {
2344 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2345 return eANI_BOOLEAN_FALSE;
2346 }
2347
2348 if (!fEnabled)
2349 return eANI_BOOLEAN_FALSE;
2350
2351 if(wlan_cfgGetInt(pMac, WNI_CFG_RDET_FLAG, &fEnabled) != eSIR_SUCCESS)
2352 {
2353 limLog(pMac, LOGP, FL("HAL: could not retrieve radar config from CFG"));
2354 return eANI_BOOLEAN_FALSE;
2355 }
2356
2357 if (fEnabled)
2358 return eANI_BOOLEAN_TRUE;
2359
2360 return eANI_BOOLEAN_FALSE;
2361}
2362
2363/**---------------------------------------
2364\fn limRadarInit
2365\brief Initialize Radar Interrupt.
2366
2367\param pMac
2368\return None
2369 ----------------------------------------*/
2370void limRadarInit(tpAniSirGlobal pMac)
2371{
2372 tANI_U32 status;
2373 tSirMsgQ msg;
2374
2375 PELOG3(limLog(pMac, LOG3, FL("Radar Interrupt Already configured? %s\n"),
2376 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured?"Yes":"No");)
2377 /** To avoid configuring the radar multiple times */
2378 if (pMac->lim.gLimSpecMgmt.fRadarIntrConfigured)
2379 return;
2380
2381 if (!limIsRadarEnabled(pMac))
2382 return;
2383 // Prepare and post message to HAL Message Queue
2384 msg.type = WDA_INIT_RADAR_IND;
2385 msg.bodyptr = NULL;
2386 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002387 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 status = wdaPostCtrlMsg(pMac, &msg);
2389 if (status != eHAL_STATUS_SUCCESS)
2390 {
2391 limLog(pMac, LOGP,
2392 FL("posting to HAL failed, reason=%d\n"), status);
2393 return;
2394 }
2395 pMac->lim.gLimSpecMgmt.fRadarIntrConfigured = eANI_BOOLEAN_TRUE;
2396} /****** end limRadarInit() ******/
2397
2398#endif
2399
2400
2401/** -----------------------------------------------------------------
2402 \brief limHandleLowRssiInd() - handles low rssi indication
2403
2404 This function process the SIR_HAL_LOW_RSSI_IND message from
2405 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2406
2407 \param pMac - global mac structure
2408
2409 \return
2410
2411 \sa
2412 ----------------------------------------------------------------- */
2413void limHandleLowRssiInd(tpAniSirGlobal pMac)
2414{
2415#if 0 //RSSI related indications will now go to TL and not PE
2416 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2417 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2418 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2419 {
2420 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME \n"));)
2421 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2422 }
2423 else
2424 {
2425 limLog(pMac, LOGE,
2426 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d\n"),
2427 pMac->pmm.gPmmState);
2428 }
2429 return;
2430#endif
2431}
2432
2433
2434/** -----------------------------------------------------------------
2435 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2436
2437 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2438 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2439 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2440
2441 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2442 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2443 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2444 This message can also come from FW anytime after we have entered BMPS.
2445 This means we should handle it in WoWL and UAPSD states as well
2446
2447 \param pMac - global mac structure
2448 \return - none
2449 \sa
2450 ----------------------------------------------------------------- */
2451void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2452{
2453 switch(pMac->pmm.gPmmState)
2454 {
2455 case ePMM_STATE_BMPS_SLEEP:
2456 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2457 case ePMM_STATE_UAPSD_SLEEP:
2458 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2459 case ePMM_STATE_WOWLAN:
2460 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2461 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2462 break;
2463
2464 default:
2465 limLog(pMac, LOGE,
2466 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d\n"),
2467 pMac->pmm.gPmmState);
2468 break;
2469 }
2470 return;
2471}
2472
2473
2474/** -----------------------------------------------------------------
2475 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2476
2477 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2478 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2479 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2480
2481 \param pMac - global mac structure
2482 \return - none
2483 \sa
2484 ----------------------------------------------------------------- */
2485void limHandleMissedBeaconInd(tpAniSirGlobal pMac)
2486{
2487 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2488 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2489 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2490 {
2491 pMac->pmm.inMissedBeaconScenario = TRUE;
2492 PELOG1(limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME \n"));)
2493 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2494 }
2495 else
2496 {
2497 limLog(pMac, LOGE,
2498 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d\n"),
2499 pMac->pmm.gPmmState);
2500 }
2501 return;
2502}
2503
2504/** -----------------------------------------------------------------
2505 \brief limMicFailureInd() - handles mic failure indication
2506
2507 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2508
2509 \param pMac - global mac structure
2510 \return - none
2511 \sa
2512 ----------------------------------------------------------------- */
2513void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2514{
2515 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2516 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2517 tSirMsgQ mmhMsg;
2518 tpPESession psessionEntry ;
2519 tANI_U8 sessionId;
2520
2521 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2522 {
2523 limLog(pMac, LOGE,
2524 FL("session does not exist for given BSSId\n"));
2525 return;
2526 }
2527
2528 if (eHAL_STATUS_SUCCESS !=
2529 palAllocateMemory(pMac->hHdd,
2530 (void **) &pSirSmeMicFailureInd,
2531 sizeof(tSirSmeMicFailureInd)))
2532 {
2533 // Log error
2534 limLog(pMac, LOGP,
2535 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND\n"));
2536 return;
2537 }
2538
2539 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2540 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2541 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2542
2543 vos_mem_copy(pSirSmeMicFailureInd->bssId,
2544 pSirMicFailureInd->bssId,
2545 sizeof(tSirMacAddr));
2546
2547 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
2548 pSirMicFailureInd->info.srcMacAddr,
2549 sizeof(tSirMacAddr));
2550
2551 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
2552 pSirMicFailureInd->info.taMacAddr,
2553 sizeof(tSirMacAddr));
2554
2555 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
2556 pSirMicFailureInd->info.dstMacAddr,
2557 sizeof(tSirMacAddr));
2558
2559 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
2560 pSirMicFailureInd->info.rxMacAddr,
2561 sizeof(tSirMacAddr));
2562
2563 pSirSmeMicFailureInd->info.multicast =
2564 pSirMicFailureInd->info.multicast;
2565
2566 pSirSmeMicFailureInd->info.keyId=
2567 pSirMicFailureInd->info.keyId;
2568
2569 pSirSmeMicFailureInd->info.IV1=
2570 pSirMicFailureInd->info.IV1;
2571
2572 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
2573 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
2574
2575 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2576 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2577 mmhMsg.bodyval = 0;
2578 MTRACE(macTraceMsgTx(pMac, 0, mmhMsg.type));
2579 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2580 return;
2581}
2582
2583
2584/** -----------------------------------------------------------------
2585 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2586
2587 This function is called before enqueuing the frame to PE queue for further processing.
2588 This prevents unnecessary frames getting into PE Queue and drops them right away.
2589 Frames will be droped in the following scenarios:
2590
2591 - In Scan State, drop the frames which are not marked as scan frames
2592 - In non-Scan state, drop the frames which are marked as scan frames.
2593 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2594 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2595
2596 \param pMac - global mac structure
2597 \return - none
2598 \sa
2599 ----------------------------------------------------------------- */
2600
2601tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2602{
2603 tANI_U32 framelen;
2604 tANI_U8 *pBody;
2605 tSirMacCapabilityInfo capabilityInfo;
2606
2607 /*
2608 *
2609 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2610 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2611 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2612 * other than beacons or probe responses in scan state.
2613 */
2614 if( (subType == SIR_MAC_MGMT_BEACON) ||
2615 (subType == SIR_MAC_MGMT_PROBE_RSP))
2616 {
2617 if(pMac->pmm.inMissedBeaconScenario)
2618 {
2619 PELOGE(limLog(pMac, LOGE, FL("Do not drop beacon and probe response - Missed beacon sceanrio"));)
2620 return eMGMT_DROP_NO_DROP;
2621 }
2622 if (limIsSystemInScanState(pMac))
2623 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002624 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 }
2626 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2627 {
2628 return eMGMT_DROP_SCAN_MODE_FRAME;
2629 }
2630 }
2631
2632 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2633 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2634
2635 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2636 * beacons from an infrastructure network
2637 */
2638 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2639 if(!capabilityInfo.ibss)
2640 return eMGMT_DROP_NO_DROP;
2641#if 0
2642 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2643 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2644 return eMGMT_DROP_NO_DROP;
2645#endif
2646
2647 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2648 if( (subType == SIR_MAC_MGMT_BEACON) ||
2649 (subType == SIR_MAC_MGMT_PROBE_RSP))
2650 {
2651 //drop the frame if length is less than 12
2652 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2653 return eMGMT_DROP_INVALID_SIZE;
2654
2655 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2656
2657 //This can be enhanced to even check the SSID before deciding to enque the frame.
2658 if(capabilityInfo.ess)
2659 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2660 }
2661 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2662 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2663 {
2664 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2665 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2666 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2667 }
2668
2669 return eMGMT_DROP_NO_DROP;
2670}
2671
2672