blob: 3bd335dbf0ae122117a8b1c2cd0fa330900845a5 [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>
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053074#include "cfg_ucfg_api.h"
75#include "wlan_mlme_public_struct.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076
77static void __lim_init_scan_vars(tpAniSirGlobal pMac)
78{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053079 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080}
81
82static void __lim_init_bss_vars(tpAniSirGlobal pMac)
83{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053084 qdf_mem_set((void *)pMac->lim.gpSession,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 sizeof(*pMac->lim.gpSession) * pMac->lim.maxBssId, 0);
86
87 /* This is for testing purposes only, be default should always be off */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 pMac->lim.gpLimMlmSetKeysReq = NULL;
89}
90
91static void __lim_init_stats_vars(tpAniSirGlobal pMac)
92{
93 pMac->lim.gLimNumBeaconsRcvd = 0;
94 pMac->lim.gLimNumBeaconsIgnored = 0;
95
96 pMac->lim.gLimNumDeferredMsgs = 0;
97
98 /* / Variable to keep track of number of currently associated STAs */
99 pMac->lim.gLimNumOfAniSTAs = 0; /* count of ANI peers */
100
101 /* Heart-Beat interval value */
102 pMac->lim.gLimHeartBeatCount = 0;
103
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530104 qdf_mem_zero(pMac->lim.gLimHeartBeatApMac[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530106 qdf_mem_zero(pMac->lim.gLimHeartBeatApMac[1],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107 sizeof(tSirMacAddr));
108 pMac->lim.gLimHeartBeatApMacIndex = 0;
109
110 /* Statistics to keep track of no. beacons rcvd in heart beat interval */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530111 qdf_mem_set(pMac->lim.gLimHeartBeatBeaconStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112 sizeof(pMac->lim.gLimHeartBeatBeaconStats), 0);
113
114#ifdef WLAN_DEBUG
115 /* Debug counters */
116 pMac->lim.numTot = 0;
117 pMac->lim.numBbt = 0;
118 pMac->lim.numProtErr = 0;
119 pMac->lim.numLearn = 0;
120 pMac->lim.numLearnIgnore = 0;
121 pMac->lim.numSme = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530122 qdf_mem_set(pMac->lim.numMAC, sizeof(pMac->lim.numMAC), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123 pMac->lim.gLimNumAssocReqDropInvldState = 0;
124 pMac->lim.gLimNumAssocReqDropACRejectTS = 0;
125 pMac->lim.gLimNumAssocReqDropACRejectSta = 0;
126 pMac->lim.gLimNumReassocReqDropInvldState = 0;
127 pMac->lim.gLimNumHashMissIgnored = 0;
128 pMac->lim.gLimUnexpBcnCnt = 0;
129 pMac->lim.gLimBcnSSIDMismatchCnt = 0;
130 pMac->lim.gLimNumLinkEsts = 0;
131 pMac->lim.gLimNumRxCleanup = 0;
132 pMac->lim.gLim11bStaAssocRejectCount = 0;
133#endif
134}
135
136static void __lim_init_states(tpAniSirGlobal pMac)
137{
138 /* Counts Heartbeat failures */
139 pMac->lim.gLimHBfailureCntInLinkEstState = 0;
140 pMac->lim.gLimProbeFailureAfterHBfailedCnt = 0;
141 pMac->lim.gLimHBfailureCntInOtherStates = 0;
142 pMac->lim.gLimRspReqd = 0;
143 pMac->lim.gLimPrevSmeState = eLIM_SME_OFFLINE_STATE;
144
145 /* / MLM State visible across all Sirius modules */
146 MTRACE(mac_trace
147 (pMac, TRACE_CODE_MLM_STATE, NO_SESSION, eLIM_MLM_IDLE_STATE));
148 pMac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
149
150 /* / Previous MLM State */
151 pMac->lim.gLimPrevMlmState = eLIM_MLM_OFFLINE_STATE;
152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 /**
154 * Initialize state to eLIM_SME_OFFLINE_STATE
155 */
156 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
157
158 /**
159 * By default assume 'unknown' role. This will be updated
160 * when SME_START_BSS_REQ is received.
161 */
162
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530163 qdf_mem_set(&pMac->lim.gLimNoShortParams, sizeof(tLimNoShortParams), 0);
164 qdf_mem_set(&pMac->lim.gLimNoShortSlotParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 sizeof(tLimNoShortSlotParams), 0);
166
167 pMac->lim.gLimPhyMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 pMac->lim.gLimProbeRespDisableFlag = 0; /* control over probe resp */
169}
170
171static void __lim_init_vars(tpAniSirGlobal pMac)
172{
173 /* Place holder for Measurement Req/Rsp/Ind related info */
174
175
Jeff Johnson47d75242018-05-12 15:58:53 -0700176 /* Deferred Queue Parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 qdf_mem_set(&pMac->lim.gLimDeferredMsgQ, sizeof(tSirAddtsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178
179 /* addts request if any - only one can be outstanding at any time */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530180 qdf_mem_set(&pMac->lim.gLimAddtsReq, sizeof(tSirAddtsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 pMac->lim.gLimAddtsSent = 0;
182 pMac->lim.gLimAddtsRspTimerCount = 0;
183
184 /* protection related config cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530185 qdf_mem_set(&pMac->lim.cfgProtection, sizeof(tCfgProtection), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 pMac->lim.gLimProtectionControl = 0;
187 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
188
189 /* WMM Related Flag */
190 pMac->lim.gUapsdEnable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191
192 /* QoS-AC Downgrade: Initially, no AC is admitted */
193 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] = 0;
194 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] = 0;
195
196 /* dialogue token List head/tail for Action frames request sent. */
197 pMac->lim.pDialogueTokenHead = NULL;
198 pMac->lim.pDialogueTokenTail = NULL;
199
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530200 qdf_mem_set(&pMac->lim.tspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 sizeof(tLimTspecInfo) * LIM_NUM_TSPEC_MAX, 0);
202
203 /* admission control policy information */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530204 qdf_mem_set(&pMac->lim.admitPolicyInfo, sizeof(tLimAdmitPolicyInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205}
206
207static void __lim_init_assoc_vars(tpAniSirGlobal pMac)
208{
Jiachao Wue6485d42017-12-12 10:54:54 +0800209 pMac->lim.gLimAssocStaLimit = 0;
210 pMac->lim.gLimIbssStaLimit = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 /* Place holder for current authentication request */
212 /* being handled */
213 pMac->lim.gpLimMlmAuthReq = NULL;
214
215 /* / MAC level Pre-authentication related globals */
216 pMac->lim.gLimPreAuthChannelNumber = 0;
217 pMac->lim.gLimPreAuthType = eSIR_OPEN_SYSTEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530218 qdf_mem_set(&pMac->lim.gLimPreAuthPeerAddr, sizeof(tSirMacAddr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 pMac->lim.gLimNumPreAuthContexts = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530220 qdf_mem_set(&pMac->lim.gLimPreAuthTimerTable, sizeof(tLimPreAuthTable),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 0);
222
223 /* Placed holder to deauth reason */
224 pMac->lim.gLimDeauthReasonCode = 0;
225
226 /* Place holder for Pre-authentication node list */
227 pMac->lim.pLimPreAuthList = NULL;
228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* One cache for each overlap and associated case. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530230 qdf_mem_set(pMac->lim.protStaOverlapCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 sizeof(tCacheParams) * LIM_PROT_STA_OVERLAP_CACHE_SIZE, 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530232 qdf_mem_set(pMac->lim.protStaCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 sizeof(tCacheParams) * LIM_PROT_STA_CACHE_SIZE, 0);
234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 pMac->lim.pSessionEntry = NULL;
236 pMac->lim.reAssocRetryAttempt = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237
238}
239
240static void __lim_init_ht_vars(tpAniSirGlobal pMac)
241{
242 pMac->lim.htCapabilityPresentInBeacon = 0;
243 pMac->lim.gHTGreenfield = 0;
244 pMac->lim.gHTShortGI40Mhz = 0;
245 pMac->lim.gHTShortGI20Mhz = 0;
246 pMac->lim.gHTMaxAmsduLength = 0;
247 pMac->lim.gHTDsssCckRate40MHzSupport = 0;
248 pMac->lim.gHTPSMPSupport = 0;
249 pMac->lim.gHTLsigTXOPProtection = 0;
250 pMac->lim.gHTMIMOPSState = eSIR_HT_MIMO_PS_STATIC;
251 pMac->lim.gHTAMpduDensity = 0;
252
253 pMac->lim.gMaxAmsduSizeEnabled = false;
254 pMac->lim.gHTMaxRxAMpduFactor = 0;
255 pMac->lim.gHTServiceIntervalGranularity = 0;
256 pMac->lim.gHTControlledAccessOnly = 0;
257 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
258 pMac->lim.gHTPCOActive = 0;
259
260 pMac->lim.gHTPCOPhase = 0;
261 pMac->lim.gHTSecondaryBeacon = 0;
262 pMac->lim.gHTDualCTSProtection = 0;
263 pMac->lim.gHTSTBCBasicMCS = 0;
264}
265
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700266static QDF_STATUS __lim_init_config(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267{
268 uint32_t val1, val2, val3;
269 uint16_t val16;
270 uint8_t val8;
Wu Gao3365e782018-07-27 18:19:35 +0800271 bool valb;
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +0530272 struct mlme_ht_capabilities_info *ht_cap_info;
Wu Gao3365e782018-07-27 18:19:35 +0800273 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 tSirMacHTInfoField1 *pHTInfoField1;
275 tSirMacHTParametersInfo *pAmpduParamInfo;
276
277 /* Read all the CFGs here that were updated before pe_start is called */
278 /* All these CFG READS/WRITES are only allowed in init, at start when there is no session
279 * and they will be used throughout when there is no session
280 */
281
Jiachao Wue6485d42017-12-12 10:54:54 +0800282 if (wlan_cfg_get_int(pMac, WNI_CFG_ASSOC_STA_LIMIT, &val1)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700283 != QDF_STATUS_SUCCESS){
Jiachao Wue6485d42017-12-12 10:54:54 +0800284 pe_err("cfg get assoc sta limit failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700285 return QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800286 }
287
288 pMac->lim.gLimAssocStaLimit = val1;
289 pMac->lim.gLimIbssStaLimit = val1;
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +0530290 ht_cap_info = &pMac->mlme_cfg->ht_caps.ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291
292 if (wlan_cfg_get_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE, &val2) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700293 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530294 pe_err("could not retrieve Channel Bonding CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700295 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297
298 /* channel bonding mode could be set to anything from 0 to 4(Titan had these */
299 /* modes But for Taurus we have only two modes: enable(>0) or disable(=0) */
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +0530300 ht_cap_info->supportedChannelWidthSet = val2 ?
301 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE :
302 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700304 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD1, &val1) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530305 pe_err("could not retrieve HT INFO Field1 CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700306 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 }
308
309 val8 = (uint8_t) val1;
310 pHTInfoField1 = (tSirMacHTInfoField1 *) &val8;
311 pHTInfoField1->recommendedTxWidthSet =
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +0530312 ht_cap_info->supportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 if (cfg_set_int(pMac, WNI_CFG_HT_INFO_FIELD1, *(uint8_t *) pHTInfoField1)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700314 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530315 pe_err("could not update HT Info Field");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700316 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 }
318
319 /* WNI_CFG_HEART_BEAT_THRESHOLD */
320
321 if (wlan_cfg_get_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700322 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530323 pe_err("could not retrieve WNI_CFG_HEART_BEAT_THRESHOLD CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700324 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 }
326 if (!val1) {
327 pMac->sys.gSysEnableLinkMonitorMode = 0;
328 } else {
329 /* No need to activate the timer during init time. */
330 pMac->sys.gSysEnableLinkMonitorMode = 1;
331 }
332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 /* WNI_CFG_MAX_RX_AMPDU_FACTOR */
334
335 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &val1) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700336 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530337 pe_err("could not retrieve HT AMPDU Param");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700338 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 }
340 if (wlan_cfg_get_int(pMac, WNI_CFG_MAX_RX_AMPDU_FACTOR, &val2) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700341 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530342 pe_err("could not retrieve AMPDU Factor CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700343 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 }
Krishna Kumaar Natarajan22b59a72015-11-23 18:54:58 -0800345 if (wlan_cfg_get_int(pMac, WNI_CFG_MPDU_DENSITY, &val3) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700346 QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530347 pe_err("could not retrieve MPDU Density CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700348 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan22b59a72015-11-23 18:54:58 -0800349 }
350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 val16 = (uint16_t) val1;
352 pAmpduParamInfo = (tSirMacHTParametersInfo *) &val16;
353 pAmpduParamInfo->maxRxAMPDUFactor = (uint8_t) val2;
Krishna Kumaar Natarajan22b59a72015-11-23 18:54:58 -0800354 pAmpduParamInfo->mpduDensity = (uint8_t)val3;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 if (cfg_set_int
356 (pMac, WNI_CFG_HT_AMPDU_PARAMS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700357 *(uint8_t *) pAmpduParamInfo) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530358 pe_err("cfg get short preamble failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700359 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 }
361
362 /* WNI_CFG_SHORT_PREAMBLE - this one is not updated in
363 lim_handle_cf_gparam_update do we want to update this? */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700364 if (wlan_cfg_get_int(pMac, WNI_CFG_SHORT_PREAMBLE, &val1) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530365 pe_err("cfg get short preamble failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700366 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 }
368
369 /* WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA - not needed */
370
371 /* This was initially done after resume notification from HAL. Now, DAL is
372 started before PE so this can be done here */
373 handle_ht_capabilityand_ht_info(pMac, NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700374 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 wlan_cfg_get_int(pMac, WNI_CFG_DISABLE_LDPC_WITH_TXBF_AP,
376 (uint32_t *) &pMac->lim.disableLDPCWithTxbfAP)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530377 pe_err("cfg get disableLDPCWithTxbfAP failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700378 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 }
380#ifdef FEATURE_WLAN_TDLS
Wu Gao3365e782018-07-27 18:19:35 +0800381 status = cfg_tdls_get_buffer_sta_enable(pMac->psoc, &valb);
382 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530383 pe_err("cfg get LimTDLSBufStaEnabled failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700384 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 }
Wu Gao3365e782018-07-27 18:19:35 +0800386 pMac->lim.gLimTDLSBufStaEnabled = (uint8_t)valb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387
Wu Gao3365e782018-07-27 18:19:35 +0800388 status = cfg_tdls_get_uapsd_mask(pMac->psoc, &val1);
389 if (QDF_STATUS_SUCCESS != status) {
390 pe_err("cfg get LimTDLSUapsdMask failed");
391 return QDF_STATUS_E_FAILURE;
392 }
393 pMac->lim.gLimTDLSUapsdMask = (uint8_t)val1;
394
395 status = cfg_tdls_get_off_channel_enable(pMac->psoc, &valb);
396 if (QDF_STATUS_SUCCESS != status) {
397 pe_err("cfg get LimTDLSUapsdMask failed");
398 return QDF_STATUS_E_FAILURE;
399 }
400 pMac->lim.gLimTDLSOffChannelEnabled = (uint8_t)valb;
401
402 status = cfg_tdls_get_wmm_mode_enable(pMac->psoc, &valb);
403 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530404 pe_err("cfg get LimTDLSWmmMode failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700405 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 }
Wu Gao3365e782018-07-27 18:19:35 +0800407 pMac->lim.gLimTDLSWmmMode = (uint8_t)valb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408#endif
Arif Hussainee10f902017-12-27 16:30:17 -0800409
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700410 if (QDF_STATUS_SUCCESS != wlan_cfg_get_int(pMac,
Arif Hussainee10f902017-12-27 16:30:17 -0800411 WNI_CFG_OBSS_DETECTION_OFFLOAD,
412 (uint32_t *)&pMac->lim.
Arif Hussain1513cb22018-01-05 19:56:31 -0800413 global_obss_offload_enabled)) {
Arif Hussainee10f902017-12-27 16:30:17 -0800414 pe_err("cfg get obss_detection_offloaded failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700415 return QDF_STATUS_E_FAILURE;
Arif Hussainee10f902017-12-27 16:30:17 -0800416 }
417
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700418 if (QDF_STATUS_SUCCESS !=
Arif Hussain05fb4872018-01-03 16:02:55 -0800419 wlan_cfg_get_int(pMac, WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD,
420 (uint32_t *) &pMac->lim.
421 global_obss_color_collision_det_offload)) {
422 pe_err("cfg get obss_color_collision_offload failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700423 return QDF_STATUS_E_FAILURE;
Arif Hussain05fb4872018-01-03 16:02:55 -0800424 }
425
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700426 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427}
428
429/*
430 lim_start
431 This function is to replace the __lim_process_sme_start_req since there is no
432 eWNI_SME_START_REQ post to PE.
433 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700434QDF_STATUS lim_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700436 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530438 pe_debug("enter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439
440 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) {
441 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
442
443 MTRACE(mac_trace
444 (pMac, TRACE_CODE_SME_STATE, NO_SESSION,
445 pMac->lim.gLimSmeState));
446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 /* Initialize MLM state machine */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700448 if (QDF_STATUS_SUCCESS != lim_init_mlm(pMac)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530449 pe_err("Init MLM failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700450 return QDF_STATUS_E_FAILURE;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800451 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452 } else {
453 /**
454 * Should not have received eWNI_SME_START_REQ in states
455 * other than OFFLINE. Return response to host and
456 * log error
457 */
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530458 pe_warn("Invalid SME state: %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 pMac->lim.gLimSmeState);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700460 retCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 }
462
Paul Zhang2f1077c2017-11-30 12:06:09 +0800463 pMac->lim.req_id =
464 ucfg_scan_register_requester(pMac->psoc,
465 "LIM",
466 lim_process_rx_scan_handler,
467 pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 return retCode;
469}
470
471/**
472 * lim_initialize()
473 *
474 ***FUNCTION:
475 * This function is called from LIM thread entry function.
476 * LIM related global data structures are initialized in this function.
477 *
478 ***LOGIC:
479 * NA
480 *
481 ***ASSUMPTIONS:
482 * NA
483 *
484 ***NOTE:
485 * NA
486 *
487 * @param pMac - Pointer to global MAC structure
488 * @return None
489 */
490
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700491QDF_STATUS lim_initialize(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700493 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494
Jiachao Wue6485d42017-12-12 10:54:54 +0800495 pMac->lim.mgmtFrameSessionId = NO_SESSION;
496 pMac->lim.tdls_frm_session_id = NO_SESSION;
497 pMac->lim.deferredMsgCnt = 0;
498 pMac->lim.retry_packet_cnt = 0;
499 pMac->lim.ibss_retry_cnt = 0;
500 pMac->lim.deauthMsgCnt = 0;
501 pMac->lim.disassocMsgCnt = 0;
502
503 if (QDF_IS_STATUS_ERROR(qdf_mutex_create(
504 &pMac->lim.lkPeGlobalLock))) {
505 pe_err("lim lock init failed!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700506 return QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800507 }
508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 __lim_init_assoc_vars(pMac);
510 __lim_init_vars(pMac);
511 __lim_init_states(pMac);
512 __lim_init_stats_vars(pMac);
513 __lim_init_bss_vars(pMac);
514 __lim_init_scan_vars(pMac);
515 __lim_init_ht_vars(pMac);
516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 /* Initializations for maintaining peers in IBSS */
518 lim_ibss_init(pMac);
519
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520 rrm_initialize(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521
Jiachao Wue6485d42017-12-12 10:54:54 +0800522 if (QDF_IS_STATUS_ERROR(qdf_mutex_create(
523 &pMac->lim.lim_frame_register_lock))) {
524 pe_err("lim lock init failed!");
525 qdf_mutex_destroy(&pMac->lim.lkPeGlobalLock);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700526 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 }
Jiachao Wue6485d42017-12-12 10:54:54 +0800528
529 qdf_list_create(&pMac->lim.gLimMgmtFrameRegistratinQueue, 0);
530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 /* initialize the TSPEC admission control table. */
532 /* Note that this was initially done after resume notification from HAL. */
533 /* Now, DAL is started before PE so this can be done here */
534 lim_admit_control_init(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 return status;
536
537} /*** end lim_initialize() ***/
538
539/**
540 * lim_cleanup()
541 *
542 ***FUNCTION:
543 * This function is called upon reset or persona change
544 * to cleanup LIM state
545 *
546 ***LOGIC:
547 * NA
548 *
549 ***ASSUMPTIONS:
550 * NA
551 *
552 ***NOTE:
553 * NA
554 *
555 * @param pMac - Pointer to Global MAC structure
556 * @return None
557 */
558
559void lim_cleanup(tpAniSirGlobal pMac)
560{
Naveen Rawat25460932016-02-05 16:56:08 -0800561 uint8_t i;
Jiachao Wue6485d42017-12-12 10:54:54 +0800562 qdf_list_node_t *lst_node;
563
564 /*
565 * Before destroying the list making sure all the nodes have been
566 * deleted
567 */
568 while (qdf_list_remove_front(
569 &pMac->lim.gLimMgmtFrameRegistratinQueue,
570 &lst_node) == QDF_STATUS_SUCCESS) {
571 qdf_mem_free(lst_node);
572 }
573 qdf_list_destroy(&pMac->lim.gLimMgmtFrameRegistratinQueue);
574 qdf_mutex_destroy(&pMac->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530576 pe_deregister_mgmt_rx_frm_callback(pMac);
577
Naveen Rawat4b1aab92017-05-23 11:37:09 -0700578 qdf_mem_free(pMac->lim.gpLimRemainOnChanReq);
579 pMac->lim.gpLimRemainOnChanReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580
581 /* free up preAuth table */
582 if (pMac->lim.gLimPreAuthTimerTable.pTable != NULL) {
Naveen Rawat25460932016-02-05 16:56:08 -0800583 for (i = 0; i < pMac->lim.gLimPreAuthTimerTable.numEntry; i++)
584 qdf_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable[i]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530585 qdf_mem_free(pMac->lim.gLimPreAuthTimerTable.pTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 pMac->lim.gLimPreAuthTimerTable.pTable = NULL;
587 pMac->lim.gLimPreAuthTimerTable.numEntry = 0;
588 }
589
590 if (NULL != pMac->lim.pDialogueTokenHead) {
591 lim_delete_dialogue_token_list(pMac);
592 }
593
594 if (NULL != pMac->lim.pDialogueTokenTail) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530595 qdf_mem_free(pMac->lim.pDialogueTokenTail);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 pMac->lim.pDialogueTokenTail = NULL;
597 }
598
599 if (pMac->lim.gpLimMlmSetKeysReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530600 qdf_mem_free(pMac->lim.gpLimMlmSetKeysReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 pMac->lim.gpLimMlmSetKeysReq = NULL;
602 }
603
604 if (pMac->lim.gpLimMlmAuthReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530605 qdf_mem_free(pMac->lim.gpLimMlmAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606 pMac->lim.gpLimMlmAuthReq = NULL;
607 }
608
Vignesh Viswanathana842b942018-02-16 16:02:50 +0530609 if (pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq) {
610 qdf_mem_free(pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq);
611 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
612 }
613
614 if (pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq) {
615 qdf_mem_free(pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq);
616 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
617 }
618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 /* Now, finally reset the deferred message queue pointers */
620 lim_reset_deferred_msg_q(pMac);
621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 rrm_cleanup(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 lim_ft_cleanup_all_ft_sessions(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625
Paul Zhang2f1077c2017-11-30 12:06:09 +0800626 ucfg_scan_unregister_requester(pMac->psoc, pMac->lim.req_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627} /*** end lim_cleanup() ***/
628
Wen Gong3f003382018-05-14 14:26:37 +0800629#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530630/**
631 * lim_state_info_dump() - print state information of lim layer
632 * @buf: buffer pointer
633 * @size: size of buffer to be filled
634 *
635 * This function is used to print state information of lim layer
636 *
637 * Return: None
638 */
639static void lim_state_info_dump(char **buf_ptr, uint16_t *size)
640{
641 tHalHandle hal;
642 tpAniSirGlobal mac;
643 uint16_t len = 0;
644 char *buf = *buf_ptr;
645
646 hal = cds_get_context(QDF_MODULE_ID_PE);
647 if (hal == NULL) {
648 QDF_ASSERT(0);
649 return;
650 }
651
652 mac = PMAC_STRUCT(hal);
653
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530654 pe_debug("size of buffer: %d", *size);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530655
656 len += qdf_scnprintf(buf + len, *size - len,
657 "\n SmeState: %d", mac->lim.gLimSmeState);
658 len += qdf_scnprintf(buf + len, *size - len,
659 "\n PrevSmeState: %d", mac->lim.gLimPrevSmeState);
660 len += qdf_scnprintf(buf + len, *size - len,
661 "\n MlmState: %d", mac->lim.gLimMlmState);
662 len += qdf_scnprintf(buf + len, *size - len,
663 "\n PrevMlmState: %d", mac->lim.gLimPrevMlmState);
664 len += qdf_scnprintf(buf + len, *size - len,
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530665 "\n ProcessDefdMsgs: %d", mac->lim.gLimProcessDefdMsgs);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530666
667 *size -= len;
668 *buf_ptr += len;
669}
670
671/**
672 * lim_register_debug_callback() - registration function for lim layer
673 * to print lim state information
674 *
675 * Return: None
676 */
677static void lim_register_debug_callback(void)
678{
679 qdf_register_debug_callback(QDF_MODULE_ID_PE, &lim_state_info_dump);
680}
Wen Gong3f003382018-05-14 14:26:37 +0800681#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +0800682static void lim_register_debug_callback(void)
683{
684}
Wen Gong3f003382018-05-14 14:26:37 +0800685#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Naveen Rawat37f62c82017-03-26 22:24:43 -0700686static void lim_nan_register_callbacks(tpAniSirGlobal mac_ctx)
687{
688 struct nan_callbacks cb_obj = {0};
689
690 cb_obj.add_ndi_peer = lim_add_ndi_peer_converged;
Naveen Rawatb3143ea2017-03-26 22:25:46 -0700691 cb_obj.ndp_delete_peers = lim_ndp_delete_peers_converged;
692 cb_obj.delete_peers_by_addr = lim_ndp_delete_peers_by_addr_converged;
Naveen Rawat37f62c82017-03-26 22:24:43 -0700693
694 ucfg_nan_register_lim_callbacks(mac_ctx->psoc, &cb_obj);
695}
Naveen Rawat37f62c82017-03-26 22:24:43 -0700696
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530697/*
698 * pe_shutdown_notifier_cb - Shutdown notifier callback
699 * @ctx: Pointer to Global MAC structure
700 *
701 * Return: None
702 */
703static void pe_shutdown_notifier_cb(void *ctx)
704{
705 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)ctx;
706 tpPESession session;
707 uint8_t i;
708
yeshwanth sriram guntukafde0d522017-08-17 19:52:11 +0530709 lim_deactivate_timers(mac_ctx);
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530710 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
711 session = &mac_ctx->lim.gpSession[i];
712 if (session->valid == true) {
713 if (LIM_IS_AP_ROLE(session))
714 qdf_mc_timer_stop(&session->
715 protection_fields_reset_timer);
716#ifdef WLAN_FEATURE_11W
717 qdf_mc_timer_stop(&session->pmfComebackTimer);
718#endif
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530719 }
720 }
721}
722
Liangwei Dongc26be332018-01-19 00:31:31 -0500723#ifdef WLAN_FEATURE_11W
724/**
725 * is_mgmt_protected - check RMF enabled for the peer
726 * @vdev_id: vdev id
727 * @peer_mac_addr: peer mac address
728 *
729 * The function check the mgmt frame protection enabled or not
730 * for station mode and AP mode
731 *
732 * Return: true, if the connection is RMF enabled.
733 */
734static bool is_mgmt_protected(uint32_t vdev_id,
735 const uint8_t *peer_mac_addr)
736{
737 uint16_t aid;
738 tpDphHashNode sta_ds;
739 tpPESession session;
740 bool protected = false;
741 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
742
743 if (!mac_ctx)
744 return false;
745
746 session = pe_find_session_by_sme_session_id(mac_ctx,
747 vdev_id);
748 if (!session) {
749 /* couldn't find session */
750 pe_err("Session not found for vdev_id: %d", vdev_id);
751 return false;
752 }
753
754 if (LIM_IS_AP_ROLE(session)) {
755 sta_ds = dph_lookup_hash_entry(mac_ctx,
756 (uint8_t *)peer_mac_addr, &aid,
757 &session->dph.dphHashTable);
758 if (sta_ds) {
759 /* rmfenabled will be set at the time of addbss.
760 * but sometimes EAP auth fails and keys are not
761 * installed then if we send any management frame
762 * like deauth/disassoc with this bit set then
763 * firmware crashes. so check for keys are
764 * installed or not also before setting the bit
765 */
766 if (sta_ds->rmfEnabled && sta_ds->is_key_installed)
767 protected = true;
768 }
769 } else if (session->limRmfEnabled &&
770 session->is_key_installed) {
771 protected = true;
772 }
773
774 return protected;
775}
776#else
777/**
778 * is_mgmt_protected - check RMF enabled for the peer
779 * @vdev_id: vdev id
780 * @peer_mac_addr: peer mac address
781 *
782 * The function check the mgmt frame protection enabled or not
783 * for station mode and AP mode
784 *
785 * Return: true, if the connection is RMF enabled.
786 */
787static bool is_mgmt_protected(uint32_t vdev_id,
788 const uint8_t *peer_mac_addr)
789{
790 return false;
791}
792#endif
793
794static void p2p_register_callbacks(tpAniSirGlobal mac_ctx)
795{
796 struct p2p_protocol_callbacks p2p_cb = {0};
797
798 p2p_cb.is_mgmt_protected = is_mgmt_protected;
799 ucfg_p2p_register_callbacks(mac_ctx->psoc, &p2p_cb);
800}
801
Vignesh Viswanathan153ae932018-04-11 14:24:13 +0530802/*
803 * lim_register_sap_bcn_callback(): Register a callback with scan module for SAP
804 * @mac_ctx: pointer to the global mac context
805 *
806 * Registers the function lim_handle_sap_beacon as callback with the Scan
807 * module to handle beacon frames for SAP sessions
808 *
809 * Return: QDF Status
810 */
811static QDF_STATUS lim_register_sap_bcn_callback(tpAniSirGlobal mac_ctx)
812{
813 QDF_STATUS status;
814
815 status = ucfg_scan_register_bcn_cb(mac_ctx->psoc,
816 lim_handle_sap_beacon,
817 SCAN_CB_TYPE_UPDATE_BCN);
818 if (!QDF_IS_STATUS_SUCCESS(status)) {
819 pe_err("failed with status code %08d [x%08x]",
820 status, status);
821 }
822
823 return status;
824}
825
826/*
827 * lim_unregister_sap_bcn_callback(): Unregister the callback with scan module
828 * @mac_ctx: pointer to the global mac context
829 *
830 * Unregisters the callback registered with the Scan
831 * module to handle beacon frames for SAP sessions
832 *
833 * Return: QDF Status
834 */
835static QDF_STATUS lim_unregister_sap_bcn_callback(tpAniSirGlobal mac_ctx)
836{
837 QDF_STATUS status;
838
839 status = ucfg_scan_register_bcn_cb(mac_ctx->psoc,
840 NULL, SCAN_CB_TYPE_UPDATE_BCN);
841 if (!QDF_IS_STATUS_SUCCESS(status)) {
842 pe_err("failed with status code %08d [x%08x]",
843 status, status);
844 }
845
846 return status;
847}
848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849/** -------------------------------------------------------------
850 \fn pe_open
851 \brief will be called in Open sequence from mac_open
852 \param tpAniSirGlobal pMac
853 \param tHalOpenParameters *pHalOpenParam
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700854 \return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 -------------------------------------------------------------*/
856
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700857QDF_STATUS pe_open(tpAniSirGlobal pMac, struct cds_config_info *cds_cfg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700859 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700861 if (QDF_DRIVER_TYPE_MFG == cds_cfg->driver_type)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700862 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
Arun Khandavallic811dcc2016-06-26 07:37:21 +0530864 pMac->lim.maxBssId = cds_cfg->max_bssid;
865 pMac->lim.maxStation = cds_cfg->max_station;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +0530866 qdf_spinlock_create(&pMac->sys.bbt_mgmt_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867
868 if ((pMac->lim.maxBssId == 0) || (pMac->lim.maxStation == 0)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530869 pe_err("max number of Bssid or Stations cannot be zero!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700870 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 }
872
Qiwei Cai50a21082018-08-07 14:30:09 +0800873 if (!QDF_IS_STATUS_SUCCESS(pe_allocate_dph_node_array_buffer())) {
874 pe_err("g_dph_node_array memory allocate failed!");
875 return QDF_STATUS_E_NOMEM;
876 }
877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 pMac->lim.limTimers.gpLimCnfWaitTimer =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530879 qdf_mem_malloc(sizeof(TX_TIMER) * (pMac->lim.maxStation + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 if (NULL == pMac->lim.limTimers.gpLimCnfWaitTimer) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530881 pe_err("gpLimCnfWaitTimer memory allocate failed!");
Qiwei Cai50a21082018-08-07 14:30:09 +0800882 status = QDF_STATUS_E_NOMEM;
883 goto pe_open_timer_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 }
885
886 pMac->lim.gpSession =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530887 qdf_mem_malloc(sizeof(tPESession) * pMac->lim.maxBssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 if (NULL == pMac->lim.gpSession) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +0530889 pe_err("gpSession memory allocate failed!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700890 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 goto pe_open_psession_fail;
892 }
893
Jiachao Wue6485d42017-12-12 10:54:54 +0800894 status = lim_initialize(pMac);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700895 if (QDF_STATUS_SUCCESS != status) {
Jiachao Wue6485d42017-12-12 10:54:54 +0800896 pe_err("lim_initialize failed!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700897 status = QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800898 goto pe_open_lock_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900
901 /*
902 * pe_open is successful by now, so it is right time to initialize
903 * MTRACE for PE module. if LIM_TRACE_RECORD is not defined in build
904 * file then nothing will be logged for PE module.
905 */
906#ifdef LIM_TRACE_RECORD
907 MTRACE(lim_trace_init(pMac));
908#endif
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530909 lim_register_debug_callback();
Naveen Rawat37f62c82017-03-26 22:24:43 -0700910 lim_nan_register_callbacks(pMac);
Liangwei Dongc26be332018-01-19 00:31:31 -0500911 p2p_register_callbacks(pMac);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +0530912 lim_register_sap_bcn_callback(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530913
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530914 if (!QDF_IS_STATUS_SUCCESS(
915 cds_shutdown_notifier_register(pe_shutdown_notifier_cb, pMac))) {
916 pe_err("%s: Shutdown notifier register failed", __func__);
917 }
918
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700919 return status; /* status here will be QDF_STATUS_SUCCESS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
Jiachao Wue6485d42017-12-12 10:54:54 +0800921pe_open_lock_fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530922 qdf_mem_free(pMac->lim.gpSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 pMac->lim.gpSession = NULL;
924pe_open_psession_fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530925 qdf_mem_free(pMac->lim.limTimers.gpLimCnfWaitTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
Qiwei Cai50a21082018-08-07 14:30:09 +0800927pe_open_timer_fail:
928 pe_free_dph_node_array_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929
930 return status;
931}
932
933/** -------------------------------------------------------------
934 \fn pe_close
935 \brief will be called in close sequence from mac_close
936 \param tpAniSirGlobal pMac
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700937 \return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 -------------------------------------------------------------*/
939
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700940QDF_STATUS pe_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941{
942 uint8_t i;
943
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700944 if (ANI_DRIVER_TYPE(pMac) == QDF_DRIVER_TYPE_MFG)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700945 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946
Jiachao Wue6485d42017-12-12 10:54:54 +0800947 lim_cleanup(pMac);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +0530948 lim_unregister_sap_bcn_callback(pMac);
Abhishek Singh51e048e2017-11-14 14:46:51 +0530949
Himanshu Agarwal8612c3b2017-12-14 14:37:08 +0530950 if (pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq) {
951 qdf_mem_free(pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq);
952 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
953 }
954
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +0530955 qdf_spinlock_destroy(&pMac->sys.bbt_mgmt_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 for (i = 0; i < pMac->lim.maxBssId; i++) {
Krunal Soni6de1b212017-10-30 23:29:20 -0700957 if (pMac->lim.gpSession[i].valid == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 pe_delete_session(pMac, &pMac->lim.gpSession[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 qdf_mem_free(pMac->lim.limTimers.gpLimCnfWaitTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 pMac->lim.limTimers.gpLimCnfWaitTimer = NULL;
962
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530963 qdf_mem_free(pMac->lim.gpSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 pMac->lim.gpSession = NULL;
Qiwei Cai50a21082018-08-07 14:30:09 +0800965
966 pe_free_dph_node_array_buffer();
967
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530968 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530969 (qdf_mutex_destroy(&pMac->lim.lkPeGlobalLock))) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700970 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700972 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973}
974
975/** -------------------------------------------------------------
976 \fn pe_start
977 \brief will be called in start sequence from mac_start
978 \param tpAniSirGlobal pMac
Jeff Johnsond9e03512018-06-29 12:04:03 -0700979 \return QDF_STATUS_SUCCESS on success, other QDF_STATUS on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 -------------------------------------------------------------*/
981
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700982QDF_STATUS pe_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700984 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jiachao Wue6485d42017-12-12 10:54:54 +0800985 status = lim_start(pMac);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700986 if (QDF_STATUS_SUCCESS != status) {
Jiachao Wue6485d42017-12-12 10:54:54 +0800987 pe_err("lim_start failed!");
988 return status;
989 }
990 /* Initialize the configurations needed by PE */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700991 if (QDF_STATUS_E_FAILURE == __lim_init_config(pMac)) {
Jiachao Wue6485d42017-12-12 10:54:54 +0800992 pe_err("lim init config failed!");
993 /* We need to undo everything in lim_start */
994 lim_cleanup_mlm(pMac);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700995 return QDF_STATUS_E_FAILURE;
Jiachao Wue6485d42017-12-12 10:54:54 +0800996 }
997 /* Initialize the configurations needed by PE */
998 lim_register_hal_ind_call_back(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 return status;
1000}
1001
1002/** -------------------------------------------------------------
1003 \fn pe_stop
1004 \brief will be called in stop sequence from mac_stop
1005 \param tpAniSirGlobal pMac
1006 \return none
1007 -------------------------------------------------------------*/
1008
1009void pe_stop(tpAniSirGlobal pMac)
1010{
Jiachao Wue6485d42017-12-12 10:54:54 +08001011 lim_cleanup_mlm(pMac);
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +05301012 pe_debug(" PE STOP: Set LIM state to eLIM_MLM_OFFLINE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 SET_LIM_MLM_STATE(pMac, eLIM_MLM_OFFLINE_STATE);
1014 return;
1015}
1016
Rajeev Kumar69ddd852018-02-20 13:58:08 -08001017static void pe_free_nested_messages(struct scheduler_msg *msg)
1018{
1019 switch (msg->type) {
1020 case WMA_SET_LINK_STATE_RSP:
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +05301021 pe_debug("pe_free_nested_messages: WMA_SET_LINK_STATE_RSP");
Rajeev Kumar69ddd852018-02-20 13:58:08 -08001022 qdf_mem_free(((tpLinkStateParams) msg->bodyptr)->callbackArg);
1023 break;
1024 default:
1025 break;
1026 }
1027}
1028
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029/** -------------------------------------------------------------
1030 \fn pe_free_msg
1031 \brief Called by CDS scheduler (function cds_sched_flush_mc_mqs)
1032 \ to free a given PE message on the TX and MC thread.
1033 \ This happens when there are messages pending in the PE
1034 \ queue when system is being stopped and reset.
1035 \param tpAniSirGlobal pMac
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001036 \param struct scheduler_msg pMsg
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 \return none
1038 -----------------------------------------------------------------*/
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001039void pe_free_msg(tpAniSirGlobal pMac, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040{
1041 if (pMsg != NULL) {
1042 if (NULL != pMsg->bodyptr) {
1043 if (SIR_BB_XPORT_MGMT_MSG == pMsg->type) {
1044 cds_pkt_return_packet((cds_pkt_t *) pMsg->
1045 bodyptr);
1046 } else {
Rajeev Kumar69ddd852018-02-20 13:58:08 -08001047 pe_free_nested_messages(pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301048 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 }
1050 }
1051 pMsg->bodyptr = 0;
1052 pMsg->bodyval = 0;
1053 pMsg->type = 0;
1054 }
1055 return;
1056}
1057
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001058QDF_STATUS lim_post_msg_api(tpAniSirGlobal mac, struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059{
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001060 return scheduler_post_msg(QDF_MODULE_ID_PE, msg);
1061}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001063QDF_STATUS lim_post_msg_high_priority(tpAniSirGlobal mac,
1064 struct scheduler_msg *msg)
Padma, Santhosh Kumar95091352016-08-16 15:23:31 +05301065{
Rajeev Kumarf7d84422017-01-21 15:45:44 -08001066 return scheduler_post_msg_by_priority(QDF_MODULE_ID_PE,
Rajeev Kumar14978712017-01-30 16:57:07 -08001067 msg, true);
Padma, Santhosh Kumar95091352016-08-16 15:23:31 +05301068}
1069
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001070QDF_STATUS pe_mc_process_handler(struct scheduler_msg *msg)
1071{
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001072 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
1073
1074 if (mac_ctx == NULL)
1075 return QDF_STATUS_E_FAILURE;
1076
Jeff Johnsonedfaf0b2018-06-29 12:47:11 -07001077 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001078 return QDF_STATUS_SUCCESS;
1079
Jeff Johnsonedfaf0b2018-06-29 12:47:11 -07001080 /*
1081 * If the Message to be handled is for CFG Module call the CFG Msg
1082 * Handler and for all the other cases post it to LIM
1083 */
1084 if (SIR_CFG_PARAM_UPDATE_IND != msg->type && IS_CFG_MSG(msg->type))
1085 cfg_process_mb_msg(mac_ctx, msg->bodyptr);
1086 else
1087 lim_message_processor(mac_ctx, msg);
1088
1089 return QDF_STATUS_SUCCESS;
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001090}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07001091
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301092/**
1093 * pe_drop_pending_rx_mgmt_frames: To drop pending RX mgmt frames
1094 * @mac_ctx: Pointer to global MAC structure
1095 * @hdr: Management header
1096 * @cds_pkt: Packet
1097 *
1098 * This function is used to drop RX pending mgmt frames if pe mgmt queue
1099 * reaches threshold
1100 *
1101 * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE on failure
1102 */
1103static QDF_STATUS pe_drop_pending_rx_mgmt_frames(tpAniSirGlobal mac_ctx,
1104 tpSirMacMgmtHdr hdr, cds_pkt_t *cds_pkt)
1105{
1106 qdf_spin_lock(&mac_ctx->sys.bbt_mgmt_lock);
1107 if (mac_ctx->sys.sys_bbt_pending_mgmt_count >=
1108 MGMT_RX_PACKETS_THRESHOLD) {
1109 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001110 pe_debug("No.of pending RX management frames reaches to threshold, dropping management frames");
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301111 cds_pkt_return_packet(cds_pkt);
1112 cds_pkt = NULL;
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301113 mac_ctx->rx_packet_drop_counter++;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301114 return QDF_STATUS_E_FAILURE;
1115 } else if (mac_ctx->sys.sys_bbt_pending_mgmt_count >
1116 (MGMT_RX_PACKETS_THRESHOLD / 2)) {
1117 /* drop all probereq, proberesp and beacons */
1118 if (hdr->fc.subType == SIR_MAC_MGMT_BEACON ||
1119 hdr->fc.subType == SIR_MAC_MGMT_PROBE_REQ ||
1120 hdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP) {
1121 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301122 if (!(mac_ctx->rx_packet_drop_counter % 100))
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001123 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 +05301124 hdr->fc.subType,
1125 mac_ctx->rx_packet_drop_counter);
1126 mac_ctx->rx_packet_drop_counter++;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301127 cds_pkt_return_packet(cds_pkt);
1128 cds_pkt = NULL;
1129 return QDF_STATUS_E_FAILURE;
1130 }
1131 }
1132 mac_ctx->sys.sys_bbt_pending_mgmt_count++;
1133 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
1134 if (mac_ctx->sys.sys_bbt_pending_mgmt_count ==
Sreelakshmi Konamki0e9fb9a2017-04-05 18:57:15 +05301135 (MGMT_RX_PACKETS_THRESHOLD / 4)) {
1136 if (!(mac_ctx->rx_packet_drop_counter % 100))
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001137 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 +05301138 mac_ctx->rx_packet_drop_counter);
1139 mac_ctx->rx_packet_drop_counter++;
1140 }
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301141 return QDF_STATUS_SUCCESS;
1142}
1143
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301144/**
Vignesh Viswanathan48b7ed92018-04-11 19:01:59 +05301145 * pe_is_ext_scan_bcn - Check if the beacon is from Ext or EPNO scan
1146 *
1147 * @hdr: pointer to the 802.11 header of the frame
1148 * @rx_pkt_info: pointer to the rx packet meta
1149 *
1150 * Checks if the beacon is from Ext Scan or EPNO scan
1151 *
1152 * Return: true or false
1153 */
1154#ifdef FEATURE_WLAN_EXTSCAN
1155static inline bool pe_is_ext_scan_bcn(tpSirMacMgmtHdr hdr,
1156 uint8_t *rx_pkt_info)
1157{
1158 if ((hdr->fc.subType == SIR_MAC_MGMT_BEACON) &&
1159 (WMA_IS_EXTSCAN_SCAN_SRC(rx_pkt_info) ||
1160 WMA_IS_EPNO_SCAN_SRC(rx_pkt_info)))
1161 return true;
1162
1163 return false;
1164}
1165#else
1166static inline bool pe_is_ext_scan_bcn(tpSirMacMgmtHdr hdr,
1167 uint8_t *rx_pkt_info)
1168{
1169 return false;
1170}
1171#endif
1172
1173/**
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301174 * pe_filter_drop_bcn_probe_frame - Apply filter on the received frame
1175 *
1176 * @mac_ctx: pointer to the global mac context
1177 * @hdr: pointer to the 802.11 header of the frame
1178 * @rx_pkt_info: pointer to the rx packet meta
1179 *
1180 * Applies the filter from global mac context on the received beacon/
1181 * probe response frame before posting it to the PE queue
1182 *
1183 * Return: true if frame is allowed, false if frame is to be dropped.
1184 */
1185static bool pe_filter_bcn_probe_frame(tpAniSirGlobal mac_ctx,
1186 tpSirMacMgmtHdr hdr,
1187 uint8_t *rx_pkt_info)
1188{
1189 uint8_t session_id;
1190 uint8_t *body;
1191 const uint8_t *ssid_ie;
1192 uint16_t frame_len;
1193 struct mgmt_beacon_probe_filter *filter;
1194 tpSirMacCapabilityInfo bcn_caps;
1195 tSirMacSSid bcn_ssid;
1196
Vignesh Viswanathan48b7ed92018-04-11 19:01:59 +05301197 if (pe_is_ext_scan_bcn(hdr, rx_pkt_info))
1198 return true;
1199
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301200 filter = &mac_ctx->bcn_filter;
1201
1202 /*
1203 * If any STA session exists and beacon source matches any of the
1204 * STA BSSIDs, allow the frame
1205 */
1206 if (filter->num_sta_sessions) {
1207 for (session_id = 0; session_id < SIR_MAX_SUPPORTED_BSS;
1208 session_id++) {
1209 if (sir_compare_mac_addr(filter->sta_bssid[session_id],
1210 hdr->bssId)) {
1211 return true;
1212 }
1213 }
1214 }
1215
1216 /*
1217 * If any IBSS session exists and beacon is has IBSS capability set
1218 * and SSID matches the IBSS SSID, allow the frame
1219 */
1220 if (filter->num_ibss_sessions) {
1221 body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
1222 frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
1223 if (frame_len < SIR_MAC_B_PR_SSID_OFFSET)
1224 return false;
1225
1226 bcn_caps = (tpSirMacCapabilityInfo)
1227 (body + SIR_MAC_B_PR_CAPAB_OFFSET);
1228 if (!bcn_caps->ibss)
1229 return false;
1230
1231 ssid_ie = wlan_get_ie_ptr_from_eid(SIR_MAC_SSID_EID,
1232 body + SIR_MAC_B_PR_SSID_OFFSET,
1233 frame_len);
1234
1235 if (!ssid_ie)
1236 return false;
1237
1238 bcn_ssid.length = ssid_ie[1];
1239 qdf_mem_copy(&bcn_ssid.ssId,
1240 &ssid_ie[2],
1241 bcn_ssid.length);
1242
1243 for (session_id = 0; session_id < SIR_MAX_SUPPORTED_BSS;
1244 session_id++) {
1245 if (filter->ibss_ssid[session_id].length ==
1246 bcn_ssid.length &&
1247 (!qdf_mem_cmp(filter->ibss_ssid[session_id].ssId,
1248 bcn_ssid.ssId, bcn_ssid.length))) {
1249 return true;
1250 }
1251 }
1252 }
1253
1254 return false;
1255}
1256
Vignesh Viswanathan18eb2b22018-05-08 19:34:56 +05301257static QDF_STATUS pe_handle_probe_req_frames(tpAniSirGlobal mac_ctx,
1258 cds_pkt_t *pkt)
1259{
1260 QDF_STATUS status;
1261 struct scheduler_msg msg = {0};
1262
1263 /* Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG */
1264 msg.type = SIR_BB_XPORT_MGMT_MSG;
1265 msg.bodyptr = pkt;
1266 msg.bodyval = 0;
1267 msg.callback = pe_mc_process_handler;
1268
1269 status = scheduler_post_msg(QDF_MODULE_ID_SCAN, &msg);
1270
1271 if (!QDF_IS_STATUS_SUCCESS(status))
1272 pe_err_rl("Failed to post probe req frame to Scan Queue");
1273
1274 return status;
1275}
1276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277/* --------------------------------------------------------------------------- */
1278/**
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301279 * pe_handle_mgmt_frame() - Process the Management frames from TXRX
1280 * @psoc: psoc context
1281 * @peer: peer
1282 * @buf: buffer
1283 * @mgmt_rx_params; rx event params
1284 * @frm_type: frame type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301286 * This function handles the mgmt rx frame from mgmt txrx component and forms
1287 * a cds packet and schedule it in controller thread for further processing.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301289 * Return: QDF_STATUS_SUCCESS - in case of success
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 */
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301291static QDF_STATUS pe_handle_mgmt_frame(struct wlan_objmgr_psoc *psoc,
1292 struct wlan_objmgr_peer *peer, qdf_nbuf_t buf,
Himanshu Agarwald2e6cde2017-01-10 14:47:04 +05301293 struct mgmt_rx_event_params *mgmt_rx_params,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301294 uint32_t frm_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295{
1296 tpAniSirGlobal pMac;
1297 tpSirMacMgmtHdr mHdr;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001298 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 cds_pkt_t *pVosPkt;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301300 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 uint8_t *pRxPacketInfo;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301302 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303
Anurag Chouhan6d760662016-02-20 16:05:43 +05301304 pMac = cds_get_context(QDF_MODULE_ID_PE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 if (NULL == pMac) {
1306 /* cannot log a failure without a valid pMac */
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301307 qdf_nbuf_free(buf);
1308 return QDF_STATUS_E_FAILURE;
1309 }
1310
1311 pVosPkt = qdf_mem_malloc(sizeof(*pVosPkt));
1312 if (!pVosPkt) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001313 pe_err("Failed to allocate rx packet");
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301314 qdf_nbuf_free(buf);
1315 return QDF_STATUS_E_NOMEM;
1316 }
1317
1318 ret = wma_form_rx_packet(buf, mgmt_rx_params, pVosPkt);
1319 if (ret) {
Dustin Brown897dae42018-03-13 17:08:47 -07001320 pe_err_rl("Failed to fill cds packet from event buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301321 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 }
1323
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301324 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 wma_ds_peek_rx_packet_info(pVosPkt, (void *)&pRxPacketInfo, false);
1326
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301327 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 cds_pkt_return_packet(pVosPkt);
1329 pVosPkt = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301330 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 }
1332
1333 /*
1334 * The MPDU header is now present at a certain "offset" in
1335 * the BD and is specified in the BD itself
1336 */
1337
1338 mHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301340 /*
1341 * Filter the beacon/probe response frames before posting it
1342 * on the PE queue
1343 */
1344 if ((mHdr->fc.subType == SIR_MAC_MGMT_BEACON ||
1345 mHdr->fc.subType == SIR_MAC_MGMT_PROBE_RSP) &&
1346 !pe_filter_bcn_probe_frame(pMac, mHdr, pRxPacketInfo)) {
1347 cds_pkt_return_packet(pVosPkt);
1348 pVosPkt = NULL;
1349 return QDF_STATUS_SUCCESS;
1350 }
1351
Vignesh Viswanathan18eb2b22018-05-08 19:34:56 +05301352 /*
1353 * Post Probe Req frames to Scan queue and return
1354 */
1355 if (mHdr->fc.subType == SIR_MAC_MGMT_PROBE_REQ) {
1356 qdf_status = pe_handle_probe_req_frames(pMac, pVosPkt);
1357 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
1358 cds_pkt_return_packet(pVosPkt);
1359 pVosPkt = NULL;
1360 }
1361 return qdf_status;
1362 }
1363
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301364 if (QDF_STATUS_SUCCESS !=
1365 pe_drop_pending_rx_mgmt_frames(pMac, mHdr, pVosPkt))
1366 return QDF_STATUS_E_FAILURE;
1367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 /* Forward to MAC via mesg = SIR_BB_XPORT_MGMT_MSG */
1369 msg.type = SIR_BB_XPORT_MGMT_MSG;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301370 msg.bodyptr = pVosPkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 msg.bodyval = 0;
1372
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001373 if (QDF_STATUS_SUCCESS != sys_bbt_process_message_core(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 &msg,
1375 mHdr->fc.type,
1376 mHdr->fc.subType)) {
1377 cds_pkt_return_packet(pVosPkt);
1378 pVosPkt = NULL;
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05301379 /*
1380 * Decrement sys_bbt_pending_mgmt_count if packet
1381 * is dropped before posting to LIM
1382 */
1383 lim_decrement_pending_mgmt_count(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301384 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 }
1386
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301387 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388}
1389
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301390void pe_register_mgmt_rx_frm_callback(tpAniSirGlobal mac_ctx)
1391{
1392 QDF_STATUS status;
1393 struct mgmt_txrx_mgmt_frame_cb_info frm_cb_info;
1394
1395 frm_cb_info.frm_type = MGMT_FRAME_TYPE_ALL;
1396 frm_cb_info.mgmt_rx_cb = (mgmt_frame_rx_callback)
1397 pe_handle_mgmt_frame;
1398
1399 status = wlan_mgmt_txrx_register_rx_cb(mac_ctx->psoc,
1400 WLAN_UMAC_COMP_MLME, &frm_cb_info, 1);
1401 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001402 pe_err("Registering the PE Handle with MGMT TXRX layer has failed");
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301403
1404 wma_register_mgmt_frm_client();
1405}
1406
1407void pe_deregister_mgmt_rx_frm_callback(tpAniSirGlobal mac_ctx)
1408{
1409 QDF_STATUS status;
1410 struct mgmt_txrx_mgmt_frame_cb_info frm_cb_info;
1411
1412 frm_cb_info.frm_type = MGMT_FRAME_TYPE_ALL;
1413 frm_cb_info.mgmt_rx_cb = (mgmt_frame_rx_callback)
1414 pe_handle_mgmt_frame;
1415
1416 status = wlan_mgmt_txrx_deregister_rx_cb(mac_ctx->psoc,
1417 WLAN_UMAC_COMP_MLME, &frm_cb_info, 1);
1418 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001419 pe_err("Deregistering the PE Handle with MGMT TXRX layer has failed");
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05301420
1421 wma_de_register_mgmt_frm_client();
1422}
1423
1424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425/**
Naveen Rawat0fc3f692016-06-22 14:30:54 -07001426 * pe_register_callbacks_with_wma() - register SME and PE callback functions to
1427 * WMA.
Jeff Johnson82b0c622016-10-07 07:53:55 -07001428 * (function documentation in lim_api.h)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 */
Naveen Rawat0fc3f692016-06-22 14:30:54 -07001430void pe_register_callbacks_with_wma(tpAniSirGlobal pMac,
1431 tSirSmeReadyReq *ready_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432{
Jeff Johnsona9b66572017-09-02 12:41:21 -07001433 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434
Jeff Johnsona9b66572017-09-02 12:41:21 -07001435 status = wma_register_roaming_callbacks(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001436 ready_req->csr_roam_synch_cb,
1437 ready_req->pe_roam_synch_cb);
Jeff Johnsona9b66572017-09-02 12:41:21 -07001438 if (status != QDF_STATUS_SUCCESS)
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301439 pe_err("Registering roaming callbacks with WMA failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440}
1441
1442/**
1443 * lim_is_system_in_scan_state()
1444 *
1445 ***FUNCTION:
1446 * This function is called by various MAC software modules to
1447 * determine if System is in Scan/Learn state
1448 *
1449 ***LOGIC:
1450 * NA
1451 *
1452 ***ASSUMPTIONS:
1453 * NA
1454 *
1455 ***NOTE:
1456 *
1457 * @param pMac - Pointer to Global MAC structure
1458 * @return true - System is in Scan/Learn state
1459 * false - System is NOT in Scan/Learn state
1460 */
1461
1462uint8_t lim_is_system_in_scan_state(tpAniSirGlobal pMac)
1463{
1464 switch (pMac->lim.gLimSmeState) {
1465 case eLIM_SME_CHANNEL_SCAN_STATE:
1466 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
1467 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
1468 case eLIM_SME_WT_SCAN_STATE:
1469 /* System is in Learn mode */
1470 return true;
1471
1472 default:
1473 /* System is NOT in Learn mode */
1474 return false;
1475 }
1476} /*** end lim_is_system_in_scan_state() ***/
1477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478/**
1479 *\brief lim_received_hb_handler()
1480 *
1481 * This function is called by sch_beacon_process() upon
1482 * receiving a Beacon on STA. This also gets called upon
1483 * receiving Probe Response after heat beat failure is
1484 * detected.
1485 *
1486 * param pMac - global mac structure
1487 * param channel - channel number indicated in Beacon, Probe Response
1488 * return - none
1489 */
1490
1491void
1492lim_received_hb_handler(tpAniSirGlobal pMac, uint8_t channelId,
1493 tpPESession psessionEntry)
1494{
1495 if ((channelId == 0)
1496 || (channelId == psessionEntry->currentOperChannel))
1497 psessionEntry->LimRxedBeaconCntDuringHB++;
1498
1499 psessionEntry->pmmOffloadInfo.bcnmiss = false;
1500} /*** lim_init_wds_info_params() ***/
1501
1502/** -------------------------------------------------------------
1503 \fn lim_update_overlap_sta_param
1504 \brief Updates overlap cache and param data structure
1505 \param tpAniSirGlobal pMac
1506 \param tSirMacAddr bssId
1507 \param tpLimProtStaParams pStaParams
1508 \return None
1509 -------------------------------------------------------------*/
1510void
1511lim_update_overlap_sta_param(tpAniSirGlobal pMac, tSirMacAddr bssId,
1512 tpLimProtStaParams pStaParams)
1513{
1514 int i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 if (!pStaParams->numSta) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301517 qdf_mem_copy(pMac->lim.protStaOverlapCache[0].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 bssId, sizeof(tSirMacAddr));
1519 pMac->lim.protStaOverlapCache[0].active = true;
1520
1521 pStaParams->numSta = 1;
1522
1523 return;
1524 }
1525
1526 for (i = 0; i < LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++) {
1527 if (pMac->lim.protStaOverlapCache[i].active) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301528 if (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 (pMac->lim.protStaOverlapCache[i].addr, bssId,
1530 sizeof(tSirMacAddr))) {
1531 return;
1532 }
1533 } else
1534 break;
1535 }
1536
1537 if (i == LIM_PROT_STA_OVERLAP_CACHE_SIZE) {
Abhishek Singhe156ea32017-05-02 17:07:30 +05301538 pe_debug("Overlap cache is full");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301540 qdf_mem_copy(pMac->lim.protStaOverlapCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 bssId, sizeof(tSirMacAddr));
1542 pMac->lim.protStaOverlapCache[i].active = true;
1543
1544 pStaParams->numSta++;
1545 }
1546}
1547
1548/**
1549 * lim_ibss_enc_type_matched
1550 *
1551 ***FUNCTION:
1552 * This function compares the encryption type of the peer with self
1553 * while operating in IBSS mode and detects mismatch.
1554 *
1555 ***LOGIC:
1556 *
1557 ***ASSUMPTIONS:
1558 *
1559 ***NOTE:
1560 *
1561 * @param pBeacon - Parsed Beacon Frame structure
1562 * @param pSession - Pointer to the PE session
1563 *
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001564 * @return true if encryption type is matched; false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 */
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001566static bool lim_ibss_enc_type_matched(tpSchBeaconStruct pBeacon,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 tpPESession pSession)
1568{
1569 if (!pBeacon || !pSession)
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001570 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571
1572 /* Open case */
1573 if (pBeacon->capabilityInfo.privacy == 0
1574 && pSession->encryptType == eSIR_ED_NONE)
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001575 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576
1577 /* WEP case */
1578 if (pBeacon->capabilityInfo.privacy == 1 && pBeacon->wpaPresent == 0
1579 && pBeacon->rsnPresent == 0
1580 && (pSession->encryptType == eSIR_ED_WEP40
1581 || pSession->encryptType == eSIR_ED_WEP104))
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001582 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583
1584 /* WPA-None case */
1585 if (pBeacon->capabilityInfo.privacy == 1 && pBeacon->wpaPresent == 1
1586 && pBeacon->rsnPresent == 0
1587 && ((pSession->encryptType == eSIR_ED_CCMP) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05301588 (pSession->encryptType == eSIR_ED_GCMP) ||
1589 (pSession->encryptType == eSIR_ED_GCMP_256) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 (pSession->encryptType == eSIR_ED_TKIP)))
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001591 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001593 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594}
1595
1596/**
1597 * lim_handle_ibs_scoalescing()
1598 *
1599 ***FUNCTION:
1600 * This function is called upon receiving Beacon/Probe Response
1601 * while operating in IBSS mode.
1602 *
1603 ***LOGIC:
1604 *
1605 ***ASSUMPTIONS:
1606 *
1607 ***NOTE:
1608 *
1609 * @param pMac - Pointer to Global MAC structure
1610 * @param pBeacon - Parsed Beacon Frame structure
1611 * @param pRxPacketInfo - Pointer to RX packet info structure
1612 *
1613 * @return Status whether to process or ignore received Beacon Frame
1614 */
1615
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001616QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617lim_handle_ibss_coalescing(tpAniSirGlobal pMac,
1618 tpSchBeaconStruct pBeacon,
1619 uint8_t *pRxPacketInfo, tpPESession psessionEntry)
1620{
1621 tpSirMacMgmtHdr pHdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001622 QDF_STATUS retCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623
1624 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
1625
1626 /* Ignore the beacon when any of the conditions below is met:
1627 1. The beacon claims no IBSS network
1628 2. SSID in the beacon does not match SSID of self station
1629 3. Operational channel in the beacon does not match self station
1630 4. Encyption type in the beacon does not match with self station
1631 */
1632 if ((!pBeacon->capabilityInfo.ibss) ||
Ankit Guptad66a8812016-09-15 11:00:16 -07001633 lim_cmp_ssid(&pBeacon->ssId, psessionEntry) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 (psessionEntry->currentOperChannel != pBeacon->channelNumber))
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001635 retCode = QDF_STATUS_E_INVAL;
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001636 else if (lim_ibss_enc_type_matched(pBeacon, psessionEntry) != true) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301637 pe_debug("peer privacy: %d peer wpa: %d peer rsn: %d self encType: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 pBeacon->capabilityInfo.privacy,
1639 pBeacon->wpaPresent, pBeacon->rsnPresent,
1640 psessionEntry->encryptType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001641 retCode = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 } else {
1643 uint32_t ieLen;
1644 uint16_t tsfLater;
1645 uint8_t *pIEs;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 ieLen = WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
1648 tsfLater = WMA_GET_RX_TSF_LATER(pRxPacketInfo);
1649 pIEs = WMA_GET_RX_MPDU_DATA(pRxPacketInfo);
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301650 pe_debug("BEFORE Coalescing tsfLater val: %d", tsfLater);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 retCode =
1652 lim_ibss_coalesce(pMac, pHdr, pBeacon, pIEs, ieLen, tsfLater,
1653 psessionEntry);
1654 }
1655 return retCode;
1656} /*** end lim_handle_ibs_scoalescing() ***/
1657
1658/**
1659 * lim_enc_type_matched() - matches security type of incoming beracon with
1660 * current
1661 * @mac_ctx Pointer to Global MAC structure
1662 * @bcn Pointer to parsed Beacon structure
1663 * @session PE session entry
1664 *
1665 * This function matches security type of incoming beracon with current
1666 *
1667 * @return true if matched, false otherwise
1668 */
1669static bool
1670lim_enc_type_matched(tpAniSirGlobal mac_ctx,
1671 tpSchBeaconStruct bcn,
1672 tpPESession session)
1673{
1674 if (!bcn || !session)
1675 return false;
1676
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301677 pe_debug("Beacon/Probe:: Privacy: %d WPA Present: %d RSN Present: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 bcn->capabilityInfo.privacy, bcn->wpaPresent, bcn->rsnPresent);
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301679 pe_debug("session:: Privacy: %d EncyptionType: %d OSEN: %d WPS: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 SIR_MAC_GET_PRIVACY(session->limCurrentBssCaps),
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301681 session->encryptType, session->isOSENConnection,
1682 session->wps_registration);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683
1684 /*
1685 * This is handled by sending probe req due to IOT issues so
1686 * return TRUE
1687 */
1688 if ((bcn->capabilityInfo.privacy) !=
1689 SIR_MAC_GET_PRIVACY(session->limCurrentBssCaps)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301690 pe_warn("Privacy bit miss match");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 return true;
1692 }
1693
1694 /* Open */
1695 if ((bcn->capabilityInfo.privacy == 0) &&
1696 (session->encryptType == eSIR_ED_NONE))
1697 return true;
1698
1699 /* WEP */
1700 if ((bcn->capabilityInfo.privacy == 1) &&
1701 (bcn->wpaPresent == 0) && (bcn->rsnPresent == 0) &&
1702 ((session->encryptType == eSIR_ED_WEP40) ||
1703 (session->encryptType == eSIR_ED_WEP104)
1704#ifdef FEATURE_WLAN_WAPI
1705 || (session->encryptType == eSIR_ED_WPI)
1706#endif
1707 ))
1708 return true;
1709
1710 /* WPA OR RSN*/
1711 if ((bcn->capabilityInfo.privacy == 1) &&
1712 ((bcn->wpaPresent == 1) || (bcn->rsnPresent == 1)) &&
1713 ((session->encryptType == eSIR_ED_TKIP) ||
1714 (session->encryptType == eSIR_ED_CCMP) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05301715 (session->encryptType == eSIR_ED_GCMP) ||
1716 (session->encryptType == eSIR_ED_GCMP_256) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 (session->encryptType == eSIR_ED_AES_128_CMAC)))
1718 return true;
1719
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301720 /*
1721 * For HS2.0, RSN ie is not present
Abhishek Singh4560fa02016-08-29 12:45:38 +05301722 * in beacon. Therefore no need to
1723 * check for security type in case
1724 * OSEN session.
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301725 * For WPS registration session no need to detect
1726 * detect security mismatch as it wont match and
1727 * driver may end up sending probe request without
1728 * WPS IE during WPS registration process.
Abhishek Singh4560fa02016-08-29 12:45:38 +05301729 */
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301730 if (session->isOSENConnection ||
1731 session->wps_registration)
Abhishek Singh4560fa02016-08-29 12:45:38 +05301732 return true;
1733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 return false;
1735}
1736
1737/**
1738 * lim_detect_change_in_ap_capabilities()
1739 *
1740 ***FUNCTION:
1741 * This function is called while SCH is processing
1742 * received Beacon from AP on STA to detect any
1743 * change in AP's capabilities. If there any change
1744 * is detected, Roaming is informed of such change
1745 * so that it can trigger reassociation.
1746 *
1747 ***LOGIC:
1748 *
1749 ***ASSUMPTIONS:
1750 *
1751 ***NOTE:
1752 * Notification is enabled for STA product only since
1753 * it is not a requirement on BP side.
1754 *
1755 * @param pMac Pointer to Global MAC structure
1756 * @param pBeacon Pointer to parsed Beacon structure
1757 * @return None
1758 */
1759
1760void
1761lim_detect_change_in_ap_capabilities(tpAniSirGlobal pMac,
1762 tpSirProbeRespBeacon pBeacon,
1763 tpPESession psessionEntry)
1764{
1765 uint8_t len;
1766 tSirSmeApNewCaps apNewCaps;
1767 uint8_t newChannel;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001768 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 bool security_caps_matched = true;
1770
1771 apNewCaps.capabilityInfo =
1772 lim_get_u16((uint8_t *) &pBeacon->capabilityInfo);
1773 newChannel = (uint8_t) pBeacon->channelNumber;
1774
1775 security_caps_matched = lim_enc_type_matched(pMac, pBeacon,
1776 psessionEntry);
1777 if ((false == psessionEntry->limSentCapsChangeNtf) &&
1778 (((!lim_is_null_ssid(&pBeacon->ssId)) &&
Ankit Guptad66a8812016-09-15 11:00:16 -07001779 lim_cmp_ssid(&pBeacon->ssId, psessionEntry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
1781 SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
1782 (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
1783 SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
1784 (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
1785 SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
1786 (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
1787 SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
1788 ((newChannel != psessionEntry->currentOperChannel) &&
1789 (newChannel != 0)) ||
1790 (false == security_caps_matched)
1791 ))) {
1792 if (false == psessionEntry->fWaitForProbeRsp) {
1793 /* If Beacon capabilities is not matching with the current capability,
1794 * then send unicast probe request to AP and take decision after
1795 * receiving probe response */
1796 if (true == psessionEntry->fIgnoreCapsChange) {
Arif Hussain458ad462018-05-11 11:14:38 -07001797 pe_debug("Ignoring the Capability change as it is false alarm");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 return;
1799 }
1800 psessionEntry->fWaitForProbeRsp = true;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301801 pe_warn("AP capabilities are not matching, sending directed probe request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 status =
1803 lim_send_probe_req_mgmt_frame(pMac, &psessionEntry->ssId,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -07001804 psessionEntry->bssId,
1805 psessionEntry->currentOperChannel,
1806 psessionEntry->selfMacAddr,
1807 psessionEntry->dot11mode,
1808 NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001810 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301811 pe_err("send ProbeReq failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 psessionEntry->fWaitForProbeRsp = false;
1813 }
1814 return;
1815 }
1816 /**
1817 * BSS capabilities have changed.
1818 * Inform Roaming.
1819 */
1820 len = sizeof(tSirMacCapabilityInfo) + sizeof(tSirMacAddr) + sizeof(uint8_t) + 3 * sizeof(uint8_t) + /* reserved fields */
1821 pBeacon->ssId.length + 1;
1822
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301823 qdf_mem_copy(apNewCaps.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301824 psessionEntry->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 if (newChannel != psessionEntry->currentOperChannel) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301826 pe_err("Channel Change from %d --> %d Ignoring beacon!",
Nishank Aggarwal8d4c7202017-03-10 13:13:54 +05301827 psessionEntry->currentOperChannel, newChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 return;
1829 }
1830
1831 /**
1832 * When Cisco 1262 Enterprise APs are configured with WPA2-PSK with
1833 * AES+TKIP Pairwise ciphers and WEP-40 Group cipher, they do not set
1834 * the privacy bit in Beacons (wpa/rsnie is still present in beacons),
1835 * the privacy bit is set in Probe and association responses.
1836 * Due to this anomaly, we detect a change in
1837 * AP capabilities when we receive a beacon after association and
1838 * disconnect from the AP. The following check makes sure that we can
1839 * connect to such APs
1840 */
1841 else if ((SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) == 0) &&
1842 (pBeacon->rsnPresent || pBeacon->wpaPresent)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301843 pe_err("BSS Caps (Privacy) bit 0 in beacon, but WPA or RSN IE present, Ignore Beacon!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 return;
1845 } else
1846 apNewCaps.channelId = psessionEntry->currentOperChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301847 qdf_mem_copy((uint8_t *) &apNewCaps.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 (uint8_t *) &pBeacon->ssId,
1849 pBeacon->ssId.length + 1);
1850
1851 psessionEntry->fIgnoreCapsChange = false;
1852 psessionEntry->fWaitForProbeRsp = false;
1853 psessionEntry->limSentCapsChangeNtf = true;
1854 lim_send_sme_wm_status_change_ntf(pMac, eSIR_SME_AP_CAPS_CHANGED,
1855 (uint32_t *) &apNewCaps,
1856 len, psessionEntry->smeSessionId);
1857 } else if (true == psessionEntry->fWaitForProbeRsp) {
1858 /* Only for probe response frames and matching capabilities the control
1859 * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
1860 * will be false, the control will not come here*/
1861
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301862 pe_debug("capabilities in probe response are"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 "matching with the current setting,"
1864 "Ignoring subsequent capability"
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301865 "mismatch");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 psessionEntry->fIgnoreCapsChange = true;
1867 psessionEntry->fWaitForProbeRsp = false;
1868 }
1869
1870} /*** lim_detect_change_in_ap_capabilities() ***/
1871
1872/* --------------------------------------------------------------------- */
1873/**
1874 * lim_update_short_slot
1875 *
1876 * FUNCTION:
1877 * Enable/Disable short slot
1878 *
1879 * LOGIC:
1880 *
1881 * ASSUMPTIONS:
1882 *
1883 * NOTE:
1884 *
1885 * @param enable Flag to enable/disable short slot
1886 * @return None
1887 */
1888
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001889QDF_STATUS lim_update_short_slot(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 tpSirProbeRespBeacon pBeacon,
1891 tpUpdateBeaconParams pBeaconParams,
1892 tpPESession psessionEntry)
1893{
1894
1895 tSirSmeApNewCaps apNewCaps;
1896 uint32_t nShortSlot;
1897 uint32_t val = 0;
1898 uint32_t phyMode;
1899
1900 /* Check Admin mode first. If it is disabled just return */
1901 if (wlan_cfg_get_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001902 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301903 pe_err("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001904 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 }
1906 if (val == false)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001907 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908
1909 /* Check for 11a mode or 11b mode. In both cases return since slot time is constant and cannot/should not change in beacon */
1910 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
1911 if ((phyMode == WNI_CFG_PHY_MODE_11A)
1912 || (phyMode == WNI_CFG_PHY_MODE_11B))
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001913 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914
1915 apNewCaps.capabilityInfo =
1916 lim_get_u16((uint8_t *) &pBeacon->capabilityInfo);
1917
1918 /* Earlier implementation: determine the appropriate short slot mode based on AP advertised modes */
1919 /* when erp is present, apply short slot always unless, prot=on && shortSlot=off */
1920 /* if no erp present, use short slot based on current ap caps */
1921
1922 /* Issue with earlier implementation : Cisco 1231 BG has shortSlot = 0, erpIEPresent and useProtection = 0 (Case4); */
1923
1924 /* Resolution : always use the shortSlot setting the capability info to decide slot time. */
1925 /* The difference between the earlier implementation and the new one is only Case4. */
1926 /*
1927 ERP IE Present | useProtection | shortSlot = QC STA Short Slot
1928 Case1 1 1 1 1 //AP should not advertise this combination.
1929 Case2 1 1 0 0
1930 Case3 1 0 1 1
1931 Case4 1 0 0 0
1932 Case5 0 1 1 1
1933 Case6 0 1 0 0
1934 Case7 0 0 1 1
1935 Case8 0 0 0 0
1936 */
1937 nShortSlot = SIR_MAC_GET_SHORT_SLOT_TIME(apNewCaps.capabilityInfo);
1938
1939 if (nShortSlot != psessionEntry->shortSlotTimeSupported) {
1940 /* Short slot time capability of AP has changed. Adopt to it. */
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301941 pe_debug("Shortslot capability of AP changed: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 nShortSlot);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 ((tpSirMacCapabilityInfo) & psessionEntry->
1944 limCurrentBssCaps)->shortSlotTime = (uint16_t) nShortSlot;
1945 psessionEntry->shortSlotTimeSupported = nShortSlot;
1946 pBeaconParams->fShortSlotTime = (uint8_t) nShortSlot;
1947 pBeaconParams->paramChangeBitmap |=
1948 PARAM_SHORT_SLOT_TIME_CHANGED;
1949 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001950 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951}
1952
1953
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001954void lim_send_heart_beat_timeout_ind(tpAniSirGlobal pMac,
1955 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956{
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001957 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001958 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959
1960 /* Prepare and post message to LIM Message Queue */
1961 msg.type = (uint16_t) SIR_LIM_HEART_BEAT_TIMEOUT;
1962 msg.bodyptr = psessionEntry;
1963 msg.bodyval = 0;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301964 pe_err("Heartbeat failure from Fw");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001966 status = lim_post_msg_api(pMac, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001968 if (status != QDF_STATUS_SUCCESS) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301969 pe_err("posting message: %X to LIM failed, reason: %d",
Jeff Johnsonc9f44622018-06-29 14:18:53 -07001970 msg.type, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 }
1972}
1973
1974/**
1975 * lim_ps_offload_handle_missed_beacon_ind(): handles missed beacon indication
1976 * @pMac : global mac context
1977 * @pMsg: message
1978 *
1979 * This function process the SIR_HAL_MISSED_BEACON_IND
1980 * message from HAL, to do active AP probing.
1981 *
1982 * Return: void
1983 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001984void lim_ps_offload_handle_missed_beacon_ind(tpAniSirGlobal pMac,
1985 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986{
1987 tpSirSmeMissedBeaconInd pSirMissedBeaconInd =
1988 (tpSirSmeMissedBeaconInd) pMsg->bodyptr;
1989 tpPESession psessionEntry =
1990 pe_find_session_by_bss_idx(pMac, pSirMissedBeaconInd->bssIdx);
1991
1992 if (!psessionEntry) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301993 pe_err("session does not exist for given BSSId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 return;
1995 }
1996
1997 /* Set Beacon Miss in Powersave Offload */
1998 psessionEntry->pmmOffloadInfo.bcnmiss = true;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05301999 pe_err("Received Heart Beat Failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000
2001 /* Do AP probing immediately */
2002 lim_send_heart_beat_timeout_ind(pMac, psessionEntry);
2003 return;
2004}
2005
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002006#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2007/**
2008 * lim_fill_join_rsp_ht_caps() - Fill the HT caps in join response
2009 * @session: PE Session
2010 * @join_rsp: Join response buffer to be filled up.
2011 *
2012 * Return: None
2013 */
2014void lim_fill_join_rsp_ht_caps(tpPESession session, tpSirSmeJoinRsp join_rsp)
2015{
2016 tSirSmeHTProfile *ht_profile;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002017
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002018 if (session == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302019 pe_err("Invalid Session");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002020 return;
2021 }
2022 if (join_rsp == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302023 pe_err("Invalid Join Response");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002024 return;
2025 }
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302026
2027 if (session->cc_switch_mode == QDF_MCC_TO_SCC_SWITCH_DISABLE)
2028 return;
2029
2030 ht_profile = &join_rsp->HTProfile;
2031 ht_profile->htSupportedChannelWidthSet =
2032 session->htSupportedChannelWidthSet;
2033 ht_profile->htRecommendedTxWidthSet =
2034 session->htRecommendedTxWidthSet;
2035 ht_profile->htSecondaryChannelOffset =
2036 session->htSecondaryChannelOffset;
2037 ht_profile->dot11mode = session->dot11mode;
2038 ht_profile->htCapability = session->htCapability;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002039 ht_profile->vhtCapability = session->vhtCapability;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002040 ht_profile->apCenterChan = session->ch_center_freq_seg0;
2041 ht_profile->apChanWidth = session->ch_width;
2042}
2043#endif
2044
Krunal Soni4bfecf62017-06-05 15:26:35 -07002045#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Selvaraj, Sridhar6f97f412017-05-26 19:32:05 +05302046/**
2047 * sir_parse_bcn_fixed_fields() - Parse fixed fields in Beacon IE's
2048 *
2049 * @mac_ctx: MAC Context
2050 * @beacon_struct: Beacon/Probe Response structure
2051 * @buf: Fixed Fields buffer
2052 */
2053static void sir_parse_bcn_fixed_fields(tpAniSirGlobal mac_ctx,
2054 tpSirProbeRespBeacon beacon_struct,
2055 uint8_t *buf)
2056{
2057 tDot11fFfCapabilities dst;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002058
Selvaraj, Sridhar6f97f412017-05-26 19:32:05 +05302059 beacon_struct->timeStamp[0] = lim_get_u32(buf);
2060 beacon_struct->timeStamp[1] = lim_get_u32(buf + 4);
2061 buf += 8;
2062
2063 beacon_struct->beaconInterval = lim_get_u16(buf);
2064 buf += 2;
2065
2066 dot11f_unpack_ff_capabilities(mac_ctx, buf, &dst);
2067
2068 sir_copy_caps_info(mac_ctx, dst, beacon_struct);
2069}
2070
Jeff Johnson82b0c622016-10-07 07:53:55 -07002071static QDF_STATUS
2072lim_roam_fill_bss_descr(tpAniSirGlobal pMac,
2073 roam_offload_synch_ind *roam_offload_synch_ind_ptr,
2074 tpSirBssDescription bss_desc_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075{
2076 uint32_t ie_len = 0;
2077 tpSirProbeRespBeacon parsed_frm_ptr;
2078 tpSirMacMgmtHdr mac_hdr;
2079 uint8_t *bcn_proberesp_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080
2081 bcn_proberesp_ptr = (uint8_t *)roam_offload_synch_ind_ptr +
2082 roam_offload_synch_ind_ptr->beaconProbeRespOffset;
2083 mac_hdr = (tpSirMacMgmtHdr)bcn_proberesp_ptr;
2084 parsed_frm_ptr =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302085 (tpSirProbeRespBeacon) qdf_mem_malloc(sizeof(tSirProbeRespBeacon));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 if (NULL == parsed_frm_ptr) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302087 pe_err("fail to allocate memory for frame");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302088 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 }
2090
2091 if (roam_offload_synch_ind_ptr->beaconProbeRespLength <=
2092 SIR_MAC_HDR_LEN_3A) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302093 pe_err("%s: very few bytes in synchInd beacon / probe resp frame! length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 __func__, roam_offload_synch_ind_ptr->beaconProbeRespLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302095 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302096 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 }
2098
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302099 pe_debug("LFR3:Beacon/Prb Rsp: %d", roam_offload_synch_ind_ptr->isBeacon);
Nishank Aggarwal8d4c7202017-03-10 13:13:54 +05302100 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 bcn_proberesp_ptr, roam_offload_synch_ind_ptr->beaconProbeRespLength);
2102 if (roam_offload_synch_ind_ptr->isBeacon) {
2103 if (sir_parse_beacon_ie(pMac, parsed_frm_ptr,
2104 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A +
2105 SIR_MAC_B_PR_SSID_OFFSET],
2106 roam_offload_synch_ind_ptr->beaconProbeRespLength -
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002107 SIR_MAC_HDR_LEN_3A) != QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 !parsed_frm_ptr->ssidPresent) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302109 pe_err("Parse error Beacon, length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 roam_offload_synch_ind_ptr->beaconProbeRespLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302111 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302112 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 }
2114 } else {
2115 if (sir_convert_probe_frame2_struct(pMac,
2116 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A],
2117 roam_offload_synch_ind_ptr->beaconProbeRespLength -
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002118 SIR_MAC_HDR_LEN_3A, parsed_frm_ptr) != QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 !parsed_frm_ptr->ssidPresent) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302120 pe_err("Parse error ProbeResponse, length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 roam_offload_synch_ind_ptr->beaconProbeRespLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302122 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302123 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 }
2125 }
Selvaraj, Sridhar6f97f412017-05-26 19:32:05 +05302126
2127 /*
2128 * For probe response, unpack core parses beacon interval, capabilities,
2129 * timestamp. For beacon IEs, these fields are not parsed.
2130 */
2131 if (roam_offload_synch_ind_ptr->isBeacon)
2132 sir_parse_bcn_fixed_fields(pMac, parsed_frm_ptr,
2133 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A]);
2134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 /* 24 byte MAC header and 12 byte to ssid IE */
2136 if (roam_offload_synch_ind_ptr->beaconProbeRespLength >
2137 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET)) {
2138 ie_len = roam_offload_synch_ind_ptr->beaconProbeRespLength -
2139 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET);
2140 }
2141 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 * Length of BSS desription is without length of
2143 * length itself and length of pointer
2144 * that holds ieFields
2145 *
2146 * tSirBssDescription
2147 * +--------+---------------------------------+---------------+
2148 * | length | other fields | pointer to IEs|
2149 * +--------+---------------------------------+---------------+
2150 * ^
2151 * ieFields
2152 */
2153 bss_desc_ptr->length = (uint16_t) (offsetof(tSirBssDescription,
2154 ieFields[0]) -
2155 sizeof(bss_desc_ptr->length) + ie_len);
2156
Abhishek Singhc4a864b2017-04-17 17:09:52 +05302157 bss_desc_ptr->fProbeRsp = !roam_offload_synch_ind_ptr->isBeacon;
2158 /* Copy Timestamp */
2159 bss_desc_ptr->scansystimensec = qdf_get_monotonic_boottime_ns();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 if (parsed_frm_ptr->dsParamsPresent) {
2161 bss_desc_ptr->channelId = parsed_frm_ptr->channelNumber;
2162 } else if (parsed_frm_ptr->HTInfo.present) {
2163 bss_desc_ptr->channelId = parsed_frm_ptr->HTInfo.primaryChannel;
2164 } else {
2165 /*
2166 * If DS Params or HTIE is not present in the probe resp or
2167 * beacon, then use the channel frequency provided by firmware
2168 * to fill the channel in the BSS descriptor.*/
2169 bss_desc_ptr->channelId =
2170 cds_freq_to_chan(roam_offload_synch_ind_ptr->chan_freq);
2171 }
2172 bss_desc_ptr->channelIdSelf = bss_desc_ptr->channelId;
2173
Abhishek Singh86dc2212017-11-08 13:57:46 +05302174 bss_desc_ptr->nwType = lim_get_nw_type(pMac, bss_desc_ptr->channelId,
2175 SIR_MAC_MGMT_FRAME,
2176 parsed_frm_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177
2178 bss_desc_ptr->sinr = 0;
2179 bss_desc_ptr->beaconInterval = parsed_frm_ptr->beaconInterval;
2180 bss_desc_ptr->timeStamp[0] = parsed_frm_ptr->timeStamp[0];
2181 bss_desc_ptr->timeStamp[1] = parsed_frm_ptr->timeStamp[1];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302182 qdf_mem_copy(&bss_desc_ptr->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 &bcn_proberesp_ptr[SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_CAPAB_OFFSET], 2);
Abhishek Singhe9a17012017-07-13 16:38:44 +05302184
2185 if (qdf_is_macaddr_zero((struct qdf_mac_addr *)mac_hdr->bssId)) {
2186 pe_debug("bssid is 0 in beacon/probe update it with bssId %pM in sync ind",
2187 roam_offload_synch_ind_ptr->bssid.bytes);
2188 qdf_mem_copy(mac_hdr->bssId,
2189 roam_offload_synch_ind_ptr->bssid.bytes,
2190 sizeof(tSirMacAddr));
2191 }
2192
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_copy((uint8_t *) &bss_desc_ptr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 (uint8_t *) mac_hdr->bssId,
2195 sizeof(tSirMacAddr));
Deepthi Gowri6acee342016-10-28 15:00:38 +05302196 bss_desc_ptr->received_time =
2197 (uint64_t)qdf_mc_timer_get_system_time();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 if (parsed_frm_ptr->mdiePresent) {
2199 bss_desc_ptr->mdiePresent = parsed_frm_ptr->mdiePresent;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302200 qdf_mem_copy((uint8_t *)bss_desc_ptr->mdie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 (uint8_t *)parsed_frm_ptr->mdie,
2202 SIR_MDIE_SIZE);
2203 }
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07002204 pe_debug("LFR3: BssDescr Info:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302205 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 bss_desc_ptr->bssId, sizeof(tSirMacAddr));
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302207 pe_debug("chan: %d rssi: %d", bss_desc_ptr->channelId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 bss_desc_ptr->rssi);
2209 if (ie_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(&bss_desc_ptr->ieFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 bcn_proberesp_ptr +
2212 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET),
2213 ie_len);
2214 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302215 qdf_mem_free(parsed_frm_ptr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302216 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217}
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302218
2219#if defined(WLAN_FEATURE_FILS_SK)
2220/**
2221 * lim_copy_and_free_hlp_data_from_session - Copy HLP info
2222 * @session_ptr: PE session
2223 * @roam_sync_ind_ptr: Roam Synch Indication pointer
2224 *
2225 * This API is used to copy the parsed HLP info from PE session
2226 * to roam synch indication data. THe HLP info is expected to be
2227 * parsed/stored in PE session already from assoc IE's received
2228 * from fw as part of Roam Synch Indication.
2229 *
2230 * Return: None
2231 */
2232static void lim_copy_and_free_hlp_data_from_session(tpPESession session_ptr,
2233 roam_offload_synch_ind *roam_sync_ind_ptr)
2234{
2235 if (session_ptr->hlp_data && session_ptr->hlp_data_len) {
2236 cds_copy_hlp_info(&session_ptr->dst_mac,
2237 &session_ptr->src_mac,
2238 session_ptr->hlp_data_len,
2239 session_ptr->hlp_data,
2240 &roam_sync_ind_ptr->dst_mac,
2241 &roam_sync_ind_ptr->src_mac,
2242 &roam_sync_ind_ptr->hlp_data_len,
2243 roam_sync_ind_ptr->hlp_data);
2244 qdf_mem_free(session_ptr->hlp_data);
2245 session_ptr->hlp_data = NULL;
2246 session_ptr->hlp_data_len = 0;
2247 }
2248}
2249#else
2250static inline void lim_copy_and_free_hlp_data_from_session(
2251 tpPESession session_ptr,
2252 roam_offload_synch_ind
2253 *roam_sync_ind_ptr)
2254{}
2255#endif
2256
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002257/**
2258 * pe_roam_synch_callback() - PE level callback for roam synch propagation
2259 * @mac_ctx: MAC Context
2260 * @roam_sync_ind_ptr: Roam synch indication buffer pointer
2261 * @bss_desc: BSS Descriptor pointer
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002262 * @reason: Reason for calling callback which decides the action to be taken.
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002263 *
2264 * This is a PE level callback called from WMA to complete the roam synch
2265 * propagation at PE level and also fill the BSS descriptor which will be
2266 * helpful further to complete the roam synch propagation.
2267 *
2268 * Return: Success or Failure status
2269 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302270QDF_STATUS pe_roam_synch_callback(tpAniSirGlobal mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002271 roam_offload_synch_ind *roam_sync_ind_ptr,
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002272 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273{
2274 tpPESession session_ptr;
2275 tpPESession ft_session_ptr;
2276 uint8_t session_id;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002277 tpDphHashNode curr_sta_ds;
2278 uint16_t aid;
2279 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302280 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002281 uint16_t join_rsp_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282
2283 if (!roam_sync_ind_ptr) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302284 pe_err("LFR3:roam_sync_ind_ptr is NULL");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002285 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002287 session_ptr = pe_find_session_by_sme_session_id(mac_ctx,
2288 roam_sync_ind_ptr->roamedVdevId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 if (session_ptr == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302290 pe_err("LFR3:Unable to find session");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002291 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 }
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 if (!LIM_IS_STA_ROLE(session_ptr)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302295 pe_err("LFR3:session is not in STA mode");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002296 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 }
Varun Reddy Yeturub5d858e2017-12-15 16:08:13 -08002298
2299 pe_debug("LFR3: PE callback reason: %d", reason);
2300 switch (reason) {
2301 case SIR_ROAMING_START:
2302 session_ptr->fw_roaming_started = true;
2303 return QDF_STATUS_SUCCESS;
2304 case SIR_ROAMING_ABORT:
2305 session_ptr->fw_roaming_started = false;
2306 /*
2307 * If there was a disassoc or deauth that was received
2308 * during roaming and it was not honored, then we have
2309 * to internally initiate a disconnect because with
2310 * ROAM_ABORT we come back to original AP.
2311 */
2312 if (session_ptr->recvd_deauth_while_roaming)
2313 lim_perform_deauth(mac_ctx, session_ptr,
2314 session_ptr->deauth_disassoc_rc,
2315 session_ptr->bssId, 0);
2316 if (session_ptr->recvd_disassoc_while_roaming) {
2317 lim_disassoc_tdls_peers(mac_ctx, session_ptr,
2318 session_ptr->bssId);
2319 lim_perform_disassoc(mac_ctx, 0,
2320 session_ptr->deauth_disassoc_rc,
2321 session_ptr, session_ptr->bssId);
2322 }
2323 return QDF_STATUS_SUCCESS;
2324 case SIR_ROAM_SYNCH_PROPAGATION:
2325 session_ptr->fw_roaming_started = false;
2326 break;
2327 default:
2328 return status;
2329 }
2330
2331 pe_debug("LFR3:Received WMA_ROAM_OFFLOAD_SYNCH_IND LFR3:auth: %d vdevId: %d",
2332 roam_sync_ind_ptr->authStatus, roam_sync_ind_ptr->roamedVdevId);
2333 lim_print_mac_addr(mac_ctx, roam_sync_ind_ptr->bssid.bytes,
2334 QDF_TRACE_LEVEL_DEBUG);
Selvaraj, Sridhara6e3eba2017-03-14 19:52:39 +05302335 /*
2336 * If deauth from AP already in progress, ignore Roam Synch Indication
2337 * from firmware.
2338 */
2339 if (session_ptr->limSmeState != eLIM_SME_LINK_EST_STATE) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302340 pe_err("LFR3: Not in Link est state");
Selvaraj, Sridhara6e3eba2017-03-14 19:52:39 +05302341 return status;
2342 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002343 status = lim_roam_fill_bss_descr(mac_ctx, roam_sync_ind_ptr, bss_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302344 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302345 pe_err("LFR3:Failed to fill Bss Descr");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002346 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302348 status = QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002349 ft_session_ptr = pe_create_session(mac_ctx, bss_desc->bssId,
2350 &session_id, mac_ctx->lim.maxStation,
2351 eSIR_INFRASTRUCTURE_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 if (ft_session_ptr == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302353 pe_err("LFR3:Cannot create PE Session");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002354 lim_print_mac_addr(mac_ctx, bss_desc->bssId, LOGE);
2355 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05302357 /* Update the beacon/probe filter in mac_ctx */
2358 lim_set_bcn_probe_filter(mac_ctx, ft_session_ptr, NULL, 0);
2359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 sir_copy_mac_addr(ft_session_ptr->selfMacAddr, session_ptr->selfMacAddr);
Varun Reddy Yeturu28925b42016-02-08 07:18:50 -08002361 sir_copy_mac_addr(roam_sync_ind_ptr->self_mac.bytes,
2362 session_ptr->selfMacAddr);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002363 sir_copy_mac_addr(ft_session_ptr->limReAssocbssId, bss_desc->bssId);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002364 session_ptr->bRoamSynchInProgress = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 ft_session_ptr->bRoamSynchInProgress = true;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002366 ft_session_ptr->limSystemRole = eLIM_STA_ROLE;
2367 sir_copy_mac_addr(session_ptr->limReAssocbssId, bss_desc->bssId);
2368 ft_session_ptr->csaOffloadEnable = session_ptr->csaOffloadEnable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369
Deepak Dhamdherea7987a22017-07-26 23:06:38 -07002370 /* Assign default configured nss value in the new session */
Naveen Rawat746a90b2017-06-07 15:16:35 -07002371 if (IS_5G_CH(ft_session_ptr->currentOperChannel))
2372 ft_session_ptr->vdev_nss = mac_ctx->vdev_type_nss_5g.sta;
2373 else
2374 ft_session_ptr->vdev_nss = mac_ctx->vdev_type_nss_2g.sta;
2375
2376 ft_session_ptr->nss = ft_session_ptr->vdev_nss;
2377
Deepak Dhamdherea7987a22017-07-26 23:06:38 -07002378 /* Next routine will update nss and vdev_nss with AP's capabilities */
2379 lim_fill_ft_session(mac_ctx, bss_desc, ft_session_ptr, session_ptr);
2380
2381 /* Next routine may update nss based on dot11Mode */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002382 lim_ft_prepare_add_bss_req(mac_ctx, false, ft_session_ptr, bss_desc);
2383 roam_sync_ind_ptr->add_bss_params =
2384 (tpAddBssParams) ft_session_ptr->ftPEContext.pAddBssReq;
2385 add_bss_params = ft_session_ptr->ftPEContext.pAddBssReq;
2386 lim_delete_tdls_peers(mac_ctx, session_ptr);
2387 curr_sta_ds = dph_lookup_hash_entry(mac_ctx, session_ptr->bssId,
2388 &aid, &session_ptr->dph.dphHashTable);
Varun Reddy Yeturu3b21c7e2016-09-13 15:04:54 -07002389 if (curr_sta_ds == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302390 pe_err("LFR3:failed to lookup hash entry");
Varun Reddy Yeturu3b21c7e2016-09-13 15:04:54 -07002391 ft_session_ptr->bRoamSynchInProgress = false;
2392 return status;
2393 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002394 session_ptr->limSmeState = eLIM_SME_IDLE_STATE;
2395 lim_cleanup_rx_path(mac_ctx, curr_sta_ds, session_ptr);
2396 lim_delete_dph_hash_entry(mac_ctx, curr_sta_ds->staAddr,
2397 aid, session_ptr);
2398 pe_delete_session(mac_ctx, session_ptr);
2399 session_ptr = NULL;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002400 curr_sta_ds = dph_add_hash_entry(mac_ctx,
2401 roam_sync_ind_ptr->bssid.bytes, DPH_STA_HASH_INDEX_PEER,
2402 &ft_session_ptr->dph.dphHashTable);
2403 if (curr_sta_ds == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302404 pe_err("LFR3:failed to add hash entry for");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002405 lim_print_mac_addr(mac_ctx,
2406 add_bss_params->staContext.staMac, LOGE);
2407 ft_session_ptr->bRoamSynchInProgress = false;
2408 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 }
Paul Zhangfda3a592017-08-17 17:13:35 +08002410
2411 add_bss_params->bssIdx = roam_sync_ind_ptr->roamedVdevId;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002412 ft_session_ptr->bssIdx = (uint8_t) add_bss_params->bssIdx;
2413
2414 curr_sta_ds->bssId = add_bss_params->bssIdx;
2415 curr_sta_ds->staIndex =
2416 add_bss_params->staContext.staIdx;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002417 rrm_cache_mgmt_tx_power(mac_ctx,
2418 add_bss_params->txMgmtPower, ft_session_ptr);
2419 mac_ctx->roam.reassocRespLen = roam_sync_ind_ptr->reassocRespLength;
2420 mac_ctx->roam.pReassocResp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302421 qdf_mem_malloc(mac_ctx->roam.reassocRespLen);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002422 if (NULL == mac_ctx->roam.pReassocResp) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302423 pe_err("LFR3:assoc resp mem alloc failed");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002424 ft_session_ptr->bRoamSynchInProgress = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302425 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002426 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302427 qdf_mem_copy(mac_ctx->roam.pReassocResp,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002428 (uint8_t *)roam_sync_ind_ptr +
2429 roam_sync_ind_ptr->reassocRespOffset,
2430 mac_ctx->roam.reassocRespLen);
2431
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302432 pe_debug("LFR3:the reassoc resp frame data:");
Nishank Aggarwal8d4c7202017-03-10 13:13:54 +05302433 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002434 mac_ctx->roam.pReassocResp,
2435 mac_ctx->roam.reassocRespLen);
2436 ft_session_ptr->bRoamSynchInProgress = true;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302437
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002438 lim_process_assoc_rsp_frame(mac_ctx, mac_ctx->roam.pReassocResp,
2439 LIM_REASSOC, ft_session_ptr);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302440
2441 lim_copy_and_free_hlp_data_from_session(ft_session_ptr,
2442 roam_sync_ind_ptr);
2443
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002444 roam_sync_ind_ptr->aid = ft_session_ptr->limAID;
2445 curr_sta_ds->mlmStaContext.mlmState =
2446 eLIM_MLM_LINK_ESTABLISHED_STATE;
Naveen Rawat746a90b2017-06-07 15:16:35 -07002447 curr_sta_ds->nss = ft_session_ptr->nss;
2448 roam_sync_ind_ptr->nss = ft_session_ptr->nss;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002449 ft_session_ptr->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
2450 lim_init_tdls_data(mac_ctx, ft_session_ptr);
Yu Wang0477ee32017-02-10 20:02:03 +08002451 join_rsp_len = ft_session_ptr->RICDataLen +
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +05302452 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Yu Wang0477ee32017-02-10 20:02:03 +08002453
2454#ifdef FEATURE_WLAN_ESE
2455 join_rsp_len += ft_session_ptr->tspecLen;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302456 pe_debug("tspecLen: %d", ft_session_ptr->tspecLen);
Yu Wang0477ee32017-02-10 20:02:03 +08002457#endif
2458
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002459 roam_sync_ind_ptr->join_rsp = qdf_mem_malloc(join_rsp_len);
2460 if (NULL == roam_sync_ind_ptr->join_rsp) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302461 pe_err("LFR3:mem alloc failed");
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002462 ft_session_ptr->bRoamSynchInProgress = false;
2463 if (mac_ctx->roam.pReassocResp)
2464 qdf_mem_free(mac_ctx->roam.pReassocResp);
2465 mac_ctx->roam.pReassocResp = NULL;
2466 return QDF_STATUS_E_NOMEM;
2467 }
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002468
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302469 pe_debug("Session RicLength: %d", ft_session_ptr->RICDataLen);
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -07002470 if (ft_session_ptr->ricData != NULL) {
2471 roam_sync_ind_ptr->join_rsp->parsedRicRspLen =
2472 ft_session_ptr->RICDataLen;
2473 qdf_mem_copy(roam_sync_ind_ptr->join_rsp->frames,
2474 ft_session_ptr->ricData,
2475 roam_sync_ind_ptr->join_rsp->parsedRicRspLen);
2476 qdf_mem_free(ft_session_ptr->ricData);
2477 ft_session_ptr->ricData = NULL;
2478 ft_session_ptr->RICDataLen = 0;
2479 }
Yu Wang0477ee32017-02-10 20:02:03 +08002480
2481#ifdef FEATURE_WLAN_ESE
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +05302482 if (ft_session_ptr->tspecIes != NULL) {
2483 roam_sync_ind_ptr->join_rsp->tspecIeLen =
2484 ft_session_ptr->tspecLen;
2485 qdf_mem_copy(roam_sync_ind_ptr->join_rsp->frames +
2486 roam_sync_ind_ptr->join_rsp->parsedRicRspLen,
2487 ft_session_ptr->tspecIes,
2488 roam_sync_ind_ptr->join_rsp->tspecIeLen);
2489 qdf_mem_free(ft_session_ptr->tspecIes);
2490 ft_session_ptr->tspecIes = NULL;
2491 ft_session_ptr->tspecLen = 0;
2492 }
Yu Wang0477ee32017-02-10 20:02:03 +08002493#endif
2494
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002495 roam_sync_ind_ptr->join_rsp->vht_channel_width =
2496 ft_session_ptr->ch_width;
2497 roam_sync_ind_ptr->join_rsp->staId = curr_sta_ds->staIndex;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002498 roam_sync_ind_ptr->join_rsp->timingMeasCap = curr_sta_ds->timingMeasCap;
2499 roam_sync_ind_ptr->join_rsp->nss = curr_sta_ds->nss;
2500 roam_sync_ind_ptr->join_rsp->max_rate_flags =
2501 lim_get_max_rate_flags(mac_ctx, curr_sta_ds);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07002502 lim_set_tdls_flags(roam_sync_ind_ptr, ft_session_ptr);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002503 roam_sync_ind_ptr->join_rsp->aid = ft_session_ptr->limAID;
2504 lim_fill_join_rsp_ht_caps(ft_session_ptr, roam_sync_ind_ptr->join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 ft_session_ptr->limPrevSmeState = ft_session_ptr->limSmeState;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002506 ft_session_ptr->limSmeState = eLIM_SME_LINK_EST_STATE;
2507 ft_session_ptr->bRoamSynchInProgress = false;
2508 if (mac_ctx->roam.pReassocResp)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302509 qdf_mem_free(mac_ctx->roam.pReassocResp);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002510 mac_ctx->roam.pReassocResp = NULL;
Naveen Rawat945894a2016-12-17 14:58:07 -08002511
2512 if (roam_sync_ind_ptr->authStatus == CSR_ROAM_AUTH_STATUS_AUTHENTICATED)
2513 ft_session_ptr->is_key_installed = true;
2514
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302515 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516}
2517#endif
2518
Jeff Johnson82b0c622016-10-07 07:53:55 -07002519static bool lim_is_beacon_miss_scenario(tpAniSirGlobal pMac,
2520 uint8_t *pRxPacketInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521{
2522 tpSirMacMgmtHdr pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
2523 uint8_t sessionId;
2524 tpPESession psessionEntry =
2525 pe_find_session_by_bssid(pMac, pHdr->bssId, &sessionId);
2526
2527 if (psessionEntry && psessionEntry->pmmOffloadInfo.bcnmiss)
2528 return true;
2529 return false;
2530}
2531
2532/** -----------------------------------------------------------------
2533 \brief lim_is_pkt_candidate_for_drop() - decides whether to drop the frame or not
2534
2535 This function is called before enqueuing the frame to PE queue for further processing.
2536 This prevents unnecessary frames getting into PE Queue and drops them right away.
2537 Frames will be droped in the following scenarios:
2538
2539 - In Scan State, drop the frames which are not marked as scan frames
2540 - In non-Scan state, drop the frames which are marked as scan frames.
2541 - Drop INFRA Beacons and Probe Responses in IBSS Mode
2542 - Drop the Probe Request in IBSS mode, if STA did not send out the last beacon
2543
2544 \param pMac - global mac structure
2545 \return - none
2546 \sa
2547 ----------------------------------------------------------------- */
2548
2549tMgmtFrmDropReason lim_is_pkt_candidate_for_drop(tpAniSirGlobal pMac,
2550 uint8_t *pRxPacketInfo,
2551 uint32_t subType)
2552{
2553 uint32_t framelen;
2554 uint8_t *pBody;
2555 tSirMacCapabilityInfo capabilityInfo;
2556 tpSirMacMgmtHdr pHdr = NULL;
2557 tpPESession psessionEntry = NULL;
2558 uint8_t sessionId;
2559
2560 /*
2561 *
2562 * In scan mode, drop only Beacon/Probe Response which are NOT marked as scan-frames.
2563 * In non-scan mode, drop only Beacon/Probe Response which are marked as scan frames.
2564 * Allow other mgmt frames, they must be from our own AP, as we don't allow
2565 * other than beacons or probe responses in scan state.
2566 */
2567 if ((subType == SIR_MAC_MGMT_BEACON) ||
2568 (subType == SIR_MAC_MGMT_PROBE_RSP)) {
2569 if (lim_is_beacon_miss_scenario(pMac, pRxPacketInfo)) {
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002570 MTRACE(mac_trace(pMac, TRACE_CODE_INFO_LOG, 0,
2571 eLOG_NODROP_MISSED_BEACON_SCENARIO));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 return eMGMT_DROP_NO_DROP;
2573 }
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002574 if (lim_is_system_in_scan_state(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 return eMGMT_DROP_NO_DROP;
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002576 else if (WMA_IS_RX_IN_SCAN(pRxPacketInfo))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 return eMGMT_DROP_SCAN_MODE_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002579 framelen = WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
2580 pBody = WMA_GET_RX_MPDU_DATA(pRxPacketInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 /* drop the frame if length is less than 12 */
2582 if (framelen < LIM_MIN_BCN_PR_LENGTH)
2583 return eMGMT_DROP_INVALID_SIZE;
2584
2585 *((uint16_t *) &capabilityInfo) =
2586 sir_read_u16(pBody + LIM_BCN_PR_CAPABILITY_OFFSET);
2587
2588 /* Note sure if this is sufficient, basically this condition allows all probe responses and
2589 * beacons from an infrastructure network
2590 */
2591 if (!capabilityInfo.ibss)
2592 return eMGMT_DROP_NO_DROP;
2593
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002594 /* Drop INFRA Beacons and Probe Responses in IBSS Mode */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 /* This can be enhanced to even check the SSID before deciding to enque the frame. */
2596 if (capabilityInfo.ess)
2597 return eMGMT_DROP_INFRA_BCN_IN_IBSS;
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 } else if ((subType == SIR_MAC_MGMT_PROBE_REQ) &&
2600 (!WMA_GET_RX_BEACON_SENT(pRxPacketInfo))) {
2601 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
Arif Hussainfe3de0d2018-04-30 19:04:29 -07002602 psessionEntry = pe_find_session_by_bssid(pMac,
2603 pHdr->bssId,
2604 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 if ((psessionEntry && !LIM_IS_IBSS_ROLE(psessionEntry)) ||
2606 (!psessionEntry))
2607 return eMGMT_DROP_NO_DROP;
2608
2609 /* Drop the Probe Request in IBSS mode, if STA did not send out the last beacon */
2610 /* In IBSS, the node which sends out the beacon, is supposed to respond to ProbeReq */
2611 return eMGMT_DROP_NOT_LAST_IBSS_BCN;
Krunal Soni05c914f2018-08-06 12:23:58 -07002612 } else if (subType == SIR_MAC_MGMT_AUTH) {
2613 uint16_t curr_seq_num = 0;
2614 struct tLimPreAuthNode *auth_node;
2615
2616 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
2617 psessionEntry = pe_find_session_by_bssid(pMac, pHdr->bssId,
2618 &sessionId);
2619 if (!psessionEntry)
2620 return eMGMT_DROP_NO_DROP;
2621
2622 curr_seq_num = ((pHdr->seqControl.seqNumHi << 4) |
2623 (pHdr->seqControl.seqNumLo));
2624 auth_node = lim_search_pre_auth_list(pMac, pHdr->sa);
2625 if (auth_node && pHdr->fc.retry &&
2626 (auth_node->seq_num == curr_seq_num)) {
2627 pe_err_rl("auth frame, seq num: %d is already processed, drop it",
2628 curr_seq_num);
2629 return eMGMT_DROP_DUPLICATE_AUTH_FRAME;
2630 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 }
2632
2633 return eMGMT_DROP_NO_DROP;
2634}
2635
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302636void lim_update_lost_link_info(tpAniSirGlobal mac, tpPESession session,
2637 int32_t rssi)
2638{
2639 struct sir_lost_link_info *lost_link_info;
Rajeev Kumarcf7bd802017-04-18 11:11:42 -07002640 struct scheduler_msg mmh_msg = {0};
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302641
2642 if ((NULL == mac) || (NULL == session)) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302643 pe_err("parameter NULL");
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302644 return;
2645 }
Yeshwanth Sriram Guntukae7303b82018-08-10 16:45:16 +05302646 if (!LIM_IS_STA_ROLE(session))
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302647 return;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302648
2649 lost_link_info = qdf_mem_malloc(sizeof(*lost_link_info));
2650 if (NULL == lost_link_info) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302651 pe_err("lost_link_info allocation failure");
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302652 return;
2653 }
2654
2655 lost_link_info->vdev_id = session->smeSessionId;
2656 lost_link_info->rssi = rssi;
2657 mmh_msg.type = eWNI_SME_LOST_LINK_INFO_IND;
2658 mmh_msg.bodyptr = lost_link_info;
2659 mmh_msg.bodyval = 0;
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302660 pe_debug("post eWNI_SME_LOST_LINK_INFO_IND, bss_idx: %d rssi: %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302661 lost_link_info->vdev_id, lost_link_info->rssi);
2662
2663 lim_sys_process_mmh_msg_api(mac, &mmh_msg, ePROT);
2664}
2665
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302666QDF_STATUS pe_acquire_global_lock(tAniSirLim *psPe)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302668 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
2670 if (psPe) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302671 if (QDF_IS_STATUS_SUCCESS
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302672 (qdf_mutex_acquire(&psPe->lkPeGlobalLock))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302673 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 }
2675 }
2676 return status;
2677}
2678
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302679QDF_STATUS pe_release_global_lock(tAniSirLim *psPe)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302681 QDF_STATUS status = QDF_STATUS_E_INVAL;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 if (psPe) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302684 if (QDF_IS_STATUS_SUCCESS
Anurag Chouhana37b5b72016-02-21 14:53:42 +05302685 (qdf_mutex_release(&psPe->lkPeGlobalLock))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302686 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 }
2688 }
2689 return status;
2690}
2691
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -07002692/**
2693 * lim_mon_init_session() - create PE session for monitor mode operation
2694 * @mac_ptr: mac pointer
2695 * @msg: Pointer to struct sir_create_session type.
2696 *
2697 * Return: NONE
2698 */
2699void lim_mon_init_session(tpAniSirGlobal mac_ptr,
2700 struct sir_create_session *msg)
2701{
2702 tpPESession psession_entry;
2703 uint8_t session_id;
2704
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -07002705 psession_entry = pe_create_session(mac_ptr, msg->bss_id.bytes,
2706 &session_id,
2707 mac_ptr->lim.maxStation,
2708 eSIR_MONITOR_MODE);
2709 if (psession_entry == NULL) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302710 pe_err("Monitor mode: Session Can not be created");
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -07002711 lim_print_mac_addr(mac_ptr, msg->bss_id.bytes, LOGE);
2712 return;
2713 }
2714 psession_entry->vhtCapability = 1;
2715}
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302716
2717/**
2718 * lim_update_ext_cap_ie() - Update Extended capabilities IE(if present)
2719 * with capabilities of Fine Time measurements(FTM) if set in driver
2720 *
2721 * @mac_ctx: Pointer to Global MAC structure
2722 * @ie_data: Default Scan IE data
2723 * @local_ie_buf: Local Scan IE data
2724 * @local_ie_len: Pointer to length of @ie_data
2725 *
2726 * Return: QDF_STATUS
2727 */
2728QDF_STATUS lim_update_ext_cap_ie(tpAniSirGlobal mac_ctx,
2729 uint8_t *ie_data, uint8_t *local_ie_buf, uint16_t *local_ie_len)
2730{
2731 uint32_t dot11mode;
2732 bool vht_enabled = false;
2733 tDot11fIEExtCap default_scan_ext_cap = {0}, driver_ext_cap = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002734 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302735
2736 status = lim_strip_extcap_update_struct(mac_ctx, ie_data,
2737 local_ie_len, &default_scan_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002738 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302739 pe_err("Strip ext cap fails %d", status);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302740 return QDF_STATUS_E_FAILURE;
2741 }
2742
Pragaspathi Thilagaraj6cf025f2018-06-25 18:37:05 +05302743 if ((*local_ie_len) > (MAX_DEFAULT_SCAN_IE_LEN - EXT_CAP_IE_HDR_LEN)) {
2744 pe_err("Invalid Scan IE length");
2745 return QDF_STATUS_E_FAILURE;
2746 }
Naveen Rawatb677c242017-03-29 16:34:50 -07002747 /* copy ie prior to ext cap to local buffer */
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302748 qdf_mem_copy(local_ie_buf, ie_data, (*local_ie_len));
Naveen Rawatb677c242017-03-29 16:34:50 -07002749
2750 /* from here ext cap ie starts, set EID */
2751 local_ie_buf[*local_ie_len] = DOT11F_EID_EXTCAP;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302752
2753 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &dot11mode);
2754 if (IS_DOT11_MODE_VHT(dot11mode))
2755 vht_enabled = true;
2756
2757 status = populate_dot11f_ext_cap(mac_ctx, vht_enabled,
2758 &driver_ext_cap, NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002759 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal524ee9a8032017-03-23 18:35:16 +05302760 pe_err("Failed %d to create ext cap IE. Use default value instead",
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302761 status);
Naveen Rawatb677c242017-03-29 16:34:50 -07002762 local_ie_buf[*local_ie_len + 1] = DOT11F_IE_EXTCAP_MAX_LEN;
Pragaspathi Thilagaraj6cf025f2018-06-25 18:37:05 +05302763
2764 if ((*local_ie_len) > (MAX_DEFAULT_SCAN_IE_LEN -
2765 (DOT11F_IE_EXTCAP_MAX_LEN + EXT_CAP_IE_HDR_LEN))) {
2766 pe_err("Invalid Scan IE length");
2767 return QDF_STATUS_E_FAILURE;
2768 }
Naveen Rawatb677c242017-03-29 16:34:50 -07002769 (*local_ie_len) += EXT_CAP_IE_HDR_LEN;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302770 qdf_mem_copy(local_ie_buf + (*local_ie_len),
2771 default_scan_ext_cap.bytes,
2772 DOT11F_IE_EXTCAP_MAX_LEN);
2773 (*local_ie_len) += DOT11F_IE_EXTCAP_MAX_LEN;
2774 return QDF_STATUS_SUCCESS;
2775 }
Hu Wangfbd279d2016-10-31 18:24:34 +08002776 lim_merge_extcap_struct(&driver_ext_cap, &default_scan_ext_cap, true);
Naveen Rawatb677c242017-03-29 16:34:50 -07002777 local_ie_buf[*local_ie_len + 1] = driver_ext_cap.num_bytes;
Pragaspathi Thilagaraj6cf025f2018-06-25 18:37:05 +05302778
2779 if ((*local_ie_len) > (MAX_DEFAULT_SCAN_IE_LEN -
2780 (EXT_CAP_IE_HDR_LEN + driver_ext_cap.num_bytes))) {
2781 pe_err("Invalid Scan IE length");
2782 return QDF_STATUS_E_FAILURE;
2783 }
Naveen Rawatb677c242017-03-29 16:34:50 -07002784 (*local_ie_len) += EXT_CAP_IE_HDR_LEN;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302785 qdf_mem_copy(local_ie_buf + (*local_ie_len),
Selvaraj, Sridhar2c46d832017-03-13 17:55:48 +05302786 driver_ext_cap.bytes, driver_ext_cap.num_bytes);
2787 (*local_ie_len) += driver_ext_cap.num_bytes;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05302788 return QDF_STATUS_SUCCESS;
2789}