blob: 64b0bd6dea229ecb221f375b44aa2abdc0e8ffd5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Manjeet Singh3ed79242017-01-11 19:04:32 +05302 * Copyright (c) 2011-2017 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;
Ganesh Kondabattini10e67352015-03-16 17:41:57 +0530354 pMac->lim.txBdToken = 0;
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530355
356 pMac->lim.EnableTdls2040BSSCoexIE = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700357}
358
359static void __limInitAssocVars(tpAniSirGlobal pMac)
360{
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800361 tANI_U32 val;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800362#if 0
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530363 vos_mem_set(pMac->lim.gpLimAIDpool,
364 sizeof(*pMac->lim.gpLimAIDpool) * (WNI_CFG_ASSOC_STA_LIMIT_STAMAX+1), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 pMac->lim.freeAidHead = 0;
366 pMac->lim.freeAidTail = 0;
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800367#endif
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800368 if(wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val) != eSIR_SUCCESS)
369 {
370 limLog( pMac, LOGP, FL( "cfg get assoc sta limit failed" ));
371 }
372 pMac->lim.gLimAssocStaLimit = val;
Ravi Joshi0fc681b2013-09-11 16:46:07 -0700373 pMac->lim.gLimIbssStaLimit = val;
Jeff Johnson295189b2012-06-20 16:38:30 -0700374
375 // Place holder for current authentication request
376 // being handled
377 pMac->lim.gpLimMlmAuthReq = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -0700378 //pMac->lim.gpLimMlmJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
380 /// MAC level Pre-authentication related globals
381 pMac->lim.gLimPreAuthChannelNumber = 0;
382 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530383 vos_mem_set(&pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 pMac->lim.gLimNumPreAuthContexts = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530385 vos_mem_set(&pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700386
387 // Placed holder to deauth reason
388 pMac->lim.gLimDeauthReasonCode = 0;
389
390 // Place holder for Pre-authentication node list
391 pMac->lim.pLimPreAuthList = NULL;
392
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 //One cache for each overlap and associated case.
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530394 vos_mem_set(pMac->lim.protStaOverlapCache,
395 sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE, 0);
396 vos_mem_set(pMac->lim.protStaCache,
397 sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700398
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800399#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -0700400 pMac->lim.pSessionEntry = NULL;
401 pMac->lim.reAssocRetryAttempt = 0;
402#endif
403
Jeff Johnson295189b2012-06-20 16:38:30 -0700404}
405
406
407static void __limInitTitanVars(tpAniSirGlobal pMac)
408{
Jeff Johnsone7245742012-09-05 17:12:55 -0700409#if 0
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530410 vos_mem_set(&pMac->lim.gLimChannelSwitch, sizeof(tLimChannelSwitchInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 pMac->lim.gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700412 pMac->lim.gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 // Debug workaround for BEACON's
415 // State change triggered by "dump 222"
416 pMac->lim.gLimScanOverride = 1;
417 pMac->lim.gLimScanOverrideSaved = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 pMac->lim.gLimTitanStaCount = 0;
419 pMac->lim.gLimBlockNonTitanSta = 0;
420}
421
422static void __limInitHTVars(tpAniSirGlobal pMac)
423{
424 pMac->lim.htCapabilityPresentInBeacon = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 pMac->lim.gHTGreenfield = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 pMac->lim.gHTShortGI40Mhz = 0;
427 pMac->lim.gHTShortGI20Mhz = 0;
428 pMac->lim.gHTMaxAmsduLength = 0;
429 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
430 pMac->lim.gHTPSMPSupport = 0;
431 pMac->lim.gHTLsigTXOPProtection = 0;
432 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
433 pMac->lim.gHTAMpduDensity = 0;
434
435 pMac->lim.gMaxAmsduSizeEnabled = false;
436 pMac->lim.gHTMaxRxAMpduFactor = 0;
437 pMac->lim.gHTServiceIntervalGranularity = 0;
438 pMac->lim.gHTControlledAccessOnly = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
440 pMac->lim.gHTPCOActive = 0;
441
442 pMac->lim.gHTPCOPhase = 0;
443 pMac->lim.gHTSecondaryBeacon = 0;
444 pMac->lim.gHTDualCTSProtection = 0;
445 pMac->lim.gHTSTBCBasicMCS = 0;
446 pMac->lim.gAddBA_Declined = 0; // Flag to Decline the BAR if the particular bit (0-7) is being set
Sreelakshmi Konamki60ccfb32016-07-08 12:53:12 +0530447 vos_mem_set(&pMac->lim.staBaInfo, sizeof(pMac->lim.staBaInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700448}
449
Jeff Johnson295189b2012-06-20 16:38:30 -0700450static tSirRetStatus __limInitConfig( tpAniSirGlobal pMac )
451{
Jeff Johnsone7245742012-09-05 17:12:55 -0700452 tANI_U32 val1, val2, val3;
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 tANI_U16 val16;
454 tANI_U8 val8;
455 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
456 tSirMacHTInfoField1 *pHTInfoField1;
457 tpSirPowerSaveCfg pPowerSaveConfig;
458 tSirMacHTParametersInfo *pAmpduParamInfo;
459
460 /* Read all the CFGs here that were updated before peStart is called */
Jeff Johnsone7245742012-09-05 17:12:55 -0700461 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
462 * and they will be used throughout when there is no session
463 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700464
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
466 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700467 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return eSIR_FAILURE;
469 }
470
471 if(wlan_cfgGetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) != eSIR_SUCCESS)
472 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700473 PELOGE(limLog(pMac, LOGE, FL("could not retrieve Channel Bonding CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 return eSIR_FAILURE;
475 }
476 val16 = ( tANI_U16 ) val1;
477 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
478
479 //channel bonding mode could be set to anything from 0 to 4(Titan had these
480 // modes But for Taurus we have only two modes: enable(>0) or disable(=0)
481 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
482 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE : WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
483 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo)
484 != eSIR_SUCCESS)
485 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700486 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return eSIR_FAILURE;
488 }
489
490 if(wlan_cfgGetInt(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != eSIR_SUCCESS)
491 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700492 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT INFO Field1 CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 return eSIR_FAILURE;
494 }
495
496 val8 = ( tANI_U8 ) val1;
497 pHTInfoField1 = ( tSirMacHTInfoField1* ) &val8;
498 pHTInfoField1->recommendedTxWidthSet =
499 (tANI_U8)pHTCapabilityInfo->supportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 if(cfgSetInt(pMac, WNI_CFG_HT_INFO_FIELD1, *(tANI_U8*)pHTInfoField1)
501 != eSIR_SUCCESS)
502 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700503 PELOGE(limLog(pMac, LOGE, FL("could not update HT Info Field"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 return eSIR_FAILURE;
505 }
506
507 /* WNI_CFG_HEART_BEAT_THRESHOLD */
508
509 if( wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
510 eSIR_SUCCESS )
511 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700512 PELOGE(limLog(pMac, LOGE, FL("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 return eSIR_FAILURE;
514 }
515 if(!val1)
516 {
517 limDeactivateAndChangeTimer(pMac, eLIM_HEART_BEAT_TIMER);
518 pMac->sys.gSysEnableLinkMonitorMode = 0;
519 }
520 else
521 {
522 //No need to activate the timer during init time.
523 pMac->sys.gSysEnableLinkMonitorMode = 1;
524 }
525
526 /* WNI_CFG_SHORT_GI_20MHZ */
527
528 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &val1) != eSIR_SUCCESS)
529 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700530 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT Cap CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 return eSIR_FAILURE;
532 }
533 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_20MHZ, &val2) != eSIR_SUCCESS)
534 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700535 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 return eSIR_FAILURE;
537 }
538 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_GI_40MHZ, &val3) != eSIR_SUCCESS)
539 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700540 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 return eSIR_FAILURE;
542 }
543
544 val16 = ( tANI_U16 ) val1;
545 pHTCapabilityInfo = ( tSirMacHTCapabilityInfo* ) &val16;
546 pHTCapabilityInfo->shortGI20MHz = (tANI_U16)val2;
547 pHTCapabilityInfo->shortGI40MHz = (tANI_U16)val3;
548
549 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) !=
550 eSIR_SUCCESS)
551 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700552 PELOGE(limLog(pMac, LOGE, FL("could not update HT Cap Info CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 return eSIR_FAILURE;
554 }
555
556 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
557
558 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) != eSIR_SUCCESS)
559 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700560 PELOGE(limLog(pMac, LOGE, FL("could not retrieve HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 return eSIR_FAILURE;
562 }
563 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) != eSIR_SUCCESS)
564 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700565 PELOGE(limLog(pMac, LOGE, FL("could not retrieve AMPDU Factor CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 return eSIR_FAILURE;
567 }
568 val16 = ( tANI_U16 ) val1;
569 pAmpduParamInfo = ( tSirMacHTParametersInfo* ) &val16;
570 pAmpduParamInfo->maxRxAMPDUFactor = (tANI_U8)val2;
571 if(cfgSetInt(pMac, WNI_CFG_HT_AMPDU_PARAMS, *(tANI_U8*)pAmpduParamInfo) !=
572 eSIR_SUCCESS)
573 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700574 PELOGE(limLog(pMac, LOGE, FL("could not update HT AMPDU Param CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 return eSIR_FAILURE;
576 }
577
578 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
579 limHandleCFGparamUpdate do we want to update this? */
580 if(wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != eSIR_SUCCESS)
581 {
Shake M Subhani5d80fda2013-12-09 17:28:23 +0530582 limLog(pMac, LOGE, FL("cfg get short preamble failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 return eSIR_FAILURE;
584 }
585
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 /* WNI_CFG_MAX_PS_POLL */
587
588 /* Allocate and fill in power save configuration. */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530589 pPowerSaveConfig = vos_mem_malloc(sizeof(tSirPowerSaveCfg));
590 if (NULL == pPowerSaveConfig)
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 {
592 PELOGE(limLog(pMac, LOGE, FL("LIM: Cannot allocate memory for power save "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700593 "configuration"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 return eSIR_FAILURE;
595 }
596
597 /* This context should be valid if power-save configuration message has been
598 * already dispatched during initialization process. Re-using the present
599 * configuration mask
600 */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530601 vos_mem_copy(pPowerSaveConfig, (tANI_U8 *)&pMac->pmm.gPmmCfg, sizeof(tSirPowerSaveCfg));
Jeff Johnson295189b2012-06-20 16:38:30 -0700602
603 /* Note: it is okay to do this since DAL/HAL is alrady started */
604 if ( (pmmSendPowerSaveCfg(pMac, pPowerSaveConfig)) != eSIR_SUCCESS)
605 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700606 PELOGE(limLog(pMac, LOGE, FL("LIM: pmmSendPowerSaveCfg() failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 return eSIR_FAILURE;
608 }
609
610 /* WNI_CFG_BG_SCAN_CHANNEL_LIST_CHANNEL_LIST */
611
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700613 FL("VALID_CHANNEL_LIST has changed, reset next bg scan channel"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 pMac->lim.gLimBackgroundScanChannelId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
616 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
617
618 /* This was initially done after resume notification from HAL. Now, DAL is
619 started before PE so this can be done here */
Jeff Johnsone7245742012-09-05 17:12:55 -0700620 handleHTCapabilityandHTInfo(pMac, NULL);
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800621 if(wlan_cfgGetInt(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,(tANI_U32 *) &pMac->lim.disableLDPCWithTxbfAP) != eSIR_SUCCESS)
622 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700623 limLog(pMac, LOGP, FL("cfg get disableLDPCWithTxbfAP failed"));
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -0800624 return eSIR_FAILURE;
625 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530626#ifdef FEATURE_WLAN_TDLS
627 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_BUF_STA_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSBufStaEnabled) != eSIR_SUCCESS)
628 {
629 limLog(pMac, LOGP, FL("cfg get LimTDLSBufStaEnabled failed"));
630 return eSIR_FAILURE;
631 }
632 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_QOS_WMM_UAPSD_MASK,(tANI_U32 *) &pMac->lim.gLimTDLSUapsdMask) != eSIR_SUCCESS)
633 {
634 limLog(pMac, LOGP, FL("cfg get LimTDLSUapsdMask failed"));
635 return eSIR_FAILURE;
636 }
Naresh Jayaramf73f3762014-02-04 16:13:20 +0530637 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_OFF_CHANNEL_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSOffChannelEnabled) != eSIR_SUCCESS)
638 {
639 limLog(pMac, LOGP, FL("cfg get LimTDLSUapsdMask failed"));
640 return eSIR_FAILURE;
641 }
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +0530642
643 if(wlan_cfgGetInt(pMac, WNI_CFG_TDLS_WMM_MODE_ENABLED,(tANI_U32 *) &pMac->lim.gLimTDLSWmmMode) != eSIR_SUCCESS)
644 {
645 limLog(pMac, LOGP, FL("cfg get LimTDLSWmmMode failed"));
646 return eSIR_FAILURE;
647 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530648#endif
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +0530649
Rashmi Ramannac7744532013-10-06 16:49:08 +0530650 if (eSIR_SUCCESS !=
651 wlan_cfgGetInt(pMac, WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL,
652 (tANI_U32 *)&pMac->lim.gDebugP2pRemainOnChannel))
653 {
654 limLog( pMac, LOGE,
655 "%s: Couldn't get WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL value",
656 __func__);
657 pMac->lim.gDebugP2pRemainOnChannel = 0;
658 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 return eSIR_SUCCESS;
660}
Jeff Johnson295189b2012-06-20 16:38:30 -0700661
662/*
663 limStart
664 This function is to replace the __limProcessSmeStartReq since there is no
665 eWNI_SME_START_REQ post to PE.
666*/
667tSirRetStatus limStart(tpAniSirGlobal pMac)
668{
669 tSirResultCodes retCode = eSIR_SUCCESS;
670
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530671 limLog(pMac, LOG1, FL(" enter"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700672
673 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
674 {
675 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
676
Jeff Johnsone7245742012-09-05 17:12:55 -0700677 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700678
679 // By default do not return after first scan match
680 pMac->lim.gLimReturnAfterFirstMatch = 0;
681
682 // Initialize MLM state machine
683 limInitMlm(pMac);
684
685 // By default return unique scan results
686 pMac->lim.gLimReturnUniqueResults = true;
687 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700688#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
689 pMac->lim.gLimSmeLfrScanResultLength = 0;
690#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 }
692 else
693 {
694 /**
695 * Should not have received eWNI_SME_START_REQ in states
696 * other than OFFLINE. Return response to host and
697 * log error
698 */
Sushant Kaushik1b645382014-10-13 16:39:36 +0530699 limLog(pMac, LOGE, FL("Invalid SME state %d"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 retCode = eSIR_FAILURE;
701 }
702
703 return retCode;
704}
705
Kapil Gupta956c0c42017-06-16 19:24:31 +0530706static void
707limInitAssocRspCompletiontionList(tpAniSirGlobal pMac)
708{
709 vos_list_init(&pMac->assoc_rsp_completion_list);
710}
711
712static void
713limDestroyAssocRspCompletiontionList(tpAniSirGlobal pMac)
714{
715 vos_list_destroy(&pMac->assoc_rsp_completion_list);
716}
717
Jeff Johnson295189b2012-06-20 16:38:30 -0700718/**
719 * limInitialize()
720 *
721 *FUNCTION:
722 * This function is called from LIM thread entry function.
723 * LIM related global data structures are initialized in this function.
724 *
725 *LOGIC:
726 * NA
727 *
728 *ASSUMPTIONS:
729 * NA
730 *
731 *NOTE:
732 * NA
733 *
734 * @param pMac - Pointer to global MAC structure
735 * @return None
736 */
737
738tSirRetStatus
739limInitialize(tpAniSirGlobal pMac)
740{
741 tSirRetStatus status = eSIR_SUCCESS;
742
743 __limInitAssocVars(pMac);
744 __limInitVars(pMac);
745 __limInitStates(pMac);
746 __limInitStatsVars(pMac);
747 __limInitBssVars(pMac);
748 __limInitScanVars(pMac);
749 __limInitHTVars(pMac);
750 __limInitTitanVars(pMac);
751
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 status = limStart(pMac);
753 if(eSIR_SUCCESS != status)
754 {
755 return status;
756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757
758 /*
759 * MLM will be intitalized when 'START' request comes from SME.
760 * limInitMlm calls limCreateTimers, which actually relies on
761 * CFG to be downloaded. So it should not be called as part of
762 * peStart, as CFG download is happening after peStart.
763 */
764 //limInitMlm(pMac);
765 // Initializations for maintaining peers in IBSS
766 limIbssInit(pMac);
767
Kapil Gupta956c0c42017-06-16 19:24:31 +0530768 limInitAssocRspCompletiontionList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 pmmInitialize(pMac);
770
771
772#if defined WLAN_FEATURE_VOWIFI
773 rrmInitialize(pMac);
774#endif
775#if defined WLAN_FEATURE_VOWIFI_11R
776 limFTOpen(pMac);
777#endif
778
Abhishek Singh00b71972016-01-07 10:51:04 +0530779#ifdef WLAN_FEATURE_RMC
780 limRmcInit(pMac);
781#endif /* WLAN_FEATURE_RMC */
782
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784
785#if 0
786
787 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
788 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
789 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
790
791 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
792 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
793
794 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
795 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
796 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
797
798 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
799
800 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
801
802 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
803 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
804
805 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
806
807
808 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
809
810 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
811#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 //Initialize the configurations needed by PE
814 if( eSIR_FAILURE == __limInitConfig(pMac))
815 {
816 //We need to undo everything in limStart
817 limCleanupMlm(pMac);
818 return eSIR_FAILURE;
819 }
820
821 //initialize the TSPEC admission control table.
822 //Note that this was initially done after resume notification from HAL.
823 //Now, DAL is started before PE so this can be done here
824 limAdmitControlInit(pMac);
825 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 return status;
828
829} /*** end limInitialize() ***/
830
831
832
833/**
834 * limCleanup()
835 *
836 *FUNCTION:
837 * This function is called upon reset or persona change
838 * to cleanup LIM state
839 *
840 *LOGIC:
841 * NA
842 *
843 *ASSUMPTIONS:
844 * NA
845 *
846 *NOTE:
847 * NA
848 *
849 * @param pMac - Pointer to Global MAC structure
850 * @return None
851 */
852
853void
854limCleanup(tpAniSirGlobal pMac)
855{
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 v_PVOID_t pvosGCTx;
857 VOS_STATUS retStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700858
Jeff Johnson295189b2012-06-20 16:38:30 -0700859//Before destroying the list making sure all the nodes have been deleted.
860//Which should be the normal case, but a memory leak has been reported.
861
862 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
863
864 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
865 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
866 {
867 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
868 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
869
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530870 vos_mem_free(pLimMgmtRegistration);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 }
872
873 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700874
875 limCleanupMlm(pMac);
876 limCleanupLmm(pMac);
877
Abhishek Singh00b71972016-01-07 10:51:04 +0530878#ifdef WLAN_FEATURE_RMC
879 limRmcCleanup(pMac);
880#endif /* WLAN_FEATURE_RMC */
881
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 // free up preAuth table
883 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
884 {
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530885 vos_mem_vfree(pMac->lim.gLimPreAuthTimerTable.pTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
887 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
888 }
889
890 if(NULL != pMac->lim.pDialogueTokenHead)
891 {
892 limDeleteDialogueTokenList(pMac);
893 }
894
895 if(NULL != pMac->lim.pDialogueTokenTail)
896 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530897 vos_mem_free(pMac->lim.pDialogueTokenTail);
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 pMac->lim.pDialogueTokenTail = NULL;
899 }
900
901 # if 0
902 if (pMac->lim.gpLimStartBssReq != NULL)
903 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530904 vos_mem_free(pMac->lim.gpLimStartBssReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 pMac->lim.gpLimStartBssReq = NULL;
906 }
907 #endif
908
909 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
910 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530911 vos_mem_free(pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 pMac->lim.gpLimMlmSetKeysReq = NULL;
913 }
914
915 #if 0
916 if (pMac->lim.gpLimJoinReq != NULL)
917 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530918 vos_mem_free(pMac->lim.gpLimJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 pMac->lim.gpLimJoinReq = NULL;
920 }
921 #endif
922
923 if (pMac->lim.gpLimMlmAuthReq != NULL)
924 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530925 vos_mem_free(pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 pMac->lim.gpLimMlmAuthReq = NULL;
927 }
928
Jeff Johnsone7245742012-09-05 17:12:55 -0700929#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 if (pMac->lim.gpLimMlmJoinReq != NULL)
931 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530932 vos_mem_free(pMac->lim.gpLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 pMac->lim.gpLimMlmJoinReq = NULL;
934 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700935#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700936
937 #if 0
938 if (pMac->lim.gpLimReassocReq != NULL)
939 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530940 vos_mem_free(pMac->lim.gpLimReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 pMac->lim.gpLimReassocReq = NULL;
942 }
943 #endif
944
945 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
946 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530947 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
949 }
950
Viral Modid440e682013-03-06 02:25:31 -0800951 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
Viral Modid86bde22012-12-10 13:09:21 -0800952 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530953 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -0800954 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800955 }
Viral Modid86bde22012-12-10 13:09:21 -0800956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 if (pMac->lim.gpLimMlmScanReq != NULL)
958 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530959 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 pMac->lim.gpLimMlmScanReq = NULL;
961 }
Kapil Gupta956c0c42017-06-16 19:24:31 +0530962 limDestroyAssocRspCompletiontionList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700963#if 0
964 if(NULL != pMac->lim.beacon)
965 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530966 vos_mem_free((void*) pMac->lim.beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 pMac->lim.beacon = NULL;
968 }
969#endif
970 #if 0
971 if(NULL != pMac->lim.assocReq)
972 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530973 vos_mem_free((void*) pMac->lim.assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 pMac->lim.assocReq= NULL;
975 }
976 #endif
977
978#if 0
979 if(NULL != pMac->lim.assocRsp)
980 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530981 vos_mem_free((void*) pMac->lim.assocRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 pMac->lim.assocRsp= NULL;
983 }
984#endif
985 // Now, finally reset the deferred message queue pointers
986 limResetDeferredMsgQ(pMac);
987
Jeff Johnson295189b2012-06-20 16:38:30 -0700988
989 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
990 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
991
992 if ( retStatus != VOS_STATUS_SUCCESS )
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700993 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700994
995#if defined WLAN_FEATURE_VOWIFI
996 rrmCleanup(pMac);
997#endif
998#if defined WLAN_FEATURE_VOWIFI_11R
999 limFTCleanup(pMac);
1000#endif
1001
1002} /*** end limCleanup() ***/
1003
1004
1005/** -------------------------------------------------------------
1006\fn peOpen
1007\brief will be called in Open sequence from macOpen
1008\param tpAniSirGlobal pMac
1009\param tHalOpenParameters *pHalOpenParam
1010\return tSirRetStatus
1011 -------------------------------------------------------------*/
1012
1013tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
1014{
Kaushik, Sushant16def7c2014-06-17 14:20:49 +05301015 if (eDRIVER_TYPE_MFG == pMacOpenParam->driverType)
1016 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
1018 pMac->lim.maxStation = pMacOpenParam->maxStation;
Katya Nigam53799202014-12-18 15:59:38 +05301019 vos_spin_lock_init( &pMac->sys.lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001020
1021 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
1022 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001023 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 return eSIR_FAILURE;
1025 }
1026
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301027 pMac->lim.limTimers.gpLimCnfWaitTimer = vos_mem_vmalloc(sizeof(TX_TIMER) * pMac->lim.maxStation);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301028 if (NULL == pMac->lim.limTimers.gpLimCnfWaitTimer)
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001030 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 return eSIR_FAILURE;
1032 }
1033
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301034 pMac->lim.gpSession = vos_mem_vmalloc(sizeof(tPESession)* pMac->lim.maxBssId);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301035 if (NULL == pMac->lim.gpSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001037 limLog(pMac, LOGE, FL("memory allocate failed!"));
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301038 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 return eSIR_FAILURE;
1040 }
1041
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301042 vos_mem_set(pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301044 pMac->pmm.gPmmTim.pTim = vos_mem_malloc(sizeof(tANI_U8)*pMac->lim.maxStation);
1045 if (NULL == pMac->pmm.gPmmTim.pTim)
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001047 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!"));)
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301048 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
1049 vos_mem_vfree(pMac->lim.gpSession);
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 return eSIR_FAILURE;
1051 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301052 vos_mem_set(pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001053
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001054 pMac->lim.mgmtFrameSessionId = 0xff;
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001055 pMac->lim.deferredMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001056
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001057 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1058 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001059 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!"));)
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301060 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
Leela Venkata Kiran Kumar Reddy Chiralabcf1b8b2013-12-16 17:13:52 -08001061 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301062 vos_mem_vfree(pMac->lim.gpSession);
Leela Venkata Kiran Kumar Reddy Chiralabcf1b8b2013-12-16 17:13:52 -08001063 pMac->lim.gpSession = NULL;
1064 vos_mem_free(pMac->pmm.gPmmTim.pTim);
1065 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001066 return eSIR_FAILURE;
1067 }
Venkata Prathyusha Kuntupalli22ba5982013-04-24 13:09:20 -07001068 pMac->lim.deauthMsgCnt = 0;
Agarwal Ashishb4ce9922014-11-04 18:40:38 +05301069 pMac->lim.retryPacketCnt = 0;
Sushant Kaushike06bd872015-03-12 16:17:48 +05301070 pMac->lim.gLimIbssRetryCnt = 0;
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07001071
1072 /*
1073 * peOpen is successful by now, so it is right time to initialize
1074 * MTRACE for PE module. if LIM_TRACE_RECORD is not defined in build file
1075 * then nothing will be logged for PE module.
1076 */
1077#ifdef LIM_TRACE_RECORD
1078 MTRACE(limTraceInit(pMac));
1079#endif
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +05301080 lim_register_debug_callback();
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 return eSIR_SUCCESS;
1082}
1083
1084/** -------------------------------------------------------------
1085\fn peClose
1086\brief will be called in close sequence from macClose
1087\param tpAniSirGlobal pMac
1088\return tSirRetStatus
1089 -------------------------------------------------------------*/
1090
1091tSirRetStatus peClose(tpAniSirGlobal pMac)
1092{
1093 tANI_U8 i;
1094
1095 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1096 return eSIR_SUCCESS;
Katya Nigam53799202014-12-18 15:59:38 +05301097
1098 vos_spin_lock_destroy( &pMac->sys.lock );
1099
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 for(i =0; i < pMac->lim.maxBssId; i++)
1101 {
1102 if(pMac->lim.gpSession[i].valid == TRUE)
1103 {
1104 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1105 }
1106 }
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301107 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
Jeff Johnsone7245742012-09-05 17:12:55 -07001108 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301109 vos_mem_vfree(pMac->lim.gpSession);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 pMac->lim.gpSession = NULL;
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301111
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301112 vos_mem_free(pMac->pmm.gPmmTim.pTim);
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001114 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1115 {
1116 return eSIR_FAILURE;
1117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 return eSIR_SUCCESS;
1119}
1120
1121/** -------------------------------------------------------------
1122\fn peStart
1123\brief will be called in start sequence from macStart
1124\param tpAniSirGlobal pMac
1125\return none
1126 -------------------------------------------------------------*/
1127
1128tSirRetStatus peStart(tpAniSirGlobal pMac)
1129{
1130 tSirRetStatus status = eSIR_SUCCESS;
1131
1132 status = limInitialize(pMac);
1133#if defined(ANI_LOGDUMP)
1134 limDumpInit(pMac);
1135#endif //#if defined(ANI_LOGDUMP)
1136
1137 return status;
1138}
1139
1140/** -------------------------------------------------------------
1141\fn peStop
1142\brief will be called in stop sequence from macStop
1143\param tpAniSirGlobal pMac
1144\return none
1145 -------------------------------------------------------------*/
1146
1147void peStop(tpAniSirGlobal pMac)
1148{
1149 limCleanup(pMac);
1150 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1151 return;
1152}
1153
1154/** -------------------------------------------------------------
1155\fn peFreeMsg
1156\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1157\ to free a given PE message on the TX and MC thread.
1158\ This happens when there are messages pending in the PE
1159\ queue when system is being stopped and reset.
1160\param tpAniSirGlobal pMac
1161\param tSirMsgQ pMsg
1162\return none
1163-----------------------------------------------------------------*/
1164v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1165{
1166 if (pMsg != NULL)
1167 {
1168 if (NULL != pMsg->bodyptr)
1169 {
1170 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1171 {
1172 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1173 }
1174 else
1175 {
1176 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1177 }
1178 }
1179 pMsg->bodyptr = 0;
1180 pMsg->bodyval = 0;
1181 pMsg->type = 0;
1182 }
1183 return;
1184}
1185
1186
1187/**
1188 * The function checks if a particular timer should be allowed
1189 * into LIM while device is sleeping
1190 */
1191tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1192{
1193 tANI_U8 retStatus = TRUE;
1194
1195 if(!limIsSystemInActiveState(pMac))
1196 {
1197 switch(pMsg->type)
1198 {
1199 /* Don't allow following timer messages if in sleep */
1200 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1201 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1202 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1203 retStatus = FALSE;
1204 break;
1205 /* May allow following timer messages in sleep mode */
Jeff Johnson295189b2012-06-20 16:38:30 -07001206
1207 /* Safe to allow as of today, this triggers background scan
1208 * which will not be started if the device is in power-save mode
1209 * might need to block in the future if we decide to implement
1210 * spectrum management
1211 */
1212 case SIR_LIM_QUIET_TIMEOUT:
1213
1214 /* Safe to allow as of today, this triggers background scan
1215 * which will not be started if the device is in power-save mode
1216 * might need to block in the future if we decide to implement
1217 * spectrum management
1218 */
1219 case SIR_LIM_QUIET_BSS_TIMEOUT:
1220
1221 /* Safe to allow this timermessage, triggers background scan
1222 * which is blocked in sleep mode
1223 */
1224 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1225
1226 /* Safe to allow this timer, since, while in IMPS this timer will not
1227 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1228 * when heart-beat control is handled back to PE, device would have
1229 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1230 */
1231 case SIR_LIM_HEART_BEAT_TIMEOUT:
1232 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1233
1234 /* Safe to allow, PE is not handling this message as of now. May need
1235 * to block it, basically, free the buffer and restart the timer
1236 */
1237 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1238 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001239 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1241 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1242 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Sushant Kaushik9e923872015-04-02 17:09:31 +05301243 case SIR_LIM_AUTH_RETRY_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 retStatus = TRUE;
1245 break;
1246
1247 /* by default allow rest of messages */
1248 default:
1249 retStatus = TRUE;
1250 break;
1251
1252
1253 }
1254 }
1255
1256 return retStatus;
1257
1258}
1259
1260
1261
1262/**
1263 * limPostMsgApi()
1264 *
1265 *FUNCTION:
1266 * This function is called from other thread while posting a
1267 * message to LIM message Queue gSirLimMsgQ.
1268 *
1269 *LOGIC:
1270 * NA
1271 *
1272 *ASSUMPTIONS:
1273 * NA
1274 *
1275 *NOTE:
1276 * NA
1277 *
1278 * @param pMac - Pointer to Global MAC structure
1279 * @param pMsg - Pointer to the message structure
1280 * @return None
1281 */
1282
1283tANI_U32
1284limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1285{
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1287
1288
Jeff Johnson295189b2012-06-20 16:38:30 -07001289} /*** end limPostMsgApi() ***/
1290
Padma, Santhosh Kumarb036fc72015-11-13 16:22:23 +05301291/**
1292 * limPostMsgApiHighPri()
1293 *
1294 * FUNCTION:
1295 * This function is called from other thread while posting a
1296 * message to LIM message Queue gSirLimMsgQ.
1297 *
1298 * LOGIC:
1299 * NA
1300 *
1301 * ASSUMPTIONS:
1302 * NA
1303 *
1304 * NOTE:
1305 * NA
1306 *
1307 * @param pMac - Pointer to Global MAC structure
1308 * @param pMsg - Pointer to the message structure
1309 * @return None
1310 */
1311
1312tANI_U32
1313limPostMsgApiHighPri(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1314{
1315 return vos_mq_post_message_high_pri(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1316
1317
1318} /*** end limPostMsgApi() ***/
1319
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
1321/*--------------------------------------------------------------------------
1322
1323 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1324
1325 This function can be called by legacy code to post message to voss queues OR
1326 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1327 for dispatching it later.
1328
1329 \param pMac - Pointer to Global MAC structure
1330 \param pMsg - Pointer to the message structure
1331
1332 \return tANI_U32 - TX_SUCCESS for success.
1333
1334 --------------------------------------------------------------------------*/
1335
1336tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1337{
1338 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1339}
1340
1341/*--------------------------------------------------------------------------
1342
1343 \brief peProcessMessages() - Message Processor for PE
1344
1345 Voss calls this function to dispatch the message to PE
1346
1347 \param pMac - Pointer to Global MAC structure
1348 \param pMsg - Pointer to the message structure
1349
1350 \return tANI_U32 - TX_SUCCESS for success.
1351
1352 --------------------------------------------------------------------------*/
1353
1354tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1355{
1356 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1357 {
1358 return eSIR_SUCCESS;
1359 }
1360 /**
1361 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1362 * for all the other cases post it to LIM
1363 */
1364 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1365 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1366 else
1367 limMessageProcessor(pMac, pMsg);
1368 return eSIR_SUCCESS;
1369}
1370
Katya Nigam53799202014-12-18 15:59:38 +05301371#define RSRVD_MGMT_RX_PACKETS 10
Jeff Johnson295189b2012-06-20 16:38:30 -07001372
1373// ---------------------------------------------------------------------------
1374/**
1375 * peHandleMgmtFrame
1376 *
1377 * FUNCTION:
1378 * Process the Management frames from TL
1379 *
1380 * LOGIC:
1381 *
1382 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1383 *
1384 * NOTE:
1385 *
1386 * @param pvosGCtx Global Vos Context
1387 * @param vossBuff Packet
1388 * @return None
1389 */
1390
1391VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1392{
1393 tpAniSirGlobal pMac;
1394 tpSirMacMgmtHdr mHdr;
1395 tSirMsgQ msg;
1396 vos_pkt_t *pVosPkt;
1397 VOS_STATUS vosStatus;
1398 v_U8_t *pRxPacketInfo;
1399
1400 pVosPkt = (vos_pkt_t *)vosBuff;
1401 if (NULL == pVosPkt)
1402 {
1403 return VOS_STATUS_E_FAILURE;
1404 }
1405
1406 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1407 if (NULL == pMac)
1408 {
1409 // cannot log a failure without a valid pMac
1410 vos_pkt_return_packet(pVosPkt);
1411 return VOS_STATUS_E_FAILURE;
1412 }
1413
1414 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1415
1416 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1417 {
1418 vos_pkt_return_packet(pVosPkt);
1419 return VOS_STATUS_E_FAILURE;
1420 }
1421
1422
1423 //
1424 // The MPDU header is now present at a certain "offset" in
1425 // the BD and is specified in the BD itself
1426 //
1427 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1428 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1429 {
1430 PELOG1(limLog( pMac, LOG1,
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001431 FL ( "RxBd=%pK mHdr=%pK Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001432 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +05301434#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1435 if (WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
1436 limLog(pMac, LOG1, FL("roamCandidateInd %d"),
1437 WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo));
1438
1439 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
1440 limLog(pMac, LOG1, FL("offloadScanLearn %d"),
1441 WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo));
1442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 }
1444
1445
1446 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1447 msg.type = SIR_BB_XPORT_MGMT_MSG;
1448 msg.bodyptr = vosBuff;
1449 msg.bodyval = 0;
1450
Katya Nigam53799202014-12-18 15:59:38 +05301451 vos_spin_lock_acquire( &pMac->sys.lock );
1452 if( pMac->sys.gSysBbtPendingMgmtCount > (vos_pkt_get_num_of_rx_raw_pkts()/4) )
1453 {
1454 vos_spin_lock_release( &pMac->sys.lock );
1455 // drop all management packets
Katya Nigamfdf5a522015-02-03 14:38:55 +05301456 limLog( pMac, LOGW,
1457 FL ( "Management queue 1/4th full, dropping management packets" ));
Katya Nigam53799202014-12-18 15:59:38 +05301458 vos_pkt_return_packet(pVosPkt);
1459 return VOS_STATUS_SUCCESS;
1460 }
1461
1462 if( pMac->sys.gSysBbtPendingMgmtCount > ( vos_pkt_get_num_of_rx_raw_pkts()/4
1463 - RSRVD_MGMT_RX_PACKETS ))
1464 {
1465 // drop all probereq, proberesp and beacons
1466 if( mHdr->fc.subType == SIR_MAC_MGMT_BEACON || mHdr->fc.subType ==
1467 SIR_MAC_MGMT_PROBE_REQ || mHdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP )
1468 {
1469 vos_spin_lock_release( &pMac->sys.lock );
Katya Nigamfdf5a522015-02-03 14:38:55 +05301470 limLog( pMac, LOGW,
1471 FL ( "Dropping probe req, probe resp or beacon" ));
Katya Nigam53799202014-12-18 15:59:38 +05301472 vos_pkt_return_packet(pVosPkt);
1473 return VOS_STATUS_SUCCESS;
1474 }
1475 }
1476 pMac->sys.gSysBbtPendingMgmtCount++;
1477 vos_spin_lock_release( &pMac->sys.lock );
1478
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1480 &msg,
1481 mHdr->fc.type,
1482 mHdr->fc.subType ))
1483 {
1484 vos_pkt_return_packet(pVosPkt);
Abhishek Singh5d765712015-03-12 14:04:16 +05301485
1486 /* Decrement gSysBbtPendingMgmtCount if packet
1487 * is dropped before posting to LIM
1488 */
1489 limDecrementPendingMgmtCount(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001491 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 return VOS_STATUS_E_FAILURE;
1493 }
1494
1495 return VOS_STATUS_SUCCESS;
1496}
1497
1498// ---------------------------------------------------------------------------
1499/**
1500 * peRegisterTLHandle
1501 *
1502 * FUNCTION:
1503 * Registers the Handler which, process the Management frames from TL
1504 *
1505 * LOGIC:
1506 *
1507 * ASSUMPTIONS:
1508 *
1509 * NOTE:
1510 *
1511 * @return None
1512 */
1513
1514void peRegisterTLHandle(tpAniSirGlobal pMac)
1515{
1516 v_PVOID_t pvosGCTx;
1517 VOS_STATUS retStatus;
1518
1519 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1520
1521 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1522
1523 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001524 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001525
1526}
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
1528
1529/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 * limIsSystemInScanState()
1531 *
1532 *FUNCTION:
1533 * This function is called by various MAC software modules to
1534 * determine if System is in Scan/Learn state
1535 *
1536 *LOGIC:
1537 * NA
1538 *
1539 *ASSUMPTIONS:
1540 * NA
1541 *
1542 *NOTE:
1543 *
1544 * @param pMac - Pointer to Global MAC structure
1545 * @return true - System is in Scan/Learn state
1546 * false - System is NOT in Scan/Learn state
1547 */
1548
1549tANI_U8
1550limIsSystemInScanState(tpAniSirGlobal pMac)
1551{
1552 switch (pMac->lim.gLimSmeState)
1553 {
1554 case eLIM_SME_CHANNEL_SCAN_STATE:
1555 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1556 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1557 case eLIM_SME_WT_SCAN_STATE:
1558 // System is in Learn mode
1559 return true;
1560
1561 default:
1562 // System is NOT in Learn mode
1563 return false;
1564 }
1565} /*** end limIsSystemInScanState() ***/
1566
1567
1568
1569/**
1570 * limIsSystemInActiveState()
1571 *
1572 *FUNCTION:
1573 * This function is called by various MAC software modules to
1574 * determine if System is in Active/Wakeup state
1575 *
1576 *LOGIC:
1577 * NA
1578 *
1579 *ASSUMPTIONS:
1580 * NA
1581 *
1582 *NOTE:
1583 *
1584 * @param pMac - Pointer to Global MAC structure
1585 * @return true - System is in Active state
1586 * false - System is not in Active state
1587 */
1588
1589tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1590{
1591 switch (pMac->pmm.gPmmState)
1592 {
1593 case ePMM_STATE_BMPS_WAKEUP:
1594 case ePMM_STATE_IMPS_WAKEUP:
1595 case ePMM_STATE_READY:
1596 // System is in Active mode
1597 return true;
1598 default:
1599 return false;
1600 // System is NOT in Active mode
1601 }
1602}
1603
1604
Jeff Johnson295189b2012-06-20 16:38:30 -07001605
Jeff Johnson295189b2012-06-20 16:38:30 -07001606
1607
1608/**
1609*\brief limReceivedHBHandler()
1610*
1611* This function is called by schBeaconProcess() upon
1612* receiving a Beacon on STA. This also gets called upon
1613* receiving Probe Response after heat beat failure is
1614* detected.
1615*
1616* param pMac - global mac structure
1617* param channel - channel number indicated in Beacon, Probe Response
1618* return - none
1619*/
1620
1621
1622void
1623limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1624{
1625 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1626 psessionEntry->LimRxedBeaconCntDuringHB++;
1627
1628 pMac->pmm.inMissedBeaconScenario = FALSE;
1629} /*** end limReceivedHBHandler() ***/
1630
1631
1632
1633#if 0
1634void limResetHBPktCount(tpPESession psessionEntry)
1635{
1636 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1637}
1638#endif
1639
1640
1641/*
1642 * limProcessWdsInfo()
1643 *
1644 *FUNCTION:
1645 * This function is called from schBeaconProcess in BP
1646 *
1647 *PARAMS:
1648 * @param pMac - Pointer to Global MAC structure
1649 * @param propIEInfo - proprietary IE info
1650 *
1651 *LOGIC:
1652 *
1653 *ASSUMPTIONS:
1654 * NA
1655 *
1656 *NOTE:
1657 *
1658 *
1659 *RETURNS:
1660 *
1661 */
1662
1663void limProcessWdsInfo(tpAniSirGlobal pMac,
1664 tSirPropIEStruct propIEInfo)
1665{
Jeff Johnson295189b2012-06-20 16:38:30 -07001666}
1667
1668
1669
1670/**
1671 * limInitWdsInfoParams()
1672 *
1673 *FUNCTION:
1674 * This function is called while processing
1675 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1676 * ind/set related parameters.
1677 *
1678 *LOGIC:
1679 *
1680 *ASSUMPTIONS:
1681 *
1682 *NOTE:
1683 *
1684 * @param pMac Pointer to Global MAC structure
1685 * @return None
1686 */
1687
1688void
1689limInitWdsInfoParams(tpAniSirGlobal pMac)
1690{
1691 pMac->lim.gLimWdsInfo.wdsLength = 0;
1692 pMac->lim.gLimNumWdsInfoInd = 0;
1693 pMac->lim.gLimNumWdsInfoSet = 0;
1694} /*** limInitWdsInfoParams() ***/
1695
1696
1697/** -------------------------------------------------------------
1698\fn limUpdateOverlapStaParam
1699\brief Updates overlap cache and param data structure
1700\param tpAniSirGlobal pMac
1701\param tSirMacAddr bssId
1702\param tpLimProtStaParams pStaParams
1703\return None
1704 -------------------------------------------------------------*/
1705void
1706limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1707{
1708 int i;
1709 if (!pStaParams->numSta)
1710 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301711 vos_mem_copy(pMac->lim.protStaOverlapCache[0].addr,
1712 bssId,
1713 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 pMac->lim.protStaOverlapCache[0].active = true;
1715
1716 pStaParams->numSta = 1;
1717
1718 return;
1719 }
1720
1721 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1722 {
1723 if (pMac->lim.protStaOverlapCache[i].active)
1724 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301725 if (vos_mem_compare( pMac->lim.protStaOverlapCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 bssId,
1727 sizeof(tSirMacAddr))) {
1728 return; }
1729 }
1730 else
1731 break;
1732 }
1733
1734 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1735 {
Shake M Subhani5d80fda2013-12-09 17:28:23 +05301736 PELOG1(limLog(pMac, LOGW, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 }
1738 else
1739 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301740 vos_mem_copy(pMac->lim.protStaOverlapCache[i].addr,
1741 bssId,
1742 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 pMac->lim.protStaOverlapCache[i].active = true;
1744
1745 pStaParams->numSta++;
1746 }
1747}
1748
1749
1750/**
1751 * limHandleIBSScoalescing()
1752 *
1753 *FUNCTION:
1754 * This function is called upon receiving Beacon/Probe Response
1755 * while operating in IBSS mode.
1756 *
1757 *LOGIC:
1758 *
1759 *ASSUMPTIONS:
1760 *
1761 *NOTE:
1762 *
1763 * @param pMac - Pointer to Global MAC structure
1764 * @param pBeacon - Parsed Beacon Frame structure
1765 * @param pRxPacketInfo - Pointer to RX packet info structure
1766 *
1767 * @return Status whether to process or ignore received Beacon Frame
1768 */
1769
1770tSirRetStatus
1771limHandleIBSScoalescing(
1772 tpAniSirGlobal pMac,
1773 tpSchBeaconStruct pBeacon,
1774 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1775{
1776 tpSirMacMgmtHdr pHdr;
1777 tSirRetStatus retCode;
1778
1779 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001780 if ( (!pBeacon->capabilityInfo.ibss) ||
Abhishek Singhd5c31272014-03-07 14:46:50 +05301781 ( psessionEntry->privacy !=
1782 (tANI_U8)pBeacon->capabilityInfo.privacy ) ||
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001783 (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) ||
1784 (psessionEntry->currentOperChannel != pBeacon->channelNumber) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 /* Received SSID does not match => Ignore received Beacon frame. */
1786 retCode = eSIR_LIM_IGNORE_BEACON;
1787 else
1788 {
1789 tANI_U32 ieLen;
1790 tANI_U16 tsfLater;
1791 tANI_U8 *pIEs;
1792 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1793 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1794 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Abhishek Singh127a8442014-12-15 17:31:27 +05301795 limLog(pMac, LOG1, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1797 }
1798 return retCode;
1799} /*** end limHandleIBSScoalescing() ***/
1800
Abhishek Singh5fef4042014-11-25 18:33:00 +05301801tAniBool limEncTypeMatched(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon,
1802 tpPESession pSession)
1803{
1804 if (!pBeacon || !pSession)
1805 return eSIR_FALSE;
1806
1807 limLog(pMac, LOG1,
1808 FL("Beacon/Probe:: Privacy :%d WPA Present:%d RSN Present: %d"),
1809 pBeacon->capabilityInfo.privacy, pBeacon->wpaPresent,
1810 pBeacon->rsnPresent);
1811 limLog(pMac, LOG1,
Abhishek Singheef5c992016-01-27 13:41:54 +05301812 FL("pSession:: Privacy :%d EncyptionType: %d WPS %d OSEN %d"),
Abhishek Singh5fef4042014-11-25 18:33:00 +05301813 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps),
Abhishek Singheef5c992016-01-27 13:41:54 +05301814 pSession->encryptType, pSession->bWPSAssociation,
1815 pSession->bOSENAssociation);
Abhishek Singh5fef4042014-11-25 18:33:00 +05301816
1817 /* This is handled by sending probe req due to IOT issues so return TRUE
1818 */
1819 if ( (pBeacon->capabilityInfo.privacy) !=
1820 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps))
1821 {
1822 limLog(pMac, LOG1, FL("Return for Privacy bit miss match, As "
1823 "for this driver need to send the probe request to handle"
1824 " IOT issues "));
1825 return eSIR_TRUE;
1826 }
1827
1828 /*Open*/
1829 if( (pBeacon->capabilityInfo.privacy == 0) &&
1830 (pSession->encryptType == eSIR_ED_NONE))
1831 return eSIR_TRUE;
1832
1833 /* WEP */
1834 if ( (pBeacon->capabilityInfo.privacy == 1) && (pBeacon->wpaPresent == 0) &&
1835 (pBeacon->rsnPresent == 0) &&
Abhishek Singh31dfa3c2014-12-12 17:25:19 +05301836 ( ( pSession->encryptType == eSIR_ED_WEP40 ) ||
1837 ( pSession->encryptType == eSIR_ED_WEP104 )
1838#ifdef FEATURE_WLAN_WAPI
1839 || ( pSession->encryptType == eSIR_ED_WPI )
1840#endif
1841 ))
Abhishek Singh5fef4042014-11-25 18:33:00 +05301842 return eSIR_TRUE;
1843
1844 /* WPA OR RSN*/
1845 if ( (pBeacon->capabilityInfo.privacy == 1) &&
1846 ( (pBeacon->wpaPresent == 1) ||
1847 ( pBeacon->rsnPresent == 1)) &&
1848 ( (pSession->encryptType == eSIR_ED_TKIP) ||
1849 (pSession->encryptType == eSIR_ED_CCMP) ||
1850 (pSession->encryptType == eSIR_ED_AES_128_CMAC)))
1851 return eSIR_TRUE;
1852
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301853 /* For HS2.0, RSN ie is not present
1854 * in beacon. Therefore no need to
1855 * check for security type in case
1856 * OSEN session.
Abhishek Singheef5c992016-01-27 13:41:54 +05301857 * For WPS registration session no need to detect
1858 * security mismatch as it wont match and
1859 * driver may end up sending probe request without
1860 * WPS IE during WPS registartion process.
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301861 */
1862 /*TODO: AP capability mismatch
1863 * is not checked here because
1864 * no logic for beacon parsing
1865 * is avilable for HS2.0.
1866 */
Abhishek Singheef5c992016-01-27 13:41:54 +05301867 if (pSession->bOSENAssociation ||
1868 pSession->bWPSAssociation)
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301869 return eSIR_TRUE;
1870
Abhishek Singh5fef4042014-11-25 18:33:00 +05301871 return eSIR_FALSE;
1872}
Jeff Johnson295189b2012-06-20 16:38:30 -07001873
1874
1875/**
1876 * limDetectChangeInApCapabilities()
1877 *
1878 *FUNCTION:
1879 * This function is called while SCH is processing
1880 * received Beacon from AP on STA to detect any
1881 * change in AP's capabilities. If there any change
1882 * is detected, Roaming is informed of such change
1883 * so that it can trigger reassociation.
1884 *
1885 *LOGIC:
1886 *
1887 *ASSUMPTIONS:
1888 *
1889 *NOTE:
1890 * Notification is enabled for STA product only since
1891 * it is not a requirement on BP side.
1892 *
1893 * @param pMac Pointer to Global MAC structure
1894 * @param pBeacon Pointer to parsed Beacon structure
1895 * @return None
1896 */
1897
1898void
1899limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1900 tpSirProbeRespBeacon pBeacon,
1901 tpPESession psessionEntry)
1902{
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 tANI_U8 len;
1904 tSirSmeApNewCaps apNewCaps;
1905 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301906 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh5fef4042014-11-25 18:33:00 +05301907 tAniBool securityCapsMatched = eSIR_TRUE;
1908
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1910 newChannel = (tANI_U8) pBeacon->channelNumber;
1911
Abhishek Singh5fef4042014-11-25 18:33:00 +05301912 securityCapsMatched = limEncTypeMatched(pMac, pBeacon, psessionEntry);
1913
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301914 if ( ( false == psessionEntry->limSentCapsChangeNtf ) &&
Abhishek Singh4f8446a2014-05-22 14:07:31 +05301915 ( ( ( !limIsNullSsid(&pBeacon->ssId) ) &&
1916 ( false == limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) ) ) ||
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301917 ( (SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
1918 SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps) ) ||
1919 ( SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1920 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps) ) ||
1921 ( SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1922 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps) ) ||
1923 ( SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
1924 SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps) ) ||
Abhishek Singh5fef4042014-11-25 18:33:00 +05301925 ( newChannel != psessionEntry->currentOperChannel ) ||
1926 (eSIR_FALSE == securityCapsMatched)
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301927 ) ) )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301928 {
Abhishek Singha9325f72015-01-05 11:49:23 +05301929 if ( false == psessionEntry->fWaitForProbeRsp )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301930 {
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301931 /* If Beacon capabilities is not matching with the current capability,
1932 * then send unicast probe request to AP and take decision after
1933 * receiving probe response */
1934 if ( true == psessionEntry->fIgnoreCapsChange )
1935 {
1936 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1937 return;
1938 }
1939 psessionEntry->fWaitForProbeRsp = true;
1940 limLog(pMac, LOGW, FL("AP capabilities are not matching,"
1941 "sending directed probe request.. "));
1942 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1943 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1944 psessionEntry->dot11mode, 0, NULL);
1945
1946 if ( eSIR_SUCCESS != status )
1947 {
1948 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1949 psessionEntry->fWaitForProbeRsp = false;
1950 }
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301951 return;
1952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 /**
1954 * BSS capabilities have changed.
1955 * Inform Roaming.
1956 */
1957 len = sizeof(tSirMacCapabilityInfo) +
1958 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1959 3 * sizeof(tANI_U8) + // reserved fields
1960 pBeacon->ssId.length + 1;
1961
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301962 vos_mem_copy(apNewCaps.bssId,
1963 psessionEntry->bssId,
1964 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 if (newChannel != psessionEntry->currentOperChannel)
1966 {
1967 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001968 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 psessionEntry->currentOperChannel, newChannel);)
1970 return;
1971 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301972
1973 /**
1974 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1975 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1976 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1977 * the privacy bit is set in Probe and association responses.
1978 * Due to this anomaly, we detect a change in
1979 * AP capabilities when we receive a beacon after association and
1980 * disconnect from the AP. The following check makes sure that we can
1981 * connect to such APs
1982 */
1983 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1984 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1985 {
1986 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001987 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301988 return;
1989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 else
1991 apNewCaps.channelId = psessionEntry->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301992 vos_mem_copy((tANI_U8 *) &apNewCaps.ssId,
1993 (tANI_U8 *) &pBeacon->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001994 pBeacon->ssId.length + 1);
1995
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301996 psessionEntry->fIgnoreCapsChange = false;
1997 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 psessionEntry->limSentCapsChangeNtf = true;
1999 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2000 (tANI_U32 *) &apNewCaps,
2001 len, psessionEntry->smeSessionId);
2002 }
Abhishek Singh4136e4e2013-12-15 11:56:29 +05302003 else if ( true == psessionEntry->fWaitForProbeRsp )
2004 {
2005 /* Only for probe response frames and matching capabilities the control
2006 * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
2007 * will be false, the control will not come here*/
2008
2009 limLog(pMac, LOG1, FL("capabilities in probe response are"
2010 "matching with the current setting,"
2011 "Ignoring subsequent capability"
2012 "mismatch"));
2013 psessionEntry->fIgnoreCapsChange = true;
2014 psessionEntry->fWaitForProbeRsp = false;
2015 }
2016
Jeff Johnson295189b2012-06-20 16:38:30 -07002017} /*** limDetectChangeInApCapabilities() ***/
2018
2019
2020
2021
2022// ---------------------------------------------------------------------
2023/**
2024 * limUpdateShortSlot
2025 *
2026 * FUNCTION:
2027 * Enable/Disable short slot
2028 *
2029 * LOGIC:
2030 *
2031 * ASSUMPTIONS:
2032 *
2033 * NOTE:
2034 *
2035 * @param enable Flag to enable/disable short slot
2036 * @return None
2037 */
2038
2039tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2040{
2041
2042 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002043 tANI_U32 nShortSlot;
2044 tANI_U32 val = 0;
2045 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002046
Jeff Johnsone7245742012-09-05 17:12:55 -07002047 // Check Admin mode first. If it is disabled just return
2048 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2049 != eSIR_SUCCESS)
2050 {
2051 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002052 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002053 return eSIR_FAILURE;
2054 }
2055 if (val == false)
2056 return eSIR_SUCCESS;
2057
2058 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2059 limGetPhyMode(pMac, &phyMode, psessionEntry);
2060 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2061 return eSIR_SUCCESS;
2062
2063 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002064
2065 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2066 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2067 // if no erp present, use short slot based on current ap caps
2068
2069 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2070
2071 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2072 // The difference between the earlier implementation and the new one is only Case4.
2073 /*
2074 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2075 Case1 1 1 1 1 //AP should not advertise this combination.
2076 Case2 1 1 0 0
2077 Case3 1 0 1 1
2078 Case4 1 0 0 0
2079 Case5 0 1 1 1
2080 Case6 0 1 0 0
2081 Case7 0 0 1 1
2082 Case8 0 0 0 0
2083 */
2084 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2085
Jeff Johnsone7245742012-09-05 17:12:55 -07002086 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 {
2088 // Short slot time capability of AP has changed. Adopt to it.
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302089 limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002091 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2093 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 }
2095 return eSIR_SUCCESS;
2096}
2097
2098
Jeff Johnson295189b2012-06-20 16:38:30 -07002099
2100
Jeff Johnson295189b2012-06-20 16:38:30 -07002101
Jeff Johnson295189b2012-06-20 16:38:30 -07002102
2103
2104/** -----------------------------------------------------------------
2105 \brief limHandleLowRssiInd() - handles low rssi indication
2106
2107 This function process the SIR_HAL_LOW_RSSI_IND message from
2108 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2109
2110 \param pMac - global mac structure
2111
2112 \return
2113
2114 \sa
2115 ----------------------------------------------------------------- */
2116void limHandleLowRssiInd(tpAniSirGlobal pMac)
2117{
2118#if 0 //RSSI related indications will now go to TL and not PE
2119 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2120 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2121 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2122 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002123 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2125 }
2126 else
2127 {
2128 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002129 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 pMac->pmm.gPmmState);
2131 }
2132 return;
2133#endif
2134}
2135
2136
2137/** -----------------------------------------------------------------
2138 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2139
2140 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2141 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2142 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2143
2144 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2145 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2146 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2147 This message can also come from FW anytime after we have entered BMPS.
2148 This means we should handle it in WoWL and UAPSD states as well
2149
2150 \param pMac - global mac structure
2151 \return - none
2152 \sa
2153 ----------------------------------------------------------------- */
2154void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2155{
2156 switch(pMac->pmm.gPmmState)
2157 {
2158 case ePMM_STATE_BMPS_SLEEP:
2159 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2160 case ePMM_STATE_UAPSD_SLEEP:
2161 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2162 case ePMM_STATE_WOWLAN:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302163 limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2165 break;
2166
2167 default:
2168 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002169 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 pMac->pmm.gPmmState);
2171 break;
2172 }
2173 return;
2174}
2175
Kapil Gupta7a3d9b12016-12-20 20:36:38 +05302176#ifdef WLAN_FEATURE_APFIND
2177void limHandleAPFindInd(tpAniSirGlobal pMac)
2178{
2179 tANI_S8 pe_sessionid = -1;
2180 /* Find STA connection session */
2181 pe_sessionid = limGetInfraSessionId(pMac);
2182 if (pe_sessionid != -1)
2183 limTearDownLinkWithAp(pMac,
2184 pe_sessionid,
2185 eSIR_BEACON_MISSED);
2186 else
2187 limLog(pMac, LOGE,
2188 FL("session id doesn't exist for infra"));
2189}
2190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002191
2192/** -----------------------------------------------------------------
2193 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2194
2195 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2196 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2197 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2198
2199 \param pMac - global mac structure
2200 \return - none
2201 \sa
2202 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002203void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002204{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002205#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2206 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2207 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2208 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2209 if (psessionEntry == NULL)
2210 {
2211 limLog(pMac, LOGE,
2212 FL("session does not exist for given BSSIdx:%d"),
2213 pSirMissedBeaconInd->bssIdx);
2214 return;
2215 }
2216#endif
Gupta, Kapil2fc8ca22016-02-19 12:22:17 +05302217 if (pMac->pmm.inMissedBeaconScenario == TRUE) {
2218 limLog(pMac, LOGW,
2219 FL("beacon miss handling is already going on for BSSIdx:%d"),
2220 pSirMissedBeaconInd->bssIdx);
2221 return;
2222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2224 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2225 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2226 {
2227 pMac->pmm.inMissedBeaconScenario = TRUE;
Madan Mohan Koyyalamudi1a30a552013-09-17 21:20:07 +05302228 PELOGE(limLog(pMac, LOGE,
2229 FL("Sending EXIT_BMPS_IND to SME due to Missed beacon from FW"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2231 }
Yathish9f22e662012-12-10 14:21:35 -08002232/* ACTIVE_MODE_HB_OFFLOAD */
2233#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2234 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2235 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2236 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2237 {
2238 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002239 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002240 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002241 }
2242#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 else
2244 {
2245 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002246 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 pMac->pmm.gPmmState);
2248 }
2249 return;
2250}
2251
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05302252
2253void limUpdateLostLinkParams(tpAniSirGlobal pMac,
2254 tpPESession psessionEntry, tANI_U8 *pRxPacketInfo)
2255{
2256 tpSirSmeLostLinkParamsInd pSmeLostLinkParams;
2257 tSirMsgQ mmhMsg;
2258 if (NULL == pRxPacketInfo)
2259 {
2260 return;
2261 }
2262 pSmeLostLinkParams =
2263 (tpSirSmeLostLinkParamsInd)vos_mem_malloc(sizeof(tSirSmeLostLinkParamsInd));
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05302264 if (NULL == pSmeLostLinkParams)
2265 {
2266 limLog(pMac, LOGP,
2267 FL("Failed to alloc mem of size %zu for tSirSmeLostLinkParamsInd"),
2268 sizeof(*pSmeLostLinkParams));
2269 return;
2270 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05302271 vos_mem_set(pSmeLostLinkParams, sizeof(tSirSmeLostLinkParamsInd), 0);
2272 pSmeLostLinkParams->messageType = eWNI_SME_LOST_LINK_PARAMS_IND;
2273 pSmeLostLinkParams->length = sizeof(tSirSmeLostLinkParamsInd);
2274 pSmeLostLinkParams->sessionId = psessionEntry->smeSessionId;
2275 pSmeLostLinkParams->info.bssIdx = psessionEntry->bssIdx;
2276
2277 /*
2278 * Since FW adds 100 to RSSI, here also we are adding 100 so that
2279 * HDD has common logic to subtract 100 from RSSI received
2280 */
2281 pSmeLostLinkParams->info.rssi = WDA_GET_RX_RSSI_DB(pRxPacketInfo) + 100;
2282 vos_mem_copy(pSmeLostLinkParams->info.selfMacAddr,
2283 psessionEntry->selfMacAddr,
2284 sizeof(tSirMacAddr));
2285 pSmeLostLinkParams->info.lastDataRate = 0;
2286 pSmeLostLinkParams->info.linkFlCnt = 0;
2287 pSmeLostLinkParams->info.linkFlTx = 0;
2288 pSmeLostLinkParams->info.rsvd1 = 0;
2289 pSmeLostLinkParams->info.rsvd2 = 0;
2290
2291 mmhMsg.type = eWNI_SME_LOST_LINK_PARAMS_IND;
2292 mmhMsg.bodyptr = pSmeLostLinkParams;
2293 mmhMsg.bodyval = 0;
2294 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2295}
2296
2297/** -----------------------------------------------------------------
2298 \brief limProcessLostLinkParamsInd() - handles lost link params indication
2299
2300 This function process the SIR_HAL_LOST_LINK_PARAMS_IND message from HAL,
2301
2302 \param pMac - global mac structure
2303 \return - none
2304 \sa
2305 ----------------------------------------------------------------- */
2306
2307void limProcessLostLinkParamsInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2308{
2309 tpSirSmeLostLinkParamsInd pSmeLostLinkParamsInd;
2310 tpSirSmeLostLinkParamsInd pLostLInkParamsInd = (tpSirSmeLostLinkParamsInd)pMsg->bodyptr;
2311 tpPESession psessionEntry ;
2312 tSirMsgQ mmhMsg;
2313
2314 if (NULL == pLostLInkParamsInd)
2315 {
2316 limLog(pMac, LOGE,
2317 FL("pLostLInkParamsInd is NULL"));
2318 return;
2319 }
2320
2321 psessionEntry = peFindSessionByBssIdx(pMac,pLostLInkParamsInd->info.bssIdx);
2322 if (psessionEntry == NULL)
2323 {
2324 limLog(pMac, LOGE,
2325 FL("session does not exist for bdssIdx : %d"),
2326 pLostLInkParamsInd->info.bssIdx);
2327
2328 return;
2329 }
2330 pSmeLostLinkParamsInd = vos_mem_malloc(sizeof(tSirSmeLostLinkParamsInd));
2331 if (pSmeLostLinkParamsInd == NULL)
2332 {
2333 limLog(pMac, LOGP,
2334 FL("memory allocate failed for eWNI_SME_LOST_LINK_PARAMD_IND"));
2335 return;
2336 }
2337 pSmeLostLinkParamsInd->messageType = eWNI_SME_LOST_LINK_PARAMS_IND;
2338 pSmeLostLinkParamsInd->length = sizeof(tSirSmeLostLinkParamsInd);
2339 pSmeLostLinkParamsInd->sessionId = psessionEntry->smeSessionId;
2340 pSmeLostLinkParamsInd->info.bssIdx = pLostLInkParamsInd->info.bssIdx;
2341 pSmeLostLinkParamsInd->info.rssi = pLostLInkParamsInd->info.rssi;
2342 vos_mem_copy(pSmeLostLinkParamsInd->info.selfMacAddr,
2343 pLostLInkParamsInd->info.selfMacAddr,
2344 sizeof(tSirMacAddr));
2345 pSmeLostLinkParamsInd->info.linkFlCnt = pLostLInkParamsInd->info.linkFlCnt;
2346 pSmeLostLinkParamsInd->info.linkFlTx = pLostLInkParamsInd->info.linkFlTx;
2347 pSmeLostLinkParamsInd->info.lastDataRate = pLostLInkParamsInd->info.lastDataRate;
2348 pSmeLostLinkParamsInd->info.rsvd1 = pLostLInkParamsInd->info.rsvd1;
2349 pSmeLostLinkParamsInd->info.rsvd2 = pLostLInkParamsInd->info.rsvd2;
2350
2351 mmhMsg.type = eWNI_SME_LOST_LINK_PARAMS_IND;
2352 mmhMsg.bodyptr = pSmeLostLinkParamsInd;
2353 mmhMsg.bodyval = 0;
2354 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2355 return;
2356}
2357
Jeff Johnson295189b2012-06-20 16:38:30 -07002358/** -----------------------------------------------------------------
2359 \brief limMicFailureInd() - handles mic failure indication
2360
2361 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2362
2363 \param pMac - global mac structure
2364 \return - none
2365 \sa
2366 ----------------------------------------------------------------- */
2367void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2368{
2369 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2370 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2371 tSirMsgQ mmhMsg;
2372 tpPESession psessionEntry ;
2373 tANI_U8 sessionId;
2374
2375 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2376 {
2377 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002378 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 return;
2380 }
2381
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302382 pSirSmeMicFailureInd = vos_mem_malloc(sizeof(tSirSmeMicFailureInd));
2383 if (NULL == pSirSmeMicFailureInd)
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 {
2385 // Log error
2386 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002387 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 return;
2389 }
2390
2391 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
Sunkad, Anand Ningappabf1650a2016-02-08 12:08:13 +05302392 pSirSmeMicFailureInd->length = sizeof(*pSirSmeMicFailureInd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2394
2395 vos_mem_copy(pSirSmeMicFailureInd->bssId,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302396 pSirMicFailureInd->bssId,
2397 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002398
2399 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302400 pSirMicFailureInd->info.srcMacAddr,
2401 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002402
2403 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302404 pSirMicFailureInd->info.taMacAddr,
2405 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002406
2407 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302408 pSirMicFailureInd->info.dstMacAddr,
2409 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002410
2411 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302412 pSirMicFailureInd->info.rxMacAddr,
2413 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002414
2415 pSirSmeMicFailureInd->info.multicast =
2416 pSirMicFailureInd->info.multicast;
2417
2418 pSirSmeMicFailureInd->info.keyId=
2419 pSirMicFailureInd->info.keyId;
2420
2421 pSirSmeMicFailureInd->info.IV1=
2422 pSirMicFailureInd->info.IV1;
2423
2424 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302425 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002426
2427 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2428 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2429 mmhMsg.bodyval = 0;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05302430 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2432 return;
2433}
2434
Sushant Kaushik1f5f54b2015-07-28 14:32:22 +05302435#ifdef WLAN_FEATURE_11W
2436/** --------------------------------------------------------------------
2437 * lim_is_assoc_req_for_drop()- function to decides to drop assoc\reassoc
2438 * frames.
2439 * @mac: pointer to global mac structure
2440 * @rx_pkt_info: rx packet meta information
2441 *
2442 * This function is called before enqueuing the frame to PE queue to
2443 * drop flooded assoc/reassoc frames getting into PE Queue.
2444 *
2445 * Return: true for dropping the frame otherwise false
2446----------------------------------------------------------------------*/
2447
2448bool lim_is_assoc_req_for_drop(tpAniSirGlobal pMac, uint8_t *rx_pkt_info)
2449{
2450 tANI_U8 session_id;
2451 tANI_U16 aid;
2452 tpPESession session_entry;
2453 tpSirMacMgmtHdr pMacHdr;
2454 tpDphHashNode sta_ds;
2455
2456 pMacHdr = WDA_GET_RX_MAC_HEADER(rx_pkt_info);
2457 session_entry = peFindSessionByBssid(pMac, pMacHdr->bssId, &session_id);
2458 if (!session_entry)
2459 {
2460 PELOG1(limLog(pMac, LOG1,
2461 FL("session does not exist for given STA [%pM]"),
2462 pMacHdr->sa););
2463 return false;
2464 }
2465 sta_ds = dphLookupHashEntry(pMac, pMacHdr->sa, &aid,
2466 &session_entry->dph.dphHashTable);
2467 if (!sta_ds)
2468 {
2469 PELOG1(limLog(pMac, LOG1, FL("pStaDs is NULL")););
2470 return false;
2471 }
2472
2473 if (!sta_ds->rmfEnabled)
2474 return false;
2475
2476 if (sta_ds->pmfSaQueryState == DPH_SA_QUERY_IN_PROGRESS)
2477 return true;
2478
2479 if (sta_ds->last_assoc_received_time &&
2480 ((vos_timer_get_system_time() -
2481 sta_ds->last_assoc_received_time) < 1000))
2482 return true;
2483
2484 sta_ds->last_assoc_received_time = vos_timer_get_system_time();
2485 return false;
2486}
2487#endif
2488
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302489/** ----------------------------------------------------------------------
2490 *\brief limIsDeauthDiassocForDrop()..decides to drop deauth\diassoc frames.
2491 *This function is called before enqueuing the frame to PE queue.
2492 *This prevents deauth/diassoc frames getting into PE Queue.
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302494------------------------------------------------------------------------ */
2495
2496
2497boolean limIsDeauthDiassocForDrop(tpAniSirGlobal pMac,
2498 tANI_U8 *pRxPacketInfo)
2499{
2500 tANI_U8 sessionId;
2501 tANI_U16 aid;
2502 tpPESession psessionEntry;
2503 tpSirMacMgmtHdr pMacHdr;
2504 tpDphHashNode pStaDs;
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302505 eHalStatus lock_status = eHAL_STATUS_SUCCESS;
2506 boolean ret = FALSE;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302507
2508 pMacHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2509 psessionEntry = peFindSessionByBssid(pMac,pMacHdr->bssId,&sessionId);
2510 if (!psessionEntry)
2511 {
2512 PELOG1(sysLog(pMac, LOG1,
2513 FL("session does not exist for given STA [%pM]"),
2514 pMacHdr->sa););
2515 return TRUE;
2516 }
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302517
2518 lock_status = pe_AcquireGlobalLock(&pMac->lim);
2519 if (lock_status != eHAL_STATUS_SUCCESS)
2520 {
2521 limLog(pMac, LOGE, FL("pe_AcquireGlobalLock error"));
2522 return TRUE;
2523 }
2524
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302525 pStaDs = dphLookupHashEntry(pMac, pMacHdr->sa, &aid,
2526 &psessionEntry->dph.dphHashTable);
2527 if (!pStaDs)
2528 {
2529 PELOG1(sysLog(pMac, LOG1,FL("pStaDs is NULL")););
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302530 ret = TRUE;
2531 goto end;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302532 }
2533#ifdef WLAN_FEATURE_11W
2534 if (psessionEntry->limRmfEnabled)
2535 {
2536 if ((WDA_GET_RX_DPU_FEEDBACK(pRxPacketInfo) &
2537 DPU_FEEDBACK_UNPROTECTED_ERROR))
2538 {
2539 /* It may be possible that deauth/diassoc frames from a spoofy
2540 * AP is received. So if all further deauth/diassoc frmaes are
2541 * dropped, then it may result in lossing deauth/diassoc frames
2542 * from genuine AP. So process all deauth/diassoc frames with
2543 * a time difference of 1 sec.
2544 */
2545 if (vos_timer_get_system_time() - pStaDs->last_unprot_deauth_disassoc < 1000)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302546 {
2547 ret = TRUE;
2548 goto end;
2549 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302550 pStaDs->last_unprot_deauth_disassoc =
2551 vos_timer_get_system_time();
2552 }
2553/* PMF enabed, Management frames are protected */
2554 else
2555 {
2556 if (pStaDs->proct_deauh_disassoc_cnt)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302557 {
2558 ret = TRUE;
2559 goto end;
2560 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302561 else
2562 pStaDs->proct_deauh_disassoc_cnt++;
2563 }
2564 }
2565 else
2566#endif
2567/* PMF disabled */
2568 {
2569 if (pStaDs->isDisassocDeauthInProgress)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302570 {
2571 ret = TRUE;
2572 goto end;
2573 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302574 else
2575 pStaDs->isDisassocDeauthInProgress++;
2576 }
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302577
2578end:
2579 pe_ReleaseGlobalLock(&pMac->lim);
2580 return ret;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302581}
Jeff Johnson295189b2012-06-20 16:38:30 -07002582/** -----------------------------------------------------------------
2583 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2584
2585 This function is called before enqueuing the frame to PE queue for further processing.
2586 This prevents unnecessary frames getting into PE Queue and drops them right away.
2587 Frames will be droped in the following scenarios:
2588
2589 - In Scan State, drop the frames which are not marked as scan frames
2590 - In non-Scan state, drop the frames which are marked as scan frames.
2591 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2592 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2593
2594 \param pMac - global mac structure
2595 \return - none
2596 \sa
2597 ----------------------------------------------------------------- */
2598
2599tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2600{
2601 tANI_U32 framelen;
2602 tANI_U8 *pBody;
2603 tSirMacCapabilityInfo capabilityInfo;
2604
2605 /*
2606 *
2607 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2608 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2609 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2610 * other than beacons or probe responses in scan state.
2611 */
2612 if( (subType == SIR_MAC_MGMT_BEACON) ||
2613 (subType == SIR_MAC_MGMT_PROBE_RSP))
2614 {
2615 if(pMac->pmm.inMissedBeaconScenario)
2616 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002617 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2618 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 }
2620 if (limIsSystemInScanState(pMac))
2621 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002622 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002624#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2625 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2626 {
2627 return eMGMT_DROP_NO_DROP;
2628 }
2629#endif
Dino Mycle7a76e662014-06-10 11:36:34 +05302630#ifdef WLAN_FEATURE_EXTSCAN
2631 else if (WDA_GET_EXTSCANFULLSCANRESIND(pRxPacketInfo))
2632 {
2633 return eMGMT_DROP_NO_DROP;
2634 }
2635#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2637 {
2638 return eMGMT_DROP_SCAN_MODE_FRAME;
2639 }
2640 }
2641
2642 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2643 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2644
2645 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2646 * beacons from an infrastructure network
2647 */
2648 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2649 if(!capabilityInfo.ibss)
2650 return eMGMT_DROP_NO_DROP;
2651#if 0
2652 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2653 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2654 return eMGMT_DROP_NO_DROP;
2655#endif
2656
Sushant Kaushik1f5f54b2015-07-28 14:32:22 +05302657#ifdef WLAN_FEATURE_11W
2658 if ((subType == SIR_MAC_MGMT_ASSOC_REQ ||
2659 subType == SIR_MAC_MGMT_REASSOC_REQ) &&
2660 lim_is_assoc_req_for_drop(pMac, pRxPacketInfo))
2661 return eMGMT_DROP_SPURIOUS_FRAME;
2662#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2664 if( (subType == SIR_MAC_MGMT_BEACON) ||
2665 (subType == SIR_MAC_MGMT_PROBE_RSP))
2666 {
2667 //drop the frame if length is less than 12
2668 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2669 return eMGMT_DROP_INVALID_SIZE;
2670
2671 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2672
2673 //This can be enhanced to even check the SSID before deciding to enque the frame.
2674 if(capabilityInfo.ess)
2675 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2676 }
2677 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2678 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2679 {
2680 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2681 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2682 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2683 }
2684
2685 return eMGMT_DROP_NO_DROP;
2686}
2687
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002688eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2689{
2690 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002691
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002692 if(psPe)
2693 {
2694 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2695 {
2696 status = eHAL_STATUS_SUCCESS;
2697 }
2698 }
2699 return (status);
2700}
2701eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2702{
2703 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2704 if(psPe)
2705 {
2706 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2707 {
2708 status = eHAL_STATUS_SUCCESS;
2709 }
2710 }
2711 return (status);
2712}
Manjeet Singh3ed79242017-01-11 19:04:32 +05302713/**
2714 * lim_process_sme_cap_tsf_req()- send cap tsf request to WDA
2715 * Get bss_idx from PE and fill in cap tsf request.
2716 * @pMac:Mac ctx
2717 * @pMsgBuf: message buffer from sme
2718 * Returns success on post to WDA, otherwise failure
2719 */
2720
2721tSirRetStatus lim_process_sme_cap_tsf_req(tpAniSirGlobal pMac,
2722 tANI_U32 *pMsgBuf)
2723{
2724 tSirCapTsfParams *pMsg = NULL;
2725 tpPESession psessionEntry = NULL;
2726 uint8_t sessionId;
2727 tSirMsgQ msg;
2728 tSirCapTsfParams *cap_tsf_params;
2729
2730 pMsg = (tSirCapTsfParams*)pMsgBuf;
2731 if (pMsg == NULL) {
2732 limLog(pMac, LOGE, FL("NULL pMsg"));
2733 return eSIR_FAILURE;
2734 }
2735
2736 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
2737 if (NULL == psessionEntry)
2738 {
2739 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2740 return eSIR_FAILURE;
2741 }
2742 cap_tsf_params = (tSirCapTsfParams *)
2743 vos_mem_malloc(sizeof(*cap_tsf_params));
2744 if (!cap_tsf_params) {
2745 limLog(pMac, LOGE, FL(" Unable to allocate memory for cap tsf params"));
2746 return eSIR_MEM_ALLOC_FAILED;
2747 }
2748 vos_mem_copy (cap_tsf_params, pMsg, sizeof(*cap_tsf_params));
2749 cap_tsf_params->bss_idx = psessionEntry->bssIdx;
2750
2751 msg.type = WDA_CAP_TSF_REQ;
2752 msg.reserved = 0;
2753 msg.bodyptr = cap_tsf_params;
2754 msg.bodyval = 0;
2755 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
2756 {
2757 limLog(pMac, LOGE, FL("lim_process_sme_cap_tsf_req failed\n"));
2758 vos_mem_free(cap_tsf_params);
2759 return eSIR_FAILURE;
2760 }
2761
2762 return eSIR_SUCCESS;
2763}
2764
2765/**
2766 * lim_process_sme_get_tsf_req()- send get tsf request to WDA
2767 * Get bss_idx from PE and fill in cap tsf request.
2768 * @pMac:Mac ctx
2769 * @pMsgBuf: message buffer from sme
2770 * Returns success on post to WDA, otherwise failure
2771 */
2772tSirRetStatus lim_process_sme_get_tsf_req(tpAniSirGlobal pMac,
2773 tANI_U32 *pMsgBuf)
2774{
2775 tSirCapTsfParams *pMsg = NULL;
2776 tpPESession psessionEntry = NULL;
2777 uint8_t sessionId;
2778 tSirMsgQ msg;
2779 tSirCapTsfParams *get_tsf_params;
2780
2781 pMsg = (tSirCapTsfParams*)pMsgBuf;
2782 if (pMsg == NULL) {
2783 limLog(pMac, LOGE, FL("NULL pMsg"));
2784 return eSIR_FAILURE;
2785 }
2786
2787 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
2788 if (NULL == psessionEntry)
2789 {
2790 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2791 return eSIR_FAILURE;
2792 }
2793 get_tsf_params = (tSirCapTsfParams *)
2794 vos_mem_malloc(sizeof(*get_tsf_params));
2795 if (!get_tsf_params) {
2796 limLog(pMac, LOGE, FL(" Unable to allocate memory for cap tsf params"));
2797 return eSIR_MEM_ALLOC_FAILED;
2798 }
2799 vos_mem_copy (get_tsf_params, pMsg, sizeof(*get_tsf_params));
2800 get_tsf_params->bss_idx = psessionEntry->bssIdx;
2801
2802 msg.type = WDA_GET_TSF_REQ;
2803 msg.reserved = 0;
2804 msg.bodyptr = get_tsf_params;
2805 msg.bodyval = 0;
2806 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
2807 {
2808 limLog(pMac, LOGE, FL("lim_process_sme_cap_tsf_req failed\n"));
2809 vos_mem_free(get_tsf_params);
2810 return eSIR_FAILURE;
2811 }
2812
2813 return eSIR_SUCCESS;
2814}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05302815
2816/**
2817 * lim_process_sme_del_ba_ses_req()- process del ba req
2818 * @pMac:Mac ctx
2819 * @pMsgBuf: message buffer from sme
2820 * Returns success on taking action based on cfg value, otherwise failure
2821 */
2822tSirRetStatus lim_process_sme_del_ba_ses_req(tpAniSirGlobal pMac,
2823 tANI_U32 *pMsgBuf)
2824{
2825 tDelBaParams *pMsg = NULL;
2826 tpPESession psessionEntry = NULL;
2827 int val;
2828
2829 pMsg = (tDelBaParams*)pMsgBuf;
2830 if (pMsg == NULL) {
2831 limLog(pMac, LOGE, FL("NULL pMsg"));
2832 return eSIR_FAILURE;
2833 }
2834
2835 psessionEntry = peFindSessionBySessionId(pMac, pMsg->session_id);
2836 if (NULL == psessionEntry)
2837 {
2838 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2839 return eSIR_FAILURE;
2840 }
2841
2842 if (wlan_cfgGetInt
2843 (pMac, WNI_CFG_ENABLE_TX_RX_AGGREGATION, &val) !=
2844 eSIR_SUCCESS)
2845 {
2846 limLog(pMac, LOGE,
2847 FL( "Unable to get WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
2848 return eSIR_FAILURE;
2849 }
2850
2851 if (!val)
2852 {
2853 limLog(pMac, LOGW,
2854 FL("user requested to disable all RX BA sessions"));
2855 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2856 eSIR_MAC_PEER_TIMEDOUT_REASON);
2857 }
2858
2859 return eSIR_SUCCESS;
2860}