blob: 988eec33f6768733c291ae788a0b3e3b6708bd2e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Himanshu Agarwal9c9f1c12018-02-12 19:38:09 +05302 * Copyright (c) 2011-2018 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{
Himanshu Agarwal9c9f1c12018-02-12 19:38:09 +0530715 assoc_rsp_tx_context *pAssocRspCtx;
716
717 while(vos_list_remove_front(&pMac->assoc_rsp_completion_list,
718 (vos_list_node_t**)&pAssocRspCtx) == VOS_STATUS_SUCCESS)
719 {
720 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
721 FL("Fixing leak! Deallocating pAssocRspCtx node %lu"),
722 (unsigned long)pAssocRspCtx);
723 vos_mem_free(pAssocRspCtx);
724 }
Kapil Gupta956c0c42017-06-16 19:24:31 +0530725 vos_list_destroy(&pMac->assoc_rsp_completion_list);
726}
727
Jeff Johnson295189b2012-06-20 16:38:30 -0700728/**
729 * limInitialize()
730 *
731 *FUNCTION:
732 * This function is called from LIM thread entry function.
733 * LIM related global data structures are initialized in this function.
734 *
735 *LOGIC:
736 * NA
737 *
738 *ASSUMPTIONS:
739 * NA
740 *
741 *NOTE:
742 * NA
743 *
744 * @param pMac - Pointer to global MAC structure
745 * @return None
746 */
747
748tSirRetStatus
749limInitialize(tpAniSirGlobal pMac)
750{
751 tSirRetStatus status = eSIR_SUCCESS;
752
753 __limInitAssocVars(pMac);
754 __limInitVars(pMac);
755 __limInitStates(pMac);
756 __limInitStatsVars(pMac);
757 __limInitBssVars(pMac);
758 __limInitScanVars(pMac);
759 __limInitHTVars(pMac);
760 __limInitTitanVars(pMac);
761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 status = limStart(pMac);
763 if(eSIR_SUCCESS != status)
764 {
765 return status;
766 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700767
768 /*
769 * MLM will be intitalized when 'START' request comes from SME.
770 * limInitMlm calls limCreateTimers, which actually relies on
771 * CFG to be downloaded. So it should not be called as part of
772 * peStart, as CFG download is happening after peStart.
773 */
774 //limInitMlm(pMac);
775 // Initializations for maintaining peers in IBSS
776 limIbssInit(pMac);
777
Kapil Gupta956c0c42017-06-16 19:24:31 +0530778 limInitAssocRspCompletiontionList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 pmmInitialize(pMac);
780
781
782#if defined WLAN_FEATURE_VOWIFI
783 rrmInitialize(pMac);
784#endif
785#if defined WLAN_FEATURE_VOWIFI_11R
786 limFTOpen(pMac);
787#endif
788
Abhishek Singh00b71972016-01-07 10:51:04 +0530789#ifdef WLAN_FEATURE_RMC
790 limRmcInit(pMac);
791#endif /* WLAN_FEATURE_RMC */
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 vos_list_init(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700794
795#if 0
796
797 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR);
798 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN);
799 vos_trace_setLevel(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL);
800
801 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_WARN);
802 vos_trace_setLevel(VOS_MODULE_ID_HAL, VOS_TRACE_LEVEL_ERROR);
803
804 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_WARN);
805 vos_trace_setLevel(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR);
806 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
807
808 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
809
810 vos_trace_setLevel(VOS_MODULE_ID_SSC, VOS_TRACE_LEVEL_ERROR);
811
812 vos_trace_setLevel(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR);
813 vos_trace_setLevel(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR);
814
815 vos_trace_setLevel(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR);
816
817
818 vos_trace_setLevel(VOS_MODULE_ID_BAL, VOS_TRACE_LEVEL_ERROR);
819
820 vos_trace_setLevel(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR);
821#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700822
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 //Initialize the configurations needed by PE
824 if( eSIR_FAILURE == __limInitConfig(pMac))
825 {
826 //We need to undo everything in limStart
827 limCleanupMlm(pMac);
828 return eSIR_FAILURE;
829 }
830
831 //initialize the TSPEC admission control table.
832 //Note that this was initially done after resume notification from HAL.
833 //Now, DAL is started before PE so this can be done here
834 limAdmitControlInit(pMac);
835 limRegisterHalIndCallBack(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700836
837 return status;
838
839} /*** end limInitialize() ***/
840
841
842
843/**
844 * limCleanup()
845 *
846 *FUNCTION:
847 * This function is called upon reset or persona change
848 * to cleanup LIM state
849 *
850 *LOGIC:
851 * NA
852 *
853 *ASSUMPTIONS:
854 * NA
855 *
856 *NOTE:
857 * NA
858 *
859 * @param pMac - Pointer to Global MAC structure
860 * @return None
861 */
862
863void
864limCleanup(tpAniSirGlobal pMac)
865{
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 v_PVOID_t pvosGCTx;
867 VOS_STATUS retStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700868
Jeff Johnson295189b2012-06-20 16:38:30 -0700869//Before destroying the list making sure all the nodes have been deleted.
870//Which should be the normal case, but a memory leak has been reported.
871
872 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL;
873
874 while(vos_list_remove_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
875 (vos_list_node_t**)&pLimMgmtRegistration) == VOS_STATUS_SUCCESS)
876 {
877 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
878 FL("Fixing leak! Deallocating pLimMgmtRegistration node"));
879
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530880 vos_mem_free(pLimMgmtRegistration);
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 }
882
883 vos_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
Jeff Johnson295189b2012-06-20 16:38:30 -0700884
885 limCleanupMlm(pMac);
886 limCleanupLmm(pMac);
887
Abhishek Singh00b71972016-01-07 10:51:04 +0530888#ifdef WLAN_FEATURE_RMC
889 limRmcCleanup(pMac);
890#endif /* WLAN_FEATURE_RMC */
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 // free up preAuth table
893 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL)
894 {
Sushant Kaushikf4a27972015-04-16 16:48:00 +0530895 vos_mem_vfree(pMac->lim.gLimPreAuthTimerTable.pTable);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
897 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
898 }
899
900 if(NULL != pMac->lim.pDialogueTokenHead)
901 {
902 limDeleteDialogueTokenList(pMac);
903 }
904
905 if(NULL != pMac->lim.pDialogueTokenTail)
906 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530907 vos_mem_free(pMac->lim.pDialogueTokenTail);
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 pMac->lim.pDialogueTokenTail = NULL;
909 }
910
911 # if 0
912 if (pMac->lim.gpLimStartBssReq != NULL)
913 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530914 vos_mem_free(pMac->lim.gpLimStartBssReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 pMac->lim.gpLimStartBssReq = NULL;
916 }
917 #endif
918
919 if (pMac->lim.gpLimMlmSetKeysReq != NULL)
920 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530921 vos_mem_free(pMac->lim.gpLimMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pMac->lim.gpLimMlmSetKeysReq = NULL;
923 }
924
925 #if 0
926 if (pMac->lim.gpLimJoinReq != NULL)
927 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530928 vos_mem_free(pMac->lim.gpLimJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 pMac->lim.gpLimJoinReq = NULL;
930 }
931 #endif
932
933 if (pMac->lim.gpLimMlmAuthReq != NULL)
934 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530935 vos_mem_free(pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 pMac->lim.gpLimMlmAuthReq = NULL;
937 }
938
Jeff Johnsone7245742012-09-05 17:12:55 -0700939#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if (pMac->lim.gpLimMlmJoinReq != NULL)
941 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530942 vos_mem_free(pMac->lim.gpLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 pMac->lim.gpLimMlmJoinReq = NULL;
944 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700946
947 #if 0
948 if (pMac->lim.gpLimReassocReq != NULL)
949 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530950 vos_mem_free(pMac->lim.gpLimReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 pMac->lim.gpLimReassocReq = NULL;
952 }
953 #endif
954
955 if (pMac->lim.gpLimMlmRemoveKeyReq != NULL)
956 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530957 vos_mem_free(pMac->lim.gpLimMlmRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
959 }
960
Viral Modid440e682013-03-06 02:25:31 -0800961 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
Viral Modid86bde22012-12-10 13:09:21 -0800962 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530963 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -0800964 pMac->lim.gpDefdSmeMsgForNOA = NULL;
Viral Modid86bde22012-12-10 13:09:21 -0800965 }
Viral Modid86bde22012-12-10 13:09:21 -0800966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 if (pMac->lim.gpLimMlmScanReq != NULL)
968 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530969 vos_mem_free(pMac->lim.gpLimMlmScanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 pMac->lim.gpLimMlmScanReq = NULL;
971 }
Kapil Gupta956c0c42017-06-16 19:24:31 +0530972 limDestroyAssocRspCompletiontionList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973#if 0
974 if(NULL != pMac->lim.beacon)
975 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530976 vos_mem_free((void*) pMac->lim.beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 pMac->lim.beacon = NULL;
978 }
979#endif
980 #if 0
981 if(NULL != pMac->lim.assocReq)
982 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530983 vos_mem_free((void*) pMac->lim.assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 pMac->lim.assocReq= NULL;
985 }
986 #endif
987
988#if 0
989 if(NULL != pMac->lim.assocRsp)
990 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530991 vos_mem_free((void*) pMac->lim.assocRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 pMac->lim.assocRsp= NULL;
993 }
994#endif
995 // Now, finally reset the deferred message queue pointers
996 limResetDeferredMsgQ(pMac);
997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998
999 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1000 retStatus = WLANTL_DeRegisterMgmtFrmClient(pvosGCTx);
1001
1002 if ( retStatus != VOS_STATUS_SUCCESS )
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001003 PELOGE(limLog(pMac, LOGE, FL("DeRegistering the PE Handle with TL has failed bailing out..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001004
1005#if defined WLAN_FEATURE_VOWIFI
1006 rrmCleanup(pMac);
1007#endif
1008#if defined WLAN_FEATURE_VOWIFI_11R
1009 limFTCleanup(pMac);
1010#endif
1011
1012} /*** end limCleanup() ***/
1013
1014
1015/** -------------------------------------------------------------
1016\fn peOpen
1017\brief will be called in Open sequence from macOpen
1018\param tpAniSirGlobal pMac
1019\param tHalOpenParameters *pHalOpenParam
1020\return tSirRetStatus
1021 -------------------------------------------------------------*/
1022
1023tSirRetStatus peOpen(tpAniSirGlobal pMac, tMacOpenParameters *pMacOpenParam)
1024{
Kaushik, Sushant16def7c2014-06-17 14:20:49 +05301025 if (eDRIVER_TYPE_MFG == pMacOpenParam->driverType)
1026 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pMac->lim.maxBssId = pMacOpenParam->maxBssId;
1028 pMac->lim.maxStation = pMacOpenParam->maxStation;
Katya Nigam53799202014-12-18 15:59:38 +05301029 vos_spin_lock_init( &pMac->sys.lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001030
1031 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0))
1032 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001033 PELOGE(limLog(pMac, LOGE, FL("max number of Bssid or Stations cannot be zero!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 return eSIR_FAILURE;
1035 }
1036
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301037 pMac->lim.limTimers.gpLimCnfWaitTimer = vos_mem_vmalloc(sizeof(TX_TIMER) * pMac->lim.maxStation);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301038 if (NULL == pMac->lim.limTimers.gpLimCnfWaitTimer)
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001040 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 return eSIR_FAILURE;
1042 }
1043
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301044 pMac->lim.gpSession = vos_mem_vmalloc(sizeof(tPESession)* pMac->lim.maxBssId);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301045 if (NULL == pMac->lim.gpSession)
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001047 limLog(pMac, LOGE, FL("memory allocate failed!"));
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301048 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 return eSIR_FAILURE;
1050 }
1051
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301052 vos_mem_set(pMac->lim.gpSession, sizeof(tPESession)*pMac->lim.maxBssId, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001053
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301054 pMac->pmm.gPmmTim.pTim = vos_mem_malloc(sizeof(tANI_U8)*pMac->lim.maxStation);
1055 if (NULL == pMac->pmm.gPmmTim.pTim)
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001057 PELOGE(limLog(pMac, LOGE, FL("memory allocate failed for pTim!"));)
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301058 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
1059 vos_mem_vfree(pMac->lim.gpSession);
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 return eSIR_FAILURE;
1061 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301062 vos_mem_set(pMac->pmm.gPmmTim.pTim, sizeof(tANI_U8)*pMac->lim.maxStation, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001064 pMac->lim.mgmtFrameSessionId = 0xff;
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001065 pMac->lim.deferredMsgCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001066
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001067 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->lim.lkPeGlobalLock ) ) )
1068 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001069 PELOGE(limLog(pMac, LOGE, FL("pe lock init failed!"));)
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301070 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
Leela Venkata Kiran Kumar Reddy Chiralabcf1b8b2013-12-16 17:13:52 -08001071 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301072 vos_mem_vfree(pMac->lim.gpSession);
Leela Venkata Kiran Kumar Reddy Chiralabcf1b8b2013-12-16 17:13:52 -08001073 pMac->lim.gpSession = NULL;
1074 vos_mem_free(pMac->pmm.gPmmTim.pTim);
1075 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001076 return eSIR_FAILURE;
1077 }
Venkata Prathyusha Kuntupalli22ba5982013-04-24 13:09:20 -07001078 pMac->lim.deauthMsgCnt = 0;
Agarwal Ashishb4ce9922014-11-04 18:40:38 +05301079 pMac->lim.retryPacketCnt = 0;
Sushant Kaushike06bd872015-03-12 16:17:48 +05301080 pMac->lim.gLimIbssRetryCnt = 0;
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07001081
1082 /*
1083 * peOpen is successful by now, so it is right time to initialize
1084 * MTRACE for PE module. if LIM_TRACE_RECORD is not defined in build file
1085 * then nothing will be logged for PE module.
1086 */
1087#ifdef LIM_TRACE_RECORD
1088 MTRACE(limTraceInit(pMac));
1089#endif
Padma, Santhosh Kumar9093b202015-07-21 15:37:38 +05301090 lim_register_debug_callback();
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 return eSIR_SUCCESS;
1092}
1093
1094/** -------------------------------------------------------------
1095\fn peClose
1096\brief will be called in close sequence from macClose
1097\param tpAniSirGlobal pMac
1098\return tSirRetStatus
1099 -------------------------------------------------------------*/
1100
1101tSirRetStatus peClose(tpAniSirGlobal pMac)
1102{
1103 tANI_U8 i;
1104
1105 if (ANI_DRIVER_TYPE(pMac) == eDRIVER_TYPE_MFG)
1106 return eSIR_SUCCESS;
Katya Nigam53799202014-12-18 15:59:38 +05301107
1108 vos_spin_lock_destroy( &pMac->sys.lock );
1109
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 for(i =0; i < pMac->lim.maxBssId; i++)
1111 {
1112 if(pMac->lim.gpSession[i].valid == TRUE)
1113 {
1114 peDeleteSession(pMac,&pMac->lim.gpSession[i]);
1115 }
1116 }
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301117 vos_mem_vfree(pMac->lim.limTimers.gpLimCnfWaitTimer);
Jeff Johnsone7245742012-09-05 17:12:55 -07001118 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301119 vos_mem_vfree(pMac->lim.gpSession);
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 pMac->lim.gpSession = NULL;
Sushant Kaushikf4a27972015-04-16 16:48:00 +05301121
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301122 vos_mem_free(pMac->pmm.gPmmTim.pTim);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 pMac->pmm.gPmmTim.pTim = NULL;
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08001124 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->lim.lkPeGlobalLock ) ) )
1125 {
1126 return eSIR_FAILURE;
1127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 return eSIR_SUCCESS;
1129}
1130
1131/** -------------------------------------------------------------
1132\fn peStart
1133\brief will be called in start sequence from macStart
1134\param tpAniSirGlobal pMac
1135\return none
1136 -------------------------------------------------------------*/
1137
1138tSirRetStatus peStart(tpAniSirGlobal pMac)
1139{
1140 tSirRetStatus status = eSIR_SUCCESS;
1141
1142 status = limInitialize(pMac);
1143#if defined(ANI_LOGDUMP)
1144 limDumpInit(pMac);
1145#endif //#if defined(ANI_LOGDUMP)
1146
1147 return status;
1148}
1149
1150/** -------------------------------------------------------------
1151\fn peStop
1152\brief will be called in stop sequence from macStop
1153\param tpAniSirGlobal pMac
1154\return none
1155 -------------------------------------------------------------*/
1156
1157void peStop(tpAniSirGlobal pMac)
1158{
1159 limCleanup(pMac);
1160 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1161 return;
1162}
1163
1164/** -------------------------------------------------------------
1165\fn peFreeMsg
1166\brief Called by VOS scheduler (function vos_sched_flush_mc_mqs)
1167\ to free a given PE message on the TX and MC thread.
1168\ This happens when there are messages pending in the PE
1169\ queue when system is being stopped and reset.
1170\param tpAniSirGlobal pMac
1171\param tSirMsgQ pMsg
1172\return none
1173-----------------------------------------------------------------*/
1174v_VOID_t peFreeMsg( tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1175{
1176 if (pMsg != NULL)
1177 {
1178 if (NULL != pMsg->bodyptr)
1179 {
1180 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type)
1181 {
1182 vos_pkt_return_packet((vos_pkt_t *)pMsg->bodyptr);
1183 }
1184 else
1185 {
1186 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
1187 }
1188 }
1189 pMsg->bodyptr = 0;
1190 pMsg->bodyval = 0;
1191 pMsg->type = 0;
1192 }
1193 return;
1194}
1195
1196
1197/**
1198 * The function checks if a particular timer should be allowed
1199 * into LIM while device is sleeping
1200 */
1201tANI_U8 limIsTimerAllowedInPowerSaveState(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1202{
1203 tANI_U8 retStatus = TRUE;
1204
1205 if(!limIsSystemInActiveState(pMac))
1206 {
1207 switch(pMsg->type)
1208 {
1209 /* Don't allow following timer messages if in sleep */
1210 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
1211 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
1212 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1213 retStatus = FALSE;
1214 break;
1215 /* May allow following timer messages in sleep mode */
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
1217 /* Safe to allow as of today, this triggers background scan
1218 * which will not be started if the device is in power-save mode
1219 * might need to block in the future if we decide to implement
1220 * spectrum management
1221 */
1222 case SIR_LIM_QUIET_TIMEOUT:
1223
1224 /* Safe to allow as of today, this triggers background scan
1225 * which will not be started if the device is in power-save mode
1226 * might need to block in the future if we decide to implement
1227 * spectrum management
1228 */
1229 case SIR_LIM_QUIET_BSS_TIMEOUT:
1230
1231 /* Safe to allow this timermessage, triggers background scan
1232 * which is blocked in sleep mode
1233 */
1234 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
1235
1236 /* Safe to allow this timer, since, while in IMPS this timer will not
1237 * be started. In case of BMPS sleep, SoftMAC handles the heart-beat
1238 * when heart-beat control is handled back to PE, device would have
1239 * already woken-up due to EXIT_BMPS_IND mesage from SoftMAC
1240 */
1241 case SIR_LIM_HEART_BEAT_TIMEOUT:
1242 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1243
1244 /* Safe to allow, PE is not handling this message as of now. May need
1245 * to block it, basically, free the buffer and restart the timer
1246 */
1247 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1248 case SIR_LIM_JOIN_FAIL_TIMEOUT:
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08001249 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1251 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1252 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Sushant Kaushik9e923872015-04-02 17:09:31 +05301253 case SIR_LIM_AUTH_RETRY_TIMEOUT:
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 retStatus = TRUE;
1255 break;
1256
1257 /* by default allow rest of messages */
1258 default:
1259 retStatus = TRUE;
1260 break;
1261
1262
1263 }
1264 }
1265
1266 return retStatus;
1267
1268}
1269
1270
1271
1272/**
1273 * limPostMsgApi()
1274 *
1275 *FUNCTION:
1276 * This function is called from other thread while posting a
1277 * message to LIM message Queue gSirLimMsgQ.
1278 *
1279 *LOGIC:
1280 * NA
1281 *
1282 *ASSUMPTIONS:
1283 * NA
1284 *
1285 *NOTE:
1286 * NA
1287 *
1288 * @param pMac - Pointer to Global MAC structure
1289 * @param pMsg - Pointer to the message structure
1290 * @return None
1291 */
1292
1293tANI_U32
1294limPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1295{
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 return vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1297
1298
Jeff Johnson295189b2012-06-20 16:38:30 -07001299} /*** end limPostMsgApi() ***/
1300
Padma, Santhosh Kumarb036fc72015-11-13 16:22:23 +05301301/**
1302 * limPostMsgApiHighPri()
1303 *
1304 * FUNCTION:
1305 * This function is called from other thread while posting a
1306 * message to LIM message Queue gSirLimMsgQ.
1307 *
1308 * LOGIC:
1309 * NA
1310 *
1311 * ASSUMPTIONS:
1312 * NA
1313 *
1314 * NOTE:
1315 * NA
1316 *
1317 * @param pMac - Pointer to Global MAC structure
1318 * @param pMsg - Pointer to the message structure
1319 * @return None
1320 */
1321
1322tANI_U32
1323limPostMsgApiHighPri(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1324{
1325 return vos_mq_post_message_high_pri(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1326
1327
1328} /*** end limPostMsgApi() ***/
1329
Jeff Johnson295189b2012-06-20 16:38:30 -07001330
1331/*--------------------------------------------------------------------------
1332
1333 \brief pePostMsgApi() - A wrapper function to post message to Voss msg queues
1334
1335 This function can be called by legacy code to post message to voss queues OR
1336 legacy code may keep on invoking 'limPostMsgApi' to post the message to voss queue
1337 for dispatching it later.
1338
1339 \param pMac - Pointer to Global MAC structure
1340 \param pMsg - Pointer to the message structure
1341
1342 \return tANI_U32 - TX_SUCCESS for success.
1343
1344 --------------------------------------------------------------------------*/
1345
1346tSirRetStatus pePostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1347{
1348 return (tSirRetStatus)limPostMsgApi(pMac, pMsg);
1349}
1350
1351/*--------------------------------------------------------------------------
1352
1353 \brief peProcessMessages() - Message Processor for PE
1354
1355 Voss calls this function to dispatch the message to PE
1356
1357 \param pMac - Pointer to Global MAC structure
1358 \param pMsg - Pointer to the message structure
1359
1360 \return tANI_U32 - TX_SUCCESS for success.
1361
1362 --------------------------------------------------------------------------*/
1363
1364tSirRetStatus peProcessMessages(tpAniSirGlobal pMac, tSirMsgQ* pMsg)
1365{
1366 if(pMac->gDriverType == eDRIVER_TYPE_MFG)
1367 {
1368 return eSIR_SUCCESS;
1369 }
1370 /**
1371 * If the Message to be handled is for CFG Module call the CFG Msg Handler and
1372 * for all the other cases post it to LIM
1373 */
1374 if ( SIR_CFG_PARAM_UPDATE_IND != pMsg->type && IS_CFG_MSG(pMsg->type))
1375 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
1376 else
1377 limMessageProcessor(pMac, pMsg);
1378 return eSIR_SUCCESS;
1379}
1380
Katya Nigam53799202014-12-18 15:59:38 +05301381#define RSRVD_MGMT_RX_PACKETS 10
Jeff Johnson295189b2012-06-20 16:38:30 -07001382
1383// ---------------------------------------------------------------------------
1384/**
1385 * peHandleMgmtFrame
1386 *
1387 * FUNCTION:
1388 * Process the Management frames from TL
1389 *
1390 * LOGIC:
1391 *
1392 * ASSUMPTIONS: TL sends the packet along with the VOS GlobalContext
1393 *
1394 * NOTE:
1395 *
1396 * @param pvosGCtx Global Vos Context
1397 * @param vossBuff Packet
1398 * @return None
1399 */
1400
1401VOS_STATUS peHandleMgmtFrame( v_PVOID_t pvosGCtx, v_PVOID_t vosBuff)
1402{
1403 tpAniSirGlobal pMac;
1404 tpSirMacMgmtHdr mHdr;
1405 tSirMsgQ msg;
1406 vos_pkt_t *pVosPkt;
1407 VOS_STATUS vosStatus;
1408 v_U8_t *pRxPacketInfo;
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +05301409 tANI_U16 frameLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001410
1411 pVosPkt = (vos_pkt_t *)vosBuff;
1412 if (NULL == pVosPkt)
1413 {
1414 return VOS_STATUS_E_FAILURE;
1415 }
1416
1417 pMac = (tpAniSirGlobal)vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
1418 if (NULL == pMac)
1419 {
1420 // cannot log a failure without a valid pMac
1421 vos_pkt_return_packet(pVosPkt);
1422 return VOS_STATUS_E_FAILURE;
1423 }
1424
1425 vosStatus = WDA_DS_PeekRxPacketInfo( pVosPkt, (void *)&pRxPacketInfo, VOS_FALSE );
1426
1427 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1428 {
1429 vos_pkt_return_packet(pVosPkt);
1430 return VOS_STATUS_E_FAILURE;
1431 }
1432
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +05301433 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1434 if (frameLen > WDA_MAX_MGMT_MPDU_LEN) {
1435 PELOG1(limLog(pMac, LOG1, FL("Dropping frame of len %d"), frameLen));
1436 vos_pkt_return_packet(pVosPkt);
1437 return VOS_STATUS_E_FAILURE;
1438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001439
1440 //
1441 // The MPDU header is now present at a certain "offset" in
1442 // the BD and is specified in the BD itself
1443 //
1444 mHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
1445 if(mHdr->fc.type == SIR_MAC_MGMT_FRAME)
1446 {
1447 PELOG1(limLog( pMac, LOG1,
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001448 FL ( "RxBd=%pK mHdr=%pK Type: %d Subtype: %d Sizes:FC%d Mgmt%d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07001449 pRxPacketInfo, mHdr, mHdr->fc.type, mHdr->fc.subType, sizeof(tSirMacFrameCtl), sizeof(tSirMacMgmtHdr) );)
Jeff Johnson295189b2012-06-20 16:38:30 -07001450
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +05301451#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1452 if (WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
1453 limLog(pMac, LOG1, FL("roamCandidateInd %d"),
1454 WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo));
1455
1456 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
1457 limLog(pMac, LOG1, FL("offloadScanLearn %d"),
1458 WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo));
1459#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 }
1461
1462
1463 // Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG
1464 msg.type = SIR_BB_XPORT_MGMT_MSG;
1465 msg.bodyptr = vosBuff;
1466 msg.bodyval = 0;
1467
Katya Nigam53799202014-12-18 15:59:38 +05301468 vos_spin_lock_acquire( &pMac->sys.lock );
1469 if( pMac->sys.gSysBbtPendingMgmtCount > (vos_pkt_get_num_of_rx_raw_pkts()/4) )
1470 {
1471 vos_spin_lock_release( &pMac->sys.lock );
1472 // drop all management packets
Katya Nigamfdf5a522015-02-03 14:38:55 +05301473 limLog( pMac, LOGW,
1474 FL ( "Management queue 1/4th full, dropping management packets" ));
Katya Nigam53799202014-12-18 15:59:38 +05301475 vos_pkt_return_packet(pVosPkt);
1476 return VOS_STATUS_SUCCESS;
1477 }
1478
1479 if( pMac->sys.gSysBbtPendingMgmtCount > ( vos_pkt_get_num_of_rx_raw_pkts()/4
1480 - RSRVD_MGMT_RX_PACKETS ))
1481 {
1482 // drop all probereq, proberesp and beacons
1483 if( mHdr->fc.subType == SIR_MAC_MGMT_BEACON || mHdr->fc.subType ==
1484 SIR_MAC_MGMT_PROBE_REQ || mHdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP )
1485 {
1486 vos_spin_lock_release( &pMac->sys.lock );
Katya Nigamfdf5a522015-02-03 14:38:55 +05301487 limLog( pMac, LOGW,
1488 FL ( "Dropping probe req, probe resp or beacon" ));
Katya Nigam53799202014-12-18 15:59:38 +05301489 vos_pkt_return_packet(pVosPkt);
1490 return VOS_STATUS_SUCCESS;
1491 }
1492 }
1493 pMac->sys.gSysBbtPendingMgmtCount++;
1494 vos_spin_lock_release( &pMac->sys.lock );
1495
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if( eSIR_SUCCESS != sysBbtProcessMessageCore( pMac,
1497 &msg,
1498 mHdr->fc.type,
1499 mHdr->fc.subType ))
1500 {
1501 vos_pkt_return_packet(pVosPkt);
Abhishek Singh5d765712015-03-12 14:04:16 +05301502
1503 /* Decrement gSysBbtPendingMgmtCount if packet
1504 * is dropped before posting to LIM
1505 */
1506 limDecrementPendingMgmtCount(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 limLog( pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001508 FL ( "sysBbtProcessMessageCore failed to process SIR_BB_XPORT_MGMT_MSG" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 return VOS_STATUS_E_FAILURE;
1510 }
1511
1512 return VOS_STATUS_SUCCESS;
1513}
1514
1515// ---------------------------------------------------------------------------
1516/**
1517 * peRegisterTLHandle
1518 *
1519 * FUNCTION:
1520 * Registers the Handler which, process the Management frames from TL
1521 *
1522 * LOGIC:
1523 *
1524 * ASSUMPTIONS:
1525 *
1526 * NOTE:
1527 *
1528 * @return None
1529 */
1530
1531void peRegisterTLHandle(tpAniSirGlobal pMac)
1532{
1533 v_PVOID_t pvosGCTx;
1534 VOS_STATUS retStatus;
1535
1536 pvosGCTx = vos_get_global_context(VOS_MODULE_ID_PE, (v_VOID_t *) pMac);
1537
1538 retStatus = WLANTL_RegisterMgmtFrmClient(pvosGCTx, peHandleMgmtFrame);
1539
1540 if (retStatus != VOS_STATUS_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001541 limLog( pMac, LOGP, FL("Registering the PE Handle with TL has failed bailing out..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001542
1543}
Jeff Johnson295189b2012-06-20 16:38:30 -07001544
1545
1546/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 * limIsSystemInScanState()
1548 *
1549 *FUNCTION:
1550 * This function is called by various MAC software modules to
1551 * determine if System is in Scan/Learn state
1552 *
1553 *LOGIC:
1554 * NA
1555 *
1556 *ASSUMPTIONS:
1557 * NA
1558 *
1559 *NOTE:
1560 *
1561 * @param pMac - Pointer to Global MAC structure
1562 * @return true - System is in Scan/Learn state
1563 * false - System is NOT in Scan/Learn state
1564 */
1565
1566tANI_U8
1567limIsSystemInScanState(tpAniSirGlobal pMac)
1568{
1569 switch (pMac->lim.gLimSmeState)
1570 {
1571 case eLIM_SME_CHANNEL_SCAN_STATE:
1572 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1573 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1574 case eLIM_SME_WT_SCAN_STATE:
1575 // System is in Learn mode
1576 return true;
1577
1578 default:
1579 // System is NOT in Learn mode
1580 return false;
1581 }
1582} /*** end limIsSystemInScanState() ***/
1583
1584
1585
1586/**
1587 * limIsSystemInActiveState()
1588 *
1589 *FUNCTION:
1590 * This function is called by various MAC software modules to
1591 * determine if System is in Active/Wakeup state
1592 *
1593 *LOGIC:
1594 * NA
1595 *
1596 *ASSUMPTIONS:
1597 * NA
1598 *
1599 *NOTE:
1600 *
1601 * @param pMac - Pointer to Global MAC structure
1602 * @return true - System is in Active state
1603 * false - System is not in Active state
1604 */
1605
1606tANI_U8 limIsSystemInActiveState(tpAniSirGlobal pMac)
1607{
1608 switch (pMac->pmm.gPmmState)
1609 {
1610 case ePMM_STATE_BMPS_WAKEUP:
1611 case ePMM_STATE_IMPS_WAKEUP:
1612 case ePMM_STATE_READY:
1613 // System is in Active mode
1614 return true;
1615 default:
1616 return false;
1617 // System is NOT in Active mode
1618 }
1619}
1620
1621
Jeff Johnson295189b2012-06-20 16:38:30 -07001622
Jeff Johnson295189b2012-06-20 16:38:30 -07001623
1624
1625/**
1626*\brief limReceivedHBHandler()
1627*
1628* This function is called by schBeaconProcess() upon
1629* receiving a Beacon on STA. This also gets called upon
1630* receiving Probe Response after heat beat failure is
1631* detected.
1632*
1633* param pMac - global mac structure
1634* param channel - channel number indicated in Beacon, Probe Response
1635* return - none
1636*/
1637
1638
1639void
1640limReceivedHBHandler(tpAniSirGlobal pMac, tANI_U8 channelId, tpPESession psessionEntry)
1641{
1642 if((channelId == 0 ) || (channelId == psessionEntry->currentOperChannel) )
1643 psessionEntry->LimRxedBeaconCntDuringHB++;
1644
1645 pMac->pmm.inMissedBeaconScenario = FALSE;
1646} /*** end limReceivedHBHandler() ***/
1647
1648
1649
1650#if 0
1651void limResetHBPktCount(tpPESession psessionEntry)
1652{
1653 psessionEntry->LimRxedBeaconCntDuringHB = 0;
1654}
1655#endif
1656
1657
1658/*
1659 * limProcessWdsInfo()
1660 *
1661 *FUNCTION:
1662 * This function is called from schBeaconProcess in BP
1663 *
1664 *PARAMS:
1665 * @param pMac - Pointer to Global MAC structure
1666 * @param propIEInfo - proprietary IE info
1667 *
1668 *LOGIC:
1669 *
1670 *ASSUMPTIONS:
1671 * NA
1672 *
1673 *NOTE:
1674 *
1675 *
1676 *RETURNS:
1677 *
1678 */
1679
1680void limProcessWdsInfo(tpAniSirGlobal pMac,
1681 tSirPropIEStruct propIEInfo)
1682{
Jeff Johnson295189b2012-06-20 16:38:30 -07001683}
1684
1685
1686
1687/**
1688 * limInitWdsInfoParams()
1689 *
1690 *FUNCTION:
1691 * This function is called while processing
1692 * START_BSS/JOIN/REASSOC_REQ to initialize WDS info
1693 * ind/set related parameters.
1694 *
1695 *LOGIC:
1696 *
1697 *ASSUMPTIONS:
1698 *
1699 *NOTE:
1700 *
1701 * @param pMac Pointer to Global MAC structure
1702 * @return None
1703 */
1704
1705void
1706limInitWdsInfoParams(tpAniSirGlobal pMac)
1707{
1708 pMac->lim.gLimWdsInfo.wdsLength = 0;
1709 pMac->lim.gLimNumWdsInfoInd = 0;
1710 pMac->lim.gLimNumWdsInfoSet = 0;
1711} /*** limInitWdsInfoParams() ***/
1712
1713
1714/** -------------------------------------------------------------
1715\fn limUpdateOverlapStaParam
1716\brief Updates overlap cache and param data structure
1717\param tpAniSirGlobal pMac
1718\param tSirMacAddr bssId
1719\param tpLimProtStaParams pStaParams
1720\return None
1721 -------------------------------------------------------------*/
1722void
1723limUpdateOverlapStaParam(tpAniSirGlobal pMac, tSirMacAddr bssId, tpLimProtStaParams pStaParams)
1724{
1725 int i;
1726 if (!pStaParams->numSta)
1727 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301728 vos_mem_copy(pMac->lim.protStaOverlapCache[0].addr,
1729 bssId,
1730 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 pMac->lim.protStaOverlapCache[0].active = true;
1732
1733 pStaParams->numSta = 1;
1734
1735 return;
1736 }
1737
1738 for (i=0; i<LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1739 {
1740 if (pMac->lim.protStaOverlapCache[i].active)
1741 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301742 if (vos_mem_compare( pMac->lim.protStaOverlapCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 bssId,
1744 sizeof(tSirMacAddr))) {
1745 return; }
1746 }
1747 else
1748 break;
1749 }
1750
1751 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE)
1752 {
Shake M Subhani5d80fda2013-12-09 17:28:23 +05301753 PELOG1(limLog(pMac, LOGW, FL("Overlap cache is full"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 }
1755 else
1756 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301757 vos_mem_copy(pMac->lim.protStaOverlapCache[i].addr,
1758 bssId,
1759 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 pMac->lim.protStaOverlapCache[i].active = true;
1761
1762 pStaParams->numSta++;
1763 }
1764}
1765
1766
1767/**
1768 * limHandleIBSScoalescing()
1769 *
1770 *FUNCTION:
1771 * This function is called upon receiving Beacon/Probe Response
1772 * while operating in IBSS mode.
1773 *
1774 *LOGIC:
1775 *
1776 *ASSUMPTIONS:
1777 *
1778 *NOTE:
1779 *
1780 * @param pMac - Pointer to Global MAC structure
1781 * @param pBeacon - Parsed Beacon Frame structure
1782 * @param pRxPacketInfo - Pointer to RX packet info structure
1783 *
1784 * @return Status whether to process or ignore received Beacon Frame
1785 */
1786
1787tSirRetStatus
1788limHandleIBSScoalescing(
1789 tpAniSirGlobal pMac,
1790 tpSchBeaconStruct pBeacon,
1791 tANI_U8 *pRxPacketInfo,tpPESession psessionEntry)
1792{
1793 tpSirMacMgmtHdr pHdr;
1794 tSirRetStatus retCode;
1795
1796 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001797 if ( (!pBeacon->capabilityInfo.ibss) ||
Abhishek Singhd5c31272014-03-07 14:46:50 +05301798 ( psessionEntry->privacy !=
1799 (tANI_U8)pBeacon->capabilityInfo.privacy ) ||
Ravi Joshi2c83c7e2013-10-29 10:21:08 -07001800 (limCmpSSid(pMac, &pBeacon->ssId,psessionEntry) != true) ||
1801 (psessionEntry->currentOperChannel != pBeacon->channelNumber) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 /* Received SSID does not match => Ignore received Beacon frame. */
1803 retCode = eSIR_LIM_IGNORE_BEACON;
1804 else
1805 {
1806 tANI_U32 ieLen;
1807 tANI_U16 tsfLater;
1808 tANI_U8 *pIEs;
1809 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1810 tsfLater = WDA_GET_RX_TSF_LATER(pRxPacketInfo);
1811 pIEs = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Abhishek Singh127a8442014-12-15 17:31:27 +05301812 limLog(pMac, LOG1, FL("BEFORE Coalescing tsfLater val :%d"), tsfLater);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 retCode = limIbssCoalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,psessionEntry);
1814 }
1815 return retCode;
1816} /*** end limHandleIBSScoalescing() ***/
1817
Abhishek Singh5fef4042014-11-25 18:33:00 +05301818tAniBool limEncTypeMatched(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon,
1819 tpPESession pSession)
1820{
1821 if (!pBeacon || !pSession)
1822 return eSIR_FALSE;
1823
1824 limLog(pMac, LOG1,
1825 FL("Beacon/Probe:: Privacy :%d WPA Present:%d RSN Present: %d"),
1826 pBeacon->capabilityInfo.privacy, pBeacon->wpaPresent,
1827 pBeacon->rsnPresent);
1828 limLog(pMac, LOG1,
Abhishek Singheef5c992016-01-27 13:41:54 +05301829 FL("pSession:: Privacy :%d EncyptionType: %d WPS %d OSEN %d"),
Abhishek Singh5fef4042014-11-25 18:33:00 +05301830 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps),
Abhishek Singheef5c992016-01-27 13:41:54 +05301831 pSession->encryptType, pSession->bWPSAssociation,
1832 pSession->bOSENAssociation);
Abhishek Singh5fef4042014-11-25 18:33:00 +05301833
1834 /* This is handled by sending probe req due to IOT issues so return TRUE
1835 */
1836 if ( (pBeacon->capabilityInfo.privacy) !=
1837 SIR_MAC_GET_PRIVACY(pSession->limCurrentBssCaps))
1838 {
1839 limLog(pMac, LOG1, FL("Return for Privacy bit miss match, As "
1840 "for this driver need to send the probe request to handle"
1841 " IOT issues "));
1842 return eSIR_TRUE;
1843 }
1844
1845 /*Open*/
1846 if( (pBeacon->capabilityInfo.privacy == 0) &&
1847 (pSession->encryptType == eSIR_ED_NONE))
1848 return eSIR_TRUE;
1849
1850 /* WEP */
1851 if ( (pBeacon->capabilityInfo.privacy == 1) && (pBeacon->wpaPresent == 0) &&
1852 (pBeacon->rsnPresent == 0) &&
Abhishek Singh31dfa3c2014-12-12 17:25:19 +05301853 ( ( pSession->encryptType == eSIR_ED_WEP40 ) ||
1854 ( pSession->encryptType == eSIR_ED_WEP104 )
1855#ifdef FEATURE_WLAN_WAPI
1856 || ( pSession->encryptType == eSIR_ED_WPI )
1857#endif
1858 ))
Abhishek Singh5fef4042014-11-25 18:33:00 +05301859 return eSIR_TRUE;
1860
1861 /* WPA OR RSN*/
1862 if ( (pBeacon->capabilityInfo.privacy == 1) &&
1863 ( (pBeacon->wpaPresent == 1) ||
1864 ( pBeacon->rsnPresent == 1)) &&
1865 ( (pSession->encryptType == eSIR_ED_TKIP) ||
1866 (pSession->encryptType == eSIR_ED_CCMP) ||
1867 (pSession->encryptType == eSIR_ED_AES_128_CMAC)))
1868 return eSIR_TRUE;
1869
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301870 /* For HS2.0, RSN ie is not present
1871 * in beacon. Therefore no need to
1872 * check for security type in case
1873 * OSEN session.
Abhishek Singheef5c992016-01-27 13:41:54 +05301874 * For WPS registration session no need to detect
1875 * security mismatch as it wont match and
1876 * driver may end up sending probe request without
1877 * WPS IE during WPS registartion process.
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301878 */
1879 /*TODO: AP capability mismatch
1880 * is not checked here because
1881 * no logic for beacon parsing
1882 * is avilable for HS2.0.
1883 */
Abhishek Singheef5c992016-01-27 13:41:54 +05301884 if (pSession->bOSENAssociation ||
1885 pSession->bWPSAssociation)
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301886 return eSIR_TRUE;
1887
Abhishek Singh5fef4042014-11-25 18:33:00 +05301888 return eSIR_FALSE;
1889}
Jeff Johnson295189b2012-06-20 16:38:30 -07001890
1891
1892/**
1893 * limDetectChangeInApCapabilities()
1894 *
1895 *FUNCTION:
1896 * This function is called while SCH is processing
1897 * received Beacon from AP on STA to detect any
1898 * change in AP's capabilities. If there any change
1899 * is detected, Roaming is informed of such change
1900 * so that it can trigger reassociation.
1901 *
1902 *LOGIC:
1903 *
1904 *ASSUMPTIONS:
1905 *
1906 *NOTE:
1907 * Notification is enabled for STA product only since
1908 * it is not a requirement on BP side.
1909 *
1910 * @param pMac Pointer to Global MAC structure
1911 * @param pBeacon Pointer to parsed Beacon structure
1912 * @return None
1913 */
1914
1915void
1916limDetectChangeInApCapabilities(tpAniSirGlobal pMac,
1917 tpSirProbeRespBeacon pBeacon,
1918 tpPESession psessionEntry)
1919{
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 tANI_U8 len;
1921 tSirSmeApNewCaps apNewCaps;
1922 tANI_U8 newChannel;
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301923 tSirRetStatus status = eSIR_SUCCESS;
Abhishek Singh5fef4042014-11-25 18:33:00 +05301924 tAniBool securityCapsMatched = eSIR_TRUE;
1925
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
1927 newChannel = (tANI_U8) pBeacon->channelNumber;
1928
Abhishek Singh5fef4042014-11-25 18:33:00 +05301929 securityCapsMatched = limEncTypeMatched(pMac, pBeacon, psessionEntry);
1930
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301931 if ( ( false == psessionEntry->limSentCapsChangeNtf ) &&
Abhishek Singh4f8446a2014-05-22 14:07:31 +05301932 ( ( ( !limIsNullSsid(&pBeacon->ssId) ) &&
1933 ( false == limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) ) ) ||
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301934 ( (SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
1935 SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps) ) ||
1936 ( SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1937 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps) ) ||
1938 ( SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1939 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps) ) ||
1940 ( SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
1941 SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps) ) ||
Abhishek Singh5fef4042014-11-25 18:33:00 +05301942 ( newChannel != psessionEntry->currentOperChannel ) ||
1943 (eSIR_FALSE == securityCapsMatched)
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301944 ) ) )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301945 {
Abhishek Singha9325f72015-01-05 11:49:23 +05301946 if ( false == psessionEntry->fWaitForProbeRsp )
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301947 {
Abhishek Singh4136e4e2013-12-15 11:56:29 +05301948 /* If Beacon capabilities is not matching with the current capability,
1949 * then send unicast probe request to AP and take decision after
1950 * receiving probe response */
1951 if ( true == psessionEntry->fIgnoreCapsChange )
1952 {
1953 limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
1954 return;
1955 }
1956 psessionEntry->fWaitForProbeRsp = true;
1957 limLog(pMac, LOGW, FL("AP capabilities are not matching,"
1958 "sending directed probe request.. "));
1959 status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
1960 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
1961 psessionEntry->dot11mode, 0, NULL);
1962
1963 if ( eSIR_SUCCESS != status )
1964 {
1965 limLog(pMac, LOGE, FL("send ProbeReq failed"));
1966 psessionEntry->fWaitForProbeRsp = false;
1967 }
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05301968 return;
1969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 /**
1971 * BSS capabilities have changed.
1972 * Inform Roaming.
1973 */
1974 len = sizeof(tSirMacCapabilityInfo) +
1975 sizeof(tSirMacAddr) + sizeof(tANI_U8) +
1976 3 * sizeof(tANI_U8) + // reserved fields
1977 pBeacon->ssId.length + 1;
1978
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301979 vos_mem_copy(apNewCaps.bssId,
1980 psessionEntry->bssId,
1981 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 if (newChannel != psessionEntry->currentOperChannel)
1983 {
1984 PELOGE(limLog(pMac, LOGE, FL("Channel Change from %d --> %d - "
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001985 "Ignoring beacon!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 psessionEntry->currentOperChannel, newChannel);)
1987 return;
1988 }
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05301989
1990 /**
1991 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1992 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1993 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1994 * the privacy bit is set in Probe and association responses.
1995 * Due to this anomaly, we detect a change in
1996 * AP capabilities when we receive a beacon after association and
1997 * disconnect from the AP. The following check makes sure that we can
1998 * connect to such APs
1999 */
2000 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
2001 (pBeacon->rsnPresent || pBeacon->wpaPresent))
2002 {
2003 PELOGE(limLog(pMac, LOGE, FL("BSS Caps (Privacy) bit 0 in beacon,"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002004 " but WPA or RSN IE present, Ignore Beacon!"));)
Madan Mohan Koyyalamudi84479982013-01-24 17:58:05 +05302005 return;
2006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 else
2008 apNewCaps.channelId = psessionEntry->currentOperChannel;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302009 vos_mem_copy((tANI_U8 *) &apNewCaps.ssId,
2010 (tANI_U8 *) &pBeacon->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 pBeacon->ssId.length + 1);
2012
Gopichand Nakkalabe8653b2013-04-10 08:16:05 +05302013 psessionEntry->fIgnoreCapsChange = false;
2014 psessionEntry->fWaitForProbeRsp = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 psessionEntry->limSentCapsChangeNtf = true;
2016 limSendSmeWmStatusChangeNtf(pMac, eSIR_SME_AP_CAPS_CHANGED,
2017 (tANI_U32 *) &apNewCaps,
2018 len, psessionEntry->smeSessionId);
2019 }
Abhishek Singh4136e4e2013-12-15 11:56:29 +05302020 else if ( true == psessionEntry->fWaitForProbeRsp )
2021 {
2022 /* Only for probe response frames and matching capabilities the control
2023 * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
2024 * will be false, the control will not come here*/
2025
2026 limLog(pMac, LOG1, FL("capabilities in probe response are"
2027 "matching with the current setting,"
2028 "Ignoring subsequent capability"
2029 "mismatch"));
2030 psessionEntry->fIgnoreCapsChange = true;
2031 psessionEntry->fWaitForProbeRsp = false;
2032 }
2033
Jeff Johnson295189b2012-06-20 16:38:30 -07002034} /*** limDetectChangeInApCapabilities() ***/
2035
2036
2037
2038
2039// ---------------------------------------------------------------------
2040/**
2041 * limUpdateShortSlot
2042 *
2043 * FUNCTION:
2044 * Enable/Disable short slot
2045 *
2046 * LOGIC:
2047 *
2048 * ASSUMPTIONS:
2049 *
2050 * NOTE:
2051 *
2052 * @param enable Flag to enable/disable short slot
2053 * @return None
2054 */
2055
2056tSirRetStatus limUpdateShortSlot(tpAniSirGlobal pMac, tpSirProbeRespBeacon pBeacon, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2057{
2058
2059 tSirSmeApNewCaps apNewCaps;
Jeff Johnsone7245742012-09-05 17:12:55 -07002060 tANI_U32 nShortSlot;
2061 tANI_U32 val = 0;
2062 tANI_U32 phyMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
Jeff Johnsone7245742012-09-05 17:12:55 -07002064 // Check Admin mode first. If it is disabled just return
2065 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
2066 != eSIR_SUCCESS)
2067 {
2068 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002069 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002070 return eSIR_FAILURE;
2071 }
2072 if (val == false)
2073 return eSIR_SUCCESS;
2074
2075 // Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon
2076 limGetPhyMode(pMac, &phyMode, psessionEntry);
2077 if ((phyMode == WNI_CFG_PHY_MODE_11A) || (phyMode == WNI_CFG_PHY_MODE_11B))
2078 return eSIR_SUCCESS;
2079
2080 apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002081
2082 // Earlier implementation: determine the appropriate short slot mode based on AP advertised modes
2083 // when erp is present, apply short slot always unless, prot=on && shortSlot=off
2084 // if no erp present, use short slot based on current ap caps
2085
2086 // Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4);
2087
2088 //Resolution : always use the shortSlot setting the capability info to decide slot time.
2089 // The difference between the earlier implementation and the new one is only Case4.
2090 /*
2091 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
2092 Case1 1 1 1 1 //AP should not advertise this combination.
2093 Case2 1 1 0 0
2094 Case3 1 0 1 1
2095 Case4 1 0 0 0
2096 Case5 0 1 1 1
2097 Case6 0 1 0 0
2098 Case7 0 0 1 1
2099 Case8 0 0 0 0
2100 */
2101 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
2102
Jeff Johnsone7245742012-09-05 17:12:55 -07002103 if (nShortSlot != psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 {
2105 // Short slot time capability of AP has changed. Adopt to it.
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302106 limLog(pMac, LOG1, FL("Shortslot capability of AP changed: %d"), nShortSlot);
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 ((tpSirMacCapabilityInfo)&psessionEntry->limCurrentBssCaps)->shortSlotTime = (tANI_U16)nShortSlot;
Jeff Johnsone7245742012-09-05 17:12:55 -07002108 psessionEntry->shortSlotTimeSupported = nShortSlot;
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 pBeaconParams->fShortSlotTime = (tANI_U8) nShortSlot;
2110 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 }
2112 return eSIR_SUCCESS;
2113}
2114
2115
Jeff Johnson295189b2012-06-20 16:38:30 -07002116
2117
Jeff Johnson295189b2012-06-20 16:38:30 -07002118
Jeff Johnson295189b2012-06-20 16:38:30 -07002119
2120
2121/** -----------------------------------------------------------------
2122 \brief limHandleLowRssiInd() - handles low rssi indication
2123
2124 This function process the SIR_HAL_LOW_RSSI_IND message from
2125 HAL, and sends a eWNI_SME_LOW_RSSI_IND to CSR.
2126
2127 \param pMac - global mac structure
2128
2129 \return
2130
2131 \sa
2132 ----------------------------------------------------------------- */
2133void limHandleLowRssiInd(tpAniSirGlobal pMac)
2134{
2135#if 0 //RSSI related indications will now go to TL and not PE
2136 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2137 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2138 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2139 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002140 PELOG1(limLog(pMac, LOG1, FL("Sending LOW_RSSI_IND to SME "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 limSendSmeRsp(pMac, eWNI_SME_LOW_RSSI_IND, eSIR_SME_SUCCESS, 0, 0);
2142 }
2143 else
2144 {
2145 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002146 FL("Received SIR_HAL_LOW_RSSI_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 pMac->pmm.gPmmState);
2148 }
2149 return;
2150#endif
2151}
2152
2153
2154/** -----------------------------------------------------------------
2155 \brief limHandleBmpsStatusInd() - handles BMPS status indication
2156
2157 This function process the SIR_HAL_BMPS_STATUS_IND message from HAL,
2158 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2159 to SME with reason code 'eSME_EXIT_BMPS_IND_RCVD'.
2160
2161 HAL sends this message when Firmware fails to enter BMPS mode 'AFTER'
2162 HAL had already send PE a SIR_HAL_ENTER_BMPS_RSP with status
2163 code "success". Hence, HAL needs to notify PE to get out of BMPS mode.
2164 This message can also come from FW anytime after we have entered BMPS.
2165 This means we should handle it in WoWL and UAPSD states as well
2166
2167 \param pMac - global mac structure
2168 \return - none
2169 \sa
2170 ----------------------------------------------------------------- */
2171void limHandleBmpsStatusInd(tpAniSirGlobal pMac)
2172{
2173 switch(pMac->pmm.gPmmState)
2174 {
2175 case ePMM_STATE_BMPS_SLEEP:
2176 case ePMM_STATE_UAPSD_WT_SLEEP_RSP:
2177 case ePMM_STATE_UAPSD_SLEEP:
2178 case ePMM_STATE_UAPSD_WT_WAKEUP_RSP:
2179 case ePMM_STATE_WOWLAN:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302180 limLog(pMac, LOG1, FL("Sending EXIT_BMPS_IND to SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 limSendExitBmpsInd(pMac, eSME_BMPS_STATUS_IND_RCVD);
2182 break;
2183
2184 default:
2185 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002186 FL("Received SIR_HAL_BMPS_STATUS_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 pMac->pmm.gPmmState);
2188 break;
2189 }
2190 return;
2191}
2192
Kapil Gupta7a3d9b12016-12-20 20:36:38 +05302193#ifdef WLAN_FEATURE_APFIND
2194void limHandleAPFindInd(tpAniSirGlobal pMac)
2195{
2196 tANI_S8 pe_sessionid = -1;
2197 /* Find STA connection session */
2198 pe_sessionid = limGetInfraSessionId(pMac);
2199 if (pe_sessionid != -1)
2200 limTearDownLinkWithAp(pMac,
2201 pe_sessionid,
2202 eSIR_BEACON_MISSED);
2203 else
2204 limLog(pMac, LOGE,
2205 FL("session id doesn't exist for infra"));
2206}
2207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002208
2209/** -----------------------------------------------------------------
2210 \brief limHandleMissedBeaconInd() - handles missed beacon indication
2211
2212 This function process the SIR_HAL_MISSED_BEACON_IND message from HAL,
2213 and invokes limSendExitBmpsInd( ) to send an eWNI_PMC_EXIT_BMPS_IND
2214 to SME with reason code 'eSME_MISSED_BEACON_IND_RCVD'.
2215
2216 \param pMac - global mac structure
2217 \return - none
2218 \sa
2219 ----------------------------------------------------------------- */
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002220void limHandleMissedBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002221{
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002222#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2223 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
2224 (tpSirSmeMissedBeaconInd)pMsg->bodyptr;
2225 tpPESession psessionEntry = peFindSessionByBssIdx(pMac,pSirMissedBeaconInd->bssIdx);
2226 if (psessionEntry == NULL)
2227 {
2228 limLog(pMac, LOGE,
2229 FL("session does not exist for given BSSIdx:%d"),
2230 pSirMissedBeaconInd->bssIdx);
2231 return;
2232 }
2233#endif
Gupta, Kapil2fc8ca22016-02-19 12:22:17 +05302234 if (pMac->pmm.inMissedBeaconScenario == TRUE) {
2235 limLog(pMac, LOGW,
2236 FL("beacon miss handling is already going on for BSSIdx:%d"),
2237 pSirMissedBeaconInd->bssIdx);
2238 return;
2239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 if ( (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP) ||
2241 (pMac->pmm.gPmmState == ePMM_STATE_UAPSD_SLEEP)||
2242 (pMac->pmm.gPmmState == ePMM_STATE_WOWLAN) )
2243 {
2244 pMac->pmm.inMissedBeaconScenario = TRUE;
Madan Mohan Koyyalamudi1a30a552013-09-17 21:20:07 +05302245 PELOGE(limLog(pMac, LOGE,
2246 FL("Sending EXIT_BMPS_IND to SME due to Missed beacon from FW"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 limSendExitBmpsInd(pMac, eSME_MISSED_BEACON_IND_RCVD);
2248 }
Yathish9f22e662012-12-10 14:21:35 -08002249/* ACTIVE_MODE_HB_OFFLOAD */
2250#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
2251 else if(((pMac->pmm.gPmmState == ePMM_STATE_READY) ||
2252 (pMac->pmm.gPmmState == ePMM_STATE_BMPS_WAKEUP)) &&
2253 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
2254 {
2255 pMac->pmm.inMissedBeaconScenario = TRUE;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002256 PELOGE(limLog(pMac, LOGE, FL("Received Heart Beat Failure"));)
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08002257 limMissedBeaconInActiveMode(pMac, psessionEntry);
Yathish9f22e662012-12-10 14:21:35 -08002258 }
2259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 else
2261 {
2262 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002263 FL("Received SIR_HAL_MISSED_BEACON_IND while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 pMac->pmm.gPmmState);
2265 }
2266 return;
2267}
2268
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05302269
2270void limUpdateLostLinkParams(tpAniSirGlobal pMac,
2271 tpPESession psessionEntry, tANI_U8 *pRxPacketInfo)
2272{
2273 tpSirSmeLostLinkParamsInd pSmeLostLinkParams;
2274 tSirMsgQ mmhMsg;
2275 if (NULL == pRxPacketInfo)
2276 {
2277 return;
2278 }
2279 pSmeLostLinkParams =
2280 (tpSirSmeLostLinkParamsInd)vos_mem_malloc(sizeof(tSirSmeLostLinkParamsInd));
Sreelakshmi Konamkid8784d92016-04-14 14:59:13 +05302281 if (NULL == pSmeLostLinkParams)
2282 {
2283 limLog(pMac, LOGP,
2284 FL("Failed to alloc mem of size %zu for tSirSmeLostLinkParamsInd"),
2285 sizeof(*pSmeLostLinkParams));
2286 return;
2287 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05302288 vos_mem_set(pSmeLostLinkParams, sizeof(tSirSmeLostLinkParamsInd), 0);
2289 pSmeLostLinkParams->messageType = eWNI_SME_LOST_LINK_PARAMS_IND;
2290 pSmeLostLinkParams->length = sizeof(tSirSmeLostLinkParamsInd);
2291 pSmeLostLinkParams->sessionId = psessionEntry->smeSessionId;
2292 pSmeLostLinkParams->info.bssIdx = psessionEntry->bssIdx;
2293
2294 /*
2295 * Since FW adds 100 to RSSI, here also we are adding 100 so that
2296 * HDD has common logic to subtract 100 from RSSI received
2297 */
2298 pSmeLostLinkParams->info.rssi = WDA_GET_RX_RSSI_DB(pRxPacketInfo) + 100;
2299 vos_mem_copy(pSmeLostLinkParams->info.selfMacAddr,
2300 psessionEntry->selfMacAddr,
2301 sizeof(tSirMacAddr));
2302 pSmeLostLinkParams->info.lastDataRate = 0;
2303 pSmeLostLinkParams->info.linkFlCnt = 0;
2304 pSmeLostLinkParams->info.linkFlTx = 0;
2305 pSmeLostLinkParams->info.rsvd1 = 0;
2306 pSmeLostLinkParams->info.rsvd2 = 0;
2307
2308 mmhMsg.type = eWNI_SME_LOST_LINK_PARAMS_IND;
2309 mmhMsg.bodyptr = pSmeLostLinkParams;
2310 mmhMsg.bodyval = 0;
2311 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2312}
2313
2314/** -----------------------------------------------------------------
2315 \brief limProcessLostLinkParamsInd() - handles lost link params indication
2316
2317 This function process the SIR_HAL_LOST_LINK_PARAMS_IND message from HAL,
2318
2319 \param pMac - global mac structure
2320 \return - none
2321 \sa
2322 ----------------------------------------------------------------- */
2323
2324void limProcessLostLinkParamsInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2325{
2326 tpSirSmeLostLinkParamsInd pSmeLostLinkParamsInd;
2327 tpSirSmeLostLinkParamsInd pLostLInkParamsInd = (tpSirSmeLostLinkParamsInd)pMsg->bodyptr;
2328 tpPESession psessionEntry ;
2329 tSirMsgQ mmhMsg;
2330
2331 if (NULL == pLostLInkParamsInd)
2332 {
2333 limLog(pMac, LOGE,
2334 FL("pLostLInkParamsInd is NULL"));
2335 return;
2336 }
2337
2338 psessionEntry = peFindSessionByBssIdx(pMac,pLostLInkParamsInd->info.bssIdx);
2339 if (psessionEntry == NULL)
2340 {
2341 limLog(pMac, LOGE,
2342 FL("session does not exist for bdssIdx : %d"),
2343 pLostLInkParamsInd->info.bssIdx);
2344
2345 return;
2346 }
2347 pSmeLostLinkParamsInd = vos_mem_malloc(sizeof(tSirSmeLostLinkParamsInd));
2348 if (pSmeLostLinkParamsInd == NULL)
2349 {
2350 limLog(pMac, LOGP,
2351 FL("memory allocate failed for eWNI_SME_LOST_LINK_PARAMD_IND"));
2352 return;
2353 }
2354 pSmeLostLinkParamsInd->messageType = eWNI_SME_LOST_LINK_PARAMS_IND;
2355 pSmeLostLinkParamsInd->length = sizeof(tSirSmeLostLinkParamsInd);
2356 pSmeLostLinkParamsInd->sessionId = psessionEntry->smeSessionId;
2357 pSmeLostLinkParamsInd->info.bssIdx = pLostLInkParamsInd->info.bssIdx;
2358 pSmeLostLinkParamsInd->info.rssi = pLostLInkParamsInd->info.rssi;
2359 vos_mem_copy(pSmeLostLinkParamsInd->info.selfMacAddr,
2360 pLostLInkParamsInd->info.selfMacAddr,
2361 sizeof(tSirMacAddr));
2362 pSmeLostLinkParamsInd->info.linkFlCnt = pLostLInkParamsInd->info.linkFlCnt;
2363 pSmeLostLinkParamsInd->info.linkFlTx = pLostLInkParamsInd->info.linkFlTx;
2364 pSmeLostLinkParamsInd->info.lastDataRate = pLostLInkParamsInd->info.lastDataRate;
2365 pSmeLostLinkParamsInd->info.rsvd1 = pLostLInkParamsInd->info.rsvd1;
2366 pSmeLostLinkParamsInd->info.rsvd2 = pLostLInkParamsInd->info.rsvd2;
2367
2368 mmhMsg.type = eWNI_SME_LOST_LINK_PARAMS_IND;
2369 mmhMsg.bodyptr = pSmeLostLinkParamsInd;
2370 mmhMsg.bodyval = 0;
2371 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2372 return;
2373}
2374
Jeff Johnson295189b2012-06-20 16:38:30 -07002375/** -----------------------------------------------------------------
2376 \brief limMicFailureInd() - handles mic failure indication
2377
2378 This function process the SIR_HAL_MIC_FAILURE_IND message from HAL,
2379
2380 \param pMac - global mac structure
2381 \return - none
2382 \sa
2383 ----------------------------------------------------------------- */
2384void limMicFailureInd(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2385{
2386 tpSirSmeMicFailureInd pSirSmeMicFailureInd;
2387 tpSirSmeMicFailureInd pSirMicFailureInd = (tpSirSmeMicFailureInd)pMsg->bodyptr;
2388 tSirMsgQ mmhMsg;
2389 tpPESession psessionEntry ;
2390 tANI_U8 sessionId;
2391
2392 if((psessionEntry = peFindSessionByBssid(pMac,pSirMicFailureInd->bssId,&sessionId))== NULL)
2393 {
2394 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002395 FL("session does not exist for given BSSId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 return;
2397 }
2398
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302399 pSirSmeMicFailureInd = vos_mem_malloc(sizeof(tSirSmeMicFailureInd));
2400 if (NULL == pSirSmeMicFailureInd)
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 {
2402 // Log error
2403 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002404 FL("memory allocate failed for eWNI_SME_MIC_FAILURE_IND"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 return;
2406 }
2407
2408 pSirSmeMicFailureInd->messageType = eWNI_SME_MIC_FAILURE_IND;
Sunkad, Anand Ningappabf1650a2016-02-08 12:08:13 +05302409 pSirSmeMicFailureInd->length = sizeof(*pSirSmeMicFailureInd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 pSirSmeMicFailureInd->sessionId = psessionEntry->smeSessionId;
2411
2412 vos_mem_copy(pSirSmeMicFailureInd->bssId,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302413 pSirMicFailureInd->bssId,
2414 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002415
2416 vos_mem_copy(pSirSmeMicFailureInd->info.srcMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302417 pSirMicFailureInd->info.srcMacAddr,
2418 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002419
2420 vos_mem_copy(pSirSmeMicFailureInd->info.taMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302421 pSirMicFailureInd->info.taMacAddr,
2422 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002423
2424 vos_mem_copy(pSirSmeMicFailureInd->info.dstMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302425 pSirMicFailureInd->info.dstMacAddr,
2426 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002427
2428 vos_mem_copy(pSirSmeMicFailureInd->info.rxMacAddr,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302429 pSirMicFailureInd->info.rxMacAddr,
2430 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002431
2432 pSirSmeMicFailureInd->info.multicast =
2433 pSirMicFailureInd->info.multicast;
2434
2435 pSirSmeMicFailureInd->info.keyId=
2436 pSirMicFailureInd->info.keyId;
2437
2438 pSirSmeMicFailureInd->info.IV1=
2439 pSirMicFailureInd->info.IV1;
2440
2441 vos_mem_copy(pSirSmeMicFailureInd->info.TSC,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302442 pSirMicFailureInd->info.TSC,SIR_CIPHER_SEQ_CTR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002443
2444 mmhMsg.type = eWNI_SME_MIC_FAILURE_IND;
2445 mmhMsg.bodyptr = pSirSmeMicFailureInd;
2446 mmhMsg.bodyval = 0;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05302447 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2449 return;
2450}
2451
Sushant Kaushik1f5f54b2015-07-28 14:32:22 +05302452#ifdef WLAN_FEATURE_11W
2453/** --------------------------------------------------------------------
2454 * lim_is_assoc_req_for_drop()- function to decides to drop assoc\reassoc
2455 * frames.
2456 * @mac: pointer to global mac structure
2457 * @rx_pkt_info: rx packet meta information
2458 *
2459 * This function is called before enqueuing the frame to PE queue to
2460 * drop flooded assoc/reassoc frames getting into PE Queue.
2461 *
2462 * Return: true for dropping the frame otherwise false
2463----------------------------------------------------------------------*/
2464
2465bool lim_is_assoc_req_for_drop(tpAniSirGlobal pMac, uint8_t *rx_pkt_info)
2466{
2467 tANI_U8 session_id;
2468 tANI_U16 aid;
2469 tpPESession session_entry;
2470 tpSirMacMgmtHdr pMacHdr;
2471 tpDphHashNode sta_ds;
2472
2473 pMacHdr = WDA_GET_RX_MAC_HEADER(rx_pkt_info);
2474 session_entry = peFindSessionByBssid(pMac, pMacHdr->bssId, &session_id);
2475 if (!session_entry)
2476 {
2477 PELOG1(limLog(pMac, LOG1,
2478 FL("session does not exist for given STA [%pM]"),
2479 pMacHdr->sa););
2480 return false;
2481 }
2482 sta_ds = dphLookupHashEntry(pMac, pMacHdr->sa, &aid,
2483 &session_entry->dph.dphHashTable);
2484 if (!sta_ds)
2485 {
2486 PELOG1(limLog(pMac, LOG1, FL("pStaDs is NULL")););
2487 return false;
2488 }
2489
2490 if (!sta_ds->rmfEnabled)
2491 return false;
2492
2493 if (sta_ds->pmfSaQueryState == DPH_SA_QUERY_IN_PROGRESS)
2494 return true;
2495
2496 if (sta_ds->last_assoc_received_time &&
2497 ((vos_timer_get_system_time() -
2498 sta_ds->last_assoc_received_time) < 1000))
2499 return true;
2500
2501 sta_ds->last_assoc_received_time = vos_timer_get_system_time();
2502 return false;
2503}
2504#endif
2505
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302506/** ----------------------------------------------------------------------
2507 *\brief limIsDeauthDiassocForDrop()..decides to drop deauth\diassoc frames.
2508 *This function is called before enqueuing the frame to PE queue.
2509 *This prevents deauth/diassoc frames getting into PE Queue.
Jeff Johnson295189b2012-06-20 16:38:30 -07002510
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302511------------------------------------------------------------------------ */
2512
2513
2514boolean limIsDeauthDiassocForDrop(tpAniSirGlobal pMac,
2515 tANI_U8 *pRxPacketInfo)
2516{
2517 tANI_U8 sessionId;
2518 tANI_U16 aid;
2519 tpPESession psessionEntry;
2520 tpSirMacMgmtHdr pMacHdr;
2521 tpDphHashNode pStaDs;
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302522 eHalStatus lock_status = eHAL_STATUS_SUCCESS;
2523 boolean ret = FALSE;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302524
2525 pMacHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
2526 psessionEntry = peFindSessionByBssid(pMac,pMacHdr->bssId,&sessionId);
2527 if (!psessionEntry)
2528 {
2529 PELOG1(sysLog(pMac, LOG1,
2530 FL("session does not exist for given STA [%pM]"),
2531 pMacHdr->sa););
2532 return TRUE;
2533 }
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302534
2535 lock_status = pe_AcquireGlobalLock(&pMac->lim);
2536 if (lock_status != eHAL_STATUS_SUCCESS)
2537 {
2538 limLog(pMac, LOGE, FL("pe_AcquireGlobalLock error"));
2539 return TRUE;
2540 }
2541
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302542 pStaDs = dphLookupHashEntry(pMac, pMacHdr->sa, &aid,
2543 &psessionEntry->dph.dphHashTable);
2544 if (!pStaDs)
2545 {
2546 PELOG1(sysLog(pMac, LOG1,FL("pStaDs is NULL")););
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302547 ret = TRUE;
2548 goto end;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302549 }
2550#ifdef WLAN_FEATURE_11W
2551 if (psessionEntry->limRmfEnabled)
2552 {
2553 if ((WDA_GET_RX_DPU_FEEDBACK(pRxPacketInfo) &
2554 DPU_FEEDBACK_UNPROTECTED_ERROR))
2555 {
2556 /* It may be possible that deauth/diassoc frames from a spoofy
2557 * AP is received. So if all further deauth/diassoc frmaes are
2558 * dropped, then it may result in lossing deauth/diassoc frames
2559 * from genuine AP. So process all deauth/diassoc frames with
2560 * a time difference of 1 sec.
2561 */
2562 if (vos_timer_get_system_time() - pStaDs->last_unprot_deauth_disassoc < 1000)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302563 {
2564 ret = TRUE;
2565 goto end;
2566 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302567 pStaDs->last_unprot_deauth_disassoc =
2568 vos_timer_get_system_time();
2569 }
2570/* PMF enabed, Management frames are protected */
2571 else
2572 {
2573 if (pStaDs->proct_deauh_disassoc_cnt)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302574 {
2575 ret = TRUE;
2576 goto end;
2577 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302578 else
2579 pStaDs->proct_deauh_disassoc_cnt++;
2580 }
2581 }
2582 else
2583#endif
2584/* PMF disabled */
2585 {
2586 if (pStaDs->isDisassocDeauthInProgress)
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302587 {
2588 ret = TRUE;
2589 goto end;
2590 }
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302591 else
2592 pStaDs->isDisassocDeauthInProgress++;
2593 }
Padma, Santhosh Kumarbe316c92015-09-14 18:29:55 +05302594
2595end:
2596 pe_ReleaseGlobalLock(&pMac->lim);
2597 return ret;
Sushant Kaushikefe08fa2015-07-06 14:54:09 +05302598}
Jeff Johnson295189b2012-06-20 16:38:30 -07002599/** -----------------------------------------------------------------
2600 \brief limIsPktCandidateForDrop() - decides whether to drop the frame or not
2601
2602 This function is called before enqueuing the frame to PE queue for further processing.
2603 This prevents unnecessary frames getting into PE Queue and drops them right away.
2604 Frames will be droped in the following scenarios:
2605
2606 - In Scan State, drop the frames which are not marked as scan frames
2607 - In non-Scan state, drop the frames which are marked as scan frames.
2608 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2609 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2610
2611 \param pMac - global mac structure
2612 \return - none
2613 \sa
2614 ----------------------------------------------------------------- */
2615
2616tMgmtFrmDropReason limIsPktCandidateForDrop(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tANI_U32 subType)
2617{
2618 tANI_U32 framelen;
2619 tANI_U8 *pBody;
2620 tSirMacCapabilityInfo capabilityInfo;
2621
2622 /*
2623 *
2624 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2625 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2626 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2627 * other than beacons or probe responses in scan state.
2628 */
2629 if( (subType == SIR_MAC_MGMT_BEACON) ||
2630 (subType == SIR_MAC_MGMT_PROBE_RSP))
2631 {
2632 if(pMac->pmm.inMissedBeaconScenario)
2633 {
Leela Venkata Kiran Kumar Reddy Chiralaf3fe6302013-03-18 12:32:14 -07002634 MTRACE(macTrace(pMac, TRACE_CODE_INFO_LOG, 0, eLOG_NODROP_MISSED_BEACON_SCENARIO));
2635 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 }
2637 if (limIsSystemInScanState(pMac))
2638 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002639 return eMGMT_DROP_NO_DROP;
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002641#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2642 else if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || WDA_GET_ROAMCANDIDATEIND(pRxPacketInfo))
2643 {
2644 return eMGMT_DROP_NO_DROP;
2645 }
2646#endif
Dino Mycle7a76e662014-06-10 11:36:34 +05302647#ifdef WLAN_FEATURE_EXTSCAN
2648 else if (WDA_GET_EXTSCANFULLSCANRESIND(pRxPacketInfo))
2649 {
2650 return eMGMT_DROP_NO_DROP;
2651 }
2652#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 else if (WDA_IS_RX_IN_SCAN(pRxPacketInfo))
2654 {
2655 return eMGMT_DROP_SCAN_MODE_FRAME;
2656 }
2657 }
2658
2659 framelen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2660 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
2661
2662 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2663 * beacons from an infrastructure network
2664 */
2665 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2666 if(!capabilityInfo.ibss)
2667 return eMGMT_DROP_NO_DROP;
2668#if 0
2669 //Allow the mgmt frames to be queued if STA not in IBSS mode.
2670 if (pMac->lim.gLimSystemRole != eLIM_STA_IN_IBSS_ROLE)
2671 return eMGMT_DROP_NO_DROP;
2672#endif
2673
Sushant Kaushik1f5f54b2015-07-28 14:32:22 +05302674#ifdef WLAN_FEATURE_11W
2675 if ((subType == SIR_MAC_MGMT_ASSOC_REQ ||
2676 subType == SIR_MAC_MGMT_REASSOC_REQ) &&
2677 lim_is_assoc_req_for_drop(pMac, pRxPacketInfo))
2678 return eMGMT_DROP_SPURIOUS_FRAME;
2679#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 //Drop INFRA Beacons and Probe Responses in IBSS Mode
2681 if( (subType == SIR_MAC_MGMT_BEACON) ||
2682 (subType == SIR_MAC_MGMT_PROBE_RSP))
2683 {
2684 //drop the frame if length is less than 12
2685 if(framelen < LIM_MIN_BCN_PR_LENGTH)
2686 return eMGMT_DROP_INVALID_SIZE;
2687
2688 *((tANI_U16*) &capabilityInfo) = sirReadU16(pBody+ LIM_BCN_PR_CAPABILITY_OFFSET);
2689
2690 //This can be enhanced to even check the SSID before deciding to enque the frame.
2691 if(capabilityInfo.ess)
2692 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
2693 }
2694 else if( (subType == SIR_MAC_MGMT_PROBE_REQ) &&
2695 (!WDA_GET_RX_BEACON_SENT(pRxPacketInfo)))
2696 {
2697 //Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2698 //In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq
2699 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
2700 }
2701
2702 return eMGMT_DROP_NO_DROP;
2703}
2704
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002705eHalStatus pe_AcquireGlobalLock( tAniSirLim *psPe)
2706{
2707 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002708
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002709 if(psPe)
2710 {
2711 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psPe->lkPeGlobalLock) ) )
2712 {
2713 status = eHAL_STATUS_SUCCESS;
2714 }
2715 }
2716 return (status);
2717}
2718eHalStatus pe_ReleaseGlobalLock( tAniSirLim *psPe)
2719{
2720 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2721 if(psPe)
2722 {
2723 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psPe->lkPeGlobalLock) ) )
2724 {
2725 status = eHAL_STATUS_SUCCESS;
2726 }
2727 }
2728 return (status);
2729}
Manjeet Singh3ed79242017-01-11 19:04:32 +05302730/**
2731 * lim_process_sme_cap_tsf_req()- send cap tsf request to WDA
2732 * Get bss_idx from PE and fill in cap tsf request.
2733 * @pMac:Mac ctx
2734 * @pMsgBuf: message buffer from sme
2735 * Returns success on post to WDA, otherwise failure
2736 */
2737
2738tSirRetStatus lim_process_sme_cap_tsf_req(tpAniSirGlobal pMac,
2739 tANI_U32 *pMsgBuf)
2740{
2741 tSirCapTsfParams *pMsg = NULL;
2742 tpPESession psessionEntry = NULL;
2743 uint8_t sessionId;
2744 tSirMsgQ msg;
2745 tSirCapTsfParams *cap_tsf_params;
2746
2747 pMsg = (tSirCapTsfParams*)pMsgBuf;
2748 if (pMsg == NULL) {
2749 limLog(pMac, LOGE, FL("NULL pMsg"));
2750 return eSIR_FAILURE;
2751 }
2752
2753 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
2754 if (NULL == psessionEntry)
2755 {
2756 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2757 return eSIR_FAILURE;
2758 }
2759 cap_tsf_params = (tSirCapTsfParams *)
2760 vos_mem_malloc(sizeof(*cap_tsf_params));
2761 if (!cap_tsf_params) {
2762 limLog(pMac, LOGE, FL(" Unable to allocate memory for cap tsf params"));
2763 return eSIR_MEM_ALLOC_FAILED;
2764 }
2765 vos_mem_copy (cap_tsf_params, pMsg, sizeof(*cap_tsf_params));
2766 cap_tsf_params->bss_idx = psessionEntry->bssIdx;
2767
2768 msg.type = WDA_CAP_TSF_REQ;
2769 msg.reserved = 0;
2770 msg.bodyptr = cap_tsf_params;
2771 msg.bodyval = 0;
2772 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
2773 {
2774 limLog(pMac, LOGE, FL("lim_process_sme_cap_tsf_req failed\n"));
2775 vos_mem_free(cap_tsf_params);
2776 return eSIR_FAILURE;
2777 }
2778
2779 return eSIR_SUCCESS;
2780}
2781
2782/**
2783 * lim_process_sme_get_tsf_req()- send get tsf request to WDA
2784 * Get bss_idx from PE and fill in cap tsf request.
2785 * @pMac:Mac ctx
2786 * @pMsgBuf: message buffer from sme
2787 * Returns success on post to WDA, otherwise failure
2788 */
2789tSirRetStatus lim_process_sme_get_tsf_req(tpAniSirGlobal pMac,
2790 tANI_U32 *pMsgBuf)
2791{
2792 tSirCapTsfParams *pMsg = NULL;
2793 tpPESession psessionEntry = NULL;
2794 uint8_t sessionId;
2795 tSirMsgQ msg;
2796 tSirCapTsfParams *get_tsf_params;
2797
2798 pMsg = (tSirCapTsfParams*)pMsgBuf;
2799 if (pMsg == NULL) {
2800 limLog(pMac, LOGE, FL("NULL pMsg"));
2801 return eSIR_FAILURE;
2802 }
2803
2804 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
2805 if (NULL == psessionEntry)
2806 {
2807 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2808 return eSIR_FAILURE;
2809 }
2810 get_tsf_params = (tSirCapTsfParams *)
2811 vos_mem_malloc(sizeof(*get_tsf_params));
2812 if (!get_tsf_params) {
2813 limLog(pMac, LOGE, FL(" Unable to allocate memory for cap tsf params"));
2814 return eSIR_MEM_ALLOC_FAILED;
2815 }
2816 vos_mem_copy (get_tsf_params, pMsg, sizeof(*get_tsf_params));
2817 get_tsf_params->bss_idx = psessionEntry->bssIdx;
2818
2819 msg.type = WDA_GET_TSF_REQ;
2820 msg.reserved = 0;
2821 msg.bodyptr = get_tsf_params;
2822 msg.bodyval = 0;
2823 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
2824 {
2825 limLog(pMac, LOGE, FL("lim_process_sme_cap_tsf_req failed\n"));
2826 vos_mem_free(get_tsf_params);
2827 return eSIR_FAILURE;
2828 }
2829
2830 return eSIR_SUCCESS;
2831}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05302832
2833/**
2834 * lim_process_sme_del_ba_ses_req()- process del ba req
2835 * @pMac:Mac ctx
2836 * @pMsgBuf: message buffer from sme
2837 * Returns success on taking action based on cfg value, otherwise failure
2838 */
2839tSirRetStatus lim_process_sme_del_ba_ses_req(tpAniSirGlobal pMac,
2840 tANI_U32 *pMsgBuf)
2841{
2842 tDelBaParams *pMsg = NULL;
2843 tpPESession psessionEntry = NULL;
2844 int val;
2845
2846 pMsg = (tDelBaParams*)pMsgBuf;
2847 if (pMsg == NULL) {
2848 limLog(pMac, LOGE, FL("NULL pMsg"));
2849 return eSIR_FAILURE;
2850 }
2851
2852 psessionEntry = peFindSessionBySessionId(pMac, pMsg->session_id);
2853 if (NULL == psessionEntry)
2854 {
2855 limLog(pMac, LOGE, FL("NULL psessionEntry"));
2856 return eSIR_FAILURE;
2857 }
2858
2859 if (wlan_cfgGetInt
2860 (pMac, WNI_CFG_ENABLE_TX_RX_AGGREGATION, &val) !=
2861 eSIR_SUCCESS)
2862 {
2863 limLog(pMac, LOGE,
2864 FL( "Unable to get WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
2865 return eSIR_FAILURE;
2866 }
2867
2868 if (!val)
2869 {
2870 limLog(pMac, LOGW,
2871 FL("user requested to disable all RX BA sessions"));
2872 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2873 eSIR_MAC_PEER_TIMEDOUT_REASON);
2874 }
2875
2876 return eSIR_SUCCESS;
2877}