blob: 07461c9480acbb4238f43e21e5a19c139f16779e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080031/*
Jeff Johnson295189b2012-06-20 16:38:30 -070032 * This file limApi.cc contains the functions that are
33 * exported by LIM to other modules.
34 *
35 * Author: Chandra Modumudi
36 * Date: 02/11/02
37 * History:-
38 * Date Modified by Modification Information
39 * --------------------------------------------------------------------
40 *
41 */
42#include "palTypes.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053043#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070044#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070045#include "sirCommon.h"
46#include "sirDebug.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070047#include "cfgApi.h"
48
49#include "schApi.h"
50#include "utilsApi.h"
51#include "limApi.h"
52#include "limGlobal.h"
53#include "limTypes.h"
54#include "limUtils.h"
55#include "limAssocUtils.h"
56#include "limPropExtsUtils.h"
57#include "limSerDesUtils.h"
58#include "limIbssPeerMgmt.h"
59#include "limAdmitControl.h"
60#include "pmmApi.h"
61#include "logDump.h"
62#include "limSendSmeRspMessages.h"
63#include "wmmApsd.h"
64#include "limTrace.h"
65#include "limSession.h"
66#include "wlan_qct_wda.h"
67
68#if defined WLAN_FEATURE_VOWIFI
69#include "rrmApi.h"
70#endif
71
72#include <limFT.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070073#include "vos_types.h"
74#include "vos_packet.h"
75#include "wlan_qct_tl.h"
76#include "sysStartup.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070077
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
Jeff Johnson92751692013-03-06 16:00:33 -080098 pMac->lim.gLimReportBackgroundScanResults = FALSE; //controlled by SME
Jeff Johnson295189b2012-06-20 16:38:30 -070099
100 pMac->lim.gLimCurrentScanChannelId = 0;
101 pMac->lim.gpLimMlmScanReq = NULL;
Viral Modid440e682013-03-06 02:25:31 -0800102 pMac->lim.gDeferMsgTypeForNOA = 0;
103 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700104 pMac->lim.gLimMlmScanResultLength = 0;
105 pMac->lim.gLimSmeScanResultLength = 0;
106
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530107 vos_mem_set(pMac->lim.gLimCachedScanHashTable,
108 sizeof(pMac->lim.gLimCachedScanHashTable), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700110#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
111
112 pMac->lim.gLimMlmLfrScanResultLength = 0;
113 pMac->lim.gLimSmeLfrScanResultLength = 0;
114
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530115 vos_mem_set(pMac->lim.gLimCachedLfrScanHashTable,
116 sizeof(pMac->lim.gLimCachedLfrScanHashTable), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118 pMac->lim.gLimBackgroundScanChannelId = 0;
119 pMac->lim.gLimBackgroundScanStarted = 0;
120 pMac->lim.gLimRestoreCBNumScanInterval = LIM_RESTORE_CB_NUM_SCAN_INTERVAL_DEFAULT;
121 pMac->lim.gLimRestoreCBCount = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530122 vos_mem_set(pMac->lim.gLimLegacyBssidList,
123 sizeof(pMac->lim.gLimLegacyBssidList), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700124
125 /* Fill in default values */
126 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss = 0;
127
Jeff Johnson295189b2012-06-20 16:38:30 -0700128
129 // abort scan is used to abort an on-going scan
130 pMac->lim.abortScan = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530131 vos_mem_set(&pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo), 0);
132 vos_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
134//WLAN_SUSPEND_LINK Related
135 pMac->lim.gpLimSuspendCallback = NULL;
136 pMac->lim.gpLimResumeCallback = NULL;
137//end WLAN_SUSPEND_LINK Related
138}
139
140
141static void __limInitBssVars(tpAniSirGlobal pMac)
142{
143
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530144 vos_mem_set((void*)pMac->lim.gpSession,
145 sizeof(*pMac->lim.gpSession)*pMac->lim.maxBssId, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700146
147
148 //pMac->lim.gpLimStartBssReq = NULL;
149
Jeff Johnson295189b2012-06-20 16:38:30 -0700150
151
152
153/* These global variables are moved to session table and intialization is done during session creation Oct 9th Review */
154#if 0
155
156 // Place holder for BSS description that we're
157 // currently joined with
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530158 vos_mem_set(&pMac->lim.gLimCurrentBssId, sizeof(tSirMacAddr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 pMac->lim.gLimCurrentChannelId = HAL_INVALID_CHANNEL_ID;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530160 vos_mem_set(&pMac->lim.gLimCurrentSSID, sizeof(tSirMacSSid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 pMac->lim.gLimCurrentBssCaps = 0;
162 QosCaps is a bit map of various qos capabilities - see defn above
163 pMac->lim.gLimCurrentBssQosCaps = 0;
164 pMac->lim.gLimCurrentBssPropCap = 0;
165 pMac->lim.gLimSentCapsChangeNtf = 0;
166
167 // Place holder for BSS description that
168 // we're currently Reassociating
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530169 vos_mem_set(&pMac->lim.gLimReassocBssId, sizeof(tSirMacAddr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 pMac->lim.gLimReassocChannelId = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530171 vos_mem_set(&pMac->lim.gLimReassocSSID, sizeof(tSirMacSSid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 pMac->lim.gLimReassocBssCaps = 0;
173 pMac->lim.gLimReassocBssQosCaps = 0;
174 pMac->lim.gLimReassocBssPropCap = 0;
175 #endif
176
177 /* This is for testing purposes only, be default should always be off */
178 pMac->lim.gLimForceNoPropIE = 0;
179
180 // pMac->lim.gLimBssIdx = 0;
181
182 pMac->lim.gpLimMlmSetKeysReq = NULL;
183 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
184 // pMac->lim.gLimStaid = 0; //TO SUPPORT BT-AMP
185
186}
187
188
189static void __limInitStatsVars(tpAniSirGlobal pMac)
190{
191 pMac->lim.gLimNumBeaconsRcvd = 0;
192 pMac->lim.gLimNumBeaconsIgnored = 0;
193
194 pMac->lim.gLimNumDeferredMsgs = 0;
195
196 /// Variable to keep track of number of currently associated STAs
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800197 //pMac->lim.gLimNumOfCurrentSTAs = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700198 pMac->lim.gLimNumOfAniSTAs = 0; // count of ANI peers
199
200 /// This indicates number of RXed Beacons during HB period
201 //pMac->lim.gLimRxedBeaconCntDuringHB = 0;
202
203 // Heart-Beat interval value
204 pMac->lim.gLimHeartBeatCount = 0;
205
Abhishek Singhde51a412014-05-20 19:17:26 +0530206 vos_mem_zero(pMac->lim.gLimHeartBeatApMac[0],
207 sizeof(tSirMacAddr));
208 vos_mem_zero(pMac->lim.gLimHeartBeatApMac[1],
209 sizeof(tSirMacAddr));
210 pMac->lim.gLimHeartBeatApMacIndex = 0;
211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 // Statistics to keep track of no. beacons rcvd in heart beat interval
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530213 vos_mem_set(pMac->lim.gLimHeartBeatBeaconStats,
214 sizeof(pMac->lim.gLimHeartBeatBeaconStats), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216#ifdef WLAN_DEBUG
217 // Debug counters
218 pMac->lim.numTot = 0;
219 pMac->lim.numBbt = 0;
220 pMac->lim.numProtErr = 0;
221 pMac->lim.numLearn = 0;
222 pMac->lim.numLearnIgnore = 0;
223 pMac->lim.numSme = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530224 vos_mem_set(pMac->lim.numMAC, sizeof(pMac->lim.numMAC), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 pMac->lim.gLimNumAssocReqDropInvldState = 0;
226 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
227 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
228 pMac->lim.gLimNumReassocReqDropInvldState = 0;
229 pMac->lim.gLimNumHashMissIgnored = 0;
230 pMac->lim.gLimUnexpBcnCnt = 0;
231 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
232 pMac->lim.gLimNumLinkEsts = 0;
233 pMac->lim.gLimNumRxCleanup = 0;
234 pMac->lim.gLim11bStaAssocRejectCount = 0;
235#endif
236}
237
238
239
240static void __limInitStates(tpAniSirGlobal pMac)
241{
242 // Counts Heartbeat failures
243 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
244 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
245 pMac->lim.gLimHBfailureCntInOtherStates = 0;
246 pMac->lim.gLimRspReqd = 0;
247 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
248
249 /// MLM State visible across all Sirius modules
Jeff Johnsone7245742012-09-05 17:12:55 -0700250 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
252
253 /// Previous MLM State
254 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
255
256#ifdef GEN4_SCAN
257 // LIM to HAL SCAN Management Message Interface states
258 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
259#endif // GEN4_SCAN
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 /**
Jeff Johnsone7245742012-09-05 17:12:55 -0700262 * Initialize state to eLIM_SME_OFFLINE_STATE
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700264 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 /**
267 * By default assume 'unknown' role. This will be updated
268 * when SME_START_BSS_REQ is received.
269 */
270
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530271 vos_mem_set(&pMac->lim.gLimOverlap11gParams, sizeof(tLimProtStaParams), 0);
272 vos_mem_set(&pMac->lim.gLimOverlap11aParams, sizeof(tLimProtStaParams), 0);
273 vos_mem_set(&pMac->lim.gLimOverlapHt20Params, sizeof(tLimProtStaParams), 0);
274 vos_mem_set(&pMac->lim.gLimOverlapNonGfParams, sizeof(tLimProtStaParams), 0);
275 vos_mem_set(&pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams), 0);
276 vos_mem_set(&pMac->lim.gLimNoShortSlotParams, sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278 pMac->lim.gLimPhyMode = 0;
279 pMac->lim.scanStartTime = 0; // used to measure scan time
280
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530281 vos_mem_set(pMac->lim.gLimMyMacAddr, sizeof(pMac->lim.gLimMyMacAddr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 pMac->lim.ackPolicy = 0;
283
284#if 0 /* Moving all these to session specific elements */
285 pMac->lim.gLimQosEnabled = 0; //11E
286 pMac->lim.gLimWmeEnabled = 0; //WME
287 pMac->lim.gLimWsmEnabled = 0; //WSM
288 pMac->lim.gLimHcfEnabled = 0;
289 pMac->lim.gLim11dEnabled = 0;
290#endif
291
292 pMac->lim.gLimProbeRespDisableFlag = 0; // control over probe response
293}
294
295static void __limInitVars(tpAniSirGlobal pMac)
296{
297
Jeff Johnson295189b2012-06-20 16:38:30 -0700298
299 // Place holder for Measurement Req/Rsp/Ind related info
Jeff Johnson295189b2012-06-20 16:38:30 -0700300
301 // WDS info
302 pMac->lim.gLimNumWdsInfoInd = 0;
303 pMac->lim.gLimNumWdsInfoSet = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530304 vos_mem_set(&pMac->lim.gLimWdsInfo, sizeof(tSirWdsInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 /* initialize some parameters */
306 limInitWdsInfoParams(pMac);
307
308 // Deferred Queue Paramters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530309 vos_mem_set(&pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700310
311 // addts request if any - only one can be outstanding at any time
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530312 vos_mem_set(&pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq) , 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 pMac->lim.gLimAddtsSent = 0;
314 pMac->lim.gLimAddtsRspTimerCount = 0;
315
316 //protection related config cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530317 vos_mem_set(&pMac->lim.cfgProtection, sizeof(tCfgProtection), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 pMac->lim.gLimProtectionControl = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530319 vos_mem_set(&pMac->lim.gLimAlternateRadio, sizeof(tSirAlternateRadioInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
321
Jeff Johnsone7245742012-09-05 17:12:55 -0700322#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 // 11h Spectrum Management Related Flag
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_FALSE);
325 pMac->sys.gSysEnableLearnMode = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700326#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 // WMM Related Flag
328 pMac->lim.gUapsdEnable = 0;
329 pMac->lim.gUapsdPerAcBitmask = 0;
330 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
331 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
332
333 // QoS-AC Downgrade: Initially, no AC is admitted
334 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
335 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
336
337 //dialogue token List head/tail for Action frames request sent.
338 pMac->lim.pDialogueTokenHead = NULL;
339 pMac->lim.pDialogueTokenTail = NULL;
340
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530341 vos_mem_set(&pMac->lim.tspecInfo,
342 sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700343
344 // admission control policy information
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530345 vos_mem_set(&pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700346
347 pMac->lim.gLastBeaconDtimCount = 0;
348 pMac->lim.gLastBeaconDtimPeriod = 0;
349
350 //Scan in Power Save Flag
351 pMac->lim.gScanInPowersave = 0;
Praveen Kumar Sirisilla7ea8dc92013-12-22 16:35:05 -0800352 pMac->lim.probeCounter = 0;
353 pMac->lim.maxProbe = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700354}
355
356static void __limInitAssocVars(tpAniSirGlobal pMac)
357{
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800358 tANI_U32 val;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800359#if 0
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530360 vos_mem_set(pMac->lim.gpLimAIDpool,
361 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 pMac->lim.freeAidHead = 0;
363 pMac->lim.freeAidTail = 0;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800364#endif
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800365 if(wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS)
366 {
367 limLog( pMac, LOGP, FL( "cfg get assoc sta limit failed" ));
368 }
369 pMac->lim.gLimAssocStaLimit = val;
Ravi Joshi0fc681b2013-09-11 16:46:07 -0700370 pMac->lim.gLimIbssStaLimit = val;
Jeff Johnson295189b2012-06-20 16:38:30 -0700371
372 // Place holder for current authentication request
373 // being handled
374 pMac->lim.gpLimMlmAuthReq = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -0700375 //pMac->lim.gpLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
377 /// MAC level Pre-authentication related globals
378 pMac->lim.gLimPreAuthChannelNumber = 0;
379 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530380 vos_mem_set(&pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 pMac->lim.gLimNumPreAuthContexts = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530382 vos_mem_set(&pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700383
384 // Placed holder to deauth reason
385 pMac->lim.gLimDeauthReasonCode = 0;
386
387 // Place holder for Pre-authentication node list
388 pMac->lim.pLimPreAuthList = NULL;
389
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 //One cache for each overlap and associated case.
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530391 vos_mem_set(pMac->lim.protStaOverlapCache,
392 sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE, 0);
393 vos_mem_set(pMac->lim.protStaCache,
394 sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700395
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800396#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -0700397 pMac->lim.pSessionEntry = NULL;
398 pMac->lim.reAssocRetryAttempt = 0;
399#endif
400
Jeff Johnson295189b2012-06-20 16:38:30 -0700401}
402
403
404static void __limInitTitanVars(tpAniSirGlobal pMac)
405{
Jeff Johnsone7245742012-09-05 17:12:55 -0700406#if 0
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530407 vos_mem_set(&pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700409 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
410#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 // Debug workaround for BEACON's
412 // State change triggered by "dump 222"
413 pMac->lim.gLimScanOverride = 1;
414 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 pMac->lim.gLimTitanStaCount = 0;
416 pMac->lim.gLimBlockNonTitanSta = 0;
417}
418
419static void __limInitHTVars(tpAniSirGlobal pMac)
420{
421 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 pMac->lim.gHTShortGI40Mhz = 0;
424 pMac->lim.gHTShortGI20Mhz = 0;
425 pMac->lim.gHTMaxAmsduLength = 0;
426 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
427 pMac->lim.gHTPSMPSupport = 0;
428 pMac->lim.gHTLsigTXOPProtection = 0;
429 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
430 pMac->lim.gHTAMpduDensity = 0;
431
432 pMac->lim.gMaxAmsduSizeEnabled = false;
433 pMac->lim.gHTMaxRxAMpduFactor = 0;
434 pMac->lim.gHTServiceIntervalGranularity = 0;
435 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
437 pMac->lim.gHTPCOActive = 0;
438
439 pMac->lim.gHTPCOPhase = 0;
440 pMac->lim.gHTSecondaryBeacon = 0;
441 pMac->lim.gHTDualCTSProtection = 0;
442 pMac->lim.gHTSTBCBasicMCS = 0;
443 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
444}
445
Jeff Johnson295189b2012-06-20 16:38:30 -0700446static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
447{
Jeff Johnsone7245742012-09-05 17:12:55 -0700448 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 tANI_U16 val16;
450 tANI_U8 val8;
451 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
452 tSirMacHTInfoField1 *pHTInfoField1;
453 tpSirPowerSaveCfg pPowerSaveConfig;
454 tSirMacHTParametersInfo *pAmpduParamInfo;
455
456 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700457 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
458 * and they will be used throughout when there is no session
459 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700460
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
462 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700463 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 return eSIR_FAILURE;
465 }
466
467 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
468 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700469 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 return eSIR_FAILURE;
471 }
472 val16 = ( tANI_U16 ) val1;
473 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
474
475 //channel bonding mode could be set to anything from 0 to 4(Titan had these
476 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
477 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
478 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
479 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
480 != eSIR_SUCCESS)
481 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700482 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 return eSIR_FAILURE;
484 }
485
486 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
487 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700488 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 return eSIR_FAILURE;
490 }
491
492 val8 = ( tANI_U8 ) val1;
493 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
494 pHTInfoField1->recommendedTxWidthSet =
495 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
497 != eSIR_SUCCESS)
498 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700499 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 return eSIR_FAILURE;
501 }
502
503 /* WNI_CFG_HEART_BEAT_THRESHOLD */
504
505 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
506 eSIR_SUCCESS )
507 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700508 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 return eSIR_FAILURE;
510 }
511 if(!val1)
512 {
513 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
514 pMac->sys.gSysEnableLinkMonitorMode = 0;
515 }
516 else
517 {
518 //No need to activate the timer during init time.
519 pMac->sys.gSysEnableLinkMonitorMode = 1;
520 }
521
522 /* WNI_CFG_SHORT_GI_20MHZ */
523
524 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
525 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700526 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 return eSIR_FAILURE;
528 }
529 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
530 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700531 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 return eSIR_FAILURE;
533 }
534 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
535 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700536 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 return eSIR_FAILURE;
538 }
539
540 val16 = ( tANI_U16 ) val1;
541 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
542 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
543 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
544
545 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
546 eSIR_SUCCESS)
547 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700548 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 return eSIR_FAILURE;
550 }
551
552 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
553
554 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
555 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700556 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 return eSIR_FAILURE;
558 }
559 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
560 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700561 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 return eSIR_FAILURE;
563 }
564 val16 = ( tANI_U16 ) val1;
565 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
566 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
567 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
568 eSIR_SUCCESS)
569 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700570 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 return eSIR_FAILURE;
572 }
573
574 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
575 limHandleCFGparamUpdate do we want to update this? */
576 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
577 {
Shake M Subhani5d80fda2013-12-09 17:28:23 +0530578 limLog(pMac, LOGE, FL("cfg get short preamble failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 return eSIR_FAILURE;
580 }
581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 /* WNI_CFG_MAX_PS_POLL */
583
584 /* Allocate and fill in power save configuration. */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530585 pPowerSaveConfig = vos_mem_malloc(sizeof(tSirPowerSaveCfg));
586 if (NULL == pPowerSaveConfig)
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 {
588 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700589 "configuration"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 return eSIR_FAILURE;
591 }
592
593 /* This context should be valid if power-save configuration message has been
594 * already dispatched during initialization process. Re-using the present
595 * configuration mask
596 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530597 vos_mem_copy(pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg, sizeof(tSirPowerSaveCfg));
Jeff Johnson295189b2012-06-20 16:38:30 -0700598
599 /* Note: it is okay to do this since DAL/HAL is alrady started */
600 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
601 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700602 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 return eSIR_FAILURE;
604 }
605
606 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
607
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700609 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 pMac->lim.gLimBackgroundScanChannelId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700611
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);
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800617 if(wlan_cfgGetInt(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,(tANI_U32 *) &pMac->lim.disableLDPCWithTxbfAP) != eSIR_SUCCESS)
618 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700619 limLog(pMac, LOGP, FL("cfg get disableLDPCWithTxbfAP failed"));
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800620 return eSIR_FAILURE;
621 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530622#ifdef FEATURE_WLAN_TDLS
623 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_BUF_STA_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSBufStaEnabled) != eSIR_SUCCESS)
624 {
625 limLog(pMac, LOGP, FL("cfg get LimTDLSBufStaEnabled failed"));
626 return eSIR_FAILURE;
627 }
628 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_QOS_WMM_UAPSD_MASK,(tANI_U32 *) &pMac->lim.gLimTDLSUapsdMask) != eSIR_SUCCESS)
629 {
630 limLog(pMac, LOGP, FL("cfg get LimTDLSUapsdMask failed"));
631 return eSIR_FAILURE;
632 }
Naresh Jayaramf73f3762014-02-04 16:13:20 +0530633 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_OFF_CHANNEL_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSOffChannelEnabled) != eSIR_SUCCESS)
634 {
635 limLog(pMac, LOGP, FL("cfg get LimTDLSUapsdMask failed"));
636 return eSIR_FAILURE;
637 }
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +0530638
639 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_WMM_MODE_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSWmmMode) != eSIR_SUCCESS)
640 {
641 limLog(pMac, LOGP, FL("cfg get LimTDLSWmmMode failed"));
642 return eSIR_FAILURE;
643 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530644#endif
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +0530645
Rashmi Ramannac7744532013-10-06 16:49:08 +0530646 if (eSIR_SUCCESS !=
647 wlan_cfgGetInt(pMac, WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL,
648 (tANI_U32 *)&pMac->lim.gDebugP2pRemainOnChannel))
649 {
650 limLog( pMac, LOGE,
651 "%s: Couldn't get WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL value",
652 __func__);
653 pMac->lim.gDebugP2pRemainOnChannel = 0;
654 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 return eSIR_SUCCESS;
656}
Jeff Johnson295189b2012-06-20 16:38:30 -0700657
658/*
659 limStart
660 This function is to replace the __limProcessSmeStartReq since there is no
661 eWNI_SME_START_REQ post to PE.
662*/
663tSirRetStatus limStart(tpAniSirGlobal pMac)
664{
665 tSirResultCodes retCode = eSIR_SUCCESS;
666
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530667 limLog(pMac, LOG1, FL(" enter"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700668
669 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
670 {
671 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
672
Jeff Johnsone7245742012-09-05 17:12:55 -0700673 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700674
675 // By default do not return after first scan match
676 pMac->lim.gLimReturnAfterFirstMatch = 0;
677
678 // Initialize MLM state machine
679 limInitMlm(pMac);
680
681 // By default return unique scan results
682 pMac->lim.gLimReturnUniqueResults = true;
683 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700684#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
685 pMac->lim.gLimSmeLfrScanResultLength = 0;
686#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 }
688 else
689 {
690 /**
691 * Should not have received eWNI_SME_START_REQ in states
692 * other than OFFLINE. Return response to host and
693 * log error
694 */
Sushant Kaushik1b645382014-10-13 16:39:36 +0530695 limLog(pMac, LOGE, FL("Invalid SME state %d"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 retCode = eSIR_FAILURE;
697 }
698
699 return retCode;
700}
701
702/**
703 * limInitialize()
704 *
705 *FUNCTION:
706 * This function is called from LIM thread entry function.
707 * LIM related global data structures are initialized in this function.
708 *
709 *LOGIC:
710 * NA
711 *
712 *ASSUMPTIONS:
713 * NA
714 *
715 *NOTE:
716 * NA
717 *
718 * @param pMac - Pointer to global MAC structure
719 * @return None
720 */
721
722tSirRetStatus
723limInitialize(tpAniSirGlobal pMac)
724{
725 tSirRetStatus status = eSIR_SUCCESS;
726
727 __limInitAssocVars(pMac);
728 __limInitVars(pMac);
729 __limInitStates(pMac);
730 __limInitStatsVars(pMac);
731 __limInitBssVars(pMac);
732 __limInitScanVars(pMac);
733 __limInitHTVars(pMac);
734 __limInitTitanVars(pMac);
735
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 status = limStart(pMac);
737 if(eSIR_SUCCESS != status)
738 {
739 return status;
740 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700741
742 /*
743 * MLM will be intitalized when 'START' request comes from SME.
744 * limInitMlm calls limCreateTimers, which actually relies on
745 * CFG to be downloaded. So it should not be called as part of
746 * peStart, as CFG download is happening after peStart.
747 */
748 //limInitMlm(pMac);
749 // Initializations for maintaining peers in IBSS
750 limIbssInit(pMac);
751
752 pmmInitialize(pMac);
753
754
755#if defined WLAN_FEATURE_VOWIFI
756 rrmInitialize(pMac);
757#endif
758#if defined WLAN_FEATURE_VOWIFI_11R
759 limFTOpen(pMac);
760#endif
761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763
764#if 0
765
766 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
767 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
768 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
769
770 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
771 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
772
773 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
774 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
775 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
776
777 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
778
779 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
780
781 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
782 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
783
784 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
785
786
787 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
788
789 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 //Initialize the configurations needed by PE
793 if( eSIR_FAILURE == __limInitConfig(pMac))
794 {
795 //We need to undo everything in limStart
796 limCleanupMlm(pMac);
797 return eSIR_FAILURE;
798 }
799
800 //initialize the TSPEC admission control table.
801 //Note that this was initially done after resume notification from HAL.
802 //Now, DAL is started before PE so this can be done here
803 limAdmitControlInit(pMac);
804 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700805
806 return status;
807
808} /*** end limInitialize() ***/
809
810
811
812/**
813 * limCleanup()
814 *
815 *FUNCTION:
816 * This function is called upon reset or persona change
817 * to cleanup LIM state
818 *
819 *LOGIC:
820 * NA
821 *
822 *ASSUMPTIONS:
823 * NA
824 *
825 *NOTE:
826 * NA
827 *
828 * @param pMac - Pointer to Global MAC structure
829 * @return None
830 */
831
832void
833limCleanup(tpAniSirGlobal pMac)
834{
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 v_PVOID_t pvosGCTx;
836 VOS_STATUS retStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838//Before destroying the list making sure all the nodes have been deleted.
839//Which should be the normal case, but a memory leak has been reported.
840
841 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
842
843 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
844 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
845 {
846 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
847 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
848
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530849 vos_mem_free(pLimMgmtRegistration);
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 }
851
852 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700853
854 limCleanupMlm(pMac);
855 limCleanupLmm(pMac);
856
857 // free up preAuth table
858 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
859 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530860 vos_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
862 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
863 }
864
865 if(NULL != pMac->lim.pDialogueTokenHead)
866 {
867 limDeleteDialogueTokenList(pMac);
868 }
869
870 if(NULL != pMac->lim.pDialogueTokenTail)
871 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530872 vos_mem_free(pMac->lim.pDialogueTokenTail);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 pMac->lim.pDialogueTokenTail = NULL;
874 }
875
876 # if 0
877 if (pMac->lim.gpLimStartBssReq != NULL)
878 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530879 vos_mem_free(pMac->lim.gpLimStartBssReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 pMac->lim.gpLimStartBssReq = NULL;
881 }
882 #endif
883
884 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
885 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530886 vos_mem_free(pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 pMac->lim.gpLimMlmSetKeysReq = NULL;
888 }
889
890 #if 0
891 if (pMac->lim.gpLimJoinReq != NULL)
892 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530893 vos_mem_free(pMac->lim.gpLimJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 pMac->lim.gpLimJoinReq = NULL;
895 }
896 #endif
897
898 if (pMac->lim.gpLimMlmAuthReq != NULL)
899 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530900 vos_mem_free(pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 pMac->lim.gpLimMlmAuthReq = NULL;
902 }
903
Jeff Johnsone7245742012-09-05 17:12:55 -0700904#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 if (pMac->lim.gpLimMlmJoinReq != NULL)
906 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530907 vos_mem_free(pMac->lim.gpLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 pMac->lim.gpLimMlmJoinReq = NULL;
909 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700911
912 #if 0
913 if (pMac->lim.gpLimReassocReq != NULL)
914 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530915 vos_mem_free(pMac->lim.gpLimReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 pMac->lim.gpLimReassocReq = NULL;
917 }
918 #endif
919
920 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
921 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530922 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
924 }
925
Viral Modid440e682013-03-06 02:25:31 -0800926 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
Viral Modid86bde22012-12-10 13:09:21 -0800927 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530928 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -0800929 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800930 }
Viral Modid86bde22012-12-10 13:09:21 -0800931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if (pMac->lim.gpLimMlmScanReq != NULL)
933 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530934 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 pMac->lim.gpLimMlmScanReq = NULL;
936 }
937
938#if 0
939 if(NULL != pMac->lim.beacon)
940 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530941 vos_mem_free((void*) pMac->lim.beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 pMac->lim.beacon = NULL;
943 }
944#endif
945 #if 0
946 if(NULL != pMac->lim.assocReq)
947 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530948 vos_mem_free((void*) pMac->lim.assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 pMac->lim.assocReq= NULL;
950 }
951 #endif
952
953#if 0
954 if(NULL != pMac->lim.assocRsp)
955 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530956 vos_mem_free((void*) pMac->lim.assocRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 pMac->lim.assocRsp= NULL;
958 }
959#endif
960 // Now, finally reset the deferred message queue pointers
961 limResetDeferredMsgQ(pMac);
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963
964 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
965 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
966
967 if ( retStatus != VOS_STATUS_SUCCESS )
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700968 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700969
970#if defined WLAN_FEATURE_VOWIFI
971 rrmCleanup(pMac);
972#endif
973#if defined WLAN_FEATURE_VOWIFI_11R
974 limFTCleanup(pMac);
975#endif
976
977} /*** end limCleanup() ***/
978
979
980/** -------------------------------------------------------------
981\fn peOpen
982\brief will be called in Open sequence from macOpen
983\param tpAniSirGlobal pMac
984\param tHalOpenParameters *pHalOpenParam
985\return tSirRetStatus
986 -------------------------------------------------------------*/
987
988tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
989{
Kaushik, Sushant16def7c2014-06-17 14:20:49 +0530990 if (eDRIVER_TYPE_MFG == pMacOpenParam->driverType)
991 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
993 pMac->lim.maxStation = pMacOpenParam->maxStation;
Katya Nigam53799202014-12-18 15:59:38 +0530994 vos_spin_lock_init( &pMac->sys.lock );
Jeff Johnson295189b2012-06-20 16:38:30 -0700995
996 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
997 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700998 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 return eSIR_FAILURE;
1000 }
1001
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301002 pMac->lim.limTimers.gpLimCnfWaitTimer = vos_mem_malloc(sizeof(TX_TIMER) * pMac->lim.maxStation);
1003 if (NULL == pMac->lim.limTimers.gpLimCnfWaitTimer)
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001005 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 return eSIR_FAILURE;
1007 }
1008
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001009#if 0
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301010 pMac->lim.gpLimAIDpool = vos_mem_malloc(sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1));
1011 if (NULL == pMac->lim.gpLimAIDpool)
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001013 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 return eSIR_FAILURE;
1015 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001016#endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301017 pMac->lim.gpSession = vos_mem_malloc(sizeof(tPESession)* pMac->lim.maxBssId);
1018 if (NULL == pMac->lim.gpSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001020 limLog(pMac, LOGE, FL("memory allocate failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return eSIR_FAILURE;
1022 }
1023
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301024 vos_mem_set(pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
1026
1027 /*
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301028 pMac->dph.dphHashTable.pHashTable = vos_mem_malloc(sizeof(tpDphHashNode)*pMac->lim.maxStation);
1029 if (NULL == pMac->dph.dphHashTable.pHashTable)
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001031 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 return eSIR_FAILURE;
1033 }
1034
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301035 pMac->dph.dphHashTable.pDphNodeArray = vos_mem_malloc(sizeof(tDphHashNode)*pMac->lim.maxStation);
1036 if (NULL == pMac->dph.dphHashTable.pDphNodeArray)
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001038 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 return eSIR_FAILURE;
1040 }
1041 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301042 pMac->pmm.gPmmTim.pTim = vos_mem_malloc(sizeof(tANI_U8)*pMac->lim.maxStation);
1043 if (NULL == pMac->pmm.gPmmTim.pTim)
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001045 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 return eSIR_FAILURE;
1047 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301048 vos_mem_set(pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001049
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001050 pMac->lim.mgmtFrameSessionId = 0xff;
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001051 pMac->lim.deferredMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001052
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001053 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1054 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001055 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!"));)
Leela Venkata Kiran Kumar Reddy Chiralabcf1b8b2013-12-16 17:13:52 -08001056 vos_mem_free(pMac->lim.limTimers.gpLimCnfWaitTimer);
1057 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
1058 vos_mem_free(pMac->lim.gpSession);
1059 pMac->lim.gpSession = NULL;
1060 vos_mem_free(pMac->pmm.gPmmTim.pTim);
1061 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001062 return eSIR_FAILURE;
1063 }
Venkata Prathyusha Kuntupalli22ba5982013-04-24 13:09:20 -07001064 pMac->lim.deauthMsgCnt = 0;
Agarwal Ashishb4ce9922014-11-04 18:40:38 +05301065 pMac->lim.retryPacketCnt = 0;
Sushant Kaushike06bd872015-03-12 16:17:48 +05301066 pMac->lim.gLimIbssRetryCnt = 0;
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07001067
1068 /*
1069 * peOpen is successful by now, so it is right time to initialize
1070 * MTRACE for PE module. if LIM_TRACE_RECORD is not defined in build file
1071 * then nothing will be logged for PE module.
1072 */
1073#ifdef LIM_TRACE_RECORD
1074 MTRACE(limTraceInit(pMac));
1075#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 return eSIR_SUCCESS;
1077}
1078
1079/** -------------------------------------------------------------
1080\fn peClose
1081\brief will be called in close sequence from macClose
1082\param tpAniSirGlobal pMac
1083\return tSirRetStatus
1084 -------------------------------------------------------------*/
1085
1086tSirRetStatus peClose(tpAniSirGlobal pMac)
1087{
1088 tANI_U8 i;
1089
1090 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1091 return eSIR_SUCCESS;
Katya Nigam53799202014-12-18 15:59:38 +05301092
1093 vos_spin_lock_destroy( &pMac->sys.lock );
1094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 for(i =0; i < pMac->lim.maxBssId; i++)
1096 {
1097 if(pMac->lim.gpSession[i].valid == TRUE)
1098 {
1099 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1100 }
1101 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301102 vos_mem_free(pMac->lim.limTimers.gpLimCnfWaitTimer);
Jeff Johnsone7245742012-09-05 17:12:55 -07001103 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001104#if 0
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301105 vos_mem_free(pMac->lim.gpLimAIDpool);
Jeff Johnsone7245742012-09-05 17:12:55 -07001106 pMac->lim.gpLimAIDpool = NULL;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08001107#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001108
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301109 vos_mem_free(pMac->lim.gpSession);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 pMac->lim.gpSession = NULL;
1111 /*
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301112 vos_mem_free(pMac->dph.dphHashTable.pHashTable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 pMac->dph.dphHashTable.pHashTable = NULL;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301114 vos_mem_free(pMac->dph.dphHashTable.pDphNodeArray);
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 pMac->dph.dphHashTable.pDphNodeArray = NULL;
1116 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301117 vos_mem_free(pMac->pmm.gPmmTim.pTim);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001119 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1120 {
1121 return eSIR_FAILURE;
1122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 return eSIR_SUCCESS;
1124}
1125
1126/** -------------------------------------------------------------
1127\fn peStart
1128\brief will be called in start sequence from macStart
1129\param tpAniSirGlobal pMac
1130\return none
1131 -------------------------------------------------------------*/
1132
1133tSirRetStatus peStart(tpAniSirGlobal pMac)
1134{
1135 tSirRetStatus status = eSIR_SUCCESS;
1136
1137 status = limInitialize(pMac);
1138#if defined(ANI_LOGDUMP)
1139 limDumpInit(pMac);
1140#endif //#if defined(ANI_LOGDUMP)
1141
1142 return status;
1143}
1144
1145/** -------------------------------------------------------------
1146\fn peStop
1147\brief will be called in stop sequence from macStop
1148\param tpAniSirGlobal pMac
1149\return none
1150 -------------------------------------------------------------*/
1151
1152void peStop(tpAniSirGlobal pMac)
1153{
1154 limCleanup(pMac);
1155 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1156 return;
1157}
1158
1159/** -------------------------------------------------------------
1160\fn peFreeMsg
1161\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1162\ to free a given PE message on the TX and MC thread.
1163\ This happens when there are messages pending in the PE
1164\ queue when system is being stopped and reset.
1165\param tpAniSirGlobal pMac
1166\param tSirMsgQ pMsg
1167\return none
1168-----------------------------------------------------------------*/
1169v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1170{
1171 if (pMsg != NULL)
1172 {
1173 if (NULL != pMsg->bodyptr)
1174 {
1175 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1176 {
1177 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1178 }
1179 else
1180 {
1181 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1182 }
1183 }
1184 pMsg->bodyptr = 0;
1185 pMsg->bodyval = 0;
1186 pMsg->type = 0;
1187 }
1188 return;
1189}
1190
1191
1192/**
1193 * The function checks if a particular timer should be allowed
1194 * into LIM while device is sleeping
1195 */
1196tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1197{
1198 tANI_U8 retStatus = TRUE;
1199
1200 if(!limIsSystemInActiveState(pMac))
1201 {
1202 switch(pMsg->type)
1203 {
1204 /* Don't allow following timer messages if in sleep */
1205 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1206 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1207 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1208 retStatus = FALSE;
1209 break;
1210 /* May allow following timer messages in sleep mode */
Jeff Johnson295189b2012-06-20 16:38:30 -07001211
1212 /* Safe to allow as of today, this triggers background scan
1213 * which will not be started if the device is in power-save mode
1214 * might need to block in the future if we decide to implement
1215 * spectrum management
1216 */
1217 case SIR_LIM_QUIET_TIMEOUT:
1218
1219 /* Safe to allow as of today, this triggers background scan
1220 * which will not be started if the device is in power-save mode
1221 * might need to block in the future if we decide to implement
1222 * spectrum management
1223 */
1224 case SIR_LIM_QUIET_BSS_TIMEOUT:
1225
1226 /* Safe to allow this timermessage, triggers background scan
1227 * which is blocked in sleep mode
1228 */
1229 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1230
1231 /* Safe to allow this timer, since, while in IMPS this timer will not
1232 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1233 * when heart-beat control is handled back to PE, device would have
1234 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1235 */
1236 case SIR_LIM_HEART_BEAT_TIMEOUT:
1237 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1238
1239 /* Safe to allow, PE is not handling this message as of now. May need
1240 * to block it, basically, free the buffer and restart the timer
1241 */
1242 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1243 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001244 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1246 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1247 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1248 retStatus = TRUE;
1249 break;
1250
1251 /* by default allow rest of messages */
1252 default:
1253 retStatus = TRUE;
1254 break;
1255
1256
1257 }
1258 }
1259
1260 return retStatus;
1261
1262}
1263
1264
1265
1266/**
1267 * limPostMsgApi()
1268 *
1269 *FUNCTION:
1270 * This function is called from other thread while posting a
1271 * message to LIM message Queue gSirLimMsgQ.
1272 *
1273 *LOGIC:
1274 * NA
1275 *
1276 *ASSUMPTIONS:
1277 * NA
1278 *
1279 *NOTE:
1280 * NA
1281 *
1282 * @param pMac - Pointer to Global MAC structure
1283 * @param pMsg - Pointer to the message structure
1284 * @return None
1285 */
1286
1287tANI_U32
1288limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1289{
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1291
1292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293} /*** end limPostMsgApi() ***/
1294
1295
1296/*--------------------------------------------------------------------------
1297
1298 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1299
1300 This function can be called by legacy code to post message to voss queues OR
1301 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1302 for dispatching it later.
1303
1304 \param pMac - Pointer to Global MAC structure
1305 \param pMsg - Pointer to the message structure
1306
1307 \return tANI_U32 - TX_SUCCESS for success.
1308
1309 --------------------------------------------------------------------------*/
1310
1311tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1312{
1313 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1314}
1315
1316/*--------------------------------------------------------------------------
1317
1318 \brief peProcessMessages() - Message Processor for PE
1319
1320 Voss calls this function to dispatch the message to PE
1321
1322 \param pMac - Pointer to Global MAC structure
1323 \param pMsg - Pointer to the message structure
1324
1325 \return tANI_U32 - TX_SUCCESS for success.
1326
1327 --------------------------------------------------------------------------*/
1328
1329tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1330{
1331 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1332 {
1333 return eSIR_SUCCESS;
1334 }
1335 /**
1336 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1337 * for all the other cases post it to LIM
1338 */
1339 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1340 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1341 else
1342 limMessageProcessor(pMac, pMsg);
1343 return eSIR_SUCCESS;
1344}
1345
Katya Nigam53799202014-12-18 15:59:38 +05301346#define RSRVD_MGMT_RX_PACKETS 10
Jeff Johnson295189b2012-06-20 16:38:30 -07001347
1348// ---------------------------------------------------------------------------
1349/**
1350 * peHandleMgmtFrame
1351 *
1352 * FUNCTION:
1353 * Process the Management frames from TL
1354 *
1355 * LOGIC:
1356 *
1357 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1358 *
1359 * NOTE:
1360 *
1361 * @param pvosGCtx Global Vos Context
1362 * @param vossBuff Packet
1363 * @return None
1364 */
1365
1366VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1367{
1368 tpAniSirGlobal pMac;
1369 tpSirMacMgmtHdr mHdr;
1370 tSirMsgQ msg;
1371 vos_pkt_t *pVosPkt;
1372 VOS_STATUS vosStatus;
1373 v_U8_t *pRxPacketInfo;
1374
1375 pVosPkt = (vos_pkt_t *)vosBuff;
1376 if (NULL == pVosPkt)
1377 {
1378 return VOS_STATUS_E_FAILURE;
1379 }
1380
1381 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1382 if (NULL == pMac)
1383 {
1384 // cannot log a failure without a valid pMac
1385 vos_pkt_return_packet(pVosPkt);
1386 return VOS_STATUS_E_FAILURE;
1387 }
1388
1389 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1390
1391 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1392 {
1393 vos_pkt_return_packet(pVosPkt);
1394 return VOS_STATUS_E_FAILURE;
1395 }
1396
1397
1398 //
1399 // The MPDU header is now present at a certain "offset" in
1400 // the BD and is specified in the BD itself
1401 //
1402 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1403 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1404 {
1405 PELOG1(limLog( pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001406 FL ( "RxBd=%p mHdr=%p Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001407 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001408
Jeff Johnsone7245742012-09-05 17:12:55 -07001409 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT, NO_SESSION,
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 LIM_TRACE_MAKE_RXMGMT(mHdr->fc.subType,
1411 (tANI_U16) (((tANI_U16) (mHdr->seqControl.seqNumHi << 4)) | mHdr->seqControl.seqNumLo)));)
1412 }
1413
1414
1415 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1416 msg.type = SIR_BB_XPORT_MGMT_MSG;
1417 msg.bodyptr = vosBuff;
1418 msg.bodyval = 0;
1419
Katya Nigam53799202014-12-18 15:59:38 +05301420 vos_spin_lock_acquire( &pMac->sys.lock );
1421 if( pMac->sys.gSysBbtPendingMgmtCount > (vos_pkt_get_num_of_rx_raw_pkts()/4) )
1422 {
1423 vos_spin_lock_release( &pMac->sys.lock );
1424 // drop all management packets
Katya Nigamfdf5a522015-02-03 14:38:55 +05301425 limLog( pMac, LOGW,
1426 FL ( "Management queue 1/4th full, dropping management packets" ));
Katya Nigam53799202014-12-18 15:59:38 +05301427 vos_pkt_return_packet(pVosPkt);
1428 return VOS_STATUS_SUCCESS;
1429 }
1430
1431 if( pMac->sys.gSysBbtPendingMgmtCount > ( vos_pkt_get_num_of_rx_raw_pkts()/4
1432 - RSRVD_MGMT_RX_PACKETS ))
1433 {
1434 // drop all probereq, proberesp and beacons
1435 if( mHdr->fc.subType == SIR_MAC_MGMT_BEACON || mHdr->fc.subType ==
1436 SIR_MAC_MGMT_PROBE_REQ || mHdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP )
1437 {
1438 vos_spin_lock_release( &pMac->sys.lock );
Katya Nigamfdf5a522015-02-03 14:38:55 +05301439 limLog( pMac, LOGW,
1440 FL ( "Dropping probe req, probe resp or beacon" ));
Katya Nigam53799202014-12-18 15:59:38 +05301441 vos_pkt_return_packet(pVosPkt);
1442 return VOS_STATUS_SUCCESS;
1443 }
1444 }
1445 pMac->sys.gSysBbtPendingMgmtCount++;
1446 vos_spin_lock_release( &pMac->sys.lock );
1447
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1449 &msg,
1450 mHdr->fc.type,
1451 mHdr->fc.subType ))
1452 {
1453 vos_pkt_return_packet(pVosPkt);
Abhishek Singh5d765712015-03-12 14:04:16 +05301454
1455 /* Decrement gSysBbtPendingMgmtCount if packet
1456 * is dropped before posting to LIM
1457 */
1458 limDecrementPendingMgmtCount(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001460 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 return VOS_STATUS_E_FAILURE;
1462 }
1463
1464 return VOS_STATUS_SUCCESS;
1465}
1466
1467// ---------------------------------------------------------------------------
1468/**
1469 * peRegisterTLHandle
1470 *
1471 * FUNCTION:
1472 * Registers the Handler which, process the Management frames from TL
1473 *
1474 * LOGIC:
1475 *
1476 * ASSUMPTIONS:
1477 *
1478 * NOTE:
1479 *
1480 * @return None
1481 */
1482
1483void peRegisterTLHandle(tpAniSirGlobal pMac)
1484{
1485 v_PVOID_t pvosGCTx;
1486 VOS_STATUS retStatus;
1487
1488 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1489
1490 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1491
1492 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001493 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001494
1495}
Jeff Johnson295189b2012-06-20 16:38:30 -07001496
1497
1498/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 * limIsSystemInScanState()
1500 *
1501 *FUNCTION:
1502 * This function is called by various MAC software modules to
1503 * determine if System is in Scan/Learn state
1504 *
1505 *LOGIC:
1506 * NA
1507 *
1508 *ASSUMPTIONS:
1509 * NA
1510 *
1511 *NOTE:
1512 *
1513 * @param pMac - Pointer to Global MAC structure
1514 * @return true - System is in Scan/Learn state
1515 * false - System is NOT in Scan/Learn state
1516 */
1517
1518tANI_U8
1519limIsSystemInScanState(tpAniSirGlobal pMac)
1520{
1521 switch (pMac->lim.gLimSmeState)
1522 {
1523 case eLIM_SME_CHANNEL_SCAN_STATE:
1524 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1525 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1526 case eLIM_SME_WT_SCAN_STATE:
1527 // System is in Learn mode
1528 return true;
1529
1530 default:
1531 // System is NOT in Learn mode
1532 return false;
1533 }
1534} /*** end limIsSystemInScanState() ***/
1535
1536
1537
1538/**
1539 * limIsSystemInActiveState()
1540 *
1541 *FUNCTION:
1542 * This function is called by various MAC software modules to
1543 * determine if System is in Active/Wakeup state
1544 *
1545 *LOGIC:
1546 * NA
1547 *
1548 *ASSUMPTIONS:
1549 * NA
1550 *
1551 *NOTE:
1552 *
1553 * @param pMac - Pointer to Global MAC structure
1554 * @return true - System is in Active state
1555 * false - System is not in Active state
1556 */
1557
1558tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1559{
1560 switch (pMac->pmm.gPmmState)
1561 {
1562 case ePMM_STATE_BMPS_WAKEUP:
1563 case ePMM_STATE_IMPS_WAKEUP:
1564 case ePMM_STATE_READY:
1565 // System is in Active mode
1566 return true;
1567 default:
1568 return false;
1569 // System is NOT in Active mode
1570 }
1571}
1572
1573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
Jeff Johnson295189b2012-06-20 16:38:30 -07001575
1576
1577/**
1578*\brief limReceivedHBHandler()
1579*
1580* This function is called by schBeaconProcess() upon
1581* receiving a Beacon on STA. This also gets called upon
1582* receiving Probe Response after heat beat failure is
1583* detected.
1584*
1585* param pMac - global mac structure
1586* param channel - channel number indicated in Beacon, Probe Response
1587* return - none
1588*/
1589
1590
1591void
1592limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1593{
1594 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1595 psessionEntry->LimRxedBeaconCntDuringHB++;
1596
1597 pMac->pmm.inMissedBeaconScenario = FALSE;
1598} /*** end limReceivedHBHandler() ***/
1599
1600
1601
1602#if 0
1603void limResetHBPktCount(tpPESession psessionEntry)
1604{
1605 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1606}
1607#endif
1608
1609
1610/*
1611 * limProcessWdsInfo()
1612 *
1613 *FUNCTION:
1614 * This function is called from schBeaconProcess in BP
1615 *
1616 *PARAMS:
1617 * @param pMac - Pointer to Global MAC structure
1618 * @param propIEInfo - proprietary IE info
1619 *
1620 *LOGIC:
1621 *
1622 *ASSUMPTIONS:
1623 * NA
1624 *
1625 *NOTE:
1626 *
1627 *
1628 *RETURNS:
1629 *
1630 */
1631
1632void limProcessWdsInfo(tpAniSirGlobal pMac,
1633 tSirPropIEStruct propIEInfo)
1634{
Jeff Johnson295189b2012-06-20 16:38:30 -07001635}
1636
1637
1638
1639/**
1640 * limInitWdsInfoParams()
1641 *
1642 *FUNCTION:
1643 * This function is called while processing
1644 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1645 * ind/set related parameters.
1646 *
1647 *LOGIC:
1648 *
1649 *ASSUMPTIONS:
1650 *
1651 *NOTE:
1652 *
1653 * @param pMac Pointer to Global MAC structure
1654 * @return None
1655 */
1656
1657void
1658limInitWdsInfoParams(tpAniSirGlobal pMac)
1659{
1660 pMac->lim.gLimWdsInfo.wdsLength = 0;
1661 pMac->lim.gLimNumWdsInfoInd = 0;
1662 pMac->lim.gLimNumWdsInfoSet = 0;
1663} /*** limInitWdsInfoParams() ***/
1664
1665
1666/** -------------------------------------------------------------
1667\fn limUpdateOverlapStaParam
1668\brief Updates overlap cache and param data structure
1669\param tpAniSirGlobal pMac
1670\param tSirMacAddr bssId
1671\param tpLimProtStaParams pStaParams
1672\return None
1673 -------------------------------------------------------------*/
1674void
1675limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1676{
1677 int i;
1678 if (!pStaParams->numSta)
1679 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301680 vos_mem_copy(pMac->lim.protStaOverlapCache[0].addr,
1681 bssId,
1682 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 pMac->lim.protStaOverlapCache[0].active = true;
1684
1685 pStaParams->numSta = 1;
1686
1687 return;
1688 }
1689
1690 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1691 {
1692 if (pMac->lim.protStaOverlapCache[i].active)
1693 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301694 if (vos_mem_compare( pMac->lim.protStaOverlapCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 bssId,
1696 sizeof(tSirMacAddr))) {
1697 return; }
1698 }
1699 else
1700 break;
1701 }
1702
1703 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1704 {
Shake M Subhani5d80fda2013-12-09 17:28:23 +05301705 PELOG1(limLog(pMac, LOGW, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 }
1707 else
1708 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301709 vos_mem_copy(pMac->lim.protStaOverlapCache[i].addr,
1710 bssId,
1711 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 pMac->lim.protStaOverlapCache[i].active = true;
1713
1714 pStaParams->numSta++;
1715 }
1716}
1717
1718
1719/**
1720 * limHandleIBSScoalescing()
1721 *
1722 *FUNCTION:
1723 * This function is called upon receiving Beacon/Probe Response
1724 * while operating in IBSS mode.
1725 *
1726 *LOGIC:
1727 *
1728 *ASSUMPTIONS:
1729 *
1730 *NOTE:
1731 *
1732 * @param pMac - Pointer to Global MAC structure
1733 * @param pBeacon - Parsed Beacon Frame structure
1734 * @param pRxPacketInfo - Pointer to RX packet info structure
1735 *
1736 * @return Status whether to process or ignore received Beacon Frame
1737 */
1738
1739tSirRetStatus
1740limHandleIBSScoalescing(
1741 tpAniSirGlobal pMac,
1742 tpSchBeaconStruct pBeacon,
1743 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1744{
1745 tpSirMacMgmtHdr pHdr;
1746 tSirRetStatus retCode;
1747
1748 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001749 if ( (!pBeacon->capabilityInfo.ibss) ||
Abhishek Singhd5c31272014-03-07 14:46:50 +05301750 ( psessionEntry->privacy !=
1751 (tANI_U8)pBeacon->capabilityInfo.privacy ) ||
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001752 (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) ||
1753 (psessionEntry->currentOperChannel != pBeacon->channelNumber) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 /* Received SSID does not match => Ignore received Beacon frame. */
1755 retCode = eSIR_LIM_IGNORE_BEACON;
1756 else
1757 {
1758 tANI_U32 ieLen;
1759 tANI_U16 tsfLater;
1760 tANI_U8 *pIEs;
1761 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1762 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1763 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Abhishek Singh127a8442014-12-15 17:31:27 +05301764 limLog(pMac, LOG1, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1766 }
1767 return retCode;
1768} /*** end limHandleIBSScoalescing() ***/
1769
Abhishek Singh5fef4042014-11-25 18:33:00 +05301770tAniBool limEncTypeMatched(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon,
1771 tpPESession pSession)
1772{
1773 if (!pBeacon || !pSession)
1774 return eSIR_FALSE;
1775
1776 limLog(pMac, LOG1,
1777 FL("Beacon/Probe:: Privacy :%d WPA Present:%d RSN Present: %d"),
1778 pBeacon->capabilityInfo.privacy, pBeacon->wpaPresent,
1779 pBeacon->rsnPresent);
1780 limLog(pMac, LOG1,
1781 FL("pSession:: Privacy :%d EncyptionType: %d"),
1782 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps),
1783 pSession->encryptType);
1784
1785 /* This is handled by sending probe req due to IOT issues so return TRUE
1786 */
1787 if ( (pBeacon->capabilityInfo.privacy) !=
1788 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps))
1789 {
1790 limLog(pMac, LOG1, FL("Return for Privacy bit miss match, As "
1791 "for this driver need to send the probe request to handle"
1792 " IOT issues "));
1793 return eSIR_TRUE;
1794 }
1795
1796 /*Open*/
1797 if( (pBeacon->capabilityInfo.privacy == 0) &&
1798 (pSession->encryptType == eSIR_ED_NONE))
1799 return eSIR_TRUE;
1800
1801 /* WEP */
1802 if ( (pBeacon->capabilityInfo.privacy == 1) && (pBeacon->wpaPresent == 0) &&
1803 (pBeacon->rsnPresent == 0) &&
Abhishek Singh31dfa3c2014-12-12 17:25:19 +05301804 ( ( pSession->encryptType == eSIR_ED_WEP40 ) ||
1805 ( pSession->encryptType == eSIR_ED_WEP104 )
1806#ifdef FEATURE_WLAN_WAPI
1807 || ( pSession->encryptType == eSIR_ED_WPI )
1808#endif
1809 ))
Abhishek Singh5fef4042014-11-25 18:33:00 +05301810 return eSIR_TRUE;
1811
1812 /* WPA OR RSN*/
1813 if ( (pBeacon->capabilityInfo.privacy == 1) &&
1814 ( (pBeacon->wpaPresent == 1) ||
1815 ( pBeacon->rsnPresent == 1)) &&
1816 ( (pSession->encryptType == eSIR_ED_TKIP) ||
1817 (pSession->encryptType == eSIR_ED_CCMP) ||
1818 (pSession->encryptType == eSIR_ED_AES_128_CMAC)))
1819 return eSIR_TRUE;
1820
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301821 /* For HS2.0, RSN ie is not present
1822 * in beacon. Therefore no need to
1823 * check for security type in case
1824 * OSEN session.
1825 */
1826 /*TODO: AP capability mismatch
1827 * is not checked here because
1828 * no logic for beacon parsing
1829 * is avilable for HS2.0.
1830 */
1831 if (pSession->bOSENAssociation)
1832 return eSIR_TRUE;
1833
Abhishek Singh5fef4042014-11-25 18:33:00 +05301834 return eSIR_FALSE;
1835}
Jeff Johnson295189b2012-06-20 16:38:30 -07001836
1837
1838/**
1839 * limDetectChangeInApCapabilities()
1840 *
1841 *FUNCTION:
1842 * This function is called while SCH is processing
1843 * received Beacon from AP on STA to detect any
1844 * change in AP's capabilities. If there any change
1845 * is detected, Roaming is informed of such change
1846 * so that it can trigger reassociation.
1847 *
1848 *LOGIC:
1849 *
1850 *ASSUMPTIONS:
1851 *
1852 *NOTE:
1853 * Notification is enabled for STA product only since
1854 * it is not a requirement on BP side.
1855 *
1856 * @param pMac Pointer to Global MAC structure
1857 * @param pBeacon Pointer to parsed Beacon structure
1858 * @return None
1859 */
1860
1861void
1862limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1863 tpSirProbeRespBeacon pBeacon,
1864 tpPESession psessionEntry)
1865{
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 tANI_U8 len;
1867 tSirSmeApNewCaps apNewCaps;
1868 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301869 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh5fef4042014-11-25 18:33:00 +05301870 tAniBool securityCapsMatched = eSIR_TRUE;
1871
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1873 newChannel = (tANI_U8) pBeacon->channelNumber;
1874
Abhishek Singh5fef4042014-11-25 18:33:00 +05301875 securityCapsMatched = limEncTypeMatched(pMac, pBeacon, psessionEntry);
1876
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301877 if ( ( false == psessionEntry->limSentCapsChangeNtf ) &&
Abhishek Singh4f8446a2014-05-22 14:07:31 +05301878 ( ( ( !limIsNullSsid(&pBeacon->ssId) ) &&
1879 ( false == limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) ) ) ||
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301880 ( (SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
1881 SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps) ) ||
1882 ( SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1883 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps) ) ||
1884 ( SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1885 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps) ) ||
1886 ( SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
1887 SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps) ) ||
Abhishek Singh5fef4042014-11-25 18:33:00 +05301888 ( newChannel != psessionEntry->currentOperChannel ) ||
1889 (eSIR_FALSE == securityCapsMatched)
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301890 ) ) )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301891 {
Abhishek Singha9325f72015-01-05 11:49:23 +05301892 if ( false == psessionEntry->fWaitForProbeRsp )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301893 {
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301894 /* If Beacon capabilities is not matching with the current capability,
1895 * then send unicast probe request to AP and take decision after
1896 * receiving probe response */
1897 if ( true == psessionEntry->fIgnoreCapsChange )
1898 {
1899 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1900 return;
1901 }
1902 psessionEntry->fWaitForProbeRsp = true;
1903 limLog(pMac, LOGW, FL("AP capabilities are not matching,"
1904 "sending directed probe request.. "));
1905 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1906 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1907 psessionEntry->dot11mode, 0, NULL);
1908
1909 if ( eSIR_SUCCESS != status )
1910 {
1911 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1912 psessionEntry->fWaitForProbeRsp = false;
1913 }
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301914 return;
1915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 /**
1917 * BSS capabilities have changed.
1918 * Inform Roaming.
1919 */
1920 len = sizeof(tSirMacCapabilityInfo) +
1921 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1922 3 * sizeof(tANI_U8) + // reserved fields
1923 pBeacon->ssId.length + 1;
1924
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301925 vos_mem_copy(apNewCaps.bssId,
1926 psessionEntry->bssId,
1927 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 if (newChannel != psessionEntry->currentOperChannel)
1929 {
1930 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001931 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 psessionEntry->currentOperChannel, newChannel);)
1933 return;
1934 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301935
1936 /**
1937 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1938 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1939 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1940 * the privacy bit is set in Probe and association responses.
1941 * Due to this anomaly, we detect a change in
1942 * AP capabilities when we receive a beacon after association and
1943 * disconnect from the AP. The following check makes sure that we can
1944 * connect to such APs
1945 */
1946 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1947 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1948 {
1949 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001950 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301951 return;
1952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 else
1954 apNewCaps.channelId = psessionEntry->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301955 vos_mem_copy((tANI_U8 *) &apNewCaps.ssId,
1956 (tANI_U8 *) &pBeacon->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 pBeacon->ssId.length + 1);
1958
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301959 psessionEntry->fIgnoreCapsChange = false;
1960 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 psessionEntry->limSentCapsChangeNtf = true;
1962 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1963 (tANI_U32 *) &apNewCaps,
1964 len, psessionEntry->smeSessionId);
1965 }
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301966 else if ( true == psessionEntry->fWaitForProbeRsp )
1967 {
1968 /* Only for probe response frames and matching capabilities the control
1969 * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
1970 * will be false, the control will not come here*/
1971
1972 limLog(pMac, LOG1, FL("capabilities in probe response are"
1973 "matching with the current setting,"
1974 "Ignoring subsequent capability"
1975 "mismatch"));
1976 psessionEntry->fIgnoreCapsChange = true;
1977 psessionEntry->fWaitForProbeRsp = false;
1978 }
1979
Jeff Johnson295189b2012-06-20 16:38:30 -07001980} /*** limDetectChangeInApCapabilities() ***/
1981
1982
1983
1984
1985// ---------------------------------------------------------------------
1986/**
1987 * limUpdateShortSlot
1988 *
1989 * FUNCTION:
1990 * Enable/Disable short slot
1991 *
1992 * LOGIC:
1993 *
1994 * ASSUMPTIONS:
1995 *
1996 * NOTE:
1997 *
1998 * @param enable Flag to enable/disable short slot
1999 * @return None
2000 */
2001
2002tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2003{
2004
2005 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002006 tANI_U32 nShortSlot;
2007 tANI_U32 val = 0;
2008 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002009
Jeff Johnsone7245742012-09-05 17:12:55 -07002010 // Check Admin mode first. If it is disabled just return
2011 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2012 != eSIR_SUCCESS)
2013 {
2014 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002015 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002016 return eSIR_FAILURE;
2017 }
2018 if (val == false)
2019 return eSIR_SUCCESS;
2020
2021 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2022 limGetPhyMode(pMac, &phyMode, psessionEntry);
2023 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2024 return eSIR_SUCCESS;
2025
2026 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2029 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2030 // if no erp present, use short slot based on current ap caps
2031
2032 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2033
2034 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2035 // The difference between the earlier implementation and the new one is only Case4.
2036 /*
2037 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2038 Case1 1 1 1 1 //AP should not advertise this combination.
2039 Case2 1 1 0 0
2040 Case3 1 0 1 1
2041 Case4 1 0 0 0
2042 Case5 0 1 1 1
2043 Case6 0 1 0 0
2044 Case7 0 0 1 1
2045 Case8 0 0 0 0
2046 */
2047 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2048
Jeff Johnsone7245742012-09-05 17:12:55 -07002049 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 {
2051 // Short slot time capability of AP has changed. Adopt to it.
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302052 limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002054 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2056 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
2058 return eSIR_SUCCESS;
2059}
2060
2061
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
2063
Jeff Johnson295189b2012-06-20 16:38:30 -07002064
Jeff Johnson295189b2012-06-20 16:38:30 -07002065
2066
2067/** -----------------------------------------------------------------
2068 \brief limHandleLowRssiInd() - handles low rssi indication
2069
2070 This function process the SIR_HAL_LOW_RSSI_IND message from
2071 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2072
2073 \param pMac - global mac structure
2074
2075 \return
2076
2077 \sa
2078 ----------------------------------------------------------------- */
2079void limHandleLowRssiInd(tpAniSirGlobal pMac)
2080{
2081#if 0 //RSSI related indications will now go to TL and not PE
2082 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2083 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2084 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2085 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002086 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2088 }
2089 else
2090 {
2091 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002092 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 pMac->pmm.gPmmState);
2094 }
2095 return;
2096#endif
2097}
2098
2099
2100/** -----------------------------------------------------------------
2101 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2102
2103 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2104 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2105 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2106
2107 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2108 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2109 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2110 This message can also come from FW anytime after we have entered BMPS.
2111 This means we should handle it in WoWL and UAPSD states as well
2112
2113 \param pMac - global mac structure
2114 \return - none
2115 \sa
2116 ----------------------------------------------------------------- */
2117void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2118{
2119 switch(pMac->pmm.gPmmState)
2120 {
2121 case ePMM_STATE_BMPS_SLEEP:
2122 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2123 case ePMM_STATE_UAPSD_SLEEP:
2124 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2125 case ePMM_STATE_WOWLAN:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302126 limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2128 break;
2129
2130 default:
2131 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002132 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 pMac->pmm.gPmmState);
2134 break;
2135 }
2136 return;
2137}
2138
2139
2140/** -----------------------------------------------------------------
2141 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2142
2143 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2144 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2145 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2146
2147 \param pMac - global mac structure
2148 \return - none
2149 \sa
2150 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002151void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002152{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002153#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2154 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2155 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2156 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2157 if (psessionEntry == NULL)
2158 {
2159 limLog(pMac, LOGE,
2160 FL("session does not exist for given BSSIdx:%d"),
2161 pSirMissedBeaconInd->bssIdx);
2162 return;
2163 }
2164#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2166 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2167 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2168 {
2169 pMac->pmm.inMissedBeaconScenario = TRUE;
Madan Mohan Koyyalamudi1a30a552013-09-17 21:20:07 +05302170 PELOGE(limLog(pMac, LOGE,
2171 FL("Sending EXIT_BMPS_IND to SME due to Missed beacon from FW"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2173 }
Yathish9f22e662012-12-10 14:21:35 -08002174/* ACTIVE_MODE_HB_OFFLOAD */
2175#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2176 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2177 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2178 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2179 {
2180 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002181 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002182 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002183 }
2184#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 else
2186 {
2187 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002188 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 pMac->pmm.gPmmState);
2190 }
2191 return;
2192}
2193
2194/** -----------------------------------------------------------------
2195 \brief limMicFailureInd() - handles mic failure indication
2196
2197 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2198
2199 \param pMac - global mac structure
2200 \return - none
2201 \sa
2202 ----------------------------------------------------------------- */
2203void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2204{
2205 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2206 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2207 tSirMsgQ mmhMsg;
2208 tpPESession psessionEntry ;
2209 tANI_U8 sessionId;
2210
2211 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2212 {
2213 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002214 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 return;
2216 }
2217
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302218 pSirSmeMicFailureInd = vos_mem_malloc(sizeof(tSirSmeMicFailureInd));
2219 if (NULL == pSirSmeMicFailureInd)
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 {
2221 // Log error
2222 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002223 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 return;
2225 }
2226
2227 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
2228 pSirSmeMicFailureInd->length = sizeof(pSirSmeMicFailureInd);
2229 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2230
2231 vos_mem_copy(pSirSmeMicFailureInd->bssId,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302232 pSirMicFailureInd->bssId,
2233 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002234
2235 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302236 pSirMicFailureInd->info.srcMacAddr,
2237 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302240 pSirMicFailureInd->info.taMacAddr,
2241 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
2243 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302244 pSirMicFailureInd->info.dstMacAddr,
2245 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302248 pSirMicFailureInd->info.rxMacAddr,
2249 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002250
2251 pSirSmeMicFailureInd->info.multicast =
2252 pSirMicFailureInd->info.multicast;
2253
2254 pSirSmeMicFailureInd->info.keyId=
2255 pSirMicFailureInd->info.keyId;
2256
2257 pSirSmeMicFailureInd->info.IV1=
2258 pSirMicFailureInd->info.IV1;
2259
2260 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302261 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262
2263 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2264 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2265 mmhMsg.bodyval = 0;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002266 MTRACE(macTraceMsgTx(pMac, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2268 return;
2269}
2270
2271
2272/** -----------------------------------------------------------------
2273 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2274
2275 This function is called before enqueuing the frame to PE queue for further processing.
2276 This prevents unnecessary frames getting into PE Queue and drops them right away.
2277 Frames will be droped in the following scenarios:
2278
2279 - In Scan State, drop the frames which are not marked as scan frames
2280 - In non-Scan state, drop the frames which are marked as scan frames.
2281 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2282 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2283
2284 \param pMac - global mac structure
2285 \return - none
2286 \sa
2287 ----------------------------------------------------------------- */
2288
2289tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2290{
2291 tANI_U32 framelen;
2292 tANI_U8 *pBody;
2293 tSirMacCapabilityInfo capabilityInfo;
2294
2295 /*
2296 *
2297 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2298 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2299 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2300 * other than beacons or probe responses in scan state.
2301 */
2302 if( (subType == SIR_MAC_MGMT_BEACON) ||
2303 (subType == SIR_MAC_MGMT_PROBE_RSP))
2304 {
2305 if(pMac->pmm.inMissedBeaconScenario)
2306 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002307 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2308 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 }
2310 if (limIsSystemInScanState(pMac))
2311 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002312 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002314#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2315 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2316 {
2317 return eMGMT_DROP_NO_DROP;
2318 }
2319#endif
Dino Mycle7a76e662014-06-10 11:36:34 +05302320#ifdef WLAN_FEATURE_EXTSCAN
2321 else if (WDA_GET_EXTSCANFULLSCANRESIND(pRxPacketInfo))
2322 {
2323 return eMGMT_DROP_NO_DROP;
2324 }
2325#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2327 {
2328 return eMGMT_DROP_SCAN_MODE_FRAME;
2329 }
2330 }
2331
2332 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2333 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2334
2335 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2336 * beacons from an infrastructure network
2337 */
2338 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2339 if(!capabilityInfo.ibss)
2340 return eMGMT_DROP_NO_DROP;
2341#if 0
2342 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2343 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2344 return eMGMT_DROP_NO_DROP;
2345#endif
2346
2347 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2348 if( (subType == SIR_MAC_MGMT_BEACON) ||
2349 (subType == SIR_MAC_MGMT_PROBE_RSP))
2350 {
2351 //drop the frame if length is less than 12
2352 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2353 return eMGMT_DROP_INVALID_SIZE;
2354
2355 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2356
2357 //This can be enhanced to even check the SSID before deciding to enque the frame.
2358 if(capabilityInfo.ess)
2359 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2360 }
2361 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2362 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2363 {
2364 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2365 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2366 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2367 }
2368
2369 return eMGMT_DROP_NO_DROP;
2370}
2371
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002372eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2373{
2374 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002375
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002376 if(psPe)
2377 {
2378 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2379 {
2380 status = eHAL_STATUS_SUCCESS;
2381 }
2382 }
2383 return (status);
2384}
2385eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2386{
2387 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2388 if(psPe)
2389 {
2390 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2391 {
2392 status = eHAL_STATUS_SUCCESS;
2393 }
2394 }
2395 return (status);
2396}