blob: a8d875e91d3aa77f83e7cff10047bd0765f2a6f5 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwal8612c3b2017-12-14 14:37:08 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_api.cc contains the functions that are
21 * exported by LIM to other modules.
22 *
23 * Author: Chandra Modumudi
24 * Date: 02/11/02
25 * History:-
26 * Date Modified by Modification Information
27 * --------------------------------------------------------------------
28 *
29 */
30#include "cds_api.h"
31#include "wni_cfg.h"
32#include "wni_api.h"
33#include "sir_common.h"
34#include "sir_debug.h"
35#include "cfg_api.h"
36
37#include "sch_api.h"
38#include "utils_api.h"
39#include "lim_api.h"
40#include "lim_global.h"
41#include "lim_types.h"
42#include "lim_utils.h"
43#include "lim_assoc_utils.h"
44#include "lim_prop_exts_utils.h"
45#include "lim_ser_des_utils.h"
46#include "lim_ibss_peer_mgmt.h"
47#include "lim_admit_control.h"
48#include "lim_send_sme_rsp_messages.h"
Krunal Soni05c914f2018-08-06 12:23:58 -070049#include "lim_security_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "wmm_apsd.h"
51#include "lim_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include "lim_session.h"
54#include "wma_types.h"
55
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58#include <lim_ft.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053059#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060#include "cds_packet.h"
61#include "cds_utils.h"
62#include "sys_startup.h"
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080063#include "cds_api.h"
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -080064#include "wlan_policy_mgr_api.h"
Naveen Rawat0fc3f692016-06-22 14:30:54 -070065#include "nan_datapath.h"
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +053066#include "wma.h"
67#include "wlan_mgmt_txrx_utils_api.h"
68#include "wlan_objmgr_psoc_obj.h"
Naveen Rawat37f62c82017-03-26 22:24:43 -070069#include "os_if_nan.h"
Paul Zhang2f1077c2017-11-30 12:06:09 +080070#include <wlan_scan_ucfg_api.h>
Liangwei Dongc26be332018-01-19 00:31:31 -050071#include <wlan_p2p_ucfg_api.h>
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +053072#include "wlan_utility.h"
Wu Gao3365e782018-07-27 18:19:35 +080073#include <wlan_tdls_cfg_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074
75static void __lim_init_scan_vars(tpAniSirGlobal pMac)
76{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053077 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078}
79
80static void __lim_init_bss_vars(tpAniSirGlobal pMac)
81{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053082 qdf_mem_set((void *)pMac->lim.gpSession,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 sizeof(*pMac->lim.gpSession) * pMac->lim.maxBssId, 0);
84
85 /* This is for testing purposes only, be default should always be off */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 pMac->lim.gpLimMlmSetKeysReq = NULL;
87}
88
89static void __lim_init_stats_vars(tpAniSirGlobal pMac)
90{
91 pMac->lim.gLimNumBeaconsRcvd = 0;
92 pMac->lim.gLimNumBeaconsIgnored = 0;
93
94 pMac->lim.gLimNumDeferredMsgs = 0;
95
96 /* / Variable to keep track of number of currently associated STAs */
97 pMac->lim.gLimNumOfAniSTAs = 0; /* count of ANI peers */
98
99 /* Heart-Beat interval value */
100 pMac->lim.gLimHeartBeatCount = 0;
101
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530102 qdf_mem_zero(pMac->lim.gLimHeartBeatApMac[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530104 qdf_mem_zero(pMac->lim.gLimHeartBeatApMac[1],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105 sizeof(tSirMacAddr));
106 pMac->lim.gLimHeartBeatApMacIndex = 0;
107
108 /* Statistics to keep track of no. beacons rcvd in heart beat interval */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530109 qdf_mem_set(pMac->lim.gLimHeartBeatBeaconStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110 sizeof(pMac->lim.gLimHeartBeatBeaconStats), 0);
111
112#ifdef WLAN_DEBUG
113 /* Debug counters */
114 pMac->lim.numTot = 0;
115 pMac->lim.numBbt = 0;
116 pMac->lim.numProtErr = 0;
117 pMac->lim.numLearn = 0;
118 pMac->lim.numLearnIgnore = 0;
119 pMac->lim.numSme = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530120 qdf_mem_set(pMac->lim.numMAC, sizeof(pMac->lim.numMAC), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121 pMac->lim.gLimNumAssocReqDropInvldState = 0;
122 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
123 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
124 pMac->lim.gLimNumReassocReqDropInvldState = 0;
125 pMac->lim.gLimNumHashMissIgnored = 0;
126 pMac->lim.gLimUnexpBcnCnt = 0;
127 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
128 pMac->lim.gLimNumLinkEsts = 0;
129 pMac->lim.gLimNumRxCleanup = 0;
130 pMac->lim.gLim11bStaAssocRejectCount = 0;
131#endif
132}
133
134static void __lim_init_states(tpAniSirGlobal pMac)
135{
136 /* Counts Heartbeat failures */
137 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
138 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
139 pMac->lim.gLimHBfailureCntInOtherStates = 0;
140 pMac->lim.gLimRspReqd = 0;
141 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
142
143 /* / MLM State visible across all Sirius modules */
144 MTRACE(mac_trace
145 (pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
146 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
147
148 /* / Previous MLM State */
149 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /**
152 * Initialize state to eLIM_SME_OFFLINE_STATE
153 */
154 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
155
156 /**
157 * By default assume 'unknown' role. This will be updated
158 * when SME_START_BSS_REQ is received.
159 */
160
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530161 qdf_mem_set(&pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams), 0);
162 qdf_mem_set(&pMac->lim.gLimNoShortSlotParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 sizeof(tLimNoShortSlotParams), 0);
164
165 pMac->lim.gLimPhyMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 pMac->lim.gLimProbeRespDisableFlag = 0; /* control over probe resp */
167}
168
169static void __lim_init_vars(tpAniSirGlobal pMac)
170{
171 /* Place holder for Measurement Req/Rsp/Ind related info */
172
173
Jeff Johnson47d75242018-05-12 15:58:53 -0700174 /* Deferred Queue Parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_set(&pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176
177 /* addts request if any - only one can be outstanding at any time */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530178 qdf_mem_set(&pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 pMac->lim.gLimAddtsSent = 0;
180 pMac->lim.gLimAddtsRspTimerCount = 0;
181
182 /* protection related config cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530183 qdf_mem_set(&pMac->lim.cfgProtection, sizeof(tCfgProtection), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 pMac->lim.gLimProtectionControl = 0;
185 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
186
187 /* WMM Related Flag */
188 pMac->lim.gUapsdEnable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189
190 /* QoS-AC Downgrade: Initially, no AC is admitted */
191 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
192 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
193
194 /* dialogue token List head/tail for Action frames request sent. */
195 pMac->lim.pDialogueTokenHead = NULL;
196 pMac->lim.pDialogueTokenTail = NULL;
197
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530198 qdf_mem_set(&pMac->lim.tspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX, 0);
200
201 /* admission control policy information */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530202 qdf_mem_set(&pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203}
204
205static void __lim_init_assoc_vars(tpAniSirGlobal pMac)
206{
Jiachao Wue6485d42017-12-12 10:54:54 +0800207 pMac->lim.gLimAssocStaLimit = 0;
208 pMac->lim.gLimIbssStaLimit = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /* Place holder for current authentication request */
210 /* being handled */
211 pMac->lim.gpLimMlmAuthReq = NULL;
212
213 /* / MAC level Pre-authentication related globals */
214 pMac->lim.gLimPreAuthChannelNumber = 0;
215 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530216 qdf_mem_set(&pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 pMac->lim.gLimNumPreAuthContexts = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530218 qdf_mem_set(&pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 0);
220
221 /* Placed holder to deauth reason */
222 pMac->lim.gLimDeauthReasonCode = 0;
223
224 /* Place holder for Pre-authentication node list */
225 pMac->lim.pLimPreAuthList = NULL;
226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 /* One cache for each overlap and associated case. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530228 qdf_mem_set(pMac->lim.protStaOverlapCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE, 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530230 qdf_mem_set(pMac->lim.protStaCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE, 0);
232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 pMac->lim.pSessionEntry = NULL;
234 pMac->lim.reAssocRetryAttempt = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
236}
237
238static void __lim_init_ht_vars(tpAniSirGlobal pMac)
239{
240 pMac->lim.htCapabilityPresentInBeacon = 0;
241 pMac->lim.gHTGreenfield = 0;
242 pMac->lim.gHTShortGI40Mhz = 0;
243 pMac->lim.gHTShortGI20Mhz = 0;
244 pMac->lim.gHTMaxAmsduLength = 0;
245 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
246 pMac->lim.gHTPSMPSupport = 0;
247 pMac->lim.gHTLsigTXOPProtection = 0;
248 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
249 pMac->lim.gHTAMpduDensity = 0;
250
251 pMac->lim.gMaxAmsduSizeEnabled = false;
252 pMac->lim.gHTMaxRxAMpduFactor = 0;
253 pMac->lim.gHTServiceIntervalGranularity = 0;
254 pMac->lim.gHTControlledAccessOnly = 0;
255 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
256 pMac->lim.gHTPCOActive = 0;
257
258 pMac->lim.gHTPCOPhase = 0;
259 pMac->lim.gHTSecondaryBeacon = 0;
260 pMac->lim.gHTDualCTSProtection = 0;
261 pMac->lim.gHTSTBCBasicMCS = 0;
262}
263
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700264static QDF_STATUS __lim_init_config(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265{
266 uint32_t val1, val2, val3;
267 uint16_t val16;
268 uint8_t val8;
Wu Gao3365e782018-07-27 18:19:35 +0800269 bool valb;
270 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
272 tSirMacHTInfoField1 *pHTInfoField1;
273 tSirMacHTParametersInfo *pAmpduParamInfo;
274
275 /* Read all the CFGs here that were updated before pe_start is called */
276 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
277 * and they will be used throughout when there is no session
278 */
279
Jiachao Wue6485d42017-12-12 10:54:54 +0800280 if (wlan_cfg_get_int(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val1)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700281 != QDF_STATUS_SUCCESS){
Jiachao Wue6485d42017-12-12 10:54:54 +0800282 pe_err("cfg get assoc sta limit failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700283 return QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800284 }
285
286 pMac->lim.gLimAssocStaLimit = val1;
287 pMac->lim.gLimIbssStaLimit = val1;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700288 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO, &val1) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530289 pe_err("could not retrieve HT Cap CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700290 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 }
292
293 if (wlan_cfg_get_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700294 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530295 pe_err("could not retrieve Channel Bonding CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700296 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 }
298 val16 = (uint16_t) val1;
299 pHTCapabilityInfo = (tSirMacHTCapabilityInfo *) &val16;
300
301 /* channel bonding mode could be set to anything from 0 to 4(Titan had these */
302 /* modes But for Taurus we have only two modes: enable(>0) or disable(=0) */
303 pHTCapabilityInfo->supportedChannelWidthSet = val2 ?
304 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE :
305 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
306 if (cfg_set_int
307 (pMac, WNI_CFG_HT_CAP_INFO, *(uint16_t *) pHTCapabilityInfo)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700308 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530309 pe_err("could not update HT Cap Info CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700310 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 }
312
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700313 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530314 pe_err("could not retrieve HT INFO Field1 CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700315 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 }
317
318 val8 = (uint8_t) val1;
319 pHTInfoField1 = (tSirMacHTInfoField1 *) &val8;
320 pHTInfoField1->recommendedTxWidthSet =
321 (uint8_t) pHTCapabilityInfo->supportedChannelWidthSet;
322 if (cfg_set_int(pMac, WNI_CFG_HT_INFO_FIELD1, *(uint8_t *) pHTInfoField1)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700323 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530324 pe_err("could not update HT Info Field");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700325 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 }
327
328 /* WNI_CFG_HEART_BEAT_THRESHOLD */
329
330 if (wlan_cfg_get_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700331 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530332 pe_err("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700333 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 }
335 if (!val1) {
336 pMac->sys.gSysEnableLinkMonitorMode = 0;
337 } else {
338 /* No need to activate the timer during init time. */
339 pMac->sys.gSysEnableLinkMonitorMode = 1;
340 }
341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
343
344 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700345 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530346 pe_err("could not retrieve HT AMPDU Param");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700347 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 }
349 if (wlan_cfg_get_int(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700350 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530351 pe_err("could not retrieve AMPDU Factor CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700352 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 }
Krishna Kumaar Natarajan22b59a72015-11-23 18:54:58 -0800354 if (wlan_cfg_get_int(pMac, WNI_CFG_MPDU_DENSITY, &val3) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700355 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530356 pe_err("could not retrieve MPDU Density CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700357 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan22b59a72015-11-23 18:54:58 -0800358 }
359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 val16 = (uint16_t) val1;
361 pAmpduParamInfo = (tSirMacHTParametersInfo *) &val16;
362 pAmpduParamInfo->maxRxAMPDUFactor = (uint8_t) val2;
Krishna Kumaar Natarajan22b59a72015-11-23 18:54:58 -0800363 pAmpduParamInfo->mpduDensity = (uint8_t)val3;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 if (cfg_set_int
365 (pMac, WNI_CFG_HT_AMPDU_PARAMS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700366 *(uint8_t *) pAmpduParamInfo) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530367 pe_err("cfg get short preamble failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700368 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 }
370
371 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
372 lim_handle_cf_gparam_update do we want to update this? */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700373 if (wlan_cfg_get_int(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530374 pe_err("cfg get short preamble failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700375 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 }
377
378 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
379
380 /* This was initially done after resume notification from HAL. Now, DAL is
381 started before PE so this can be done here */
382 handle_ht_capabilityand_ht_info(pMac, NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700383 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 wlan_cfg_get_int(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,
385 (uint32_t *) &pMac->lim.disableLDPCWithTxbfAP)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530386 pe_err("cfg get disableLDPCWithTxbfAP failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700387 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 }
389#ifdef FEATURE_WLAN_TDLS
Wu Gao3365e782018-07-27 18:19:35 +0800390 status = cfg_tdls_get_buffer_sta_enable(pMac->psoc, &valb);
391 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530392 pe_err("cfg get LimTDLSBufStaEnabled failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 }
Wu Gao3365e782018-07-27 18:19:35 +0800395 pMac->lim.gLimTDLSBufStaEnabled = (uint8_t)valb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396
Wu Gao3365e782018-07-27 18:19:35 +0800397 status = cfg_tdls_get_uapsd_mask(pMac->psoc, &val1);
398 if (QDF_STATUS_SUCCESS != status) {
399 pe_err("cfg get LimTDLSUapsdMask failed");
400 return QDF_STATUS_E_FAILURE;
401 }
402 pMac->lim.gLimTDLSUapsdMask = (uint8_t)val1;
403
404 status = cfg_tdls_get_off_channel_enable(pMac->psoc, &valb);
405 if (QDF_STATUS_SUCCESS != status) {
406 pe_err("cfg get LimTDLSUapsdMask failed");
407 return QDF_STATUS_E_FAILURE;
408 }
409 pMac->lim.gLimTDLSOffChannelEnabled = (uint8_t)valb;
410
411 status = cfg_tdls_get_wmm_mode_enable(pMac->psoc, &valb);
412 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530413 pe_err("cfg get LimTDLSWmmMode failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700414 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 }
Wu Gao3365e782018-07-27 18:19:35 +0800416 pMac->lim.gLimTDLSWmmMode = (uint8_t)valb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417#endif
Arif Hussainee10f902017-12-27 16:30:17 -0800418
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700419 if (QDF_STATUS_SUCCESS != wlan_cfg_get_int(pMac,
Arif Hussainee10f902017-12-27 16:30:17 -0800420 WNI_CFG_OBSS_DETECTION_OFFLOAD,
421 (uint32_t *)&pMac->lim.
Arif Hussain1513cb22018-01-05 19:56:31 -0800422 global_obss_offload_enabled)) {
Arif Hussainee10f902017-12-27 16:30:17 -0800423 pe_err("cfg get obss_detection_offloaded failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700424 return QDF_STATUS_E_FAILURE;
Arif Hussainee10f902017-12-27 16:30:17 -0800425 }
426
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700427 if (QDF_STATUS_SUCCESS !=
Arif Hussain05fb4872018-01-03 16:02:55 -0800428 wlan_cfg_get_int(pMac, WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD,
429 (uint32_t *) &pMac->lim.
430 global_obss_color_collision_det_offload)) {
431 pe_err("cfg get obss_color_collision_offload failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700432 return QDF_STATUS_E_FAILURE;
Arif Hussain05fb4872018-01-03 16:02:55 -0800433 }
434
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700435 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436}
437
438/*
439 lim_start
440 This function is to replace the __lim_process_sme_start_req since there is no
441 eWNI_SME_START_REQ post to PE.
442 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700443QDF_STATUS lim_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800444{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700445 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530447 pe_debug("enter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448
449 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) {
450 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
451
452 MTRACE(mac_trace
453 (pMac, TRACE_CODE_SME_STATE, NO_SESSION,
454 pMac->lim.gLimSmeState));
455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 /* Initialize MLM state machine */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700457 if (QDF_STATUS_SUCCESS != lim_init_mlm(pMac)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530458 pe_err("Init MLM failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700459 return QDF_STATUS_E_FAILURE;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 } else {
462 /**
463 * Should not have received eWNI_SME_START_REQ in states
464 * other than OFFLINE. Return response to host and
465 * log error
466 */
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530467 pe_warn("Invalid SME state: %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 pMac->lim.gLimSmeState);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700469 retCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
471
Paul Zhang2f1077c2017-11-30 12:06:09 +0800472 pMac->lim.req_id =
473 ucfg_scan_register_requester(pMac->psoc,
474 "LIM",
475 lim_process_rx_scan_handler,
476 pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 return retCode;
478}
479
480/**
481 * lim_initialize()
482 *
483 ***FUNCTION:
484 * This function is called from LIM thread entry function.
485 * LIM related global data structures are initialized in this function.
486 *
487 ***LOGIC:
488 * NA
489 *
490 ***ASSUMPTIONS:
491 * NA
492 *
493 ***NOTE:
494 * NA
495 *
496 * @param pMac - Pointer to global MAC structure
497 * @return None
498 */
499
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700500QDF_STATUS lim_initialize(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700502 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503
Jiachao Wue6485d42017-12-12 10:54:54 +0800504 pMac->lim.mgmtFrameSessionId = NO_SESSION;
505 pMac->lim.tdls_frm_session_id = NO_SESSION;
506 pMac->lim.deferredMsgCnt = 0;
507 pMac->lim.retry_packet_cnt = 0;
508 pMac->lim.ibss_retry_cnt = 0;
509 pMac->lim.deauthMsgCnt = 0;
510 pMac->lim.disassocMsgCnt = 0;
511
512 if (QDF_IS_STATUS_ERROR(qdf_mutex_create(
513 &pMac->lim.lkPeGlobalLock))) {
514 pe_err("lim lock init failed!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700515 return QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800516 }
517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518 __lim_init_assoc_vars(pMac);
519 __lim_init_vars(pMac);
520 __lim_init_states(pMac);
521 __lim_init_stats_vars(pMac);
522 __lim_init_bss_vars(pMac);
523 __lim_init_scan_vars(pMac);
524 __lim_init_ht_vars(pMac);
525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800526 /* Initializations for maintaining peers in IBSS */
527 lim_ibss_init(pMac);
528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 rrm_initialize(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530
Jiachao Wue6485d42017-12-12 10:54:54 +0800531 if (QDF_IS_STATUS_ERROR(qdf_mutex_create(
532 &pMac->lim.lim_frame_register_lock))) {
533 pe_err("lim lock init failed!");
534 qdf_mutex_destroy(&pMac->lim.lkPeGlobalLock);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700535 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 }
Jiachao Wue6485d42017-12-12 10:54:54 +0800537
538 qdf_list_create(&pMac->lim.gLimMgmtFrameRegistratinQueue, 0);
539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540 /* initialize the TSPEC admission control table. */
541 /* Note that this was initially done after resume notification from HAL. */
542 /* Now, DAL is started before PE so this can be done here */
543 lim_admit_control_init(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 return status;
545
546} /*** end lim_initialize() ***/
547
548/**
549 * lim_cleanup()
550 *
551 ***FUNCTION:
552 * This function is called upon reset or persona change
553 * to cleanup LIM state
554 *
555 ***LOGIC:
556 * NA
557 *
558 ***ASSUMPTIONS:
559 * NA
560 *
561 ***NOTE:
562 * NA
563 *
564 * @param pMac - Pointer to Global MAC structure
565 * @return None
566 */
567
568void lim_cleanup(tpAniSirGlobal pMac)
569{
Naveen Rawat25460932016-02-05 16:56:08 -0800570 uint8_t i;
Jiachao Wue6485d42017-12-12 10:54:54 +0800571 qdf_list_node_t *lst_node;
572
573 /*
574 * Before destroying the list making sure all the nodes have been
575 * deleted
576 */
577 while (qdf_list_remove_front(
578 &pMac->lim.gLimMgmtFrameRegistratinQueue,
579 &lst_node) == QDF_STATUS_SUCCESS) {
580 qdf_mem_free(lst_node);
581 }
582 qdf_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
583 qdf_mutex_destroy(&pMac->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530585 pe_deregister_mgmt_rx_frm_callback(pMac);
586
Naveen Rawat4b1aab92017-05-23 11:37:09 -0700587 qdf_mem_free(pMac->lim.gpLimRemainOnChanReq);
588 pMac->lim.gpLimRemainOnChanReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589
590 /* free up preAuth table */
591 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL) {
Naveen Rawat25460932016-02-05 16:56:08 -0800592 for (i = 0; i < pMac->lim.gLimPreAuthTimerTable.numEntry; i++)
593 qdf_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable[i]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530594 qdf_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
596 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
597 }
598
599 if (NULL != pMac->lim.pDialogueTokenHead) {
600 lim_delete_dialogue_token_list(pMac);
601 }
602
603 if (NULL != pMac->lim.pDialogueTokenTail) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530604 qdf_mem_free(pMac->lim.pDialogueTokenTail);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605 pMac->lim.pDialogueTokenTail = NULL;
606 }
607
608 if (pMac->lim.gpLimMlmSetKeysReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530609 qdf_mem_free(pMac->lim.gpLimMlmSetKeysReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 pMac->lim.gpLimMlmSetKeysReq = NULL;
611 }
612
613 if (pMac->lim.gpLimMlmAuthReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530614 qdf_mem_free(pMac->lim.gpLimMlmAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 pMac->lim.gpLimMlmAuthReq = NULL;
616 }
617
Vignesh Viswanathana842b942018-02-16 16:02:50 +0530618 if (pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq) {
619 qdf_mem_free(pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq);
620 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
621 }
622
623 if (pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq) {
624 qdf_mem_free(pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq);
625 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
626 }
627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628 /* Now, finally reset the deferred message queue pointers */
629 lim_reset_deferred_msg_q(pMac);
630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 rrm_cleanup(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 lim_ft_cleanup_all_ft_sessions(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634
Paul Zhang2f1077c2017-11-30 12:06:09 +0800635 ucfg_scan_unregister_requester(pMac->psoc, pMac->lim.req_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636} /*** end lim_cleanup() ***/
637
Wen Gong3f003382018-05-14 14:26:37 +0800638#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530639/**
640 * lim_state_info_dump() - print state information of lim layer
641 * @buf: buffer pointer
642 * @size: size of buffer to be filled
643 *
644 * This function is used to print state information of lim layer
645 *
646 * Return: None
647 */
648static void lim_state_info_dump(char **buf_ptr, uint16_t *size)
649{
650 tHalHandle hal;
651 tpAniSirGlobal mac;
652 uint16_t len = 0;
653 char *buf = *buf_ptr;
654
655 hal = cds_get_context(QDF_MODULE_ID_PE);
656 if (hal == NULL) {
657 QDF_ASSERT(0);
658 return;
659 }
660
661 mac = PMAC_STRUCT(hal);
662
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530663 pe_debug("size of buffer: %d", *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530664
665 len += qdf_scnprintf(buf + len, *size - len,
666 "\n SmeState: %d", mac->lim.gLimSmeState);
667 len += qdf_scnprintf(buf + len, *size - len,
668 "\n PrevSmeState: %d", mac->lim.gLimPrevSmeState);
669 len += qdf_scnprintf(buf + len, *size - len,
670 "\n MlmState: %d", mac->lim.gLimMlmState);
671 len += qdf_scnprintf(buf + len, *size - len,
672 "\n PrevMlmState: %d", mac->lim.gLimPrevMlmState);
673 len += qdf_scnprintf(buf + len, *size - len,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530674 "\n ProcessDefdMsgs: %d", mac->lim.gLimProcessDefdMsgs);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530675
676 *size -= len;
677 *buf_ptr += len;
678}
679
680/**
681 * lim_register_debug_callback() - registration function for lim layer
682 * to print lim state information
683 *
684 * Return: None
685 */
686static void lim_register_debug_callback(void)
687{
688 qdf_register_debug_callback(QDF_MODULE_ID_PE, &lim_state_info_dump);
689}
Wen Gong3f003382018-05-14 14:26:37 +0800690#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +0800691static void lim_register_debug_callback(void)
692{
693}
Wen Gong3f003382018-05-14 14:26:37 +0800694#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Naveen Rawat37f62c82017-03-26 22:24:43 -0700695static void lim_nan_register_callbacks(tpAniSirGlobal mac_ctx)
696{
697 struct nan_callbacks cb_obj = {0};
698
699 cb_obj.add_ndi_peer = lim_add_ndi_peer_converged;
Naveen Rawatb3143ea2017-03-26 22:25:46 -0700700 cb_obj.ndp_delete_peers = lim_ndp_delete_peers_converged;
701 cb_obj.delete_peers_by_addr = lim_ndp_delete_peers_by_addr_converged;
Naveen Rawat37f62c82017-03-26 22:24:43 -0700702
703 ucfg_nan_register_lim_callbacks(mac_ctx->psoc, &cb_obj);
704}
Naveen Rawat37f62c82017-03-26 22:24:43 -0700705
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530706/*
707 * pe_shutdown_notifier_cb - Shutdown notifier callback
708 * @ctx: Pointer to Global MAC structure
709 *
710 * Return: None
711 */
712static void pe_shutdown_notifier_cb(void *ctx)
713{
714 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)ctx;
715 tpPESession session;
716 uint8_t i;
717
yeshwanth sriram guntukafde0d522017-08-17 19:52:11 +0530718 lim_deactivate_timers(mac_ctx);
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530719 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
720 session = &mac_ctx->lim.gpSession[i];
721 if (session->valid == true) {
722 if (LIM_IS_AP_ROLE(session))
723 qdf_mc_timer_stop(&session->
724 protection_fields_reset_timer);
725#ifdef WLAN_FEATURE_11W
726 qdf_mc_timer_stop(&session->pmfComebackTimer);
727#endif
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530728 }
729 }
730}
731
Liangwei Dongc26be332018-01-19 00:31:31 -0500732#ifdef WLAN_FEATURE_11W
733/**
734 * is_mgmt_protected - check RMF enabled for the peer
735 * @vdev_id: vdev id
736 * @peer_mac_addr: peer mac address
737 *
738 * The function check the mgmt frame protection enabled or not
739 * for station mode and AP mode
740 *
741 * Return: true, if the connection is RMF enabled.
742 */
743static bool is_mgmt_protected(uint32_t vdev_id,
744 const uint8_t *peer_mac_addr)
745{
746 uint16_t aid;
747 tpDphHashNode sta_ds;
748 tpPESession session;
749 bool protected = false;
750 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
751
752 if (!mac_ctx)
753 return false;
754
755 session = pe_find_session_by_sme_session_id(mac_ctx,
756 vdev_id);
757 if (!session) {
758 /* couldn't find session */
759 pe_err("Session not found for vdev_id: %d", vdev_id);
760 return false;
761 }
762
763 if (LIM_IS_AP_ROLE(session)) {
764 sta_ds = dph_lookup_hash_entry(mac_ctx,
765 (uint8_t *)peer_mac_addr, &aid,
766 &session->dph.dphHashTable);
767 if (sta_ds) {
768 /* rmfenabled will be set at the time of addbss.
769 * but sometimes EAP auth fails and keys are not
770 * installed then if we send any management frame
771 * like deauth/disassoc with this bit set then
772 * firmware crashes. so check for keys are
773 * installed or not also before setting the bit
774 */
775 if (sta_ds->rmfEnabled && sta_ds->is_key_installed)
776 protected = true;
777 }
778 } else if (session->limRmfEnabled &&
779 session->is_key_installed) {
780 protected = true;
781 }
782
783 return protected;
784}
785#else
786/**
787 * is_mgmt_protected - check RMF enabled for the peer
788 * @vdev_id: vdev id
789 * @peer_mac_addr: peer mac address
790 *
791 * The function check the mgmt frame protection enabled or not
792 * for station mode and AP mode
793 *
794 * Return: true, if the connection is RMF enabled.
795 */
796static bool is_mgmt_protected(uint32_t vdev_id,
797 const uint8_t *peer_mac_addr)
798{
799 return false;
800}
801#endif
802
803static void p2p_register_callbacks(tpAniSirGlobal mac_ctx)
804{
805 struct p2p_protocol_callbacks p2p_cb = {0};
806
807 p2p_cb.is_mgmt_protected = is_mgmt_protected;
808 ucfg_p2p_register_callbacks(mac_ctx->psoc, &p2p_cb);
809}
810
Vignesh Viswanathan153ae932018-04-11 14:24:13 +0530811/*
812 * lim_register_sap_bcn_callback(): Register a callback with scan module for SAP
813 * @mac_ctx: pointer to the global mac context
814 *
815 * Registers the function lim_handle_sap_beacon as callback with the Scan
816 * module to handle beacon frames for SAP sessions
817 *
818 * Return: QDF Status
819 */
820static QDF_STATUS lim_register_sap_bcn_callback(tpAniSirGlobal mac_ctx)
821{
822 QDF_STATUS status;
823
824 status = ucfg_scan_register_bcn_cb(mac_ctx->psoc,
825 lim_handle_sap_beacon,
826 SCAN_CB_TYPE_UPDATE_BCN);
827 if (!QDF_IS_STATUS_SUCCESS(status)) {
828 pe_err("failed with status code %08d [x%08x]",
829 status, status);
830 }
831
832 return status;
833}
834
835/*
836 * lim_unregister_sap_bcn_callback(): Unregister the callback with scan module
837 * @mac_ctx: pointer to the global mac context
838 *
839 * Unregisters the callback registered with the Scan
840 * module to handle beacon frames for SAP sessions
841 *
842 * Return: QDF Status
843 */
844static QDF_STATUS lim_unregister_sap_bcn_callback(tpAniSirGlobal mac_ctx)
845{
846 QDF_STATUS status;
847
848 status = ucfg_scan_register_bcn_cb(mac_ctx->psoc,
849 NULL, SCAN_CB_TYPE_UPDATE_BCN);
850 if (!QDF_IS_STATUS_SUCCESS(status)) {
851 pe_err("failed with status code %08d [x%08x]",
852 status, status);
853 }
854
855 return status;
856}
857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858/** -------------------------------------------------------------
859 \fn pe_open
860 \brief will be called in Open sequence from mac_open
861 \param tpAniSirGlobal pMac
862 \param tHalOpenParameters *pHalOpenParam
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700863 \return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 -------------------------------------------------------------*/
865
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700866QDF_STATUS pe_open(tpAniSirGlobal pMac, struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700868 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700870 if (QDF_DRIVER_TYPE_MFG == cds_cfg->driver_type)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700871 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
Arun Khandavallic811dcc2016-06-26 07:37:21 +0530873 pMac->lim.maxBssId = cds_cfg->max_bssid;
874 pMac->lim.maxStation = cds_cfg->max_station;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +0530875 qdf_spinlock_create(&pMac->sys.bbt_mgmt_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876
877 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530878 pe_err("max number of Bssid or Stations cannot be zero!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700879 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 }
881
Qiwei Cai50a21082018-08-07 14:30:09 +0800882 if (!QDF_IS_STATUS_SUCCESS(pe_allocate_dph_node_array_buffer())) {
883 pe_err("g_dph_node_array memory allocate failed!");
884 return QDF_STATUS_E_NOMEM;
885 }
886
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 pMac->lim.limTimers.gpLimCnfWaitTimer =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530888 qdf_mem_malloc(sizeof(TX_TIMER) * (pMac->lim.maxStation + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 if (NULL == pMac->lim.limTimers.gpLimCnfWaitTimer) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530890 pe_err("gpLimCnfWaitTimer memory allocate failed!");
Qiwei Cai50a21082018-08-07 14:30:09 +0800891 status = QDF_STATUS_E_NOMEM;
892 goto pe_open_timer_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 }
894
895 pMac->lim.gpSession =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 qdf_mem_malloc(sizeof(tPESession) * pMac->lim.maxBssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 if (NULL == pMac->lim.gpSession) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530898 pe_err("gpSession memory allocate failed!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700899 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 goto pe_open_psession_fail;
901 }
902
Jiachao Wue6485d42017-12-12 10:54:54 +0800903 status = lim_initialize(pMac);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700904 if (QDF_STATUS_SUCCESS != status) {
Jiachao Wue6485d42017-12-12 10:54:54 +0800905 pe_err("lim_initialize failed!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700906 status = QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800907 goto pe_open_lock_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909
910 /*
911 * pe_open is successful by now, so it is right time to initialize
912 * MTRACE for PE module. if LIM_TRACE_RECORD is not defined in build
913 * file then nothing will be logged for PE module.
914 */
915#ifdef LIM_TRACE_RECORD
916 MTRACE(lim_trace_init(pMac));
917#endif
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530918 lim_register_debug_callback();
Naveen Rawat37f62c82017-03-26 22:24:43 -0700919 lim_nan_register_callbacks(pMac);
Liangwei Dongc26be332018-01-19 00:31:31 -0500920 p2p_register_callbacks(pMac);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +0530921 lim_register_sap_bcn_callback(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530922
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530923 if (!QDF_IS_STATUS_SUCCESS(
924 cds_shutdown_notifier_register(pe_shutdown_notifier_cb, pMac))) {
925 pe_err("%s: Shutdown notifier register failed", __func__);
926 }
927
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700928 return status; /* status here will be QDF_STATUS_SUCCESS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929
Jiachao Wue6485d42017-12-12 10:54:54 +0800930pe_open_lock_fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530931 qdf_mem_free(pMac->lim.gpSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 pMac->lim.gpSession = NULL;
933pe_open_psession_fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530934 qdf_mem_free(pMac->lim.limTimers.gpLimCnfWaitTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Qiwei Cai50a21082018-08-07 14:30:09 +0800936pe_open_timer_fail:
937 pe_free_dph_node_array_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938
939 return status;
940}
941
942/** -------------------------------------------------------------
943 \fn pe_close
944 \brief will be called in close sequence from mac_close
945 \param tpAniSirGlobal pMac
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700946 \return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 -------------------------------------------------------------*/
948
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700949QDF_STATUS pe_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950{
951 uint8_t i;
952
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700953 if (ANI_DRIVER_TYPE(pMac) == QDF_DRIVER_TYPE_MFG)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700954 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955
Jiachao Wue6485d42017-12-12 10:54:54 +0800956 lim_cleanup(pMac);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +0530957 lim_unregister_sap_bcn_callback(pMac);
Abhishek Singh51e048e2017-11-14 14:46:51 +0530958
Himanshu Agarwal8612c3b2017-12-14 14:37:08 +0530959 if (pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq) {
960 qdf_mem_free(pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq);
961 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
962 }
963
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +0530964 qdf_spinlock_destroy(&pMac->sys.bbt_mgmt_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 for (i = 0; i < pMac->lim.maxBssId; i++) {
Krunal Soni6de1b212017-10-30 23:29:20 -0700966 if (pMac->lim.gpSession[i].valid == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 pe_delete_session(pMac, &pMac->lim.gpSession[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530969 qdf_mem_free(pMac->lim.limTimers.gpLimCnfWaitTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
971
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 qdf_mem_free(pMac->lim.gpSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 pMac->lim.gpSession = NULL;
Qiwei Cai50a21082018-08-07 14:30:09 +0800974
975 pe_free_dph_node_array_buffer();
976
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530977 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530978 (qdf_mutex_destroy(&pMac->lim.lkPeGlobalLock))) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700979 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700981 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982}
983
984/** -------------------------------------------------------------
985 \fn pe_start
986 \brief will be called in start sequence from mac_start
987 \param tpAniSirGlobal pMac
Jeff Johnsond9e03512018-06-29 12:04:03 -0700988 \return QDF_STATUS_SUCCESS on success, other QDF_STATUS on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 -------------------------------------------------------------*/
990
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700991QDF_STATUS pe_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700993 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jiachao Wue6485d42017-12-12 10:54:54 +0800994 status = lim_start(pMac);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700995 if (QDF_STATUS_SUCCESS != status) {
Jiachao Wue6485d42017-12-12 10:54:54 +0800996 pe_err("lim_start failed!");
997 return status;
998 }
999 /* Initialize the configurations needed by PE */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001000 if (QDF_STATUS_E_FAILURE == __lim_init_config(pMac)) {
Jiachao Wue6485d42017-12-12 10:54:54 +08001001 pe_err("lim init config failed!");
1002 /* We need to undo everything in lim_start */
1003 lim_cleanup_mlm(pMac);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001004 return QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +08001005 }
1006 /* Initialize the configurations needed by PE */
1007 lim_register_hal_ind_call_back(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 return status;
1009}
1010
1011/** -------------------------------------------------------------
1012 \fn pe_stop
1013 \brief will be called in stop sequence from mac_stop
1014 \param tpAniSirGlobal pMac
1015 \return none
1016 -------------------------------------------------------------*/
1017
1018void pe_stop(tpAniSirGlobal pMac)
1019{
Jiachao Wue6485d42017-12-12 10:54:54 +08001020 lim_cleanup_mlm(pMac);
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +05301021 pe_debug(" PE STOP: Set LIM state to eLIM_MLM_OFFLINE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1023 return;
1024}
1025
Rajeev Kumar69ddd852018-02-20 13:58:08 -08001026static void pe_free_nested_messages(struct scheduler_msg *msg)
1027{
1028 switch (msg->type) {
1029 case WMA_SET_LINK_STATE_RSP:
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +05301030 pe_debug("pe_free_nested_messages: WMA_SET_LINK_STATE_RSP");
Rajeev Kumar69ddd852018-02-20 13:58:08 -08001031 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1032 break;
1033 default:
1034 break;
1035 }
1036}
1037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038/** -------------------------------------------------------------
1039 \fn pe_free_msg
1040 \brief Called by CDS scheduler (function cds_sched_flush_mc_mqs)
1041 \ to free a given PE message on the TX and MC thread.
1042 \ This happens when there are messages pending in the PE
1043 \ queue when system is being stopped and reset.
1044 \param tpAniSirGlobal pMac
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001045 \param struct scheduler_msg pMsg
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 \return none
1047 -----------------------------------------------------------------*/
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001048void pe_free_msg(tpAniSirGlobal pMac, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049{
1050 if (pMsg != NULL) {
1051 if (NULL != pMsg->bodyptr) {
1052 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type) {
1053 cds_pkt_return_packet((cds_pkt_t *) pMsg->
1054 bodyptr);
1055 } else {
Rajeev Kumar69ddd852018-02-20 13:58:08 -08001056 pe_free_nested_messages(pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301057 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 }
1059 }
1060 pMsg->bodyptr = 0;
1061 pMsg->bodyval = 0;
1062 pMsg->type = 0;
1063 }
1064 return;
1065}
1066
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001067QDF_STATUS lim_post_msg_api(tpAniSirGlobal mac, struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068{
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001069 return scheduler_post_msg(QDF_MODULE_ID_PE, msg);
1070}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001072QDF_STATUS lim_post_msg_high_priority(tpAniSirGlobal mac,
1073 struct scheduler_msg *msg)
Padma, Santhosh Kumar95091352016-08-16 15:23:31 +05301074{
Rajeev Kumarf7d84422017-01-21 15:45:44 -08001075 return scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
Rajeev Kumar14978712017-01-30 16:57:07 -08001076 msg, true);
Padma, Santhosh Kumar95091352016-08-16 15:23:31 +05301077}
1078
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001079QDF_STATUS pe_mc_process_handler(struct scheduler_msg *msg)
1080{
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001081 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
1082
1083 if (mac_ctx == NULL)
1084 return QDF_STATUS_E_FAILURE;
1085
Jeff Johnsonedfaf0b2018-06-29 12:47:11 -07001086 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001087 return QDF_STATUS_SUCCESS;
1088
Jeff Johnsonedfaf0b2018-06-29 12:47:11 -07001089 /*
1090 * If the Message to be handled is for CFG Module call the CFG Msg
1091 * Handler and for all the other cases post it to LIM
1092 */
1093 if (SIR_CFG_PARAM_UPDATE_IND != msg->type && IS_CFG_MSG(msg->type))
1094 cfg_process_mb_msg(mac_ctx, msg->bodyptr);
1095 else
1096 lim_message_processor(mac_ctx, msg);
1097
1098 return QDF_STATUS_SUCCESS;
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001099}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001100
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301101/**
1102 * pe_drop_pending_rx_mgmt_frames: To drop pending RX mgmt frames
1103 * @mac_ctx: Pointer to global MAC structure
1104 * @hdr: Management header
1105 * @cds_pkt: Packet
1106 *
1107 * This function is used to drop RX pending mgmt frames if pe mgmt queue
1108 * reaches threshold
1109 *
1110 * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE on failure
1111 */
1112static QDF_STATUS pe_drop_pending_rx_mgmt_frames(tpAniSirGlobal mac_ctx,
1113 tpSirMacMgmtHdr hdr, cds_pkt_t *cds_pkt)
1114{
1115 qdf_spin_lock(&mac_ctx->sys.bbt_mgmt_lock);
1116 if (mac_ctx->sys.sys_bbt_pending_mgmt_count >=
1117 MGMT_RX_PACKETS_THRESHOLD) {
1118 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001119 pe_debug("No.of pending RX management frames reaches to threshold, dropping management frames");
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301120 cds_pkt_return_packet(cds_pkt);
1121 cds_pkt = NULL;
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301122 mac_ctx->rx_packet_drop_counter++;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301123 return QDF_STATUS_E_FAILURE;
1124 } else if (mac_ctx->sys.sys_bbt_pending_mgmt_count >
1125 (MGMT_RX_PACKETS_THRESHOLD / 2)) {
1126 /* drop all probereq, proberesp and beacons */
1127 if (hdr->fc.subType == SIR_MAC_MGMT_BEACON ||
1128 hdr->fc.subType == SIR_MAC_MGMT_PROBE_REQ ||
1129 hdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP) {
1130 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301131 if (!(mac_ctx->rx_packet_drop_counter % 100))
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001132 pe_debug("No.of pending RX mgmt frames reaches 1/2 thresh, dropping frame subtype: %d rx_packet_drop_counter: %d",
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301133 hdr->fc.subType,
1134 mac_ctx->rx_packet_drop_counter);
1135 mac_ctx->rx_packet_drop_counter++;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301136 cds_pkt_return_packet(cds_pkt);
1137 cds_pkt = NULL;
1138 return QDF_STATUS_E_FAILURE;
1139 }
1140 }
1141 mac_ctx->sys.sys_bbt_pending_mgmt_count++;
1142 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
1143 if (mac_ctx->sys.sys_bbt_pending_mgmt_count ==
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301144 (MGMT_RX_PACKETS_THRESHOLD / 4)) {
1145 if (!(mac_ctx->rx_packet_drop_counter % 100))
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001146 pe_debug("No.of pending RX management frames reaches to 1/4th of threshold, rx_packet_drop_counter: %d",
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301147 mac_ctx->rx_packet_drop_counter);
1148 mac_ctx->rx_packet_drop_counter++;
1149 }
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301150 return QDF_STATUS_SUCCESS;
1151}
1152
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301153/**
Vignesh Viswanathan48b7ed92018-04-11 19:01:59 +05301154 * pe_is_ext_scan_bcn - Check if the beacon is from Ext or EPNO scan
1155 *
1156 * @hdr: pointer to the 802.11 header of the frame
1157 * @rx_pkt_info: pointer to the rx packet meta
1158 *
1159 * Checks if the beacon is from Ext Scan or EPNO scan
1160 *
1161 * Return: true or false
1162 */
1163#ifdef FEATURE_WLAN_EXTSCAN
1164static inline bool pe_is_ext_scan_bcn(tpSirMacMgmtHdr hdr,
1165 uint8_t *rx_pkt_info)
1166{
1167 if ((hdr->fc.subType == SIR_MAC_MGMT_BEACON) &&
1168 (WMA_IS_EXTSCAN_SCAN_SRC(rx_pkt_info) ||
1169 WMA_IS_EPNO_SCAN_SRC(rx_pkt_info)))
1170 return true;
1171
1172 return false;
1173}
1174#else
1175static inline bool pe_is_ext_scan_bcn(tpSirMacMgmtHdr hdr,
1176 uint8_t *rx_pkt_info)
1177{
1178 return false;
1179}
1180#endif
1181
1182/**
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301183 * pe_filter_drop_bcn_probe_frame - Apply filter on the received frame
1184 *
1185 * @mac_ctx: pointer to the global mac context
1186 * @hdr: pointer to the 802.11 header of the frame
1187 * @rx_pkt_info: pointer to the rx packet meta
1188 *
1189 * Applies the filter from global mac context on the received beacon/
1190 * probe response frame before posting it to the PE queue
1191 *
1192 * Return: true if frame is allowed, false if frame is to be dropped.
1193 */
1194static bool pe_filter_bcn_probe_frame(tpAniSirGlobal mac_ctx,
1195 tpSirMacMgmtHdr hdr,
1196 uint8_t *rx_pkt_info)
1197{
1198 uint8_t session_id;
1199 uint8_t *body;
1200 const uint8_t *ssid_ie;
1201 uint16_t frame_len;
1202 struct mgmt_beacon_probe_filter *filter;
1203 tpSirMacCapabilityInfo bcn_caps;
1204 tSirMacSSid bcn_ssid;
1205
Vignesh Viswanathan48b7ed92018-04-11 19:01:59 +05301206 if (pe_is_ext_scan_bcn(hdr, rx_pkt_info))
1207 return true;
1208
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301209 filter = &mac_ctx->bcn_filter;
1210
1211 /*
1212 * If any STA session exists and beacon source matches any of the
1213 * STA BSSIDs, allow the frame
1214 */
1215 if (filter->num_sta_sessions) {
1216 for (session_id = 0; session_id < SIR_MAX_SUPPORTED_BSS;
1217 session_id++) {
1218 if (sir_compare_mac_addr(filter->sta_bssid[session_id],
1219 hdr->bssId)) {
1220 return true;
1221 }
1222 }
1223 }
1224
1225 /*
1226 * If any IBSS session exists and beacon is has IBSS capability set
1227 * and SSID matches the IBSS SSID, allow the frame
1228 */
1229 if (filter->num_ibss_sessions) {
1230 body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
1231 frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
1232 if (frame_len < SIR_MAC_B_PR_SSID_OFFSET)
1233 return false;
1234
1235 bcn_caps = (tpSirMacCapabilityInfo)
1236 (body + SIR_MAC_B_PR_CAPAB_OFFSET);
1237 if (!bcn_caps->ibss)
1238 return false;
1239
1240 ssid_ie = wlan_get_ie_ptr_from_eid(SIR_MAC_SSID_EID,
1241 body + SIR_MAC_B_PR_SSID_OFFSET,
1242 frame_len);
1243
1244 if (!ssid_ie)
1245 return false;
1246
1247 bcn_ssid.length = ssid_ie[1];
1248 qdf_mem_copy(&bcn_ssid.ssId,
1249 &ssid_ie[2],
1250 bcn_ssid.length);
1251
1252 for (session_id = 0; session_id < SIR_MAX_SUPPORTED_BSS;
1253 session_id++) {
1254 if (filter->ibss_ssid[session_id].length ==
1255 bcn_ssid.length &&
1256 (!qdf_mem_cmp(filter->ibss_ssid[session_id].ssId,
1257 bcn_ssid.ssId, bcn_ssid.length))) {
1258 return true;
1259 }
1260 }
1261 }
1262
1263 return false;
1264}
1265
Vignesh Viswanathan18eb2b22018-05-08 19:34:56 +05301266static QDF_STATUS pe_handle_probe_req_frames(tpAniSirGlobal mac_ctx,
1267 cds_pkt_t *pkt)
1268{
1269 QDF_STATUS status;
1270 struct scheduler_msg msg = {0};
1271
1272 /* Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG */
1273 msg.type = SIR_BB_XPORT_MGMT_MSG;
1274 msg.bodyptr = pkt;
1275 msg.bodyval = 0;
1276 msg.callback = pe_mc_process_handler;
1277
1278 status = scheduler_post_msg(QDF_MODULE_ID_SCAN, &msg);
1279
1280 if (!QDF_IS_STATUS_SUCCESS(status))
1281 pe_err_rl("Failed to post probe req frame to Scan Queue");
1282
1283 return status;
1284}
1285
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286/* --------------------------------------------------------------------------- */
1287/**
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301288 * pe_handle_mgmt_frame() - Process the Management frames from TXRX
1289 * @psoc: psoc context
1290 * @peer: peer
1291 * @buf: buffer
1292 * @mgmt_rx_params; rx event params
1293 * @frm_type: frame type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301295 * This function handles the mgmt rx frame from mgmt txrx component and forms
1296 * a cds packet and schedule it in controller thread for further processing.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301298 * Return: QDF_STATUS_SUCCESS - in case of success
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 */
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301300static QDF_STATUS pe_handle_mgmt_frame(struct wlan_objmgr_psoc *psoc,
1301 struct wlan_objmgr_peer *peer, qdf_nbuf_t buf,
Himanshu Agarwald2e6cde2017-01-10 14:47:04 +05301302 struct mgmt_rx_event_params *mgmt_rx_params,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301303 uint32_t frm_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304{
1305 tpAniSirGlobal pMac;
1306 tpSirMacMgmtHdr mHdr;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001307 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 cds_pkt_t *pVosPkt;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301309 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 uint8_t *pRxPacketInfo;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301311 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312
Anurag Chouhan6d760662016-02-20 16:05:43 +05301313 pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 if (NULL == pMac) {
1315 /* cannot log a failure without a valid pMac */
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301316 qdf_nbuf_free(buf);
1317 return QDF_STATUS_E_FAILURE;
1318 }
1319
1320 pVosPkt = qdf_mem_malloc(sizeof(*pVosPkt));
1321 if (!pVosPkt) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001322 pe_err("Failed to allocate rx packet");
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301323 qdf_nbuf_free(buf);
1324 return QDF_STATUS_E_NOMEM;
1325 }
1326
1327 ret = wma_form_rx_packet(buf, mgmt_rx_params, pVosPkt);
1328 if (ret) {
Dustin Brown897dae42018-03-13 17:08:47 -07001329 pe_err_rl("Failed to fill cds packet from event buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301330 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 }
1332
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301333 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 wma_ds_peek_rx_packet_info(pVosPkt, (void *)&pRxPacketInfo, false);
1335
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301336 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 cds_pkt_return_packet(pVosPkt);
1338 pVosPkt = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301339 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 }
1341
1342 /*
1343 * The MPDU header is now present at a certain "offset" in
1344 * the BD and is specified in the BD itself
1345 */
1346
1347 mHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301349 /*
1350 * Filter the beacon/probe response frames before posting it
1351 * on the PE queue
1352 */
1353 if ((mHdr->fc.subType == SIR_MAC_MGMT_BEACON ||
1354 mHdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP) &&
1355 !pe_filter_bcn_probe_frame(pMac, mHdr, pRxPacketInfo)) {
1356 cds_pkt_return_packet(pVosPkt);
1357 pVosPkt = NULL;
1358 return QDF_STATUS_SUCCESS;
1359 }
1360
Vignesh Viswanathan18eb2b22018-05-08 19:34:56 +05301361 /*
1362 * Post Probe Req frames to Scan queue and return
1363 */
1364 if (mHdr->fc.subType == SIR_MAC_MGMT_PROBE_REQ) {
1365 qdf_status = pe_handle_probe_req_frames(pMac, pVosPkt);
1366 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
1367 cds_pkt_return_packet(pVosPkt);
1368 pVosPkt = NULL;
1369 }
1370 return qdf_status;
1371 }
1372
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301373 if (QDF_STATUS_SUCCESS !=
1374 pe_drop_pending_rx_mgmt_frames(pMac, mHdr, pVosPkt))
1375 return QDF_STATUS_E_FAILURE;
1376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 /* Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG */
1378 msg.type = SIR_BB_XPORT_MGMT_MSG;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301379 msg.bodyptr = pVosPkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 msg.bodyval = 0;
1381
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001382 if (QDF_STATUS_SUCCESS != sys_bbt_process_message_core(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 &msg,
1384 mHdr->fc.type,
1385 mHdr->fc.subType)) {
1386 cds_pkt_return_packet(pVosPkt);
1387 pVosPkt = NULL;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301388 /*
1389 * Decrement sys_bbt_pending_mgmt_count if packet
1390 * is dropped before posting to LIM
1391 */
1392 lim_decrement_pending_mgmt_count(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 }
1395
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301396 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397}
1398
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301399void pe_register_mgmt_rx_frm_callback(tpAniSirGlobal mac_ctx)
1400{
1401 QDF_STATUS status;
1402 struct mgmt_txrx_mgmt_frame_cb_info frm_cb_info;
1403
1404 frm_cb_info.frm_type = MGMT_FRAME_TYPE_ALL;
1405 frm_cb_info.mgmt_rx_cb = (mgmt_frame_rx_callback)
1406 pe_handle_mgmt_frame;
1407
1408 status = wlan_mgmt_txrx_register_rx_cb(mac_ctx->psoc,
1409 WLAN_UMAC_COMP_MLME, &frm_cb_info, 1);
1410 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001411 pe_err("Registering the PE Handle with MGMT TXRX layer has failed");
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301412
1413 wma_register_mgmt_frm_client();
1414}
1415
1416void pe_deregister_mgmt_rx_frm_callback(tpAniSirGlobal mac_ctx)
1417{
1418 QDF_STATUS status;
1419 struct mgmt_txrx_mgmt_frame_cb_info frm_cb_info;
1420
1421 frm_cb_info.frm_type = MGMT_FRAME_TYPE_ALL;
1422 frm_cb_info.mgmt_rx_cb = (mgmt_frame_rx_callback)
1423 pe_handle_mgmt_frame;
1424
1425 status = wlan_mgmt_txrx_deregister_rx_cb(mac_ctx->psoc,
1426 WLAN_UMAC_COMP_MLME, &frm_cb_info, 1);
1427 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001428 pe_err("Deregistering the PE Handle with MGMT TXRX layer has failed");
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301429
1430 wma_de_register_mgmt_frm_client();
1431}
1432
1433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434/**
Naveen Rawat0fc3f692016-06-22 14:30:54 -07001435 * pe_register_callbacks_with_wma() - register SME and PE callback functions to
1436 * WMA.
Jeff Johnson82b0c622016-10-07 07:53:55 -07001437 * (function documentation in lim_api.h)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 */
Naveen Rawat0fc3f692016-06-22 14:30:54 -07001439void pe_register_callbacks_with_wma(tpAniSirGlobal pMac,
1440 tSirSmeReadyReq *ready_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441{
Jeff Johnsona9b66572017-09-02 12:41:21 -07001442 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443
Jeff Johnsona9b66572017-09-02 12:41:21 -07001444 status = wma_register_roaming_callbacks(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001445 ready_req->csr_roam_synch_cb,
1446 ready_req->pe_roam_synch_cb);
Jeff Johnsona9b66572017-09-02 12:41:21 -07001447 if (status != QDF_STATUS_SUCCESS)
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301448 pe_err("Registering roaming callbacks with WMA failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449}
1450
1451/**
1452 * lim_is_system_in_scan_state()
1453 *
1454 ***FUNCTION:
1455 * This function is called by various MAC software modules to
1456 * determine if System is in Scan/Learn state
1457 *
1458 ***LOGIC:
1459 * NA
1460 *
1461 ***ASSUMPTIONS:
1462 * NA
1463 *
1464 ***NOTE:
1465 *
1466 * @param pMac - Pointer to Global MAC structure
1467 * @return true - System is in Scan/Learn state
1468 * false - System is NOT in Scan/Learn state
1469 */
1470
1471uint8_t lim_is_system_in_scan_state(tpAniSirGlobal pMac)
1472{
1473 switch (pMac->lim.gLimSmeState) {
1474 case eLIM_SME_CHANNEL_SCAN_STATE:
1475 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1476 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1477 case eLIM_SME_WT_SCAN_STATE:
1478 /* System is in Learn mode */
1479 return true;
1480
1481 default:
1482 /* System is NOT in Learn mode */
1483 return false;
1484 }
1485} /*** end lim_is_system_in_scan_state() ***/
1486
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487/**
1488 *\brief lim_received_hb_handler()
1489 *
1490 * This function is called by sch_beacon_process() upon
1491 * receiving a Beacon on STA. This also gets called upon
1492 * receiving Probe Response after heat beat failure is
1493 * detected.
1494 *
1495 * param pMac - global mac structure
1496 * param channel - channel number indicated in Beacon, Probe Response
1497 * return - none
1498 */
1499
1500void
1501lim_received_hb_handler(tpAniSirGlobal pMac, uint8_t channelId,
1502 tpPESession psessionEntry)
1503{
1504 if ((channelId == 0)
1505 || (channelId == psessionEntry->currentOperChannel))
1506 psessionEntry->LimRxedBeaconCntDuringHB++;
1507
1508 psessionEntry->pmmOffloadInfo.bcnmiss = false;
1509} /*** lim_init_wds_info_params() ***/
1510
1511/** -------------------------------------------------------------
1512 \fn lim_update_overlap_sta_param
1513 \brief Updates overlap cache and param data structure
1514 \param tpAniSirGlobal pMac
1515 \param tSirMacAddr bssId
1516 \param tpLimProtStaParams pStaParams
1517 \return None
1518 -------------------------------------------------------------*/
1519void
1520lim_update_overlap_sta_param(tpAniSirGlobal pMac, tSirMacAddr bssId,
1521 tpLimProtStaParams pStaParams)
1522{
1523 int i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 if (!pStaParams->numSta) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301526 qdf_mem_copy(pMac->lim.protStaOverlapCache[0].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 bssId, sizeof(tSirMacAddr));
1528 pMac->lim.protStaOverlapCache[0].active = true;
1529
1530 pStaParams->numSta = 1;
1531
1532 return;
1533 }
1534
1535 for (i = 0; i < LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++) {
1536 if (pMac->lim.protStaOverlapCache[i].active) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301537 if (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 (pMac->lim.protStaOverlapCache[i].addr, bssId,
1539 sizeof(tSirMacAddr))) {
1540 return;
1541 }
1542 } else
1543 break;
1544 }
1545
1546 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE) {
Abhishek Singhe156ea32017-05-02 17:07:30 +05301547 pe_debug("Overlap cache is full");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(pMac->lim.protStaOverlapCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 bssId, sizeof(tSirMacAddr));
1551 pMac->lim.protStaOverlapCache[i].active = true;
1552
1553 pStaParams->numSta++;
1554 }
1555}
1556
1557/**
1558 * lim_ibss_enc_type_matched
1559 *
1560 ***FUNCTION:
1561 * This function compares the encryption type of the peer with self
1562 * while operating in IBSS mode and detects mismatch.
1563 *
1564 ***LOGIC:
1565 *
1566 ***ASSUMPTIONS:
1567 *
1568 ***NOTE:
1569 *
1570 * @param pBeacon - Parsed Beacon Frame structure
1571 * @param pSession - Pointer to the PE session
1572 *
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001573 * @return true if encryption type is matched; false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 */
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001575static bool lim_ibss_enc_type_matched(tpSchBeaconStruct pBeacon,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 tpPESession pSession)
1577{
1578 if (!pBeacon || !pSession)
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001579 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580
1581 /* Open case */
1582 if (pBeacon->capabilityInfo.privacy == 0
1583 && pSession->encryptType == eSIR_ED_NONE)
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001584 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585
1586 /* WEP case */
1587 if (pBeacon->capabilityInfo.privacy == 1 && pBeacon->wpaPresent == 0
1588 && pBeacon->rsnPresent == 0
1589 && (pSession->encryptType == eSIR_ED_WEP40
1590 || pSession->encryptType == eSIR_ED_WEP104))
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001591 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
1593 /* WPA-None case */
1594 if (pBeacon->capabilityInfo.privacy == 1 && pBeacon->wpaPresent == 1
1595 && pBeacon->rsnPresent == 0
1596 && ((pSession->encryptType == eSIR_ED_CCMP) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05301597 (pSession->encryptType == eSIR_ED_GCMP) ||
1598 (pSession->encryptType == eSIR_ED_GCMP_256) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 (pSession->encryptType == eSIR_ED_TKIP)))
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001600 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001602 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603}
1604
1605/**
1606 * lim_handle_ibs_scoalescing()
1607 *
1608 ***FUNCTION:
1609 * This function is called upon receiving Beacon/Probe Response
1610 * while operating in IBSS mode.
1611 *
1612 ***LOGIC:
1613 *
1614 ***ASSUMPTIONS:
1615 *
1616 ***NOTE:
1617 *
1618 * @param pMac - Pointer to Global MAC structure
1619 * @param pBeacon - Parsed Beacon Frame structure
1620 * @param pRxPacketInfo - Pointer to RX packet info structure
1621 *
1622 * @return Status whether to process or ignore received Beacon Frame
1623 */
1624
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001625QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626lim_handle_ibss_coalescing(tpAniSirGlobal pMac,
1627 tpSchBeaconStruct pBeacon,
1628 uint8_t *pRxPacketInfo, tpPESession psessionEntry)
1629{
1630 tpSirMacMgmtHdr pHdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001631 QDF_STATUS retCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632
1633 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
1634
1635 /* Ignore the beacon when any of the conditions below is met:
1636 1. The beacon claims no IBSS network
1637 2. SSID in the beacon does not match SSID of self station
1638 3. Operational channel in the beacon does not match self station
1639 4. Encyption type in the beacon does not match with self station
1640 */
1641 if ((!pBeacon->capabilityInfo.ibss) ||
Ankit Guptad66a8812016-09-15 11:00:16 -07001642 lim_cmp_ssid(&pBeacon->ssId, psessionEntry) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 (psessionEntry->currentOperChannel != pBeacon->channelNumber))
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001644 retCode = QDF_STATUS_E_INVAL;
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001645 else if (lim_ibss_enc_type_matched(pBeacon, psessionEntry) != true) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301646 pe_debug("peer privacy: %d peer wpa: %d peer rsn: %d self encType: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 pBeacon->capabilityInfo.privacy,
1648 pBeacon->wpaPresent, pBeacon->rsnPresent,
1649 psessionEntry->encryptType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001650 retCode = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 } else {
1652 uint32_t ieLen;
1653 uint16_t tsfLater;
1654 uint8_t *pIEs;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 ieLen = WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1657 tsfLater = WMA_GET_RX_TSF_LATER(pRxPacketInfo);
1658 pIEs = WMA_GET_RX_MPDU_DATA(pRxPacketInfo);
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301659 pe_debug("BEFORE Coalescing tsfLater val: %d", tsfLater);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 retCode =
1661 lim_ibss_coalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,
1662 psessionEntry);
1663 }
1664 return retCode;
1665} /*** end lim_handle_ibs_scoalescing() ***/
1666
1667/**
1668 * lim_enc_type_matched() - matches security type of incoming beracon with
1669 * current
1670 * @mac_ctx Pointer to Global MAC structure
1671 * @bcn Pointer to parsed Beacon structure
1672 * @session PE session entry
1673 *
1674 * This function matches security type of incoming beracon with current
1675 *
1676 * @return true if matched, false otherwise
1677 */
1678static bool
1679lim_enc_type_matched(tpAniSirGlobal mac_ctx,
1680 tpSchBeaconStruct bcn,
1681 tpPESession session)
1682{
1683 if (!bcn || !session)
1684 return false;
1685
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301686 pe_debug("Beacon/Probe:: Privacy: %d WPA Present: %d RSN Present: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 bcn->capabilityInfo.privacy, bcn->wpaPresent, bcn->rsnPresent);
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301688 pe_debug("session:: Privacy: %d EncyptionType: %d OSEN: %d WPS: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 SIR_MAC_GET_PRIVACY(session->limCurrentBssCaps),
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301690 session->encryptType, session->isOSENConnection,
1691 session->wps_registration);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
1693 /*
1694 * This is handled by sending probe req due to IOT issues so
1695 * return TRUE
1696 */
1697 if ((bcn->capabilityInfo.privacy) !=
1698 SIR_MAC_GET_PRIVACY(session->limCurrentBssCaps)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301699 pe_warn("Privacy bit miss match");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 return true;
1701 }
1702
1703 /* Open */
1704 if ((bcn->capabilityInfo.privacy == 0) &&
1705 (session->encryptType == eSIR_ED_NONE))
1706 return true;
1707
1708 /* WEP */
1709 if ((bcn->capabilityInfo.privacy == 1) &&
1710 (bcn->wpaPresent == 0) && (bcn->rsnPresent == 0) &&
1711 ((session->encryptType == eSIR_ED_WEP40) ||
1712 (session->encryptType == eSIR_ED_WEP104)
1713#ifdef FEATURE_WLAN_WAPI
1714 || (session->encryptType == eSIR_ED_WPI)
1715#endif
1716 ))
1717 return true;
1718
1719 /* WPA OR RSN*/
1720 if ((bcn->capabilityInfo.privacy == 1) &&
1721 ((bcn->wpaPresent == 1) || (bcn->rsnPresent == 1)) &&
1722 ((session->encryptType == eSIR_ED_TKIP) ||
1723 (session->encryptType == eSIR_ED_CCMP) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05301724 (session->encryptType == eSIR_ED_GCMP) ||
1725 (session->encryptType == eSIR_ED_GCMP_256) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726 (session->encryptType == eSIR_ED_AES_128_CMAC)))
1727 return true;
1728
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301729 /*
1730 * For HS2.0, RSN ie is not present
Abhishek Singh4560fa02016-08-29 12:45:38 +05301731 * in beacon. Therefore no need to
1732 * check for security type in case
1733 * OSEN session.
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301734 * For WPS registration session no need to detect
1735 * detect security mismatch as it wont match and
1736 * driver may end up sending probe request without
1737 * WPS IE during WPS registration process.
Abhishek Singh4560fa02016-08-29 12:45:38 +05301738 */
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301739 if (session->isOSENConnection ||
1740 session->wps_registration)
Abhishek Singh4560fa02016-08-29 12:45:38 +05301741 return true;
1742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 return false;
1744}
1745
1746/**
1747 * lim_detect_change_in_ap_capabilities()
1748 *
1749 ***FUNCTION:
1750 * This function is called while SCH is processing
1751 * received Beacon from AP on STA to detect any
1752 * change in AP's capabilities. If there any change
1753 * is detected, Roaming is informed of such change
1754 * so that it can trigger reassociation.
1755 *
1756 ***LOGIC:
1757 *
1758 ***ASSUMPTIONS:
1759 *
1760 ***NOTE:
1761 * Notification is enabled for STA product only since
1762 * it is not a requirement on BP side.
1763 *
1764 * @param pMac Pointer to Global MAC structure
1765 * @param pBeacon Pointer to parsed Beacon structure
1766 * @return None
1767 */
1768
1769void
1770lim_detect_change_in_ap_capabilities(tpAniSirGlobal pMac,
1771 tpSirProbeRespBeacon pBeacon,
1772 tpPESession psessionEntry)
1773{
1774 uint8_t len;
1775 tSirSmeApNewCaps apNewCaps;
1776 uint8_t newChannel;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001777 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 bool security_caps_matched = true;
1779
1780 apNewCaps.capabilityInfo =
1781 lim_get_u16((uint8_t *) &pBeacon->capabilityInfo);
1782 newChannel = (uint8_t) pBeacon->channelNumber;
1783
1784 security_caps_matched = lim_enc_type_matched(pMac, pBeacon,
1785 psessionEntry);
1786 if ((false == psessionEntry->limSentCapsChangeNtf) &&
1787 (((!lim_is_null_ssid(&pBeacon->ssId)) &&
Ankit Guptad66a8812016-09-15 11:00:16 -07001788 lim_cmp_ssid(&pBeacon->ssId, psessionEntry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
1790 SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1791 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1792 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1793 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1794 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1795 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
1796 SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
1797 ((newChannel != psessionEntry->currentOperChannel) &&
1798 (newChannel != 0)) ||
1799 (false == security_caps_matched)
1800 ))) {
1801 if (false == psessionEntry->fWaitForProbeRsp) {
1802 /* If Beacon capabilities is not matching with the current capability,
1803 * then send unicast probe request to AP and take decision after
1804 * receiving probe response */
1805 if (true == psessionEntry->fIgnoreCapsChange) {
Arif Hussain458ad462018-05-11 11:14:38 -07001806 pe_debug("Ignoring the Capability change as it is false alarm");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 return;
1808 }
1809 psessionEntry->fWaitForProbeRsp = true;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301810 pe_warn("AP capabilities are not matching, sending directed probe request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 status =
1812 lim_send_probe_req_mgmt_frame(pMac, &psessionEntry->ssId,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -07001813 psessionEntry->bssId,
1814 psessionEntry->currentOperChannel,
1815 psessionEntry->selfMacAddr,
1816 psessionEntry->dot11mode,
1817 NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001819 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301820 pe_err("send ProbeReq failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 psessionEntry->fWaitForProbeRsp = false;
1822 }
1823 return;
1824 }
1825 /**
1826 * BSS capabilities have changed.
1827 * Inform Roaming.
1828 */
1829 len = sizeof(tSirMacCapabilityInfo) + sizeof(tSirMacAddr) + sizeof(uint8_t) + 3 * sizeof(uint8_t) + /* reserved fields */
1830 pBeacon->ssId.length + 1;
1831
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301832 qdf_mem_copy(apNewCaps.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301833 psessionEntry->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 if (newChannel != psessionEntry->currentOperChannel) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301835 pe_err("Channel Change from %d --> %d Ignoring beacon!",
Nishank Aggarwal8d4c7202017-03-10 13:13:54 +05301836 psessionEntry->currentOperChannel, newChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 return;
1838 }
1839
1840 /**
1841 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1842 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1843 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1844 * the privacy bit is set in Probe and association responses.
1845 * Due to this anomaly, we detect a change in
1846 * AP capabilities when we receive a beacon after association and
1847 * disconnect from the AP. The following check makes sure that we can
1848 * connect to such APs
1849 */
1850 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1851 (pBeacon->rsnPresent || pBeacon->wpaPresent)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301852 pe_err("BSS Caps (Privacy) bit 0 in beacon, but WPA or RSN IE present, Ignore Beacon!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 return;
1854 } else
1855 apNewCaps.channelId = psessionEntry->currentOperChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301856 qdf_mem_copy((uint8_t *) &apNewCaps.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 (uint8_t *) &pBeacon->ssId,
1858 pBeacon->ssId.length + 1);
1859
1860 psessionEntry->fIgnoreCapsChange = false;
1861 psessionEntry->fWaitForProbeRsp = false;
1862 psessionEntry->limSentCapsChangeNtf = true;
1863 lim_send_sme_wm_status_change_ntf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1864 (uint32_t *) &apNewCaps,
1865 len, psessionEntry->smeSessionId);
1866 } else if (true == psessionEntry->fWaitForProbeRsp) {
1867 /* Only for probe response frames and matching capabilities the control
1868 * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
1869 * will be false, the control will not come here*/
1870
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301871 pe_debug("capabilities in probe response are"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 "matching with the current setting,"
1873 "Ignoring subsequent capability"
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301874 "mismatch");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875 psessionEntry->fIgnoreCapsChange = true;
1876 psessionEntry->fWaitForProbeRsp = false;
1877 }
1878
1879} /*** lim_detect_change_in_ap_capabilities() ***/
1880
1881/* --------------------------------------------------------------------- */
1882/**
1883 * lim_update_short_slot
1884 *
1885 * FUNCTION:
1886 * Enable/Disable short slot
1887 *
1888 * LOGIC:
1889 *
1890 * ASSUMPTIONS:
1891 *
1892 * NOTE:
1893 *
1894 * @param enable Flag to enable/disable short slot
1895 * @return None
1896 */
1897
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001898QDF_STATUS lim_update_short_slot(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 tpSirProbeRespBeacon pBeacon,
1900 tpUpdateBeaconParams pBeaconParams,
1901 tpPESession psessionEntry)
1902{
1903
1904 tSirSmeApNewCaps apNewCaps;
1905 uint32_t nShortSlot;
1906 uint32_t val = 0;
1907 uint32_t phyMode;
1908
1909 /* Check Admin mode first. If it is disabled just return */
1910 if (wlan_cfg_get_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001911 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301912 pe_err("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001913 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 }
1915 if (val == false)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001916 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917
1918 /* Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon */
1919 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
1920 if ((phyMode == WNI_CFG_PHY_MODE_11A)
1921 || (phyMode == WNI_CFG_PHY_MODE_11B))
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001922 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923
1924 apNewCaps.capabilityInfo =
1925 lim_get_u16((uint8_t *) &pBeacon->capabilityInfo);
1926
1927 /* Earlier implementation: determine the appropriate short slot mode based on AP advertised modes */
1928 /* when erp is present, apply short slot always unless, prot=on && shortSlot=off */
1929 /* if no erp present, use short slot based on current ap caps */
1930
1931 /* Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4); */
1932
1933 /* Resolution : always use the shortSlot setting the capability info to decide slot time. */
1934 /* The difference between the earlier implementation and the new one is only Case4. */
1935 /*
1936 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1937 Case1 1 1 1 1 //AP should not advertise this combination.
1938 Case2 1 1 0 0
1939 Case3 1 0 1 1
1940 Case4 1 0 0 0
1941 Case5 0 1 1 1
1942 Case6 0 1 0 0
1943 Case7 0 0 1 1
1944 Case8 0 0 0 0
1945 */
1946 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1947
1948 if (nShortSlot != psessionEntry->shortSlotTimeSupported) {
1949 /* Short slot time capability of AP has changed. Adopt to it. */
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301950 pe_debug("Shortslot capability of AP changed: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 nShortSlot);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 ((tpSirMacCapabilityInfo) & psessionEntry->
1953 limCurrentBssCaps)->shortSlotTime = (uint16_t) nShortSlot;
1954 psessionEntry->shortSlotTimeSupported = nShortSlot;
1955 pBeaconParams->fShortSlotTime = (uint8_t) nShortSlot;
1956 pBeaconParams->paramChangeBitmap |=
1957 PARAM_SHORT_SLOT_TIME_CHANGED;
1958 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001959 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960}
1961
1962
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001963void lim_send_heart_beat_timeout_ind(tpAniSirGlobal pMac,
1964 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965{
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001966 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001967 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968
1969 /* Prepare and post message to LIM Message Queue */
1970 msg.type = (uint16_t) SIR_LIM_HEART_BEAT_TIMEOUT;
1971 msg.bodyptr = psessionEntry;
1972 msg.bodyval = 0;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301973 pe_err("Heartbeat failure from Fw");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001975 status = lim_post_msg_api(pMac, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001977 if (status != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301978 pe_err("posting message: %X to LIM failed, reason: %d",
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001979 msg.type, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 }
1981}
1982
1983/**
1984 * lim_ps_offload_handle_missed_beacon_ind(): handles missed beacon indication
1985 * @pMac : global mac context
1986 * @pMsg: message
1987 *
1988 * This function process the SIR_HAL_MISSED_BEACON_IND
1989 * message from HAL, to do active AP probing.
1990 *
1991 * Return: void
1992 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001993void lim_ps_offload_handle_missed_beacon_ind(tpAniSirGlobal pMac,
1994 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995{
1996 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
1997 (tpSirSmeMissedBeaconInd) pMsg->bodyptr;
1998 tpPESession psessionEntry =
1999 pe_find_session_by_bss_idx(pMac, pSirMissedBeaconInd->bssIdx);
2000
2001 if (!psessionEntry) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302002 pe_err("session does not exist for given BSSId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 return;
2004 }
2005
2006 /* Set Beacon Miss in Powersave Offload */
2007 psessionEntry->pmmOffloadInfo.bcnmiss = true;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302008 pe_err("Received Heart Beat Failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009
2010 /* Do AP probing immediately */
2011 lim_send_heart_beat_timeout_ind(pMac, psessionEntry);
2012 return;
2013}
2014
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002015#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2016/**
2017 * lim_fill_join_rsp_ht_caps() - Fill the HT caps in join response
2018 * @session: PE Session
2019 * @join_rsp: Join response buffer to be filled up.
2020 *
2021 * Return: None
2022 */
2023void lim_fill_join_rsp_ht_caps(tpPESession session, tpSirSmeJoinRsp join_rsp)
2024{
2025 tSirSmeHTProfile *ht_profile;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002026
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002027 if (session == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302028 pe_err("Invalid Session");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002029 return;
2030 }
2031 if (join_rsp == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302032 pe_err("Invalid Join Response");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002033 return;
2034 }
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302035
2036 if (session->cc_switch_mode == QDF_MCC_TO_SCC_SWITCH_DISABLE)
2037 return;
2038
2039 ht_profile = &join_rsp->HTProfile;
2040 ht_profile->htSupportedChannelWidthSet =
2041 session->htSupportedChannelWidthSet;
2042 ht_profile->htRecommendedTxWidthSet =
2043 session->htRecommendedTxWidthSet;
2044 ht_profile->htSecondaryChannelOffset =
2045 session->htSecondaryChannelOffset;
2046 ht_profile->dot11mode = session->dot11mode;
2047 ht_profile->htCapability = session->htCapability;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002048 ht_profile->vhtCapability = session->vhtCapability;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002049 ht_profile->apCenterChan = session->ch_center_freq_seg0;
2050 ht_profile->apChanWidth = session->ch_width;
2051}
2052#endif
2053
Krunal Soni4bfecf62017-06-05 15:26:35 -07002054#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Selvaraj, Sridhar6f97f412017-05-26 19:32:05 +05302055/**
2056 * sir_parse_bcn_fixed_fields() - Parse fixed fields in Beacon IE's
2057 *
2058 * @mac_ctx: MAC Context
2059 * @beacon_struct: Beacon/Probe Response structure
2060 * @buf: Fixed Fields buffer
2061 */
2062static void sir_parse_bcn_fixed_fields(tpAniSirGlobal mac_ctx,
2063 tpSirProbeRespBeacon beacon_struct,
2064 uint8_t *buf)
2065{
2066 tDot11fFfCapabilities dst;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002067
Selvaraj, Sridhar6f97f412017-05-26 19:32:05 +05302068 beacon_struct->timeStamp[0] = lim_get_u32(buf);
2069 beacon_struct->timeStamp[1] = lim_get_u32(buf + 4);
2070 buf += 8;
2071
2072 beacon_struct->beaconInterval = lim_get_u16(buf);
2073 buf += 2;
2074
2075 dot11f_unpack_ff_capabilities(mac_ctx, buf, &dst);
2076
2077 sir_copy_caps_info(mac_ctx, dst, beacon_struct);
2078}
2079
Jeff Johnson82b0c622016-10-07 07:53:55 -07002080static QDF_STATUS
2081lim_roam_fill_bss_descr(tpAniSirGlobal pMac,
2082 roam_offload_synch_ind *roam_offload_synch_ind_ptr,
2083 tpSirBssDescription bss_desc_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084{
2085 uint32_t ie_len = 0;
2086 tpSirProbeRespBeacon parsed_frm_ptr;
2087 tpSirMacMgmtHdr mac_hdr;
2088 uint8_t *bcn_proberesp_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089
2090 bcn_proberesp_ptr = (uint8_t *)roam_offload_synch_ind_ptr +
2091 roam_offload_synch_ind_ptr->beaconProbeRespOffset;
2092 mac_hdr = (tpSirMacMgmtHdr)bcn_proberesp_ptr;
2093 parsed_frm_ptr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302094 (tpSirProbeRespBeacon) qdf_mem_malloc(sizeof(tSirProbeRespBeacon));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 if (NULL == parsed_frm_ptr) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302096 pe_err("fail to allocate memory for frame");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 }
2099
2100 if (roam_offload_synch_ind_ptr->beaconProbeRespLength <=
2101 SIR_MAC_HDR_LEN_3A) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302102 pe_err("%s: very few bytes in synchInd beacon / probe resp frame! length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 __func__, roam_offload_synch_ind_ptr->beaconProbeRespLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302104 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302105 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 }
2107
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302108 pe_debug("LFR3:Beacon/Prb Rsp: %d", roam_offload_synch_ind_ptr->isBeacon);
Nishank Aggarwal8d4c7202017-03-10 13:13:54 +05302109 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 bcn_proberesp_ptr, roam_offload_synch_ind_ptr->beaconProbeRespLength);
2111 if (roam_offload_synch_ind_ptr->isBeacon) {
2112 if (sir_parse_beacon_ie(pMac, parsed_frm_ptr,
2113 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A +
2114 SIR_MAC_B_PR_SSID_OFFSET],
2115 roam_offload_synch_ind_ptr->beaconProbeRespLength -
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002116 SIR_MAC_HDR_LEN_3A) != QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 !parsed_frm_ptr->ssidPresent) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302118 pe_err("Parse error Beacon, length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 roam_offload_synch_ind_ptr->beaconProbeRespLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302120 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302121 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 }
2123 } else {
2124 if (sir_convert_probe_frame2_struct(pMac,
2125 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A],
2126 roam_offload_synch_ind_ptr->beaconProbeRespLength -
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002127 SIR_MAC_HDR_LEN_3A, parsed_frm_ptr) != QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 !parsed_frm_ptr->ssidPresent) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302129 pe_err("Parse error ProbeResponse, length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 roam_offload_synch_ind_ptr->beaconProbeRespLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302131 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302132 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 }
2134 }
Selvaraj, Sridhar6f97f412017-05-26 19:32:05 +05302135
2136 /*
2137 * For probe response, unpack core parses beacon interval, capabilities,
2138 * timestamp. For beacon IEs, these fields are not parsed.
2139 */
2140 if (roam_offload_synch_ind_ptr->isBeacon)
2141 sir_parse_bcn_fixed_fields(pMac, parsed_frm_ptr,
2142 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A]);
2143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 /* 24 byte MAC header and 12 byte to ssid IE */
2145 if (roam_offload_synch_ind_ptr->beaconProbeRespLength >
2146 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET)) {
2147 ie_len = roam_offload_synch_ind_ptr->beaconProbeRespLength -
2148 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET);
2149 }
2150 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 * Length of BSS desription is without length of
2152 * length itself and length of pointer
2153 * that holds ieFields
2154 *
2155 * tSirBssDescription
2156 * +--------+---------------------------------+---------------+
2157 * | length | other fields | pointer to IEs|
2158 * +--------+---------------------------------+---------------+
2159 * ^
2160 * ieFields
2161 */
2162 bss_desc_ptr->length = (uint16_t) (offsetof(tSirBssDescription,
2163 ieFields[0]) -
2164 sizeof(bss_desc_ptr->length) + ie_len);
2165
Abhishek Singhc4a864b2017-04-17 17:09:52 +05302166 bss_desc_ptr->fProbeRsp = !roam_offload_synch_ind_ptr->isBeacon;
2167 /* Copy Timestamp */
2168 bss_desc_ptr->scansystimensec = qdf_get_monotonic_boottime_ns();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 if (parsed_frm_ptr->dsParamsPresent) {
2170 bss_desc_ptr->channelId = parsed_frm_ptr->channelNumber;
2171 } else if (parsed_frm_ptr->HTInfo.present) {
2172 bss_desc_ptr->channelId = parsed_frm_ptr->HTInfo.primaryChannel;
2173 } else {
2174 /*
2175 * If DS Params or HTIE is not present in the probe resp or
2176 * beacon, then use the channel frequency provided by firmware
2177 * to fill the channel in the BSS descriptor.*/
2178 bss_desc_ptr->channelId =
2179 cds_freq_to_chan(roam_offload_synch_ind_ptr->chan_freq);
2180 }
2181 bss_desc_ptr->channelIdSelf = bss_desc_ptr->channelId;
2182
Abhishek Singh86dc2212017-11-08 13:57:46 +05302183 bss_desc_ptr->nwType = lim_get_nw_type(pMac, bss_desc_ptr->channelId,
2184 SIR_MAC_MGMT_FRAME,
2185 parsed_frm_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186
2187 bss_desc_ptr->sinr = 0;
2188 bss_desc_ptr->beaconInterval = parsed_frm_ptr->beaconInterval;
2189 bss_desc_ptr->timeStamp[0] = parsed_frm_ptr->timeStamp[0];
2190 bss_desc_ptr->timeStamp[1] = parsed_frm_ptr->timeStamp[1];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302191 qdf_mem_copy(&bss_desc_ptr->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_CAPAB_OFFSET], 2);
Abhishek Singhe9a17012017-07-13 16:38:44 +05302193
2194 if (qdf_is_macaddr_zero((struct qdf_mac_addr *)mac_hdr->bssId)) {
2195 pe_debug("bssid is 0 in beacon/probe update it with bssId %pM in sync ind",
2196 roam_offload_synch_ind_ptr->bssid.bytes);
2197 qdf_mem_copy(mac_hdr->bssId,
2198 roam_offload_synch_ind_ptr->bssid.bytes,
2199 sizeof(tSirMacAddr));
2200 }
2201
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302202 qdf_mem_copy((uint8_t *) &bss_desc_ptr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 (uint8_t *) mac_hdr->bssId,
2204 sizeof(tSirMacAddr));
Deepthi Gowri6acee342016-10-28 15:00:38 +05302205 bss_desc_ptr->received_time =
2206 (uint64_t)qdf_mc_timer_get_system_time();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 if (parsed_frm_ptr->mdiePresent) {
2208 bss_desc_ptr->mdiePresent = parsed_frm_ptr->mdiePresent;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302209 qdf_mem_copy((uint8_t *)bss_desc_ptr->mdie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 (uint8_t *)parsed_frm_ptr->mdie,
2211 SIR_MDIE_SIZE);
2212 }
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07002213 pe_debug("LFR3: BssDescr Info:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302214 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 bss_desc_ptr->bssId, sizeof(tSirMacAddr));
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302216 pe_debug("chan: %d rssi: %d", bss_desc_ptr->channelId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 bss_desc_ptr->rssi);
2218 if (ie_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302219 qdf_mem_copy(&bss_desc_ptr->ieFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 bcn_proberesp_ptr +
2221 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET),
2222 ie_len);
2223 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302224 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302225 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226}
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302227
2228#if defined(WLAN_FEATURE_FILS_SK)
2229/**
2230 * lim_copy_and_free_hlp_data_from_session - Copy HLP info
2231 * @session_ptr: PE session
2232 * @roam_sync_ind_ptr: Roam Synch Indication pointer
2233 *
2234 * This API is used to copy the parsed HLP info from PE session
2235 * to roam synch indication data. THe HLP info is expected to be
2236 * parsed/stored in PE session already from assoc IE's received
2237 * from fw as part of Roam Synch Indication.
2238 *
2239 * Return: None
2240 */
2241static void lim_copy_and_free_hlp_data_from_session(tpPESession session_ptr,
2242 roam_offload_synch_ind *roam_sync_ind_ptr)
2243{
2244 if (session_ptr->hlp_data && session_ptr->hlp_data_len) {
2245 cds_copy_hlp_info(&session_ptr->dst_mac,
2246 &session_ptr->src_mac,
2247 session_ptr->hlp_data_len,
2248 session_ptr->hlp_data,
2249 &roam_sync_ind_ptr->dst_mac,
2250 &roam_sync_ind_ptr->src_mac,
2251 &roam_sync_ind_ptr->hlp_data_len,
2252 roam_sync_ind_ptr->hlp_data);
2253 qdf_mem_free(session_ptr->hlp_data);
2254 session_ptr->hlp_data = NULL;
2255 session_ptr->hlp_data_len = 0;
2256 }
2257}
2258#else
2259static inline void lim_copy_and_free_hlp_data_from_session(
2260 tpPESession session_ptr,
2261 roam_offload_synch_ind
2262 *roam_sync_ind_ptr)
2263{}
2264#endif
2265
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002266/**
2267 * pe_roam_synch_callback() - PE level callback for roam synch propagation
2268 * @mac_ctx: MAC Context
2269 * @roam_sync_ind_ptr: Roam synch indication buffer pointer
2270 * @bss_desc: BSS Descriptor pointer
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002271 * @reason: Reason for calling callback which decides the action to be taken.
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002272 *
2273 * This is a PE level callback called from WMA to complete the roam synch
2274 * propagation at PE level and also fill the BSS descriptor which will be
2275 * helpful further to complete the roam synch propagation.
2276 *
2277 * Return: Success or Failure status
2278 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302279QDF_STATUS pe_roam_synch_callback(tpAniSirGlobal mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002280 roam_offload_synch_ind *roam_sync_ind_ptr,
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002281 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282{
2283 tpPESession session_ptr;
2284 tpPESession ft_session_ptr;
2285 uint8_t session_id;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002286 tpDphHashNode curr_sta_ds;
2287 uint16_t aid;
2288 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302289 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002290 uint16_t join_rsp_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291
2292 if (!roam_sync_ind_ptr) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302293 pe_err("LFR3:roam_sync_ind_ptr is NULL");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002294 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002296 session_ptr = pe_find_session_by_sme_session_id(mac_ctx,
2297 roam_sync_ind_ptr->roamedVdevId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 if (session_ptr == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302299 pe_err("LFR3:Unable to find session");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002300 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 }
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002302
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 if (!LIM_IS_STA_ROLE(session_ptr)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302304 pe_err("LFR3:session is not in STA mode");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002305 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 }
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002307
2308 pe_debug("LFR3: PE callback reason: %d", reason);
2309 switch (reason) {
2310 case SIR_ROAMING_START:
2311 session_ptr->fw_roaming_started = true;
2312 return QDF_STATUS_SUCCESS;
2313 case SIR_ROAMING_ABORT:
2314 session_ptr->fw_roaming_started = false;
2315 /*
2316 * If there was a disassoc or deauth that was received
2317 * during roaming and it was not honored, then we have
2318 * to internally initiate a disconnect because with
2319 * ROAM_ABORT we come back to original AP.
2320 */
2321 if (session_ptr->recvd_deauth_while_roaming)
2322 lim_perform_deauth(mac_ctx, session_ptr,
2323 session_ptr->deauth_disassoc_rc,
2324 session_ptr->bssId, 0);
2325 if (session_ptr->recvd_disassoc_while_roaming) {
2326 lim_disassoc_tdls_peers(mac_ctx, session_ptr,
2327 session_ptr->bssId);
2328 lim_perform_disassoc(mac_ctx, 0,
2329 session_ptr->deauth_disassoc_rc,
2330 session_ptr, session_ptr->bssId);
2331 }
2332 return QDF_STATUS_SUCCESS;
2333 case SIR_ROAM_SYNCH_PROPAGATION:
2334 session_ptr->fw_roaming_started = false;
2335 break;
2336 default:
2337 return status;
2338 }
2339
2340 pe_debug("LFR3:Received WMA_ROAM_OFFLOAD_SYNCH_IND LFR3:auth: %d vdevId: %d",
2341 roam_sync_ind_ptr->authStatus, roam_sync_ind_ptr->roamedVdevId);
2342 lim_print_mac_addr(mac_ctx, roam_sync_ind_ptr->bssid.bytes,
2343 QDF_TRACE_LEVEL_DEBUG);
Selvaraj, Sridhara6e3eba2017-03-14 19:52:39 +05302344 /*
2345 * If deauth from AP already in progress, ignore Roam Synch Indication
2346 * from firmware.
2347 */
2348 if (session_ptr->limSmeState != eLIM_SME_LINK_EST_STATE) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302349 pe_err("LFR3: Not in Link est state");
Selvaraj, Sridhara6e3eba2017-03-14 19:52:39 +05302350 return status;
2351 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002352 status = lim_roam_fill_bss_descr(mac_ctx, roam_sync_ind_ptr, bss_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302353 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302354 pe_err("LFR3:Failed to fill Bss Descr");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002355 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302357 status = QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002358 ft_session_ptr = pe_create_session(mac_ctx, bss_desc->bssId,
2359 &session_id, mac_ctx->lim.maxStation,
2360 eSIR_INFRASTRUCTURE_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 if (ft_session_ptr == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302362 pe_err("LFR3:Cannot create PE Session");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002363 lim_print_mac_addr(mac_ctx, bss_desc->bssId, LOGE);
2364 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05302366 /* Update the beacon/probe filter in mac_ctx */
2367 lim_set_bcn_probe_filter(mac_ctx, ft_session_ptr, NULL, 0);
2368
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 sir_copy_mac_addr(ft_session_ptr->selfMacAddr, session_ptr->selfMacAddr);
Varun Reddy Yeturu28925b42016-02-08 07:18:50 -08002370 sir_copy_mac_addr(roam_sync_ind_ptr->self_mac.bytes,
2371 session_ptr->selfMacAddr);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002372 sir_copy_mac_addr(ft_session_ptr->limReAssocbssId, bss_desc->bssId);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002373 session_ptr->bRoamSynchInProgress = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 ft_session_ptr->bRoamSynchInProgress = true;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002375 ft_session_ptr->limSystemRole = eLIM_STA_ROLE;
2376 sir_copy_mac_addr(session_ptr->limReAssocbssId, bss_desc->bssId);
2377 ft_session_ptr->csaOffloadEnable = session_ptr->csaOffloadEnable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378
Deepak Dhamdherea7987a22017-07-26 23:06:38 -07002379 /* Assign default configured nss value in the new session */
Naveen Rawat746a90b2017-06-07 15:16:35 -07002380 if (IS_5G_CH(ft_session_ptr->currentOperChannel))
2381 ft_session_ptr->vdev_nss = mac_ctx->vdev_type_nss_5g.sta;
2382 else
2383 ft_session_ptr->vdev_nss = mac_ctx->vdev_type_nss_2g.sta;
2384
2385 ft_session_ptr->nss = ft_session_ptr->vdev_nss;
2386
Deepak Dhamdherea7987a22017-07-26 23:06:38 -07002387 /* Next routine will update nss and vdev_nss with AP's capabilities */
2388 lim_fill_ft_session(mac_ctx, bss_desc, ft_session_ptr, session_ptr);
2389
2390 /* Next routine may update nss based on dot11Mode */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002391 lim_ft_prepare_add_bss_req(mac_ctx, false, ft_session_ptr, bss_desc);
2392 roam_sync_ind_ptr->add_bss_params =
2393 (tpAddBssParams) ft_session_ptr->ftPEContext.pAddBssReq;
2394 add_bss_params = ft_session_ptr->ftPEContext.pAddBssReq;
2395 lim_delete_tdls_peers(mac_ctx, session_ptr);
2396 curr_sta_ds = dph_lookup_hash_entry(mac_ctx, session_ptr->bssId,
2397 &aid, &session_ptr->dph.dphHashTable);
Varun Reddy Yeturu3b21c7e2016-09-13 15:04:54 -07002398 if (curr_sta_ds == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302399 pe_err("LFR3:failed to lookup hash entry");
Varun Reddy Yeturu3b21c7e2016-09-13 15:04:54 -07002400 ft_session_ptr->bRoamSynchInProgress = false;
2401 return status;
2402 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002403 session_ptr->limSmeState = eLIM_SME_IDLE_STATE;
2404 lim_cleanup_rx_path(mac_ctx, curr_sta_ds, session_ptr);
2405 lim_delete_dph_hash_entry(mac_ctx, curr_sta_ds->staAddr,
2406 aid, session_ptr);
2407 pe_delete_session(mac_ctx, session_ptr);
2408 session_ptr = NULL;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002409 curr_sta_ds = dph_add_hash_entry(mac_ctx,
2410 roam_sync_ind_ptr->bssid.bytes, DPH_STA_HASH_INDEX_PEER,
2411 &ft_session_ptr->dph.dphHashTable);
2412 if (curr_sta_ds == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302413 pe_err("LFR3:failed to add hash entry for");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002414 lim_print_mac_addr(mac_ctx,
2415 add_bss_params->staContext.staMac, LOGE);
2416 ft_session_ptr->bRoamSynchInProgress = false;
2417 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 }
Paul Zhangfda3a592017-08-17 17:13:35 +08002419
2420 add_bss_params->bssIdx = roam_sync_ind_ptr->roamedVdevId;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002421 ft_session_ptr->bssIdx = (uint8_t) add_bss_params->bssIdx;
2422
2423 curr_sta_ds->bssId = add_bss_params->bssIdx;
2424 curr_sta_ds->staIndex =
2425 add_bss_params->staContext.staIdx;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002426 rrm_cache_mgmt_tx_power(mac_ctx,
2427 add_bss_params->txMgmtPower, ft_session_ptr);
2428 mac_ctx->roam.reassocRespLen = roam_sync_ind_ptr->reassocRespLength;
2429 mac_ctx->roam.pReassocResp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302430 qdf_mem_malloc(mac_ctx->roam.reassocRespLen);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002431 if (NULL == mac_ctx->roam.pReassocResp) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302432 pe_err("LFR3:assoc resp mem alloc failed");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002433 ft_session_ptr->bRoamSynchInProgress = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302434 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002435 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302436 qdf_mem_copy(mac_ctx->roam.pReassocResp,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002437 (uint8_t *)roam_sync_ind_ptr +
2438 roam_sync_ind_ptr->reassocRespOffset,
2439 mac_ctx->roam.reassocRespLen);
2440
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302441 pe_debug("LFR3:the reassoc resp frame data:");
Nishank Aggarwal8d4c7202017-03-10 13:13:54 +05302442 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002443 mac_ctx->roam.pReassocResp,
2444 mac_ctx->roam.reassocRespLen);
2445 ft_session_ptr->bRoamSynchInProgress = true;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302446
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002447 lim_process_assoc_rsp_frame(mac_ctx, mac_ctx->roam.pReassocResp,
2448 LIM_REASSOC, ft_session_ptr);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302449
2450 lim_copy_and_free_hlp_data_from_session(ft_session_ptr,
2451 roam_sync_ind_ptr);
2452
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002453 roam_sync_ind_ptr->aid = ft_session_ptr->limAID;
2454 curr_sta_ds->mlmStaContext.mlmState =
2455 eLIM_MLM_LINK_ESTABLISHED_STATE;
Naveen Rawat746a90b2017-06-07 15:16:35 -07002456 curr_sta_ds->nss = ft_session_ptr->nss;
2457 roam_sync_ind_ptr->nss = ft_session_ptr->nss;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002458 ft_session_ptr->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
2459 lim_init_tdls_data(mac_ctx, ft_session_ptr);
Yu Wang0477ee32017-02-10 20:02:03 +08002460 join_rsp_len = ft_session_ptr->RICDataLen +
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +05302461 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Yu Wang0477ee32017-02-10 20:02:03 +08002462
2463#ifdef FEATURE_WLAN_ESE
2464 join_rsp_len += ft_session_ptr->tspecLen;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302465 pe_debug("tspecLen: %d", ft_session_ptr->tspecLen);
Yu Wang0477ee32017-02-10 20:02:03 +08002466#endif
2467
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002468 roam_sync_ind_ptr->join_rsp = qdf_mem_malloc(join_rsp_len);
2469 if (NULL == roam_sync_ind_ptr->join_rsp) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302470 pe_err("LFR3:mem alloc failed");
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002471 ft_session_ptr->bRoamSynchInProgress = false;
2472 if (mac_ctx->roam.pReassocResp)
2473 qdf_mem_free(mac_ctx->roam.pReassocResp);
2474 mac_ctx->roam.pReassocResp = NULL;
2475 return QDF_STATUS_E_NOMEM;
2476 }
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002477
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302478 pe_debug("Session RicLength: %d", ft_session_ptr->RICDataLen);
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002479 if (ft_session_ptr->ricData != NULL) {
2480 roam_sync_ind_ptr->join_rsp->parsedRicRspLen =
2481 ft_session_ptr->RICDataLen;
2482 qdf_mem_copy(roam_sync_ind_ptr->join_rsp->frames,
2483 ft_session_ptr->ricData,
2484 roam_sync_ind_ptr->join_rsp->parsedRicRspLen);
2485 qdf_mem_free(ft_session_ptr->ricData);
2486 ft_session_ptr->ricData = NULL;
2487 ft_session_ptr->RICDataLen = 0;
2488 }
Yu Wang0477ee32017-02-10 20:02:03 +08002489
2490#ifdef FEATURE_WLAN_ESE
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +05302491 if (ft_session_ptr->tspecIes != NULL) {
2492 roam_sync_ind_ptr->join_rsp->tspecIeLen =
2493 ft_session_ptr->tspecLen;
2494 qdf_mem_copy(roam_sync_ind_ptr->join_rsp->frames +
2495 roam_sync_ind_ptr->join_rsp->parsedRicRspLen,
2496 ft_session_ptr->tspecIes,
2497 roam_sync_ind_ptr->join_rsp->tspecIeLen);
2498 qdf_mem_free(ft_session_ptr->tspecIes);
2499 ft_session_ptr->tspecIes = NULL;
2500 ft_session_ptr->tspecLen = 0;
2501 }
Yu Wang0477ee32017-02-10 20:02:03 +08002502#endif
2503
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002504 roam_sync_ind_ptr->join_rsp->vht_channel_width =
2505 ft_session_ptr->ch_width;
2506 roam_sync_ind_ptr->join_rsp->staId = curr_sta_ds->staIndex;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002507 roam_sync_ind_ptr->join_rsp->timingMeasCap = curr_sta_ds->timingMeasCap;
2508 roam_sync_ind_ptr->join_rsp->nss = curr_sta_ds->nss;
2509 roam_sync_ind_ptr->join_rsp->max_rate_flags =
2510 lim_get_max_rate_flags(mac_ctx, curr_sta_ds);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07002511 lim_set_tdls_flags(roam_sync_ind_ptr, ft_session_ptr);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002512 roam_sync_ind_ptr->join_rsp->aid = ft_session_ptr->limAID;
2513 lim_fill_join_rsp_ht_caps(ft_session_ptr, roam_sync_ind_ptr->join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 ft_session_ptr->limPrevSmeState = ft_session_ptr->limSmeState;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002515 ft_session_ptr->limSmeState = eLIM_SME_LINK_EST_STATE;
2516 ft_session_ptr->bRoamSynchInProgress = false;
2517 if (mac_ctx->roam.pReassocResp)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302518 qdf_mem_free(mac_ctx->roam.pReassocResp);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002519 mac_ctx->roam.pReassocResp = NULL;
Naveen Rawat945894a2016-12-17 14:58:07 -08002520
2521 if (roam_sync_ind_ptr->authStatus == CSR_ROAM_AUTH_STATUS_AUTHENTICATED)
2522 ft_session_ptr->is_key_installed = true;
2523
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302524 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525}
2526#endif
2527
Jeff Johnson82b0c622016-10-07 07:53:55 -07002528static bool lim_is_beacon_miss_scenario(tpAniSirGlobal pMac,
2529 uint8_t *pRxPacketInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530{
2531 tpSirMacMgmtHdr pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
2532 uint8_t sessionId;
2533 tpPESession psessionEntry =
2534 pe_find_session_by_bssid(pMac, pHdr->bssId, &sessionId);
2535
2536 if (psessionEntry && psessionEntry->pmmOffloadInfo.bcnmiss)
2537 return true;
2538 return false;
2539}
2540
2541/** -----------------------------------------------------------------
2542 \brief lim_is_pkt_candidate_for_drop() - decides whether to drop the frame or not
2543
2544 This function is called before enqueuing the frame to PE queue for further processing.
2545 This prevents unnecessary frames getting into PE Queue and drops them right away.
2546 Frames will be droped in the following scenarios:
2547
2548 - In Scan State, drop the frames which are not marked as scan frames
2549 - In non-Scan state, drop the frames which are marked as scan frames.
2550 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2551 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2552
2553 \param pMac - global mac structure
2554 \return - none
2555 \sa
2556 ----------------------------------------------------------------- */
2557
2558tMgmtFrmDropReason lim_is_pkt_candidate_for_drop(tpAniSirGlobal pMac,
2559 uint8_t *pRxPacketInfo,
2560 uint32_t subType)
2561{
2562 uint32_t framelen;
2563 uint8_t *pBody;
2564 tSirMacCapabilityInfo capabilityInfo;
2565 tpSirMacMgmtHdr pHdr = NULL;
2566 tpPESession psessionEntry = NULL;
2567 uint8_t sessionId;
2568
2569 /*
2570 *
2571 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2572 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2573 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2574 * other than beacons or probe responses in scan state.
2575 */
2576 if ((subType == SIR_MAC_MGMT_BEACON) ||
2577 (subType == SIR_MAC_MGMT_PROBE_RSP)) {
2578 if (lim_is_beacon_miss_scenario(pMac, pRxPacketInfo)) {
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002579 MTRACE(mac_trace(pMac, TRACE_CODE_INFO_LOG, 0,
2580 eLOG_NODROP_MISSED_BEACON_SCENARIO));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 return eMGMT_DROP_NO_DROP;
2582 }
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002583 if (lim_is_system_in_scan_state(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 return eMGMT_DROP_NO_DROP;
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002585 else if (WMA_IS_RX_IN_SCAN(pRxPacketInfo))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586 return eMGMT_DROP_SCAN_MODE_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002588 framelen = WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2589 pBody = WMA_GET_RX_MPDU_DATA(pRxPacketInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 /* drop the frame if length is less than 12 */
2591 if (framelen < LIM_MIN_BCN_PR_LENGTH)
2592 return eMGMT_DROP_INVALID_SIZE;
2593
2594 *((uint16_t *) &capabilityInfo) =
2595 sir_read_u16(pBody + LIM_BCN_PR_CAPABILITY_OFFSET);
2596
2597 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2598 * beacons from an infrastructure network
2599 */
2600 if (!capabilityInfo.ibss)
2601 return eMGMT_DROP_NO_DROP;
2602
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002603 /* Drop INFRA Beacons and Probe Responses in IBSS Mode */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 /* This can be enhanced to even check the SSID before deciding to enque the frame. */
2605 if (capabilityInfo.ess)
2606 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 } else if ((subType == SIR_MAC_MGMT_PROBE_REQ) &&
2609 (!WMA_GET_RX_BEACON_SENT(pRxPacketInfo))) {
2610 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002611 psessionEntry = pe_find_session_by_bssid(pMac,
2612 pHdr->bssId,
2613 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 if ((psessionEntry && !LIM_IS_IBSS_ROLE(psessionEntry)) ||
2615 (!psessionEntry))
2616 return eMGMT_DROP_NO_DROP;
2617
2618 /* Drop the Probe Request in IBSS mode, if STA did not send out the last beacon */
2619 /* In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq */
2620 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
Krunal Soni05c914f2018-08-06 12:23:58 -07002621 } else if (subType == SIR_MAC_MGMT_AUTH) {
2622 uint16_t curr_seq_num = 0;
2623 struct tLimPreAuthNode *auth_node;
2624
2625 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
2626 psessionEntry = pe_find_session_by_bssid(pMac, pHdr->bssId,
2627 &sessionId);
2628 if (!psessionEntry)
2629 return eMGMT_DROP_NO_DROP;
2630
2631 curr_seq_num = ((pHdr->seqControl.seqNumHi << 4) |
2632 (pHdr->seqControl.seqNumLo));
2633 auth_node = lim_search_pre_auth_list(pMac, pHdr->sa);
2634 if (auth_node && pHdr->fc.retry &&
2635 (auth_node->seq_num == curr_seq_num)) {
2636 pe_err_rl("auth frame, seq num: %d is already processed, drop it",
2637 curr_seq_num);
2638 return eMGMT_DROP_DUPLICATE_AUTH_FRAME;
2639 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 }
2641
2642 return eMGMT_DROP_NO_DROP;
2643}
2644
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302645void lim_update_lost_link_info(tpAniSirGlobal mac, tpPESession session,
2646 int32_t rssi)
2647{
2648 struct sir_lost_link_info *lost_link_info;
Rajeev Kumarcf7bd802017-04-18 11:11:42 -07002649 struct scheduler_msg mmh_msg = {0};
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302650
2651 if ((NULL == mac) || (NULL == session)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302652 pe_err("parameter NULL");
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302653 return;
2654 }
2655 if (!LIM_IS_STA_ROLE(session)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302656 pe_err("not STA mode, do nothing");
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302657 return;
2658 }
2659
2660 lost_link_info = qdf_mem_malloc(sizeof(*lost_link_info));
2661 if (NULL == lost_link_info) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302662 pe_err("lost_link_info allocation failure");
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302663 return;
2664 }
2665
2666 lost_link_info->vdev_id = session->smeSessionId;
2667 lost_link_info->rssi = rssi;
2668 mmh_msg.type = eWNI_SME_LOST_LINK_INFO_IND;
2669 mmh_msg.bodyptr = lost_link_info;
2670 mmh_msg.bodyval = 0;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302671 pe_debug("post eWNI_SME_LOST_LINK_INFO_IND, bss_idx: %d rssi: %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302672 lost_link_info->vdev_id, lost_link_info->rssi);
2673
2674 lim_sys_process_mmh_msg_api(mac, &mmh_msg, ePROT);
2675}
2676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302677QDF_STATUS pe_acquire_global_lock(tAniSirLim *psPe)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302679 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680
2681 if (psPe) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302682 if (QDF_IS_STATUS_SUCCESS
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302683 (qdf_mutex_acquire(&psPe->lkPeGlobalLock))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302684 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 }
2686 }
2687 return status;
2688}
2689
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302690QDF_STATUS pe_release_global_lock(tAniSirLim *psPe)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302692 QDF_STATUS status = QDF_STATUS_E_INVAL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 if (psPe) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302695 if (QDF_IS_STATUS_SUCCESS
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302696 (qdf_mutex_release(&psPe->lkPeGlobalLock))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302697 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 }
2699 }
2700 return status;
2701}
2702
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -07002703/**
2704 * lim_mon_init_session() - create PE session for monitor mode operation
2705 * @mac_ptr: mac pointer
2706 * @msg: Pointer to struct sir_create_session type.
2707 *
2708 * Return: NONE
2709 */
2710void lim_mon_init_session(tpAniSirGlobal mac_ptr,
2711 struct sir_create_session *msg)
2712{
2713 tpPESession psession_entry;
2714 uint8_t session_id;
2715
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -07002716 psession_entry = pe_create_session(mac_ptr, msg->bss_id.bytes,
2717 &session_id,
2718 mac_ptr->lim.maxStation,
2719 eSIR_MONITOR_MODE);
2720 if (psession_entry == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302721 pe_err("Monitor mode: Session Can not be created");
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -07002722 lim_print_mac_addr(mac_ptr, msg->bss_id.bytes, LOGE);
2723 return;
2724 }
2725 psession_entry->vhtCapability = 1;
2726}
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302727
2728/**
2729 * lim_update_ext_cap_ie() - Update Extended capabilities IE(if present)
2730 * with capabilities of Fine Time measurements(FTM) if set in driver
2731 *
2732 * @mac_ctx: Pointer to Global MAC structure
2733 * @ie_data: Default Scan IE data
2734 * @local_ie_buf: Local Scan IE data
2735 * @local_ie_len: Pointer to length of @ie_data
2736 *
2737 * Return: QDF_STATUS
2738 */
2739QDF_STATUS lim_update_ext_cap_ie(tpAniSirGlobal mac_ctx,
2740 uint8_t *ie_data, uint8_t *local_ie_buf, uint16_t *local_ie_len)
2741{
2742 uint32_t dot11mode;
2743 bool vht_enabled = false;
2744 tDot11fIEExtCap default_scan_ext_cap = {0}, driver_ext_cap = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002745 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302746
2747 status = lim_strip_extcap_update_struct(mac_ctx, ie_data,
2748 local_ie_len, &default_scan_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002749 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302750 pe_err("Strip ext cap fails %d", status);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302751 return QDF_STATUS_E_FAILURE;
2752 }
2753
Pragaspathi Thilagaraj6cf025f2018-06-25 18:37:05 +05302754 if ((*local_ie_len) > (MAX_DEFAULT_SCAN_IE_LEN - EXT_CAP_IE_HDR_LEN)) {
2755 pe_err("Invalid Scan IE length");
2756 return QDF_STATUS_E_FAILURE;
2757 }
Naveen Rawatb677c242017-03-29 16:34:50 -07002758 /* copy ie prior to ext cap to local buffer */
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302759 qdf_mem_copy(local_ie_buf, ie_data, (*local_ie_len));
Naveen Rawatb677c242017-03-29 16:34:50 -07002760
2761 /* from here ext cap ie starts, set EID */
2762 local_ie_buf[*local_ie_len] = DOT11F_EID_EXTCAP;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302763
2764 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &dot11mode);
2765 if (IS_DOT11_MODE_VHT(dot11mode))
2766 vht_enabled = true;
2767
2768 status = populate_dot11f_ext_cap(mac_ctx, vht_enabled,
2769 &driver_ext_cap, NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002770 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302771 pe_err("Failed %d to create ext cap IE. Use default value instead",
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302772 status);
Naveen Rawatb677c242017-03-29 16:34:50 -07002773 local_ie_buf[*local_ie_len + 1] = DOT11F_IE_EXTCAP_MAX_LEN;
Pragaspathi Thilagaraj6cf025f2018-06-25 18:37:05 +05302774
2775 if ((*local_ie_len) > (MAX_DEFAULT_SCAN_IE_LEN -
2776 (DOT11F_IE_EXTCAP_MAX_LEN + EXT_CAP_IE_HDR_LEN))) {
2777 pe_err("Invalid Scan IE length");
2778 return QDF_STATUS_E_FAILURE;
2779 }
Naveen Rawatb677c242017-03-29 16:34:50 -07002780 (*local_ie_len) += EXT_CAP_IE_HDR_LEN;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302781 qdf_mem_copy(local_ie_buf + (*local_ie_len),
2782 default_scan_ext_cap.bytes,
2783 DOT11F_IE_EXTCAP_MAX_LEN);
2784 (*local_ie_len) += DOT11F_IE_EXTCAP_MAX_LEN;
2785 return QDF_STATUS_SUCCESS;
2786 }
Hu Wangfbd279d2016-10-31 18:24:34 +08002787 lim_merge_extcap_struct(&driver_ext_cap, &default_scan_ext_cap, true);
Naveen Rawatb677c242017-03-29 16:34:50 -07002788 local_ie_buf[*local_ie_len + 1] = driver_ext_cap.num_bytes;
Pragaspathi Thilagaraj6cf025f2018-06-25 18:37:05 +05302789
2790 if ((*local_ie_len) > (MAX_DEFAULT_SCAN_IE_LEN -
2791 (EXT_CAP_IE_HDR_LEN + driver_ext_cap.num_bytes))) {
2792 pe_err("Invalid Scan IE length");
2793 return QDF_STATUS_E_FAILURE;
2794 }
Naveen Rawatb677c242017-03-29 16:34:50 -07002795 (*local_ie_len) += EXT_CAP_IE_HDR_LEN;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302796 qdf_mem_copy(local_ie_buf + (*local_ie_len),
Selvaraj, Sridhar2c46d832017-03-13 17:55:48 +05302797 driver_ext_cap.bytes, driver_ext_cap.num_bytes);
2798 (*local_ie_len) += driver_ext_cap.num_bytes;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302799 return QDF_STATUS_SUCCESS;
2800}