blob: d8137ff06be1ddb8e6cfbc0bf45824de1bb20b5e [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;
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +05301399 tANI_U16 frameLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001400
1401 pVosPkt = (vos_pkt_t *)vosBuff;
1402 if (NULL == pVosPkt)
1403 {
1404 return VOS_STATUS_E_FAILURE;
1405 }
1406
1407 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1408 if (NULL == pMac)
1409 {
1410 // cannot log a failure without a valid pMac
1411 vos_pkt_return_packet(pVosPkt);
1412 return VOS_STATUS_E_FAILURE;
1413 }
1414
1415 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1416
1417 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1418 {
1419 vos_pkt_return_packet(pVosPkt);
1420 return VOS_STATUS_E_FAILURE;
1421 }
1422
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +05301423 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1424 if (frameLen > WDA_MAX_MGMT_MPDU_LEN) {
1425 PELOG1(limLog(pMac, LOG1, FL("Dropping frame of len %d"), frameLen));
1426 vos_pkt_return_packet(pVosPkt);
1427 return VOS_STATUS_E_FAILURE;
1428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001429
1430 //
1431 // The MPDU header is now present at a certain "offset" in
1432 // the BD and is specified in the BD itself
1433 //
1434 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1435 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1436 {
1437 PELOG1(limLog( pMac, LOG1,
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001438 FL ( "RxBd=%pK mHdr=%pK Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001439 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001440
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +05301441#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1442 if (WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
1443 limLog(pMac, LOG1, FL("roamCandidateInd %d"),
1444 WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo));
1445
1446 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
1447 limLog(pMac, LOG1, FL("offloadScanLearn %d"),
1448 WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo));
1449#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 }
1451
1452
1453 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1454 msg.type = SIR_BB_XPORT_MGMT_MSG;
1455 msg.bodyptr = vosBuff;
1456 msg.bodyval = 0;
1457
Katya Nigam53799202014-12-18 15:59:38 +05301458 vos_spin_lock_acquire( &pMac->sys.lock );
1459 if( pMac->sys.gSysBbtPendingMgmtCount > (vos_pkt_get_num_of_rx_raw_pkts()/4) )
1460 {
1461 vos_spin_lock_release( &pMac->sys.lock );
1462 // drop all management packets
Katya Nigamfdf5a522015-02-03 14:38:55 +05301463 limLog( pMac, LOGW,
1464 FL ( "Management queue 1/4th full, dropping management packets" ));
Katya Nigam53799202014-12-18 15:59:38 +05301465 vos_pkt_return_packet(pVosPkt);
1466 return VOS_STATUS_SUCCESS;
1467 }
1468
1469 if( pMac->sys.gSysBbtPendingMgmtCount > ( vos_pkt_get_num_of_rx_raw_pkts()/4
1470 - RSRVD_MGMT_RX_PACKETS ))
1471 {
1472 // drop all probereq, proberesp and beacons
1473 if( mHdr->fc.subType == SIR_MAC_MGMT_BEACON || mHdr->fc.subType ==
1474 SIR_MAC_MGMT_PROBE_REQ || mHdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP )
1475 {
1476 vos_spin_lock_release( &pMac->sys.lock );
Katya Nigamfdf5a522015-02-03 14:38:55 +05301477 limLog( pMac, LOGW,
1478 FL ( "Dropping probe req, probe resp or beacon" ));
Katya Nigam53799202014-12-18 15:59:38 +05301479 vos_pkt_return_packet(pVosPkt);
1480 return VOS_STATUS_SUCCESS;
1481 }
1482 }
1483 pMac->sys.gSysBbtPendingMgmtCount++;
1484 vos_spin_lock_release( &pMac->sys.lock );
1485
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1487 &msg,
1488 mHdr->fc.type,
1489 mHdr->fc.subType ))
1490 {
1491 vos_pkt_return_packet(pVosPkt);
Abhishek Singh5d765712015-03-12 14:04:16 +05301492
1493 /* Decrement gSysBbtPendingMgmtCount if packet
1494 * is dropped before posting to LIM
1495 */
1496 limDecrementPendingMgmtCount(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001498 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 return VOS_STATUS_E_FAILURE;
1500 }
1501
1502 return VOS_STATUS_SUCCESS;
1503}
1504
1505// ---------------------------------------------------------------------------
1506/**
1507 * peRegisterTLHandle
1508 *
1509 * FUNCTION:
1510 * Registers the Handler which, process the Management frames from TL
1511 *
1512 * LOGIC:
1513 *
1514 * ASSUMPTIONS:
1515 *
1516 * NOTE:
1517 *
1518 * @return None
1519 */
1520
1521void peRegisterTLHandle(tpAniSirGlobal pMac)
1522{
1523 v_PVOID_t pvosGCTx;
1524 VOS_STATUS retStatus;
1525
1526 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1527
1528 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1529
1530 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001531 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
1533}
Jeff Johnson295189b2012-06-20 16:38:30 -07001534
1535
1536/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 * limIsSystemInScanState()
1538 *
1539 *FUNCTION:
1540 * This function is called by various MAC software modules to
1541 * determine if System is in Scan/Learn state
1542 *
1543 *LOGIC:
1544 * NA
1545 *
1546 *ASSUMPTIONS:
1547 * NA
1548 *
1549 *NOTE:
1550 *
1551 * @param pMac - Pointer to Global MAC structure
1552 * @return true - System is in Scan/Learn state
1553 * false - System is NOT in Scan/Learn state
1554 */
1555
1556tANI_U8
1557limIsSystemInScanState(tpAniSirGlobal pMac)
1558{
1559 switch (pMac->lim.gLimSmeState)
1560 {
1561 case eLIM_SME_CHANNEL_SCAN_STATE:
1562 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1563 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1564 case eLIM_SME_WT_SCAN_STATE:
1565 // System is in Learn mode
1566 return true;
1567
1568 default:
1569 // System is NOT in Learn mode
1570 return false;
1571 }
1572} /*** end limIsSystemInScanState() ***/
1573
1574
1575
1576/**
1577 * limIsSystemInActiveState()
1578 *
1579 *FUNCTION:
1580 * This function is called by various MAC software modules to
1581 * determine if System is in Active/Wakeup state
1582 *
1583 *LOGIC:
1584 * NA
1585 *
1586 *ASSUMPTIONS:
1587 * NA
1588 *
1589 *NOTE:
1590 *
1591 * @param pMac - Pointer to Global MAC structure
1592 * @return true - System is in Active state
1593 * false - System is not in Active state
1594 */
1595
1596tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1597{
1598 switch (pMac->pmm.gPmmState)
1599 {
1600 case ePMM_STATE_BMPS_WAKEUP:
1601 case ePMM_STATE_IMPS_WAKEUP:
1602 case ePMM_STATE_READY:
1603 // System is in Active mode
1604 return true;
1605 default:
1606 return false;
1607 // System is NOT in Active mode
1608 }
1609}
1610
1611
Jeff Johnson295189b2012-06-20 16:38:30 -07001612
Jeff Johnson295189b2012-06-20 16:38:30 -07001613
1614
1615/**
1616*\brief limReceivedHBHandler()
1617*
1618* This function is called by schBeaconProcess() upon
1619* receiving a Beacon on STA. This also gets called upon
1620* receiving Probe Response after heat beat failure is
1621* detected.
1622*
1623* param pMac - global mac structure
1624* param channel - channel number indicated in Beacon, Probe Response
1625* return - none
1626*/
1627
1628
1629void
1630limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1631{
1632 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1633 psessionEntry->LimRxedBeaconCntDuringHB++;
1634
1635 pMac->pmm.inMissedBeaconScenario = FALSE;
1636} /*** end limReceivedHBHandler() ***/
1637
1638
1639
1640#if 0
1641void limResetHBPktCount(tpPESession psessionEntry)
1642{
1643 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1644}
1645#endif
1646
1647
1648/*
1649 * limProcessWdsInfo()
1650 *
1651 *FUNCTION:
1652 * This function is called from schBeaconProcess in BP
1653 *
1654 *PARAMS:
1655 * @param pMac - Pointer to Global MAC structure
1656 * @param propIEInfo - proprietary IE info
1657 *
1658 *LOGIC:
1659 *
1660 *ASSUMPTIONS:
1661 * NA
1662 *
1663 *NOTE:
1664 *
1665 *
1666 *RETURNS:
1667 *
1668 */
1669
1670void limProcessWdsInfo(tpAniSirGlobal pMac,
1671 tSirPropIEStruct propIEInfo)
1672{
Jeff Johnson295189b2012-06-20 16:38:30 -07001673}
1674
1675
1676
1677/**
1678 * limInitWdsInfoParams()
1679 *
1680 *FUNCTION:
1681 * This function is called while processing
1682 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1683 * ind/set related parameters.
1684 *
1685 *LOGIC:
1686 *
1687 *ASSUMPTIONS:
1688 *
1689 *NOTE:
1690 *
1691 * @param pMac Pointer to Global MAC structure
1692 * @return None
1693 */
1694
1695void
1696limInitWdsInfoParams(tpAniSirGlobal pMac)
1697{
1698 pMac->lim.gLimWdsInfo.wdsLength = 0;
1699 pMac->lim.gLimNumWdsInfoInd = 0;
1700 pMac->lim.gLimNumWdsInfoSet = 0;
1701} /*** limInitWdsInfoParams() ***/
1702
1703
1704/** -------------------------------------------------------------
1705\fn limUpdateOverlapStaParam
1706\brief Updates overlap cache and param data structure
1707\param tpAniSirGlobal pMac
1708\param tSirMacAddr bssId
1709\param tpLimProtStaParams pStaParams
1710\return None
1711 -------------------------------------------------------------*/
1712void
1713limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1714{
1715 int i;
1716 if (!pStaParams->numSta)
1717 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301718 vos_mem_copy(pMac->lim.protStaOverlapCache[0].addr,
1719 bssId,
1720 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 pMac->lim.protStaOverlapCache[0].active = true;
1722
1723 pStaParams->numSta = 1;
1724
1725 return;
1726 }
1727
1728 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1729 {
1730 if (pMac->lim.protStaOverlapCache[i].active)
1731 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301732 if (vos_mem_compare( pMac->lim.protStaOverlapCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 bssId,
1734 sizeof(tSirMacAddr))) {
1735 return; }
1736 }
1737 else
1738 break;
1739 }
1740
1741 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1742 {
Shake M Subhani5d80fda2013-12-09 17:28:23 +05301743 PELOG1(limLog(pMac, LOGW, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 }
1745 else
1746 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301747 vos_mem_copy(pMac->lim.protStaOverlapCache[i].addr,
1748 bssId,
1749 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 pMac->lim.protStaOverlapCache[i].active = true;
1751
1752 pStaParams->numSta++;
1753 }
1754}
1755
1756
1757/**
1758 * limHandleIBSScoalescing()
1759 *
1760 *FUNCTION:
1761 * This function is called upon receiving Beacon/Probe Response
1762 * while operating in IBSS mode.
1763 *
1764 *LOGIC:
1765 *
1766 *ASSUMPTIONS:
1767 *
1768 *NOTE:
1769 *
1770 * @param pMac - Pointer to Global MAC structure
1771 * @param pBeacon - Parsed Beacon Frame structure
1772 * @param pRxPacketInfo - Pointer to RX packet info structure
1773 *
1774 * @return Status whether to process or ignore received Beacon Frame
1775 */
1776
1777tSirRetStatus
1778limHandleIBSScoalescing(
1779 tpAniSirGlobal pMac,
1780 tpSchBeaconStruct pBeacon,
1781 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1782{
1783 tpSirMacMgmtHdr pHdr;
1784 tSirRetStatus retCode;
1785
1786 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001787 if ( (!pBeacon->capabilityInfo.ibss) ||
Abhishek Singhd5c31272014-03-07 14:46:50 +05301788 ( psessionEntry->privacy !=
1789 (tANI_U8)pBeacon->capabilityInfo.privacy ) ||
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001790 (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) ||
1791 (psessionEntry->currentOperChannel != pBeacon->channelNumber) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 /* Received SSID does not match => Ignore received Beacon frame. */
1793 retCode = eSIR_LIM_IGNORE_BEACON;
1794 else
1795 {
1796 tANI_U32 ieLen;
1797 tANI_U16 tsfLater;
1798 tANI_U8 *pIEs;
1799 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1800 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1801 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Abhishek Singh127a8442014-12-15 17:31:27 +05301802 limLog(pMac, LOG1, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1804 }
1805 return retCode;
1806} /*** end limHandleIBSScoalescing() ***/
1807
Abhishek Singh5fef4042014-11-25 18:33:00 +05301808tAniBool limEncTypeMatched(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon,
1809 tpPESession pSession)
1810{
1811 if (!pBeacon || !pSession)
1812 return eSIR_FALSE;
1813
1814 limLog(pMac, LOG1,
1815 FL("Beacon/Probe:: Privacy :%d WPA Present:%d RSN Present: %d"),
1816 pBeacon->capabilityInfo.privacy, pBeacon->wpaPresent,
1817 pBeacon->rsnPresent);
1818 limLog(pMac, LOG1,
Abhishek Singheef5c992016-01-27 13:41:54 +05301819 FL("pSession:: Privacy :%d EncyptionType: %d WPS %d OSEN %d"),
Abhishek Singh5fef4042014-11-25 18:33:00 +05301820 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps),
Abhishek Singheef5c992016-01-27 13:41:54 +05301821 pSession->encryptType, pSession->bWPSAssociation,
1822 pSession->bOSENAssociation);
Abhishek Singh5fef4042014-11-25 18:33:00 +05301823
1824 /* This is handled by sending probe req due to IOT issues so return TRUE
1825 */
1826 if ( (pBeacon->capabilityInfo.privacy) !=
1827 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps))
1828 {
1829 limLog(pMac, LOG1, FL("Return for Privacy bit miss match, As "
1830 "for this driver need to send the probe request to handle"
1831 " IOT issues "));
1832 return eSIR_TRUE;
1833 }
1834
1835 /*Open*/
1836 if( (pBeacon->capabilityInfo.privacy == 0) &&
1837 (pSession->encryptType == eSIR_ED_NONE))
1838 return eSIR_TRUE;
1839
1840 /* WEP */
1841 if ( (pBeacon->capabilityInfo.privacy == 1) && (pBeacon->wpaPresent == 0) &&
1842 (pBeacon->rsnPresent == 0) &&
Abhishek Singh31dfa3c2014-12-12 17:25:19 +05301843 ( ( pSession->encryptType == eSIR_ED_WEP40 ) ||
1844 ( pSession->encryptType == eSIR_ED_WEP104 )
1845#ifdef FEATURE_WLAN_WAPI
1846 || ( pSession->encryptType == eSIR_ED_WPI )
1847#endif
1848 ))
Abhishek Singh5fef4042014-11-25 18:33:00 +05301849 return eSIR_TRUE;
1850
1851 /* WPA OR RSN*/
1852 if ( (pBeacon->capabilityInfo.privacy == 1) &&
1853 ( (pBeacon->wpaPresent == 1) ||
1854 ( pBeacon->rsnPresent == 1)) &&
1855 ( (pSession->encryptType == eSIR_ED_TKIP) ||
1856 (pSession->encryptType == eSIR_ED_CCMP) ||
1857 (pSession->encryptType == eSIR_ED_AES_128_CMAC)))
1858 return eSIR_TRUE;
1859
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301860 /* For HS2.0, RSN ie is not present
1861 * in beacon. Therefore no need to
1862 * check for security type in case
1863 * OSEN session.
Abhishek Singheef5c992016-01-27 13:41:54 +05301864 * For WPS registration session no need to detect
1865 * security mismatch as it wont match and
1866 * driver may end up sending probe request without
1867 * WPS IE during WPS registartion process.
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301868 */
1869 /*TODO: AP capability mismatch
1870 * is not checked here because
1871 * no logic for beacon parsing
1872 * is avilable for HS2.0.
1873 */
Abhishek Singheef5c992016-01-27 13:41:54 +05301874 if (pSession->bOSENAssociation ||
1875 pSession->bWPSAssociation)
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301876 return eSIR_TRUE;
1877
Abhishek Singh5fef4042014-11-25 18:33:00 +05301878 return eSIR_FALSE;
1879}
Jeff Johnson295189b2012-06-20 16:38:30 -07001880
1881
1882/**
1883 * limDetectChangeInApCapabilities()
1884 *
1885 *FUNCTION:
1886 * This function is called while SCH is processing
1887 * received Beacon from AP on STA to detect any
1888 * change in AP's capabilities. If there any change
1889 * is detected, Roaming is informed of such change
1890 * so that it can trigger reassociation.
1891 *
1892 *LOGIC:
1893 *
1894 *ASSUMPTIONS:
1895 *
1896 *NOTE:
1897 * Notification is enabled for STA product only since
1898 * it is not a requirement on BP side.
1899 *
1900 * @param pMac Pointer to Global MAC structure
1901 * @param pBeacon Pointer to parsed Beacon structure
1902 * @return None
1903 */
1904
1905void
1906limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1907 tpSirProbeRespBeacon pBeacon,
1908 tpPESession psessionEntry)
1909{
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 tANI_U8 len;
1911 tSirSmeApNewCaps apNewCaps;
1912 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301913 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh5fef4042014-11-25 18:33:00 +05301914 tAniBool securityCapsMatched = eSIR_TRUE;
1915
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1917 newChannel = (tANI_U8) pBeacon->channelNumber;
1918
Abhishek Singh5fef4042014-11-25 18:33:00 +05301919 securityCapsMatched = limEncTypeMatched(pMac, pBeacon, psessionEntry);
1920
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301921 if ( ( false == psessionEntry->limSentCapsChangeNtf ) &&
Abhishek Singh4f8446a2014-05-22 14:07:31 +05301922 ( ( ( !limIsNullSsid(&pBeacon->ssId) ) &&
1923 ( false == limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) ) ) ||
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301924 ( (SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
1925 SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps) ) ||
1926 ( SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1927 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps) ) ||
1928 ( SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1929 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps) ) ||
1930 ( SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
1931 SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps) ) ||
Abhishek Singh5fef4042014-11-25 18:33:00 +05301932 ( newChannel != psessionEntry->currentOperChannel ) ||
1933 (eSIR_FALSE == securityCapsMatched)
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301934 ) ) )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301935 {
Abhishek Singha9325f72015-01-05 11:49:23 +05301936 if ( false == psessionEntry->fWaitForProbeRsp )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301937 {
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301938 /* If Beacon capabilities is not matching with the current capability,
1939 * then send unicast probe request to AP and take decision after
1940 * receiving probe response */
1941 if ( true == psessionEntry->fIgnoreCapsChange )
1942 {
1943 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1944 return;
1945 }
1946 psessionEntry->fWaitForProbeRsp = true;
1947 limLog(pMac, LOGW, FL("AP capabilities are not matching,"
1948 "sending directed probe request.. "));
1949 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1950 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1951 psessionEntry->dot11mode, 0, NULL);
1952
1953 if ( eSIR_SUCCESS != status )
1954 {
1955 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1956 psessionEntry->fWaitForProbeRsp = false;
1957 }
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301958 return;
1959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 /**
1961 * BSS capabilities have changed.
1962 * Inform Roaming.
1963 */
1964 len = sizeof(tSirMacCapabilityInfo) +
1965 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1966 3 * sizeof(tANI_U8) + // reserved fields
1967 pBeacon->ssId.length + 1;
1968
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301969 vos_mem_copy(apNewCaps.bssId,
1970 psessionEntry->bssId,
1971 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 if (newChannel != psessionEntry->currentOperChannel)
1973 {
1974 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001975 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 psessionEntry->currentOperChannel, newChannel);)
1977 return;
1978 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301979
1980 /**
1981 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1982 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1983 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1984 * the privacy bit is set in Probe and association responses.
1985 * Due to this anomaly, we detect a change in
1986 * AP capabilities when we receive a beacon after association and
1987 * disconnect from the AP. The following check makes sure that we can
1988 * connect to such APs
1989 */
1990 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1991 (pBeacon->rsnPresent || pBeacon->wpaPresent))
1992 {
1993 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001994 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301995 return;
1996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 else
1998 apNewCaps.channelId = psessionEntry->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301999 vos_mem_copy((tANI_U8 *) &apNewCaps.ssId,
2000 (tANI_U8 *) &pBeacon->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 pBeacon->ssId.length + 1);
2002
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05302003 psessionEntry->fIgnoreCapsChange = false;
2004 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 psessionEntry->limSentCapsChangeNtf = true;
2006 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2007 (tANI_U32 *) &apNewCaps,
2008 len, psessionEntry->smeSessionId);
2009 }
Abhishek Singh4136e4e2013-12-15 11:56:29 +05302010 else if ( true == psessionEntry->fWaitForProbeRsp )
2011 {
2012 /* Only for probe response frames and matching capabilities the control
2013 * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
2014 * will be false, the control will not come here*/
2015
2016 limLog(pMac, LOG1, FL("capabilities in probe response are"
2017 "matching with the current setting,"
2018 "Ignoring subsequent capability"
2019 "mismatch"));
2020 psessionEntry->fIgnoreCapsChange = true;
2021 psessionEntry->fWaitForProbeRsp = false;
2022 }
2023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024} /*** limDetectChangeInApCapabilities() ***/
2025
2026
2027
2028
2029// ---------------------------------------------------------------------
2030/**
2031 * limUpdateShortSlot
2032 *
2033 * FUNCTION:
2034 * Enable/Disable short slot
2035 *
2036 * LOGIC:
2037 *
2038 * ASSUMPTIONS:
2039 *
2040 * NOTE:
2041 *
2042 * @param enable Flag to enable/disable short slot
2043 * @return None
2044 */
2045
2046tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2047{
2048
2049 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002050 tANI_U32 nShortSlot;
2051 tANI_U32 val = 0;
2052 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002053
Jeff Johnsone7245742012-09-05 17:12:55 -07002054 // Check Admin mode first. If it is disabled just return
2055 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2056 != eSIR_SUCCESS)
2057 {
2058 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002059 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002060 return eSIR_FAILURE;
2061 }
2062 if (val == false)
2063 return eSIR_SUCCESS;
2064
2065 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2066 limGetPhyMode(pMac, &phyMode, psessionEntry);
2067 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2068 return eSIR_SUCCESS;
2069
2070 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002071
2072 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2073 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2074 // if no erp present, use short slot based on current ap caps
2075
2076 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2077
2078 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2079 // The difference between the earlier implementation and the new one is only Case4.
2080 /*
2081 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2082 Case1 1 1 1 1 //AP should not advertise this combination.
2083 Case2 1 1 0 0
2084 Case3 1 0 1 1
2085 Case4 1 0 0 0
2086 Case5 0 1 1 1
2087 Case6 0 1 0 0
2088 Case7 0 0 1 1
2089 Case8 0 0 0 0
2090 */
2091 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2092
Jeff Johnsone7245742012-09-05 17:12:55 -07002093 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 {
2095 // Short slot time capability of AP has changed. Adopt to it.
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302096 limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002098 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2100 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 }
2102 return eSIR_SUCCESS;
2103}
2104
2105
Jeff Johnson295189b2012-06-20 16:38:30 -07002106
2107
Jeff Johnson295189b2012-06-20 16:38:30 -07002108
Jeff Johnson295189b2012-06-20 16:38:30 -07002109
2110
2111/** -----------------------------------------------------------------
2112 \brief limHandleLowRssiInd() - handles low rssi indication
2113
2114 This function process the SIR_HAL_LOW_RSSI_IND message from
2115 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2116
2117 \param pMac - global mac structure
2118
2119 \return
2120
2121 \sa
2122 ----------------------------------------------------------------- */
2123void limHandleLowRssiInd(tpAniSirGlobal pMac)
2124{
2125#if 0 //RSSI related indications will now go to TL and not PE
2126 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2127 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2128 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2129 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002130 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2132 }
2133 else
2134 {
2135 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002136 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 pMac->pmm.gPmmState);
2138 }
2139 return;
2140#endif
2141}
2142
2143
2144/** -----------------------------------------------------------------
2145 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2146
2147 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2148 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2149 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2150
2151 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2152 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2153 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2154 This message can also come from FW anytime after we have entered BMPS.
2155 This means we should handle it in WoWL and UAPSD states as well
2156
2157 \param pMac - global mac structure
2158 \return - none
2159 \sa
2160 ----------------------------------------------------------------- */
2161void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2162{
2163 switch(pMac->pmm.gPmmState)
2164 {
2165 case ePMM_STATE_BMPS_SLEEP:
2166 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2167 case ePMM_STATE_UAPSD_SLEEP:
2168 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2169 case ePMM_STATE_WOWLAN:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302170 limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2172 break;
2173
2174 default:
2175 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002176 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 pMac->pmm.gPmmState);
2178 break;
2179 }
2180 return;
2181}
2182
Kapil Gupta7a3d9b12016-12-20 20:36:38 +05302183#ifdef WLAN_FEATURE_APFIND
2184void limHandleAPFindInd(tpAniSirGlobal pMac)
2185{
2186 tANI_S8 pe_sessionid = -1;
2187 /* Find STA connection session */
2188 pe_sessionid = limGetInfraSessionId(pMac);
2189 if (pe_sessionid != -1)
2190 limTearDownLinkWithAp(pMac,
2191 pe_sessionid,
2192 eSIR_BEACON_MISSED);
2193 else
2194 limLog(pMac, LOGE,
2195 FL("session id doesn't exist for infra"));
2196}
2197#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002198
2199/** -----------------------------------------------------------------
2200 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2201
2202 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2203 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2204 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2205
2206 \param pMac - global mac structure
2207 \return - none
2208 \sa
2209 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002210void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002211{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002212#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2213 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2214 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2215 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2216 if (psessionEntry == NULL)
2217 {
2218 limLog(pMac, LOGE,
2219 FL("session does not exist for given BSSIdx:%d"),
2220 pSirMissedBeaconInd->bssIdx);
2221 return;
2222 }
2223#endif
Gupta, Kapil2fc8ca22016-02-19 12:22:17 +05302224 if (pMac->pmm.inMissedBeaconScenario == TRUE) {
2225 limLog(pMac, LOGW,
2226 FL("beacon miss handling is already going on for BSSIdx:%d"),
2227 pSirMissedBeaconInd->bssIdx);
2228 return;
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2231 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2232 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2233 {
2234 pMac->pmm.inMissedBeaconScenario = TRUE;
Madan Mohan Koyyalamudi1a30a552013-09-17 21:20:07 +05302235 PELOGE(limLog(pMac, LOGE,
2236 FL("Sending EXIT_BMPS_IND to SME due to Missed beacon from FW"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2238 }
Yathish9f22e662012-12-10 14:21:35 -08002239/* ACTIVE_MODE_HB_OFFLOAD */
2240#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2241 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2242 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2243 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2244 {
2245 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002246 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002247 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002248 }
2249#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 else
2251 {
2252 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002253 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 pMac->pmm.gPmmState);
2255 }
2256 return;
2257}
2258
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05302259
2260void limUpdateLostLinkParams(tpAniSirGlobal pMac,
2261 tpPESession psessionEntry, tANI_U8 *pRxPacketInfo)
2262{
2263 tpSirSmeLostLinkParamsInd pSmeLostLinkParams;
2264 tSirMsgQ mmhMsg;
2265 if (NULL == pRxPacketInfo)
2266 {
2267 return;
2268 }
2269 pSmeLostLinkParams =
2270 (tpSirSmeLostLinkParamsInd)vos_mem_malloc(sizeof(tSirSmeLostLinkParamsInd));
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05302271 if (NULL == pSmeLostLinkParams)
2272 {
2273 limLog(pMac, LOGP,
2274 FL("Failed to alloc mem of size %zu for tSirSmeLostLinkParamsInd"),
2275 sizeof(*pSmeLostLinkParams));
2276 return;
2277 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05302278 vos_mem_set(pSmeLostLinkParams, sizeof(tSirSmeLostLinkParamsInd), 0);
2279 pSmeLostLinkParams->messageType = eWNI_SME_LOST_LINK_PARAMS_IND;
2280 pSmeLostLinkParams->length = sizeof(tSirSmeLostLinkParamsInd);
2281 pSmeLostLinkParams->sessionId = psessionEntry->smeSessionId;
2282 pSmeLostLinkParams->info.bssIdx = psessionEntry->bssIdx;
2283
2284 /*
2285 * Since FW adds 100 to RSSI, here also we are adding 100 so that
2286 * HDD has common logic to subtract 100 from RSSI received
2287 */
2288 pSmeLostLinkParams->info.rssi = WDA_GET_RX_RSSI_DB(pRxPacketInfo) + 100;
2289 vos_mem_copy(pSmeLostLinkParams->info.selfMacAddr,
2290 psessionEntry->selfMacAddr,
2291 sizeof(tSirMacAddr));
2292 pSmeLostLinkParams->info.lastDataRate = 0;
2293 pSmeLostLinkParams->info.linkFlCnt = 0;
2294 pSmeLostLinkParams->info.linkFlTx = 0;
2295 pSmeLostLinkParams->info.rsvd1 = 0;
2296 pSmeLostLinkParams->info.rsvd2 = 0;
2297
2298 mmhMsg.type = eWNI_SME_LOST_LINK_PARAMS_IND;
2299 mmhMsg.bodyptr = pSmeLostLinkParams;
2300 mmhMsg.bodyval = 0;
2301 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2302}
2303
2304/** -----------------------------------------------------------------
2305 \brief limProcessLostLinkParamsInd() - handles lost link params indication
2306
2307 This function process the SIR_HAL_LOST_LINK_PARAMS_IND message from HAL,
2308
2309 \param pMac - global mac structure
2310 \return - none
2311 \sa
2312 ----------------------------------------------------------------- */
2313
2314void limProcessLostLinkParamsInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2315{
2316 tpSirSmeLostLinkParamsInd pSmeLostLinkParamsInd;
2317 tpSirSmeLostLinkParamsInd pLostLInkParamsInd = (tpSirSmeLostLinkParamsInd)pMsg->bodyptr;
2318 tpPESession psessionEntry ;
2319 tSirMsgQ mmhMsg;
2320
2321 if (NULL == pLostLInkParamsInd)
2322 {
2323 limLog(pMac, LOGE,
2324 FL("pLostLInkParamsInd is NULL"));
2325 return;
2326 }
2327
2328 psessionEntry = peFindSessionByBssIdx(pMac,pLostLInkParamsInd->info.bssIdx);
2329 if (psessionEntry == NULL)
2330 {
2331 limLog(pMac, LOGE,
2332 FL("session does not exist for bdssIdx : %d"),
2333 pLostLInkParamsInd->info.bssIdx);
2334
2335 return;
2336 }
2337 pSmeLostLinkParamsInd = vos_mem_malloc(sizeof(tSirSmeLostLinkParamsInd));
2338 if (pSmeLostLinkParamsInd == NULL)
2339 {
2340 limLog(pMac, LOGP,
2341 FL("memory allocate failed for eWNI_SME_LOST_LINK_PARAMD_IND"));
2342 return;
2343 }
2344 pSmeLostLinkParamsInd->messageType = eWNI_SME_LOST_LINK_PARAMS_IND;
2345 pSmeLostLinkParamsInd->length = sizeof(tSirSmeLostLinkParamsInd);
2346 pSmeLostLinkParamsInd->sessionId = psessionEntry->smeSessionId;
2347 pSmeLostLinkParamsInd->info.bssIdx = pLostLInkParamsInd->info.bssIdx;
2348 pSmeLostLinkParamsInd->info.rssi = pLostLInkParamsInd->info.rssi;
2349 vos_mem_copy(pSmeLostLinkParamsInd->info.selfMacAddr,
2350 pLostLInkParamsInd->info.selfMacAddr,
2351 sizeof(tSirMacAddr));
2352 pSmeLostLinkParamsInd->info.linkFlCnt = pLostLInkParamsInd->info.linkFlCnt;
2353 pSmeLostLinkParamsInd->info.linkFlTx = pLostLInkParamsInd->info.linkFlTx;
2354 pSmeLostLinkParamsInd->info.lastDataRate = pLostLInkParamsInd->info.lastDataRate;
2355 pSmeLostLinkParamsInd->info.rsvd1 = pLostLInkParamsInd->info.rsvd1;
2356 pSmeLostLinkParamsInd->info.rsvd2 = pLostLInkParamsInd->info.rsvd2;
2357
2358 mmhMsg.type = eWNI_SME_LOST_LINK_PARAMS_IND;
2359 mmhMsg.bodyptr = pSmeLostLinkParamsInd;
2360 mmhMsg.bodyval = 0;
2361 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2362 return;
2363}
2364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365/** -----------------------------------------------------------------
2366 \brief limMicFailureInd() - handles mic failure indication
2367
2368 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2369
2370 \param pMac - global mac structure
2371 \return - none
2372 \sa
2373 ----------------------------------------------------------------- */
2374void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2375{
2376 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2377 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2378 tSirMsgQ mmhMsg;
2379 tpPESession psessionEntry ;
2380 tANI_U8 sessionId;
2381
2382 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2383 {
2384 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002385 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 return;
2387 }
2388
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302389 pSirSmeMicFailureInd = vos_mem_malloc(sizeof(tSirSmeMicFailureInd));
2390 if (NULL == pSirSmeMicFailureInd)
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 {
2392 // Log error
2393 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002394 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 return;
2396 }
2397
2398 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
Sunkad, Anand Ningappabf1650a2016-02-08 12:08:13 +05302399 pSirSmeMicFailureInd->length = sizeof(*pSirSmeMicFailureInd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2401
2402 vos_mem_copy(pSirSmeMicFailureInd->bssId,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302403 pSirMicFailureInd->bssId,
2404 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002405
2406 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302407 pSirMicFailureInd->info.srcMacAddr,
2408 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002409
2410 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302411 pSirMicFailureInd->info.taMacAddr,
2412 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002413
2414 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302415 pSirMicFailureInd->info.dstMacAddr,
2416 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
2418 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302419 pSirMicFailureInd->info.rxMacAddr,
2420 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002421
2422 pSirSmeMicFailureInd->info.multicast =
2423 pSirMicFailureInd->info.multicast;
2424
2425 pSirSmeMicFailureInd->info.keyId=
2426 pSirMicFailureInd->info.keyId;
2427
2428 pSirSmeMicFailureInd->info.IV1=
2429 pSirMicFailureInd->info.IV1;
2430
2431 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302432 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002433
2434 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2435 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2436 mmhMsg.bodyval = 0;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05302437 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2439 return;
2440}
2441
Sushant Kaushik1f5f54b2015-07-28 14:32:22 +05302442#ifdef WLAN_FEATURE_11W
2443/** --------------------------------------------------------------------
2444 * lim_is_assoc_req_for_drop()- function to decides to drop assoc\reassoc
2445 * frames.
2446 * @mac: pointer to global mac structure
2447 * @rx_pkt_info: rx packet meta information
2448 *
2449 * This function is called before enqueuing the frame to PE queue to
2450 * drop flooded assoc/reassoc frames getting into PE Queue.
2451 *
2452 * Return: true for dropping the frame otherwise false
2453----------------------------------------------------------------------*/
2454
2455bool lim_is_assoc_req_for_drop(tpAniSirGlobal pMac, uint8_t *rx_pkt_info)
2456{
2457 tANI_U8 session_id;
2458 tANI_U16 aid;
2459 tpPESession session_entry;
2460 tpSirMacMgmtHdr pMacHdr;
2461 tpDphHashNode sta_ds;
2462
2463 pMacHdr = WDA_GET_RX_MAC_HEADER(rx_pkt_info);
2464 session_entry = peFindSessionByBssid(pMac, pMacHdr->bssId, &session_id);
2465 if (!session_entry)
2466 {
2467 PELOG1(limLog(pMac, LOG1,
2468 FL("session does not exist for given STA [%pM]"),
2469 pMacHdr->sa););
2470 return false;
2471 }
2472 sta_ds = dphLookupHashEntry(pMac, pMacHdr->sa, &aid,
2473 &session_entry->dph.dphHashTable);
2474 if (!sta_ds)
2475 {
2476 PELOG1(limLog(pMac, LOG1, FL("pStaDs is NULL")););
2477 return false;
2478 }
2479
2480 if (!sta_ds->rmfEnabled)
2481 return false;
2482
2483 if (sta_ds->pmfSaQueryState == DPH_SA_QUERY_IN_PROGRESS)
2484 return true;
2485
2486 if (sta_ds->last_assoc_received_time &&
2487 ((vos_timer_get_system_time() -
2488 sta_ds->last_assoc_received_time) < 1000))
2489 return true;
2490
2491 sta_ds->last_assoc_received_time = vos_timer_get_system_time();
2492 return false;
2493}
2494#endif
2495
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302496/** ----------------------------------------------------------------------
2497 *\brief limIsDeauthDiassocForDrop()..decides to drop deauth\diassoc frames.
2498 *This function is called before enqueuing the frame to PE queue.
2499 *This prevents deauth/diassoc frames getting into PE Queue.
Jeff Johnson295189b2012-06-20 16:38:30 -07002500
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302501------------------------------------------------------------------------ */
2502
2503
2504boolean limIsDeauthDiassocForDrop(tpAniSirGlobal pMac,
2505 tANI_U8 *pRxPacketInfo)
2506{
2507 tANI_U8 sessionId;
2508 tANI_U16 aid;
2509 tpPESession psessionEntry;
2510 tpSirMacMgmtHdr pMacHdr;
2511 tpDphHashNode pStaDs;
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302512 eHalStatus lock_status = eHAL_STATUS_SUCCESS;
2513 boolean ret = FALSE;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302514
2515 pMacHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2516 psessionEntry = peFindSessionByBssid(pMac,pMacHdr->bssId,&sessionId);
2517 if (!psessionEntry)
2518 {
2519 PELOG1(sysLog(pMac, LOG1,
2520 FL("session does not exist for given STA [%pM]"),
2521 pMacHdr->sa););
2522 return TRUE;
2523 }
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302524
2525 lock_status = pe_AcquireGlobalLock(&pMac->lim);
2526 if (lock_status != eHAL_STATUS_SUCCESS)
2527 {
2528 limLog(pMac, LOGE, FL("pe_AcquireGlobalLock error"));
2529 return TRUE;
2530 }
2531
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302532 pStaDs = dphLookupHashEntry(pMac, pMacHdr->sa, &aid,
2533 &psessionEntry->dph.dphHashTable);
2534 if (!pStaDs)
2535 {
2536 PELOG1(sysLog(pMac, LOG1,FL("pStaDs is NULL")););
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302537 ret = TRUE;
2538 goto end;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302539 }
2540#ifdef WLAN_FEATURE_11W
2541 if (psessionEntry->limRmfEnabled)
2542 {
2543 if ((WDA_GET_RX_DPU_FEEDBACK(pRxPacketInfo) &
2544 DPU_FEEDBACK_UNPROTECTED_ERROR))
2545 {
2546 /* It may be possible that deauth/diassoc frames from a spoofy
2547 * AP is received. So if all further deauth/diassoc frmaes are
2548 * dropped, then it may result in lossing deauth/diassoc frames
2549 * from genuine AP. So process all deauth/diassoc frames with
2550 * a time difference of 1 sec.
2551 */
2552 if (vos_timer_get_system_time() - pStaDs->last_unprot_deauth_disassoc < 1000)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302553 {
2554 ret = TRUE;
2555 goto end;
2556 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302557 pStaDs->last_unprot_deauth_disassoc =
2558 vos_timer_get_system_time();
2559 }
2560/* PMF enabed, Management frames are protected */
2561 else
2562 {
2563 if (pStaDs->proct_deauh_disassoc_cnt)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302564 {
2565 ret = TRUE;
2566 goto end;
2567 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302568 else
2569 pStaDs->proct_deauh_disassoc_cnt++;
2570 }
2571 }
2572 else
2573#endif
2574/* PMF disabled */
2575 {
2576 if (pStaDs->isDisassocDeauthInProgress)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302577 {
2578 ret = TRUE;
2579 goto end;
2580 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302581 else
2582 pStaDs->isDisassocDeauthInProgress++;
2583 }
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302584
2585end:
2586 pe_ReleaseGlobalLock(&pMac->lim);
2587 return ret;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302588}
Jeff Johnson295189b2012-06-20 16:38:30 -07002589/** -----------------------------------------------------------------
2590 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2591
2592 This function is called before enqueuing the frame to PE queue for further processing.
2593 This prevents unnecessary frames getting into PE Queue and drops them right away.
2594 Frames will be droped in the following scenarios:
2595
2596 - In Scan State, drop the frames which are not marked as scan frames
2597 - In non-Scan state, drop the frames which are marked as scan frames.
2598 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2599 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2600
2601 \param pMac - global mac structure
2602 \return - none
2603 \sa
2604 ----------------------------------------------------------------- */
2605
2606tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2607{
2608 tANI_U32 framelen;
2609 tANI_U8 *pBody;
2610 tSirMacCapabilityInfo capabilityInfo;
2611
2612 /*
2613 *
2614 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2615 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2616 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2617 * other than beacons or probe responses in scan state.
2618 */
2619 if( (subType == SIR_MAC_MGMT_BEACON) ||
2620 (subType == SIR_MAC_MGMT_PROBE_RSP))
2621 {
2622 if(pMac->pmm.inMissedBeaconScenario)
2623 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002624 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2625 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 }
2627 if (limIsSystemInScanState(pMac))
2628 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002629 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002631#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2632 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2633 {
2634 return eMGMT_DROP_NO_DROP;
2635 }
2636#endif
Dino Mycle7a76e662014-06-10 11:36:34 +05302637#ifdef WLAN_FEATURE_EXTSCAN
2638 else if (WDA_GET_EXTSCANFULLSCANRESIND(pRxPacketInfo))
2639 {
2640 return eMGMT_DROP_NO_DROP;
2641 }
2642#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2644 {
2645 return eMGMT_DROP_SCAN_MODE_FRAME;
2646 }
2647 }
2648
2649 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2650 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2651
2652 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2653 * beacons from an infrastructure network
2654 */
2655 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2656 if(!capabilityInfo.ibss)
2657 return eMGMT_DROP_NO_DROP;
2658#if 0
2659 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2660 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2661 return eMGMT_DROP_NO_DROP;
2662#endif
2663
Sushant Kaushik1f5f54b2015-07-28 14:32:22 +05302664#ifdef WLAN_FEATURE_11W
2665 if ((subType == SIR_MAC_MGMT_ASSOC_REQ ||
2666 subType == SIR_MAC_MGMT_REASSOC_REQ) &&
2667 lim_is_assoc_req_for_drop(pMac, pRxPacketInfo))
2668 return eMGMT_DROP_SPURIOUS_FRAME;
2669#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2671 if( (subType == SIR_MAC_MGMT_BEACON) ||
2672 (subType == SIR_MAC_MGMT_PROBE_RSP))
2673 {
2674 //drop the frame if length is less than 12
2675 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2676 return eMGMT_DROP_INVALID_SIZE;
2677
2678 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2679
2680 //This can be enhanced to even check the SSID before deciding to enque the frame.
2681 if(capabilityInfo.ess)
2682 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2683 }
2684 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2685 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2686 {
2687 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2688 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2689 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2690 }
2691
2692 return eMGMT_DROP_NO_DROP;
2693}
2694
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002695eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2696{
2697 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002698
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002699 if(psPe)
2700 {
2701 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2702 {
2703 status = eHAL_STATUS_SUCCESS;
2704 }
2705 }
2706 return (status);
2707}
2708eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2709{
2710 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2711 if(psPe)
2712 {
2713 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2714 {
2715 status = eHAL_STATUS_SUCCESS;
2716 }
2717 }
2718 return (status);
2719}
Manjeet Singh3ed79242017-01-11 19:04:32 +05302720/**
2721 * lim_process_sme_cap_tsf_req()- send cap tsf request to WDA
2722 * Get bss_idx from PE and fill in cap tsf request.
2723 * @pMac:Mac ctx
2724 * @pMsgBuf: message buffer from sme
2725 * Returns success on post to WDA, otherwise failure
2726 */
2727
2728tSirRetStatus lim_process_sme_cap_tsf_req(tpAniSirGlobal pMac,
2729 tANI_U32 *pMsgBuf)
2730{
2731 tSirCapTsfParams *pMsg = NULL;
2732 tpPESession psessionEntry = NULL;
2733 uint8_t sessionId;
2734 tSirMsgQ msg;
2735 tSirCapTsfParams *cap_tsf_params;
2736
2737 pMsg = (tSirCapTsfParams*)pMsgBuf;
2738 if (pMsg == NULL) {
2739 limLog(pMac, LOGE, FL("NULL pMsg"));
2740 return eSIR_FAILURE;
2741 }
2742
2743 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
2744 if (NULL == psessionEntry)
2745 {
2746 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2747 return eSIR_FAILURE;
2748 }
2749 cap_tsf_params = (tSirCapTsfParams *)
2750 vos_mem_malloc(sizeof(*cap_tsf_params));
2751 if (!cap_tsf_params) {
2752 limLog(pMac, LOGE, FL(" Unable to allocate memory for cap tsf params"));
2753 return eSIR_MEM_ALLOC_FAILED;
2754 }
2755 vos_mem_copy (cap_tsf_params, pMsg, sizeof(*cap_tsf_params));
2756 cap_tsf_params->bss_idx = psessionEntry->bssIdx;
2757
2758 msg.type = WDA_CAP_TSF_REQ;
2759 msg.reserved = 0;
2760 msg.bodyptr = cap_tsf_params;
2761 msg.bodyval = 0;
2762 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
2763 {
2764 limLog(pMac, LOGE, FL("lim_process_sme_cap_tsf_req failed\n"));
2765 vos_mem_free(cap_tsf_params);
2766 return eSIR_FAILURE;
2767 }
2768
2769 return eSIR_SUCCESS;
2770}
2771
2772/**
2773 * lim_process_sme_get_tsf_req()- send get tsf request to WDA
2774 * Get bss_idx from PE and fill in cap tsf request.
2775 * @pMac:Mac ctx
2776 * @pMsgBuf: message buffer from sme
2777 * Returns success on post to WDA, otherwise failure
2778 */
2779tSirRetStatus lim_process_sme_get_tsf_req(tpAniSirGlobal pMac,
2780 tANI_U32 *pMsgBuf)
2781{
2782 tSirCapTsfParams *pMsg = NULL;
2783 tpPESession psessionEntry = NULL;
2784 uint8_t sessionId;
2785 tSirMsgQ msg;
2786 tSirCapTsfParams *get_tsf_params;
2787
2788 pMsg = (tSirCapTsfParams*)pMsgBuf;
2789 if (pMsg == NULL) {
2790 limLog(pMac, LOGE, FL("NULL pMsg"));
2791 return eSIR_FAILURE;
2792 }
2793
2794 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
2795 if (NULL == psessionEntry)
2796 {
2797 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2798 return eSIR_FAILURE;
2799 }
2800 get_tsf_params = (tSirCapTsfParams *)
2801 vos_mem_malloc(sizeof(*get_tsf_params));
2802 if (!get_tsf_params) {
2803 limLog(pMac, LOGE, FL(" Unable to allocate memory for cap tsf params"));
2804 return eSIR_MEM_ALLOC_FAILED;
2805 }
2806 vos_mem_copy (get_tsf_params, pMsg, sizeof(*get_tsf_params));
2807 get_tsf_params->bss_idx = psessionEntry->bssIdx;
2808
2809 msg.type = WDA_GET_TSF_REQ;
2810 msg.reserved = 0;
2811 msg.bodyptr = get_tsf_params;
2812 msg.bodyval = 0;
2813 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
2814 {
2815 limLog(pMac, LOGE, FL("lim_process_sme_cap_tsf_req failed\n"));
2816 vos_mem_free(get_tsf_params);
2817 return eSIR_FAILURE;
2818 }
2819
2820 return eSIR_SUCCESS;
2821}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05302822
2823/**
2824 * lim_process_sme_del_ba_ses_req()- process del ba req
2825 * @pMac:Mac ctx
2826 * @pMsgBuf: message buffer from sme
2827 * Returns success on taking action based on cfg value, otherwise failure
2828 */
2829tSirRetStatus lim_process_sme_del_ba_ses_req(tpAniSirGlobal pMac,
2830 tANI_U32 *pMsgBuf)
2831{
2832 tDelBaParams *pMsg = NULL;
2833 tpPESession psessionEntry = NULL;
2834 int val;
2835
2836 pMsg = (tDelBaParams*)pMsgBuf;
2837 if (pMsg == NULL) {
2838 limLog(pMac, LOGE, FL("NULL pMsg"));
2839 return eSIR_FAILURE;
2840 }
2841
2842 psessionEntry = peFindSessionBySessionId(pMac, pMsg->session_id);
2843 if (NULL == psessionEntry)
2844 {
2845 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2846 return eSIR_FAILURE;
2847 }
2848
2849 if (wlan_cfgGetInt
2850 (pMac, WNI_CFG_ENABLE_TX_RX_AGGREGATION, &val) !=
2851 eSIR_SUCCESS)
2852 {
2853 limLog(pMac, LOGE,
2854 FL( "Unable to get WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
2855 return eSIR_FAILURE;
2856 }
2857
2858 if (!val)
2859 {
2860 limLog(pMac, LOGW,
2861 FL("user requested to disable all RX BA sessions"));
2862 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2863 eSIR_MAC_PEER_TIMEDOUT_REASON);
2864 }
2865
2866 return eSIR_SUCCESS;
2867}