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