blob: 64500d781d53e688896671a84ff6f675005e918a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053061#include "sme_Trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "logDump.h"
63#include "smeQosInternal.h"
64#include "wlan_qct_tl.h"
65#include "smeInside.h"
66#include "vos_diag_core_event.h"
67#include "vos_diag_core_log.h"
68#include "csrApi.h"
69#include "pmc.h"
70#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053071#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070072#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
73#include "csrNeighborRoam.h"
74#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080075#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
76#include "csrEse.h"
77#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053078#include "vos_utils.h"
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053079#ifdef WLAN_FEATURE_LFR_MBB
80#include "csr_roam_mbb.h"
81#endif
82
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084#define CSR_NUM_IBSS_START_CHANNELS_50 4
85#define CSR_NUM_IBSS_START_CHANNELS_24 3
86#define CSR_DEF_IBSS_START_CHANNEL_50 36
87#define CSR_DEF_IBSS_START_CHANNEL_24 1
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053088
Jeff Johnson295189b2012-06-20 16:38:30 -070089/*---------------------------------------------------------------------------
90 OBIWAN recommends [8 10]% : pick 9%
91---------------------------------------------------------------------------*/
92#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070093/*---------------------------------------------------------------------------
94 OBIWAN recommends -85dBm
95---------------------------------------------------------------------------*/
96#define CSR_VCC_RSSI_THRESHOLD 80
97#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
98#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
99#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
100#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700101//We use constatnt 4 here
102//This macro returns true when higher AC parameter is bigger than lower AC for a difference
103//The bigger the number, the less chance of TX
104//It must put lower AC as the first parameter.
105#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//Flag to send/do not send disassoc frame over the air
107#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700109#define MAX_CB_VALUE_IN_INI (2)
110
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700111#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
112static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
113#endif
114
Agrawal Ashishe4288772016-01-13 14:10:10 +0530115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121/*--------------------------------------------------------------------------
122 Type declarations
123 ------------------------------------------------------------------------*/
Abhinav Kumard6d8dd22019-08-05 12:38:50 +0530124
125#ifdef WLAN_FEATURE_SAE
126/**
127 * csr_sae_callback - Update SAE info to CSR roam session
128 * @mac_ctx: MAC context
129 * @msg_ptr: pointer to SAE message
130 *
131 * API to update SAE info to roam csr session
132 *
133 * Return: QDF_STATUS
134 */
135static VOS_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
136{
137 tCsrRoamInfo roam_info;
138 uint32_t session_id;
139 struct sir_sae_info *sae_info;
140
141 sae_info = (struct sir_sae_info *) msg_ptr;
142 if (!sae_info) {
143 smsLog(mac_ctx, LOGE, "SAE info is NULL");
144 return VOS_STATUS_E_FAILURE;
145 }
146
147 smsLog(mac_ctx, LOG1, FL("vdev_id %d "MAC_ADDRESS_STR""),
148 sae_info->vdev_id,
149 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
150
151 session_id = sae_info->vdev_id;
152 if (session_id == CSR_SESSION_ID_INVALID)
153 return VOS_STATUS_E_FAILURE;
154
155 roam_info.sae_info = sae_info;
156 csrRoamCallCallback(mac_ctx, session_id, &roam_info, 0,
157 eCSR_ROAM_SAE_COMPUTE, eCSR_ROAM_RESULT_NONE);
158
159 return VOS_STATUS_SUCCESS;
160}
161#else
162static inline VOS_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
163 tSirSmeRsp *msg_ptr)
164{
165 return VOS_STATUS_SUCCESS;
166}
167#endif
168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700170int diagAuthTypeFromCSRType(eCsrAuthType authType)
171{
172 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 switch(authType)
174 {
175 case eCSR_AUTH_TYPE_SHARED_KEY:
176 n = AUTH_SHARED;
177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 case eCSR_AUTH_TYPE_WPA:
179 n = AUTH_WPA_EAP;
180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 case eCSR_AUTH_TYPE_WPA_PSK:
182 n = AUTH_WPA_PSK;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530185#ifdef WLAN_FEATURE_11W
186 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
187#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 n = AUTH_WPA2_EAP;
189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700191#ifdef WLAN_FEATURE_11W
192 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
193#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 n = AUTH_WPA2_PSK;
195 break;
196#ifdef FEATURE_WLAN_WAPI
197 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
198 n = AUTH_WAPI_CERT;
199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
201 n = AUTH_WAPI_PSK;
202 break;
203#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 default:
205 break;
206 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 return (n);
208}
Jeff Johnson295189b2012-06-20 16:38:30 -0700209int diagEncTypeFromCSRType(eCsrEncryptionType encType)
210{
211 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 switch(encType)
213 {
214 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
215 case eCSR_ENCRYPT_TYPE_WEP40:
216 n = ENC_MODE_WEP40;
217 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700218 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
219 case eCSR_ENCRYPT_TYPE_WEP104:
220 n = ENC_MODE_WEP104;
221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 case eCSR_ENCRYPT_TYPE_TKIP:
223 n = ENC_MODE_TKIP;
224 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 case eCSR_ENCRYPT_TYPE_AES:
226 n = ENC_MODE_AES;
227 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700228#ifdef FEATURE_WLAN_WAPI
229 case eCSR_ENCRYPT_TYPE_WPI:
230 n = ENC_MODE_SMS4;
231 break;
232#endif /* FEATURE_WLAN_WAPI */
233 default:
234 break;
235 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 return (n);
237}
Jeff Johnson295189b2012-06-20 16:38:30 -0700238#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700239static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
240static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static void initConfigParam(tpAniSirGlobal pMac);
242static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
243 eCsrRoamCompleteResult Result, void *Context );
244static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
245 tCsrRoamProfile *pProfile,
246 tANI_BOOLEAN *pfSameIbss );
247static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
248static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700249 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
250static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
252static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
253eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
254eHalStatus csrRoamClose(tpAniSirGlobal pMac);
255void csrRoamMICErrorTimerHandler(void *pv);
256void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
257tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
258
259static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
260static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
261static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700262eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
263static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700264static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700265static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
267 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
268 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
269 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
270 tANI_U8 *pKeyRsc );
271static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
272 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
273 tCsrRoamProfile *pProfile );
274void csrRoamStatisticsTimerHandler(void *pv);
275void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700276VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
277 v_U8_t rssiNotification,
278 void * context);
279static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
280void csrRoamVccTrigger(tpAniSirGlobal pMac);
281eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
282/*
283 pStaEntry is no longer invalid upon the return of this function.
284*/
285static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700286static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700287static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700288tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
289 tDblLinkList *pStaList,
290 tCsrStatsClientReqInfo *pStaEntry);
291void csrRoamStatsClientTimerHandler(void *pv);
292tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
293 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
294void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
295 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700296void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700297void csrRoamTlStatsTimerHandler(void *pv);
298void csrRoamPeStatsTimerHandler(void *pv);
299tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
300void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
301tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
302eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
303static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
304static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
305static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
306static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
307 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
308//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
309static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
310void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
311#ifdef FEATURE_WLAN_BTAMP_UT_RF
312void csrRoamJoinRetryTimerHandler(void *pv);
313#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530314void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700315extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530316#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700317extern void btampEstablishLogLinkHdlr(void* pMsg);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +0530318#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700319static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700320void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700321
322//Initialize global variables
323static void csrRoamInitGlobals(tpAniSirGlobal pMac)
324{
325 if(pMac)
326 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800327 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
328 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330 return;
331}
332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
334{
335 if(pMac)
336 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800337 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 }
339 return;
340}
Jeff Johnson295189b2012-06-20 16:38:30 -0700341eHalStatus csrOpen(tpAniSirGlobal pMac)
342{
343 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530344#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 static uNvTables nvTables;
346 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530348#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 tANI_U32 i;
350
351 do
352 {
353 /* Initialize CSR Roam Globals */
354 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
356 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
357
358 initConfigParam(pMac);
359 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
360 break;
361 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
362 break;
363 pMac->roam.nextRoamId = 1; //Must not be 0
364 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
365 break;
366 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
367 break;
368 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
369 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530370
371#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
373 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
374 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530375 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
376 WNI_CFG_COUNTRY_CODE_LEN);
377 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 }
379 else
380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800381 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 //hardcoded for now
383 pMac->scan.countryCodeDefault[0] = 'U';
384 pMac->scan.countryCodeDefault[1] = 'S';
385 pMac->scan.countryCodeDefault[2] = 'I';
386 //status = eHAL_STATUS_SUCCESS;
387 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700388 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530389
390 if (!('0' == pMac->scan.countryCodeDefault[0] &&
391 '0' == pMac->scan.countryCodeDefault[1]))
392 {
393 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
394 &regId, COUNTRY_NV);
395 }
396 else
397 {
398 regId = REGDOMAIN_WORLD;
399 }
Abhishek Singha306a442013-11-07 18:39:01 +0530400 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 pMac->scan.domainIdDefault = regId;
402 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530403 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
404 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530406#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700407 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530408
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 return (status);
410}
411
Mihir Shetee1093ba2014-01-21 20:13:32 +0530412/* --------------------------------------------------------------------------
413 \fn csrInitChannels
414 \brief This function must be called to initialize CSR channel lists
415 \return eHalStatus
416 ----------------------------------------------------------------------------*/
417eHalStatus csrInitChannels(tpAniSirGlobal pMac)
418{
419 eHalStatus status = eHAL_STATUS_SUCCESS;
420 static uNvTables nvTables;
421 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530422 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530423
424 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
425 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
426 {
427 vos_mem_copy(pMac->scan.countryCodeDefault,
428 nvTables.defaultCountryTable.countryCode,
429 WNI_CFG_COUNTRY_CODE_LEN);
430 }
431 else
432 {
433 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
434 //hardcoded for now
435 pMac->scan.countryCodeDefault[0] = 'U';
436 pMac->scan.countryCodeDefault[1] = 'S';
437 pMac->scan.countryCodeDefault[2] = 'I';
438 }
439 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
440
Mihir Shetee1093ba2014-01-21 20:13:32 +0530441 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
442 pMac->scan.domainIdDefault = regId;
443 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
444 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
445 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530446 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
447 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530448 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
449 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530450 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530451 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530452
453 return status;
454}
455
Mihir Shete04206452014-11-20 17:50:58 +0530456#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530457eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530458{
459 eHalStatus status = eHAL_STATUS_SUCCESS;
460 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530461 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530462
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530463 /* In case of driver load ; driver need to get channel
464 * list with default Countrycode.
465 * In case of SSR; driver need to get channel list
466 * with old country code. 0 is for init and
467 * 1 is for reinit
468 */
469 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530470 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530471 case INIT:
472 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
473 WNI_CFG_COUNTRY_CODE_LEN);
474 if (!('0' == cc[0] &&
475 '0' == cc[1]))
476 {
477 csrGetRegulatoryDomainForCountry(pMac, cc,
478 &regId, COUNTRY_NV);
479 }
480 else
481 {
482 return status;
483 }
484 pMac->scan.domainIdDefault = regId;
485 break;
486 case REINIT:
487 vos_getCurrentCountryCode(&cc[0]);
488 status = csrGetRegulatoryDomainForCountry(pMac,
489 cc, &regId, COUNTRY_QUERY);
490 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530491 }
492 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530493 pMac->scan.domainIdCurrent = regId;
494 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530495 WNI_CFG_COUNTRY_CODE_LEN);
496 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530497
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530498 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
499 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
500 pMac->scan.countryCodeCurrent[1]);
501
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530502 /* reset info based on new cc, and we are done */
503 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
504 csrScanFilterResults(pMac);
505
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530506 return status;
507}
Mihir Shete04206452014-11-20 17:50:58 +0530508#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530509
Jeff Johnson295189b2012-06-20 16:38:30 -0700510eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
511{
512 eHalStatus status = eHAL_STATUS_SUCCESS;
513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
514 v_REGDOMAIN_t regId;
515 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 if(NULL == apCntryCode)
517 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530518 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 return eHAL_STATUS_FAILURE;
520 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530521 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 /* To get correct Regulatory domain from NV table
523 * 2 character Country code should be used
524 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700525 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
526/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700528
529 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800531 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700532 return eHAL_STATUS_FAILURE;
533 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700534*/
Kiet Lam6c583332013-10-14 05:37:09 +0530535 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
536 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 if (status != eHAL_STATUS_SUCCESS)
538 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700539 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 return status;
541 }
Abhishek Singha306a442013-11-07 18:39:01 +0530542 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 if (status != eHAL_STATUS_SUCCESS)
544 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700545 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 return status;
547 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 pMac->scan.domainIdDefault = regId;
549 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530551 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
552
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530554 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
555
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 /* If 2 bytes country code, 3rd byte must be filled with space */
557 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
558 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530559 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530561 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
562 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 return status;
565}
Jeff Johnson295189b2012-06-20 16:38:30 -0700566eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
567{
568 eHalStatus status = eHAL_STATUS_SUCCESS;
569 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
570 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530571 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
572 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
574 {
575 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
576 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
577 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
578 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
579 }
580 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
581
582 return status;
583}
Jeff Johnson295189b2012-06-20 16:38:30 -0700584eHalStatus csrClose(tpAniSirGlobal pMac)
585{
586 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800587
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 csrRoamClose(pMac);
589 csrScanClose(pMac);
590 csrLLClose(&pMac->roam.statsClientReqList);
591 csrLLClose(&pMac->roam.peStatsReqList);
592 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 /* DeInit Globals */
594 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 return (status);
596}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530597
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800598eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530599{
600 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800601 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530602 tANI_U32 numChan = 0;
603 tANI_U32 bufLen ;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530604 tANI_U8 i, j;
605 tANI_U8 num_channel = 0;
606 tANI_U8 channel_state;
607 tANI_U8 cfgnumChannels = 0;
608 tANI_U8 *cfgChannelList = NULL;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530609 eHalStatus status;
610 tSmeCmd *command;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530611
Atul Mittalb849d5a2014-07-29 12:08:39 +0530612 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530613 numChan = sizeof(pMac->roam.validChannelList);
614
615 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
616 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
617 {
618 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
619 return eHAL_STATUS_FAILED_ALLOC;
620 }
621
622 bufLen = sizeof(tSirUpdateChanList) +
623 (sizeof(tSirUpdateChanParam) * (numChan - 1));
624
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530625 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
626 if (!pChanList)
627 {
628 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
629 "Failed to allocate memory for tSirUpdateChanList");
630 return eHAL_STATUS_FAILED_ALLOC;
631 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530632 vos_mem_zero(pChanList, bufLen);
633
634 smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"),
635 pMac->scan.fEnableDFSChnlScan);
636
637 for (i = 0; i < numChan; i++)
638 {
639 channel_state =
640 vos_nv_getChannelEnabledState(pMac->roam.validChannelList[i]);
641
642 if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
643 && (channel_state == NV_CHANNEL_DFS))
644 {
645 continue;
646 }
647 pChanList->chanParam[num_channel].chanId =
648 pMac->roam.validChannelList[i];
649 pChanList->chanParam[num_channel].pwr =
650 cfgGetRegulatoryMaxTransmitPower(pMac,
651 pScan->defaultPowerTable[i].chanId);
Agrawal Ashishe4288772016-01-13 14:10:10 +0530652
Sushant Kaushikece4b562015-04-09 18:27:33 +0530653 if (!pChanList->chanParam[num_channel].pwr)
654 {
655 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
656 "setting to default %d"),
657 pChanList->chanParam[num_channel].chanId,
658 TX_POWER_DEFAULT);
659 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
660 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530661 if (channel_state == NV_CHANNEL_DFS)
662 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
663 else
664 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
665
666 /* When DFS mode is 2, mark static channels as active */
667 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
668 {
669 cfgnumChannels =
670 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
671 cfgChannelList =
672 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
673
674 if (cfgChannelList)
675 {
676 for(j=0; j< cfgnumChannels; j++)
677 {
678 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
679 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
680 {
681 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
682 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
683 "%s Marked DFS ch %d as active\n", __func__,
684 cfgChannelList[j]);
685 }
686 }
687 }
688 else
689 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
690 "%s cfgChannelList is NULL \n", __func__);
691 }
692
693 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
694 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
695 pChanList->chanParam[num_channel].chanId,
696 pChanList->chanParam[num_channel].dfsSet,
697 pChanList->chanParam[num_channel].pwr);
698 num_channel++;
699 }
700 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530701
Sachin Ahuja2d15ff62015-06-30 12:46:44 +0530702 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
703 "%s : regID : %d \n", __func__,
704 pChanList->regId);
705
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530706 pChanList->numChan = num_channel;
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530707
708 status = sme_AcquireGlobalLock(&pMac->sme);
709 if (HAL_STATUS_SUCCESS(status)) {
710 command = csrGetCommandBuffer(pMac);
711 if (command) {
712 command->command = eSmeCommandUpdateChannelList;
713 command->u.chan_list = pChanList;
714
715 status = csrQueueSmeCommand(pMac, command, eANI_BOOLEAN_TRUE);
716 if (!HAL_STATUS_SUCCESS(status)) {
717 smsLog(pMac, LOGE, FL("fail to send msg status = %d"), status);
718 csrReleaseCommand(pMac, command);
719 }
720 } else {
721 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
722 status = eHAL_STATUS_RESOURCES;
723 }
724 sme_ReleaseGlobalLock(&pMac->sme);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530725 }
726
Padma, Santhosh Kumar11567cd2016-11-10 18:14:53 +0530727 return status;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530728}
729
Jeff Johnson295189b2012-06-20 16:38:30 -0700730eHalStatus csrStart(tpAniSirGlobal pMac)
731{
732 eHalStatus status = eHAL_STATUS_SUCCESS;
733 tANI_U32 i;
734
735 do
736 {
737 //save the global vos context
738 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
739 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
740 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
741
742 status = csrRoamStart(pMac);
743 if(!HAL_STATUS_SUCCESS(status)) break;
744 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
745 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
746 if(!HAL_STATUS_SUCCESS(status)) break;
747 pMac->roam.sPendingCommands = 0;
748 csrScanEnable(pMac);
749#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
750 status = csrNeighborRoamInit(pMac);
751#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
752 pMac->roam.tlStatsReqInfo.numClient = 0;
753 pMac->roam.tlStatsReqInfo.periodicity = 0;
754 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
755 //init the link quality indication also
756 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
757 if(!HAL_STATUS_SUCCESS(status))
758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800759 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 break;
761 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530762
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764#if defined(ANI_LOGDUMP)
765 csrDumpInit(pMac);
766#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return (status);
768}
769
Kiet Lama72a2322013-11-15 11:18:11 +0530770eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700771{
772 tANI_U32 sessionId;
773 tANI_U32 i;
774
775 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
776 {
mukul sharmabab477d2015-06-11 17:14:55 +0530777 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 csrScanDisable(pMac);
780 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
781 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
783
784#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
785 csrNeighborRoamClose(pMac);
786#endif
787 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 // deregister from PMC since we register during csrStart()
789 // (ignore status since there is nothing we can do if it fails)
790 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 //Reset the domain back to the deault
792 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700793
794 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
795 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530796 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530797 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE, i);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 }
799
Kiet Lama72a2322013-11-15 11:18:11 +0530800#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
801 /* When HAL resets all the context information
802 * in HAL is lost, so we might need to send the
803 * scan offload request again when it comes
804 * out of reset for scan offload to be functional
805 */
806 if (HAL_STOP_TYPE_SYS_RESET == stopType)
807 {
808 bRoamScanOffloadStarted = VOS_FALSE;
809 }
810#endif
811
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 return (eHAL_STATUS_SUCCESS);
813}
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815eHalStatus csrReady(tpAniSirGlobal pMac)
816{
817 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 csrScanGetSupportedChannels( pMac );
819 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
820 //use it to init the background scan list
821 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 //Store the AC weights in TL for later use
823 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 status = csrInitChannelList( pMac );
825 if ( ! HAL_STATUS_SUCCESS( status ) )
826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800827 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 status );
829 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 return (status);
831}
Jeff Johnson295189b2012-06-20 16:38:30 -0700832void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
833{
834 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
836 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
837}
Jeff Johnson295189b2012-06-20 16:38:30 -0700838void csrSetGlobalCfgs( tpAniSirGlobal pMac )
839{
Jeff Johnsone7245742012-09-05 17:12:55 -0700840
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
842 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
843 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
844 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
845 NULL, eANI_BOOLEAN_FALSE);
846 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700847 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
848 * Once session is established we will use the session related params stored in PE session for CB mode
849 */
850 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
852
853 //Update the operating mode to configured value during initialization,
854 //So that client can advertise full capabilities in Probe request frame.
855 csrSetDefaultDot11Mode( pMac );
856}
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
859{
860 eHalStatus status = eHAL_STATUS_SUCCESS;
861 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +0530862 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 do
864 {
865 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
866 {
867 pSession = CSR_GET_SESSION( pMac, i );
868 pSession->roamingTimerInfo.pMac = pMac;
869 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
870 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
872 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530873 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
874 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530876 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800878 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 break;
880 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530881 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
882 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
883 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800885 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 return eHAL_STATUS_FAILURE;
887 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530888 vos_spin_lock_init(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 return (status);
891}
892
Jeff Johnson295189b2012-06-20 16:38:30 -0700893eHalStatus csrRoamClose(tpAniSirGlobal pMac)
894{
895 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
897 {
mukul sharmabab477d2015-06-11 17:14:55 +0530898 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530900 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
901 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
902 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
903 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +0530904 vos_spin_lock_destroy(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 return (eHAL_STATUS_SUCCESS);
906}
907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908eHalStatus csrRoamStart(tpAniSirGlobal pMac)
909{
910 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 return (eHAL_STATUS_SUCCESS);
912}
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
915{
916 csrRoamStopRoamingTimer(pMac, sessionId);
917 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
918 csrRoamDeregStatisticsReq(pMac);
919}
Jeff Johnson295189b2012-06-20 16:38:30 -0700920eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
921{
922 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800923 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 {
925 status = eHAL_STATUS_SUCCESS;
926 *pState = pMac->roam.roamSession[sessionId].connectState;
927 }
928 return (status);
929}
930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
932{
933 eHalStatus status = eHAL_STATUS_FAILURE;
934 tANI_U32 size = 0;
935 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700936
937 if(!pSession)
938 {
939 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
940 return eHAL_STATUS_FAILURE;
941 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700942
943 if(pProfile)
944 {
945 if(pSession->pConnectBssDesc)
946 {
947 do
948 {
949 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
950 if(size)
951 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530952 pProfile->pBssDesc = vos_mem_malloc(size);
953 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530955 vos_mem_copy(pProfile->pBssDesc,
956 pSession->pConnectBssDesc, size);
957 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 }
959 else
960 break;
961 }
962 else
963 {
964 pProfile->pBssDesc = NULL;
965 }
966 pProfile->AuthType = pSession->connectedProfile.AuthType;
967 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
968 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
969 pProfile->BSSType = pSession->connectedProfile.BSSType;
970 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
971 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530972 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
973 sizeof(tCsrBssid));
974 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
975 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700976#ifdef WLAN_FEATURE_VOWIFI_11R
977 if (pSession->connectedProfile.MDID.mdiePresent)
978 {
979 pProfile->MDID.mdiePresent = 1;
980 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
981 }
982 else
983 {
984 pProfile->MDID.mdiePresent = 0;
985 pProfile->MDID.mobilityDomain = 0;
986 }
987#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800988#ifdef FEATURE_WLAN_ESE
989 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
990 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800992 vos_mem_copy (pProfile->eseCckmInfo.krk,
993 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530994 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800995 pProfile->eseCckmInfo.reassoc_req_num=
996 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
997 pProfile->eseCckmInfo.krk_plumbed =
998 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 }
1000#endif
1001 }while(0);
1002 }
1003 }
1004
1005 return (status);
1006}
1007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
1009{
1010 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -07001011
1012 if((csrIsConnStateConnected(pMac, sessionId)) ||
1013 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 {
1015 if(pProfile)
1016 {
1017 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
1018 }
1019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 return (status);
1021}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -07001022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
1024{
1025 eHalStatus status = eHAL_STATUS_SUCCESS;
1026
Kiet Lam64c1b492013-07-12 13:56:44 +05301027 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301029 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301031 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001032 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301033 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07001034 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301035 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
1038 return (status);
1039}
1040
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301041eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -07001042{
1043 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if( pConnectedInfo->pbFrames )
1045 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301046 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 pConnectedInfo->pbFrames = NULL;
1048 }
1049 pConnectedInfo->nBeaconLength = 0;
1050 pConnectedInfo->nAssocReqLength = 0;
1051 pConnectedInfo->nAssocRspLength = 0;
1052 pConnectedInfo->staId = 0;
1053#ifdef WLAN_FEATURE_VOWIFI_11R
1054 pConnectedInfo->nRICRspLength = 0;
1055#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001056#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 pConnectedInfo->nTspecIeLength = 0;
1058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 return ( status );
1060}
1061
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
1063
Jeff Johnsone7245742012-09-05 17:12:55 -07001064
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001065void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1066{
1067 csrReinitPreauthCmd(pMac, pCommand);
1068 csrReleaseCommand( pMac, pCommand );
1069}
1070
Jeff Johnson295189b2012-06-20 16:38:30 -07001071void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1072{
1073 csrReinitRoamCmd(pMac, pCommand);
1074 csrReleaseCommand( pMac, pCommand );
1075}
1076
Jeff Johnson295189b2012-06-20 16:38:30 -07001077void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1078{
1079 csrReinitScanCmd(pMac, pCommand);
1080 csrReleaseCommand( pMac, pCommand );
1081}
1082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1084{
1085 csrReinitWmStatusChangeCmd(pMac, pCommand);
1086 csrReleaseCommand( pMac, pCommand );
1087}
1088
Jeff Johnson295189b2012-06-20 16:38:30 -07001089void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1090{
Kiet Lam64c1b492013-07-12 13:56:44 +05301091 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001092}
1093
Jeff Johnson295189b2012-06-20 16:38:30 -07001094void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1095{
Kiet Lam64c1b492013-07-12 13:56:44 +05301096 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097}
1098
Jeff Johnson295189b2012-06-20 16:38:30 -07001099void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1100{
1101 csrReinitSetKeyCmd(pMac, pCommand);
1102 csrReleaseCommand( pMac, pCommand );
1103}
Jeff Johnson295189b2012-06-20 16:38:30 -07001104void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1105{
1106 csrReinitRemoveKeyCmd(pMac, pCommand);
1107 csrReleaseCommand( pMac, pCommand );
1108}
Abhishek Singh7b2d0812016-04-28 11:44:29 +05301109
1110/**
1111 * csr_is_disconnect_full_power_cmd() - Check if command is for
1112 * disconnect or for fullpower
1113 * @command: command to check
1114 *
1115 * Return: true if disconnect or full power command else false
1116 */
1117bool csr_is_disconnect_full_power_cmd(tSmeCmd *command)
1118{
1119 switch (command->command) {
1120 case eSmeCommandRoam:
1121 if (CSR_IS_DISCONNECT_COMMAND(command))
1122 return true;
1123 break;
1124 case eSmeCommandWmStatusChange:
1125 case eSmeCommandExitImps:
1126 case eSmeCommandExitBmps:
1127 case eSmeCommandExitUapsd:
1128 case eSmeCommandExitWowl:
1129 return true;
1130 default:
1131 return false;
1132 }
1133 return false;
1134}
1135
Jeff Johnson295189b2012-06-20 16:38:30 -07001136void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1137{
1138
1139 if( eSmeCsrCommandMask & pCommand->command )
1140 {
1141 switch (pCommand->command)
1142 {
1143 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001144 // We need to inform the requester before dropping the scan command
Jeff Johnson89477502017-09-19 08:35:23 -07001145 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %pK",
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001146 __func__, pCommand->u.scanCmd.reason,
1147 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 if (NULL != pCommand->u.scanCmd.callback)
1149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001150 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1152 }
1153 csrReleaseCommandScan( pMac, pCommand );
1154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 case eSmeCommandRoam:
1156 csrReleaseCommandRoam( pMac, pCommand );
1157 break;
1158
1159 case eSmeCommandWmStatusChange:
1160 csrReleaseCommandWmStatusChange( pMac, pCommand );
1161 break;
1162
1163 case eSmeCommandSetKey:
1164 csrReleaseCommandSetKey( pMac, pCommand );
1165 break;
1166
1167 case eSmeCommandRemoveKey:
1168 csrReleaseCommandRemoveKey( pMac, pCommand );
1169 break;
1170
1171 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001172 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 csrReleaseCommand( pMac, pCommand );
1174 break;
1175 }
1176 }
1177}
1178
Jeff Johnson295189b2012-06-20 16:38:30 -07001179void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1180{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301181 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1182 macTraceGetcsrRoamSubState(NewSubstate),
1183 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001184
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1186 {
1187 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001188 }
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301189 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 pMac->roam.curSubState[sessionId] = NewSubstate;
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +05301191 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192}
1193
Jeff Johnson295189b2012-06-20 16:38:30 -07001194eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1195{
1196 eCsrRoamState PreviousState;
1197
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301198 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1199 macTraceGetcsrRoamState(NewRoamState),
1200 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001201
1202 PreviousState = pMac->roam.curState[sessionId];
1203
1204 if ( NewRoamState != pMac->roam.curState[sessionId] )
1205 {
1206 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1207 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1208 {
1209 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1210 }
1211
1212 pMac->roam.curState[sessionId] = NewRoamState;
1213 }
1214 return( PreviousState );
1215}
1216
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001217void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001218{
1219 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 if(catOffset)
1221 {
1222 pMac->roam.configParam.bCatRssiOffset = catOffset;
1223 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1224 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001225 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 }
1227 }
1228}
1229
Jeff Johnson295189b2012-06-20 16:38:30 -07001230static void initConfigParam(tpAniSirGlobal pMac)
1231{
1232 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301234 pMac->roam.configParam.channelBondingMode24GHz =
1235 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1236 pMac->roam.configParam.channelBondingMode5GHz =
1237 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1239 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1240 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1241 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1242 pMac->roam.configParam.HeartbeatThresh24 = 40;
1243 pMac->roam.configParam.HeartbeatThresh50 = 40;
1244 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1245 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1246 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001247 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 pMac->roam.configParam.RTSThreshold = 2346;
1249 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1250 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1251 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1252 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1253 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1254 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1255 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1256 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1257 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1258 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1259 {
1260 pMac->roam.configParam.BssPreferValue[i] = i;
1261 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001262 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1264 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1265 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1267 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301268 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1270 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1271 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1272 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301273 pMac->roam.configParam.max_chntime_btc_esco =
1274 CSR_ACTIVE_MAX_CHANNEL_TIME_ESCO_BTC;
1275 pMac->roam.configParam.min_chntime_btc_esco =
1276 CSR_ACTIVE_MIN_CHANNEL_TIME_ESCO_BTC;
1277 pMac->roam.configParam.min_chntime_btc_sco =
1278 CSR_ACTIVE_MIN_CHANNEL_TIME_SCO_BTC;
1279 pMac->roam.configParam.max_chntime_btc_sco=
1280 CSR_ACTIVE_MAX_CHANNEL_TIME_SCO_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001281 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001282#ifdef WLAN_AP_STA_CONCURRENCY
1283 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1284 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1285 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1286 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1287 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001288 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1289 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001290#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1292 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1293 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1294 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295#ifdef WLAN_FEATURE_VOWIFI_11R
1296 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001298#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1299 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1300 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1301 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1302 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1303 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1304 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1305 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1306 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1307 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1308 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1309 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001310 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301311 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05301312 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001313#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001314#ifdef WLAN_FEATURE_11AC
1315 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001317
1318 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1319 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301320 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_FALSE;
1321 pMac->roam.configParam.num_ba_buff_btc_sco = DEFAULT_NUM_BUFF_BTC_SCO;
1322 pMac->roam.configParam.num_ba_buff = WNI_CFG_NUM_BUFF_ADVERT_STADEF;
Mohit Khanna349bc392012-09-11 17:24:52 -07001323
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001324 //Remove this code once SLM_Sessionization is supported
1325 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001326 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327
Jeff Johnsone7245742012-09-05 17:12:55 -07001328}
Jeff Johnson295189b2012-06-20 16:38:30 -07001329eCsrBand csrGetCurrentBand(tHalHandle hHal)
1330{
1331 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1332 return pMac->roam.configParam.bandCapability;
1333}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001334
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001335
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001336#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001337/*
1338 This function flushes the roam scan cache
1339*/
1340eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1341{
1342 eHalStatus status = eHAL_STATUS_SUCCESS;
1343 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1344
1345 /* Free up the memory first (if required) */
1346 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1347 {
1348 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1349 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1350 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1351 }
1352 return status;
1353}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001354#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001355
1356
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001357#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001358/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001359 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001360*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001361eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001362{
1363 eHalStatus status = eHAL_STATUS_SUCCESS;
1364 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1365
1366 /* Free up the memory first (if required) */
1367 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1368 {
1369 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1370 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001371 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001372 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001373 return status;
1374}
1375
1376
1377
1378/*
1379 This function flushes the roam scan cache and creates fresh cache
1380 based on the input channel list
1381*/
1382eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1383 const tANI_U8 *pChannelList,
1384 const tANI_U8 numChannels)
1385{
1386 eHalStatus status = eHAL_STATUS_SUCCESS;
1387 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1388
Srinivas Girigowdade697412013-02-14 16:31:48 -08001389 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1390
1391 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1392 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1393
1394 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1395 {
1396 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1397 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1398 return eHAL_STATUS_RESOURCES;
1399 }
1400
1401 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301402 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1403 pChannelList,
1404 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001405 return status;
1406}
1407
1408/* This function modifies the bgscan channel list set via config ini or
1409 runtime, whenever the band changes.
1410 if the band is auto, then no operation is performed on the channel list
1411 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1412 if the band is 5G, then make sure channel list contains only 5G valid channels
1413*/
1414eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1415 eCsrBand eBand)
1416{
1417 eHalStatus status = eHAL_STATUS_SUCCESS;
1418 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1419 tANI_U8 outNumChannels = 0;
1420 tANI_U8 inNumChannels = 0;
1421 tANI_U8 *inPtr = NULL;
1422 tANI_U8 i = 0;
1423 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1424
1425 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1426
1427 {
1428 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1429 "No update required for channel list "
1430 "either cfg.ini channel list is not set up or "
1431 "auto band (Band %d)", eBand);
1432 return status;
1433 }
1434
1435 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1436 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1437 if (eCSR_BAND_24 == eBand)
1438 {
1439 for (i = 0; i < inNumChannels; i++)
1440 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001441 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001442 {
1443 ChannelList[outNumChannels++] = inPtr[i];
1444 }
1445 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001446 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001447 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001448 }
1449 else if (eCSR_BAND_5G == eBand)
1450 {
1451 for (i = 0; i < inNumChannels; i++)
1452 {
1453 /* Add 5G Non-DFS channel */
1454 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001455 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001456 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1457 {
1458 ChannelList[outNumChannels++] = inPtr[i];
1459 }
1460 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001461 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001462 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001463 }
1464 else if (eCSR_BAND_ALL == eBand)
1465 {
1466 for (i = 0; i < inNumChannels; i++)
1467 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001468 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001469 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1470 {
1471 ChannelList[outNumChannels++] = inPtr[i];
1472 }
1473 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001474 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001475 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001476 }
1477 else
1478 {
1479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1480 "Invalid band, No operation carried out (Band %d)", eBand);
1481 status = eHAL_STATUS_INVALID_PARAMETER;
1482 }
1483
1484 return status;
1485}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001486#endif
1487
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001488#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001489/* This function modifies the roam scan channel list as per AP neighbor
1490 report; AP neighbor report may be empty or may include only other AP
1491 channels; in any case, we merge the channel list with the learned occupied
1492 channels list.
1493 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1494 if the band is 5G, then make sure channel list contains only 5G valid channels
1495*/
1496eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1497 tANI_U8 *pChannelList,
1498 tANI_U8 numChannels,
1499 const eCsrBand eBand)
1500{
1501 eHalStatus status = eHAL_STATUS_SUCCESS;
1502 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1503 tANI_U8 outNumChannels = 0;
1504 tANI_U8 inNumChannels = numChannels;
1505 tANI_U8 *inPtr = pChannelList;
1506 tANI_U8 i = 0;
1507 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1508 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1509 tANI_U8 mergedOutputNumOfChannels = 0;
1510 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1511
1512 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1513 * report Channels. This increases the chances of the DUT to get a candidate AP while
1514 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1515 if (pMac->scan.occupiedChannels.numChannels)
1516 {
1517 csrNeighborRoamMergeChannelLists(pMac,
1518 &pMac->scan.occupiedChannels.channelList[0],
1519 pMac->scan.occupiedChannels.numChannels,
1520 inPtr,
1521 inNumChannels,
1522 &mergedOutputNumOfChannels);
1523 inNumChannels = mergedOutputNumOfChannels;
1524 }
1525
1526 if (eCSR_BAND_24 == eBand)
1527 {
1528 for (i = 0; i < inNumChannels; i++)
1529 {
1530 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1531 {
1532 ChannelList[outNumChannels++] = inPtr[i];
1533 }
1534 }
1535 }
1536 else if (eCSR_BAND_5G == eBand)
1537 {
1538 for (i = 0; i < inNumChannels; i++)
1539 {
1540 /* Add 5G Non-DFS channel */
1541 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1542 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1543 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1544 {
1545 ChannelList[outNumChannels++] = inPtr[i];
1546 }
1547 }
1548 }
1549 else if (eCSR_BAND_ALL == eBand)
1550 {
1551 for (i = 0; i < inNumChannels; i++)
1552 {
1553 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1554 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1555 {
1556 ChannelList[outNumChannels++] = inPtr[i];
1557 }
1558 }
1559 }
1560 else
1561 {
1562 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1563 "Invalid band, No operation carried out (Band %d)", eBand);
1564 return eHAL_STATUS_INVALID_PARAMETER;
1565 }
1566
1567 /* if roaming within band is enabled, then select only the
1568 in band channels .
1569 This is required only if the band capability is set to ALL,
1570 E.g., if band capability is only 2.4G then all the channels in the
1571 list are already filtered for 2.4G channels, hence ignore this check*/
1572
1573 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1574 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301575 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001576 pMac,
1577 ChannelList,
1578 outNumChannels,
1579 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301580 &outNumChannels,
1581 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301582 vos_mem_copy(ChannelList,
1583 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001584 }
1585
1586 /* Prepare final roam scan channel list */
1587 if(outNumChannels)
1588 {
1589 /* Clear the channel list first */
1590 if (NULL != currChannelListInfo->ChannelList)
1591 {
1592 vos_mem_free(currChannelListInfo->ChannelList);
1593 currChannelListInfo->ChannelList = NULL;
1594 currChannelListInfo->numOfChannels = 0;
1595 }
1596
1597 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1598 if (NULL == currChannelListInfo->ChannelList)
1599 {
1600 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1601 "Failed to allocate memory for roam scan channel list");
1602 currChannelListInfo->numOfChannels = 0;
1603 return VOS_STATUS_E_RESOURCES;
1604 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301605 vos_mem_copy(currChannelListInfo->ChannelList,
1606 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001607 }
1608 return status;
1609}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001610#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001611
Jeff Johnson295189b2012-06-20 16:38:30 -07001612eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1613{
1614 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1615 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1617 (eBand == eCSR_BAND_24))
1618 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001619 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001621 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001622 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 pMac->roam.configParam.uCfgDot11Mode, eBand);
1624 return eHAL_STATUS_INVALID_PARAMETER;
1625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1627 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1628 (eBand == eCSR_BAND_5G))
1629 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001630 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001632 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001633 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 pMac->roam.configParam.uCfgDot11Mode, eBand);
1635 return eHAL_STATUS_INVALID_PARAMETER;
1636 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001637 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001638 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001639 pMac->roam.configParam.eBand = eBand;
1640 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001642#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001643 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1644 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 status = csrInitGetChannels( pMac );
1647 if (eHAL_STATUS_SUCCESS == status)
1648 csrInitChannelList( hHal );
1649 return status;
1650}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001651
1652
Jeff Johnsone7245742012-09-05 17:12:55 -07001653/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1654 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1655 * Ideally we should have kept the ini value and enum value same and representing the same
1656 * cb values as in 11n standard i.e.
1657 * Set to 1 (SCA) if the secondary channel is above the primary channel
1658 * Set to 3 (SCB) if the secondary channel is below the primary channel
1659 * Set to 0 (SCN) if no secondary channel is present
1660 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1661 * 0 - secondary none
1662 * 1 - secondary LOW
1663 * 2 - secondary HIGH
1664 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1665 * The enum values are as follows:
1666 * PHY_SINGLE_CHANNEL_CENTERED = 0
1667 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1668 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1669 */
1670ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1671{
1672
1673 ePhyChanBondState phyCbState;
1674 switch (cbIniValue) {
1675 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301676 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001677 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1678 break;
1679 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301680 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001681 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1682 break;
1683 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301684 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001685 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1686 break;
1687#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301688 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1689 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001690 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301691 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001692 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1693 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301694 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1695 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1696 break;
1697 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001698 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1699 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301700 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001701 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301702 break;
1703 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001704 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1705 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301706 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001707 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301708 break;
1709#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001710 default:
1711 // If an invalid value is passed, disable CHANNEL BONDING
1712 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1713 break;
1714 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301715
Jeff Johnsone7245742012-09-05 17:12:55 -07001716 return phyCbState;
1717}
1718
1719v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1720{
1721
1722 v_U32_t cbIniValue;
1723 switch (phyCbState) {
1724 // secondary none
1725 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301726 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001727 break;
1728 // secondary LOW
1729 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301730 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001731 break;
1732 // secondary HIGH
1733 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301734 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001735 break;
1736#ifdef WLAN_FEATURE_11AC
1737 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301738 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001739 break;
1740 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301741 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001742 break;
1743 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301744 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001745 break;
1746 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301747 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001748 break;
1749 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301750 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001751 break;
1752 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301753 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001754 break;
1755 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301756 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001757 break;
1758#endif
1759 default:
1760 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301761 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001762 break;
1763 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301764
Jeff Johnsone7245742012-09-05 17:12:55 -07001765 return cbIniValue;
1766}
Jeff Johnson295189b2012-06-20 16:38:30 -07001767
1768eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1769{
1770 eHalStatus status = eHAL_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05301771 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001772
1773 if(pParam)
1774 {
1775 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1776 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1777 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1778 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1779 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1780 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1781
1782 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001783 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1784
Jeff Johnsone7245742012-09-05 17:12:55 -07001785 /* channelBondingMode5GHz plays a dual role right now
1786 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1787 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1788 */
1789 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001791 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001792 }
1793 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1794 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001796 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001797 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301798#ifdef WLAN_FEATURE_AP_HT40_24G
1799 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1800#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001801 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1803 pMac->roam.configParam.phyMode = pParam->phyMode;
1804 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1805 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1806 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1807 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1808 pMac->roam.configParam.TxRate = pParam->TxRate;
1809 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1810 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1811 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1812 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1813 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001814 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 //if HDD passed down non zero values then only update,
1816 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301817 if (pParam->nInitialDwellTime)
1818 {
1819 pMac->roam.configParam.nInitialDwellTime =
1820 pParam->nInitialDwellTime;
1821 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001822 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 {
1824 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301825 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1826 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001828 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 {
1830 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301831 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1832 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001834 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 {
1836 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301837 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1838 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001840 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 {
1842 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301843 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1844 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301846 if (pParam->nOBSSScanWidthTriggerInterval)
1847 {
1848 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1849 pParam->nOBSSScanWidthTriggerInterval;
1850 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1851 pParam->nOBSSScanWidthTriggerInterval);
1852 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301853 if (pParam->max_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001854 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301855 pMac->roam.configParam.max_chntime_btc_esco =
1856 pParam->max_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001857 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301858 if (pParam->min_chntime_btc_esco)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001859 {
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301860 pMac->roam.configParam.min_chntime_btc_esco =
1861 pParam->min_chntime_btc_esco;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001862 }
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301863 if (pParam->min_chntime_btc_sco)
1864 pMac->roam.configParam.min_chntime_btc_sco =
1865 pParam->min_chntime_btc_sco;
1866 if (pParam->max_chntime_btc_sco)
1867 pMac->roam.configParam.max_chntime_btc_sco =
1868 pParam->max_chntime_btc_sco;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001869#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001870 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001871 {
1872 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1873 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001874 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001875 {
1876 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1877 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001878 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001879 {
1880 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1881 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001882 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001883 {
1884 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1885 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001886 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001887 {
1888 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1889 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001890 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001891 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001892 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1893 }
1894 if (pParam->nNumP2PChanCombinedConc)
1895 {
1896 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001897 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001898#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001900 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 {
1902 //Change the unit from second to microsecond
1903 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1905 {
1906 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1907 }
1908 else
1909 {
1910 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1911 }
1912 }
1913 else
1914 {
1915 pMac->roam.configParam.impsSleepTime = 0;
1916 }
1917 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1919 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 //if HDD passed down non zero values for age params, then only update,
1921 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001922 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 {
1924 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 if(pParam->scanAgeTimeNCNPS)
1927 {
1928 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 if(pParam->scanAgeTimeNCPS)
1931 {
1932 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 if(pParam->scanAgeTimeCNPS)
1935 {
1936 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1937 }
1938 if(pParam->scanAgeTimeCPS)
1939 {
1940 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1941 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301942 if (pParam->initialScanSkipDFSCh)
1943 {
1944 pMac->roam.configParam.initialScanSkipDFSCh =
1945 pParam->initialScanSkipDFSCh;
1946 }
1947
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001948 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1950 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1951 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1952 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1953 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1955 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1957 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1958 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1959 //Assign this before calling CsrInit11dInfo
1960 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 if( csrIs11dSupported( pMac ) )
1962 {
1963 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1964 }
1965 else
1966 {
1967 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1968 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001969
1970 /* Initialize the power + channel information if 11h is enabled.
1971 If 11d is enabled this information has already been initialized */
1972 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1973 {
1974 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1975 }
1976
1977
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301978#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301979 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1980 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001981 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001982#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001983#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001985 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001986 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001987 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001988 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001989 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001990 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001991 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001992 pMac->roam.configParam.nProbes = pParam->nProbes;
1993 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001994#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001995#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301996 pMac->roam.configParam.isRoamOffloadScanEnabled =
1997 pParam->isRoamOffloadScanEnabled;
1998 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1999 pParam->bFastRoamInConIniFeatureEnabled;
2000 pMac->roam.configParam.isPERRoamEnabled =
2001 pParam->isPERRoamEnabled;
2002 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
2003 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
2004 pMac->roam.configParam.waitPeriodForNextPERScan =
2005 pParam->waitPeriodForNextPERScan;
2006 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
2007 pMac->roam.configParam.isPERRoamCCAEnabled =
2008 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302009 pMac->roam.configParam.PERRoamFullScanThreshold =
2010 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302011 pMac->roam.configParam.PERroamTriggerPercent =
2012 pParam->PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302013 pMac->roam.configParam.PERMinRssiThresholdForRoam =
2014 pParam->PERMinRssiThresholdForRoam;
2015 pMac->PERroamTimeout = pParam->waitPeriodForNextPERScan;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002016#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302017
2018#ifdef WLAN_FEATURE_LFR_MBB
2019 pMac->roam.configParam.enable_lfr_mbb = pParam->enable_lfr_mbb;
2020#endif
2021
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002022#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002023 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08002024 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002025#endif
2026
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002027#ifdef FEATURE_WLAN_ESE
2028 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002030#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302031 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
2032 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002033 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
2034 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
2035 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
2036 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
2037 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
2038 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
2039 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
2040 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05302041 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +05302042 smsLog( pMac, LOG1, "nWeakZoneRssiThresholdForRoam = %d", pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 {
2044 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002045 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2047 {
2048 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 }
2051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
2053 pMac->scan.fValidateList = pParam->fValidateList;
2054 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2055 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302056 pMac->scan.disable_scan_during_sco = pParam->disable_scan_during_sco;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08002057 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002059 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05302060 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07002061 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2062 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2063 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2064 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2065 * single session
2066 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002067 //Remove this code once SLM_Sessionization is supported
2068 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002069 pMac->roam.configParam.doBMPSWorkaround = 0;
2070
Jeff Johnsone7245742012-09-05 17:12:55 -07002071#ifdef WLAN_FEATURE_11AC
2072 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002073 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002074 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002075 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302076 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2077 if ( pParam->enableTxBF )
2078 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2079 else
2080 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002081#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002082 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002083
2084 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002085 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302086 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302087 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302088 pMac->roam.configParam.disableP2PMacSpoofing =
2089 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302090 pMac->roam.configParam.enableFatalEvent =
2091 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002092 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2093 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302094 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302095 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302096#ifdef WLAN_FEATURE_AP_HT40_24G
2097 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2098#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302099 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302100 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2101 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302102
2103 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2104 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2105 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2106 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2107 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2108
2109 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2110 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2111 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2112 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2113
2114 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2115 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2116 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2117 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302118 pMac->sta_sap_scc_on_dfs_chan = pParam->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302119 pMac->force_scc_with_ecsa = pParam->force_scc_with_ecsa;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302120 for (i = 0; i < 3; i++) {
2121 pMac->roam.configParam.agg_btc_sco_oui[i] =
2122 pParam->agg_btc_sco_oui[i];
2123 }
2124 pMac->roam.configParam.num_ba_buff_btc_sco =
2125 pParam->num_ba_buff_btc_sco;
2126 pMac->roam.configParam.num_ba_buff = pParam->num_ba_buff;
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 }
2128
2129 return status;
2130}
2131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2133{
2134 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302135 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 if(pParam)
2137 {
2138 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2139 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2140 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2141 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2142 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2143 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002144 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302145#ifdef WLAN_FEATURE_AP_HT40_24G
2146 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2147#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002148 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2150 pParam->phyMode = pMac->roam.configParam.phyMode;
2151 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2152 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2153 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2154 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2155 pParam->TxRate = pMac->roam.configParam.TxRate;
2156 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2157 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2158 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2159 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2160 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2162 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2163 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2164 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Abhishek Singh3a93ee42016-09-29 17:00:03 +05302165 pParam->max_chntime_btc_esco =
2166 pMac->roam.configParam.max_chntime_btc_esco;
2167 pParam->min_chntime_btc_esco =
2168 pMac->roam.configParam.min_chntime_btc_esco;
2169 pParam->min_chntime_btc_sco =
2170 pMac->roam.configParam.min_chntime_btc_sco;
2171 pParam->max_chntime_btc_sco =
2172 pMac->roam.configParam.max_chntime_btc_sco;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002173 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002174#ifdef WLAN_AP_STA_CONCURRENCY
2175 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2176 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2177 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2178 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2179 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002180 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2181 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 //Change the unit from microsecond to second
2184 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2185 pParam->eBand = pMac->roam.configParam.eBand;
2186 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2187 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2188 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2189 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2190 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2191 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2192 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2193 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2194 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2195 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2196 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2197 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2198 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2200 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2201 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2202 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2204 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2205 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2206 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Padma, Santhosh Kumar36183352016-11-08 17:48:34 +05302207 pParam->disable_scan_during_sco = pMac->scan.disable_scan_during_sco;
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002209 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002210 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002211 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002212 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302213 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002214#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302215 vos_mem_copy(&pParam->neighborRoamConfig,
2216 &pMac->roam.configParam.neighborRoamConfig,
2217 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002218#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002219#ifdef WLAN_FEATURE_11AC
2220 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002221 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002222 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002223 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302224 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2225 if ( pParam->enableTxBF )
2226 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2227 else
2228 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002229#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002230#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302231 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2232 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002233#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002234#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002235 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2236 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2237 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2238 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2239 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002240 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002241 pParam->nProbes = pMac->roam.configParam.nProbes;
2242 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002243#endif
2244#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2245 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2246 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302247 pParam->isPERRoamEnabled =
2248 pMac->roam.configParam.isPERRoamEnabled;
2249 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2250 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2251 pParam->waitPeriodForNextPERScan =
2252 pMac->roam.configParam.waitPeriodForNextPERScan;
2253 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2254 pParam->isPERRoamCCAEnabled =
2255 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302256 pParam->PERRoamFullScanThreshold =
2257 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302258 pParam->PERroamTriggerPercent =
2259 pMac->roam.configParam.PERroamTriggerPercent;
Kapil Gupta192d9d42016-11-25 16:24:13 +05302260 pParam->PERMinRssiThresholdForRoam =
2261 pMac->roam.configParam.PERMinRssiThresholdForRoam;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002262#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302263
2264#ifdef WLAN_FEATURE_LFR_MBB
2265 pParam->enable_lfr_mbb = pMac->roam.configParam.enable_lfr_mbb;
2266#endif
2267
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002268#ifdef FEATURE_WLAN_LFR
2269 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2270#endif
2271
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002272#ifdef FEATURE_WLAN_ESE
2273 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002274#endif
2275#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302276 vos_mem_copy(&pParam->neighborRoamConfig,
2277 &pMac->roam.configParam.neighborRoamConfig,
2278 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002279 {
2280 int i;
2281 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2282 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2283 {
2284 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2285 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002286 }
2287#endif
2288
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002289 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002290
krunal soni5afa96c2013-09-06 22:19:02 -07002291 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002292 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302293 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302294 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302295 pParam->disableP2PMacSpoofing =
2296 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302297 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002298
krunal sonie9002db2013-11-25 14:24:17 -08002299 pParam->isCoalesingInIBSSAllowed =
2300 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302301 pParam->allowDFSChannelRoam =
2302 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302303 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302305#ifdef WLAN_FEATURE_AP_HT40_24G
2306 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2307#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302308 pParam->max_chan_for_dwell_time_cfg =
2309 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
Abhishek Singh48cd3402016-03-30 15:20:19 +05302311 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2312 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2313 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2314 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2315 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2316
2317 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2318 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2319 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2320 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2321
2322 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2323 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2324 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2325 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Ganesh Kondabattinie3ac17f2017-11-30 15:09:07 +05302326 pParam->sta_sap_scc_on_dfs_chan = pMac->sta_sap_scc_on_dfs_chan;
Yeshwanth Sriram Guntukad3a9fc52018-01-10 15:09:49 +05302327 pParam->force_scc_with_ecsa = pMac->force_scc_with_ecsa;
2328
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +05302329 for (i = 0; i < 3; i++) {
2330 pParam->agg_btc_sco_oui[i] =
2331 pMac->roam.configParam.agg_btc_sco_oui[i];
2332 }
2333 pParam->num_ba_buff_btc_sco =
2334 pMac->roam.configParam.num_ba_buff_btc_sco;
2335 pParam->num_ba_buff = pMac->roam.configParam.num_ba_buff;
2336
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 status = eHAL_STATUS_SUCCESS;
2338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 return (status);
2340}
2341
Jeff Johnson295189b2012-06-20 16:38:30 -07002342eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2343{
2344 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2345 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2346 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2347 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 do
2349 {
2350 if(eCSR_BAND_24 == eBand)
2351 {
2352 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2353 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2354 }
2355 if(eCSR_BAND_5G == eBand)
2356 {
2357 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2358 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2359 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2360 )
2361 {
2362 break;
2363 }
2364 }
2365 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2366 {
2367 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2368 }
2369 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2370 {
2371 newPhyMode = eCSR_DOT11_MODE_AUTO;
2372 }
2373 else
2374 {
2375 //Check for dual band and higher capability first
2376 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2377 {
2378 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2379 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2380 }
2381 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2382 {
2383 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2384 if(eCSR_BAND_24 == eBand) break;
2385 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2386 eBand = eCSR_BAND_5G;
2387 }
2388 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2389 {
2390 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2391 if(eCSR_BAND_5G == eBand) break;
2392 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2393 eBand = eCSR_BAND_24;
2394 }
2395 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2396 {
2397 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2398 if(eCSR_BAND_5G == eBand) break;
2399 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2400 eBand = eCSR_BAND_24;
2401 }
2402 else if(eCSR_DOT11_MODE_11n & phyMode)
2403 {
2404 newPhyMode = eCSR_DOT11_MODE_11n;
2405 }
2406 else if(eCSR_DOT11_MODE_abg & phyMode)
2407 {
2408 newPhyMode = eCSR_DOT11_MODE_abg;
2409 }
2410 else if(eCSR_DOT11_MODE_11a & phyMode)
2411 {
2412 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2413 {
2414 if(eCSR_BAND_ALL == eBand)
2415 {
2416 newPhyMode = eCSR_DOT11_MODE_abg;
2417 }
2418 else
2419 {
2420 //bad setting
2421 break;
2422 }
2423 }
2424 else
2425 {
2426 newPhyMode = eCSR_DOT11_MODE_11a;
2427 eBand = eCSR_BAND_5G;
2428 }
2429 }
2430 else if(eCSR_DOT11_MODE_11g & phyMode)
2431 {
2432 newPhyMode = eCSR_DOT11_MODE_11g;
2433 eBand = eCSR_BAND_24;
2434 }
2435 else if(eCSR_DOT11_MODE_11b & phyMode)
2436 {
2437 newPhyMode = eCSR_DOT11_MODE_11b;
2438 eBand = eCSR_BAND_24;
2439 }
2440 else
2441 {
2442 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002443 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 newPhyMode = eCSR_DOT11_MODE_AUTO;
2445 }
2446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 //Done validating
2448 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 //Now we need to check whether a restart is needed.
2450 if(eBand != pMac->roam.configParam.eBand)
2451 {
2452 fRestartNeeded = eANI_BOOLEAN_TRUE;
2453 break;
2454 }
2455 if(newPhyMode != pMac->roam.configParam.phyMode)
2456 {
2457 fRestartNeeded = eANI_BOOLEAN_TRUE;
2458 break;
2459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 if(HAL_STATUS_SUCCESS(status))
2462 {
2463 pMac->roam.configParam.eBand = eBand;
2464 pMac->roam.configParam.phyMode = newPhyMode;
2465 if(pfRestartNeeded)
2466 {
2467 *pfRestartNeeded = fRestartNeeded;
2468 }
2469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 return (status);
2471}
2472
Jeff Johnson295189b2012-06-20 16:38:30 -07002473void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2474{
2475 tANI_U8 Index;
2476 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 // for dual band NICs, don't need to trim the channel list....
2478 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2479 {
2480 // 2.4 GHz band operation requires the channel list to be trimmed to
2481 // the 2.4 GHz channels only...
2482 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2483 {
2484 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2485 Index++ )
2486 {
2487 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2488 {
2489 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2490 cChannels++;
2491 }
2492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2494 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2495 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2496 // only if we need to.
2497 //
2498 // The amount of memory to clear is the number of channesl that we trimmed
2499 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2500
2501 if ( pChannelList->numChannels > cChannels )
2502 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302503 vos_mem_set(&pChannelList->channelList[ cChannels ],
2504 sizeof( pChannelList->channelList[ 0 ] ) *
2505 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 }
2507
2508 pChannelList->numChannels = cChannels;
2509 }
2510 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2511 {
2512 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2513 {
2514 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2515 {
2516 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2517 cChannels++;
2518 }
2519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2521 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2522 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2523 // only if we need to.
2524 //
2525 // The amount of memory to clear is the number of channesl that we trimmed
2526 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2527 if ( pChannelList->numChannels > cChannels )
2528 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302529 vos_mem_set(&pChannelList->channelList[ cChannels ],
2530 sizeof( pChannelList->channelList[ 0 ] ) *
2531 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 }
2533
2534 pChannelList->numChannels = cChannels;
2535 }
2536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537}
Jeff Johnson295189b2012-06-20 16:38:30 -07002538#define INFRA_AP_DEFAULT_CHANNEL 6
2539eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2540{
2541 tANI_U8 index= 0;
2542 eHalStatus status = eHAL_STATUS_FAILURE;
2543 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2544 {
2545 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2546 status = eHAL_STATUS_SUCCESS;
2547 break;
2548 }
2549 }
2550 return status;
2551}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002552
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002553
Jeff Johnson295189b2012-06-20 16:38:30 -07002554eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2555{
2556 eHalStatus status = eHAL_STATUS_SUCCESS;
2557 tANI_U8 num20MHzChannelsFound = 0;
2558 VOS_STATUS vosStatus;
2559 tANI_U8 Index = 0;
2560 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562
2563 //TODO: this interface changed to include the 40MHz channel list
2564 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2565 // Read the scan channel list (including the power limit) from EEPROM
2566 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2567 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2568 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002570 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 status = eHAL_STATUS_FAILURE;
2572 }
2573 else
2574 {
2575 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2576 {
2577 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2578 }
2579 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2580 // Move the channel list to the global data
2581 // structure -- this will be used as the scan list
2582 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2583 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 }
2586 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2587 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2588 {
2589 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2590 }
2591 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2592 {
2593 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2594 }
2595 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 return (status);
2598}
Jeff Johnson295189b2012-06-20 16:38:30 -07002599eHalStatus csrInitChannelList( tHalHandle hHal )
2600{
2601 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2602 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2604 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002605 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2606 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002608 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302609 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 return (status);
2611}
Jeff Johnson295189b2012-06-20 16:38:30 -07002612eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2613 tCsrUpdateConfigParam *pUpdateConfigParam)
2614{
2615 eHalStatus status = eHAL_STATUS_FAILURE;
2616 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2618 status = CsrInit11dInfo(pMac, ps11dinfo);
2619 return status;
2620}
2621
Jeff Johnson295189b2012-06-20 16:38:30 -07002622static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2623{
2624 eHalStatus status = eHAL_STATUS_FAILURE;
2625 tANI_U8 index;
2626 tANI_U32 count=0;
2627 tSirMacChanInfo *pChanInfo;
2628 tSirMacChanInfo *pChanInfoStart;
2629 tANI_BOOLEAN applyConfig = TRUE;
2630
Mihir Shetebc866f62014-02-13 16:08:53 +05302631 pMac->scan.currentCountryRSSI = -128;
2632
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 if(!ps11dinfo)
2634 {
2635 return (status);
2636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2638 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302639 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2640 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2641 ps11dinfo->Channels.channelList,
2642 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 }
2644 else
2645 {
2646 //No change
2647 return (eHAL_STATUS_SUCCESS);
2648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302650
2651 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2652 WNI_CFG_COUNTRY_CODE_LEN);
2653
2654
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 //Tush: at csropen get this initialized with default, during csr reset if this
2656 // already set with some value no need initilaize with default again
2657 if(0 == pMac->scan.countryCodeCurrent[0])
2658 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302659 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2660 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302663 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2664 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302666 vos_mem_set(pChanInfo,
2667 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2668 0);
2669
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002671 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2672 {
2673 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2674 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2675 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2676 pChanInfo++;
2677 count++;
2678 }
2679 if(count)
2680 {
2681 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2682 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302683 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002684 }
2685 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2686 if( HAL_STATUS_SUCCESS(status) )
2687 {
2688 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2689 {
2690 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2691 {
2692 applyConfig = FALSE;
2693 }
2694 }
2695
2696 if(TRUE == applyConfig)
2697 {
2698 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002699 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002700 }
2701
2702 }
2703 return (status);
2704}
2705/* Initialize the Channel + Power List in the local cache and in the CFG */
2706eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2707{
2708 tANI_U8 index;
2709 tANI_U32 count=0;
2710 tSirMacChanInfo *pChanInfo;
2711 tSirMacChanInfo *pChanInfoStart;
2712
2713 if(!ps11dinfo || !pMac)
2714 {
2715 return eHAL_STATUS_FAILURE;
2716 }
2717
Kiet Lam64c1b492013-07-12 13:56:44 +05302718 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2719 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002720 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302721 vos_mem_set(pChanInfo,
2722 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2723 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002724 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2727 {
2728 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2729 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2730 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2731 pChanInfo++;
2732 count++;
2733 }
2734 if(count)
2735 {
2736 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2737 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302738 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 }
2740
Jeff Johnsone7245742012-09-05 17:12:55 -07002741 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742}
2743
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302744/**
2745 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2746 * list
2747 *
2748 * @pMac: pointer to global mac
2749 * @sessionId: session id for the cmd
2750 * @pList: pending list from which cmd needs to be removed
2751 * @pCommand: cmd to be removed, can be NULL
2752 * @eRoamReason: cmd with reason to be removed
2753 *
2754 * Remove duplicate command from the pending list.
2755 *
2756 * Return: void
2757 */
2758void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2759 tANI_U32 sessionId, tDblLinkList *pList,
2760 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002761{
2762 tListElem *pEntry, *pNextEntry;
2763 tSmeCmd *pDupCommand;
2764 tDblLinkList localList;
2765
2766 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302767 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302769 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 return;
2771 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302772 csrLLLock(pList);
2773 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2774 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302776 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2777 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2778 /*
Abhishek Singhd2ce6802018-05-08 15:21:06 +05302779 * If pCommand is not NULL remove the similar duplicate cmd for same
2780 * reason as pCommand. If pCommand is NULL then check if eRoamReason is
2781 * eCsrForcedDisassoc (disconnect) and remove all roam command for the
2782 * sessionId, else if eRoamReason is eCsrHddIssued (connect) remove all
2783 * connect (non disconenct) commands.
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302784 */
2785 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2786 ((pCommand->command == pDupCommand->command) &&
2787 /*
2788 * This peermac check is requried for Softap/GO scenarios
2789 * For STA scenario below OR check will suffice as pCommand
2790 * will always be NULL for STA scenarios
2791 */
2792 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2793 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2794 ((pCommand->u.roamCmd.roamReason ==
2795 pDupCommand->u.roamCmd.roamReason) ||
2796 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2797 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2798 /* OR if pCommand is NULL */
2799 ((sessionId == pDupCommand->sessionId) &&
2800 (eSmeCommandRoam == pDupCommand->command) &&
2801 ((eCsrForcedDisassoc == eRoamReason) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05302802 (eCsrHddIssued == eRoamReason &&
2803 !CSR_IS_DISCONNECT_COMMAND(pDupCommand)))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302805 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2806 pDupCommand->u.roamCmd.roamReason);
2807 /* Remove the 'stale' roam command from the pending list */
2808 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 }
2811 pEntry = pNextEntry;
2812 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302813 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002814
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302815 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 {
2817 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302818 /* Tell caller that the command is cancelled */
2819 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2820 pDupCommand->u.roamCmd.roamId,
2821 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 csrReleaseCommandRoam(pMac, pDupCommand);
2823 }
2824 csrLLClose(&localList);
2825}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302826
2827/**
2828 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2829 * from pending lists.
2830 *
2831 * @pMac: pointer to global mac
2832 * @sessionId: session id for the cmd
2833 * @pCommand: cmd to be removed, can be null
2834 * @eRoamReason: cmd with reason to be removed
2835 *
2836 * Remove duplicate command from the sme and roam pending list.
2837 *
2838 * Return: void
2839 */
2840void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2841 tANI_U32 sessionId, tSmeCmd *pCommand,
2842 eCsrRoamReason eRoamReason)
2843{
2844 /* Always lock active list before locking pending lists */
2845 csrLLLock(&pMac->sme.smeCmdActiveList);
2846 csr_roam_remove_duplicate_cmd_from_list(pMac,
2847 sessionId, &pMac->sme.smeCmdPendingList,
2848 pCommand, eRoamReason);
2849 csr_roam_remove_duplicate_cmd_from_list(pMac,
2850 sessionId, &pMac->roam.roamCmdPendingList,
2851 pCommand, eRoamReason);
2852 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2853}
2854
Jeff Johnson295189b2012-06-20 16:38:30 -07002855eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2856 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2857{
2858 eHalStatus status = eHAL_STATUS_SUCCESS;
2859#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2860 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2861#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302862 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2864 {
2865 pSession = CSR_GET_SESSION( pMac, sessionId );
2866 }
2867 else
2868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002869 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 VOS_ASSERT(0);
2871 return eHAL_STATUS_FAILURE;
2872 }
krunal soni587bf012014-02-04 12:35:11 -08002873
2874 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2875 {
2876 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2877 return eHAL_STATUS_FAILURE;
2878 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002879
krunal soni587bf012014-02-04 12:35:11 -08002880 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2881
krunal soni7f7d2c92014-02-06 15:08:43 -08002882 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002884 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002886 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2887 /*
2888 * Decrement bRefAssocStartCnt for FT reassoc failure.
2889 * Reason: For FT reassoc failures, we first call
2890 * csrRoamCallCallback before notifying a failed roam
2891 * completion through csrRoamComplete. The latter in
2892 * turn calls csrRoamProcessResults which tries to
2893 * once again call csrRoamCallCallback if bRefAssocStartCnt
2894 * is non-zero. Since this is redundant for FT reassoc
2895 * failure, decrement bRefAssocStartCnt.
2896 */
2897 pSession->bRefAssocStartCnt--;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05302898 } else if (u1 == eCSR_ROAM_ECSA_CHAN_CHANGE_RSP && u2 ==
2899 eCSR_ROAM_RESULT_NONE)
2900 pSession->connectedProfile.operationChannel =
2901 pRoamInfo->ap_chan_change_rsp->new_channel;
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002902
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05302903 if (eCSR_ROAM_RESULT_LOSTLINK == u2 ||
2904 eCSR_ROAM_LOSTLINK_DETECTED == u1)
2905 smsLog(pMac, LOG1, "eCSR_ROAM_RESULT_LOSTLINK ");
2906
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 if(NULL != pSession->callback)
2908 {
2909 if( pRoamInfo )
2910 {
2911 pRoamInfo->sessionId = (tANI_U8)sessionId;
2912 }
2913
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302914 /* avoid holding the global lock when making the roaming callback, original change came
2915 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2916 is possible on other OS ports where the callback may need to take locks to protect
2917 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2919 that may actually depend on the lock being held */
2920 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2921 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2922 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2923 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302924 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2925 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002926#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302927 vos_mem_set(&connectionStatus,
2928 sizeof(vos_event_wlan_status_payload_type), 0);
2929
krunal soni7f7d2c92014-02-06 15:08:43 -08002930 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 {
2932 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2933 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2934 if(NULL != pRoamInfo->pBssDesc)
2935 {
2936 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2937 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2940 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2941 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302942 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302943 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2944 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302945
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302947 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2950 {
2951 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2952 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302953 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 if(eCSR_ROAM_RESULT_FORCED == u2)
2956 {
2957 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2958 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302959 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2962 {
2963 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2964 connectionStatus.reason = eCSR_REASON_DISASSOC;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302965 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2968 {
2969 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2970 connectionStatus.reason = eCSR_REASON_DEAUTH;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302971 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002973#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2974
2975 return (status);
2976}
Jeff Johnson295189b2012-06-20 16:38:30 -07002977// Returns whether handoff is currently in progress or not
2978tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2979{
2980#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2981 return csrNeighborRoamIsHandoffInProgress(pMac);
2982#else
2983 return eANI_BOOLEAN_FALSE;
2984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002985}
Jeff Johnson295189b2012-06-20 16:38:30 -07002986eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2987 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2988{
2989 eHalStatus status = eHAL_STATUS_SUCCESS;
2990 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2991 tANI_U16 reasonCode;
2992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002993
2994 if(!pSession)
2995 {
2996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2997 return eHAL_STATUS_FAILURE;
2998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002999
3000 //Restore AC weight in case we change it
3001 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
3002 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003003 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
3005 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
3006 }
3007
3008 if ( fMICFailure )
3009 {
3010 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
3011 }
3012 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
3013 {
3014 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003015 }
3016 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 {
3018 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003020#ifdef WLAN_FEATURE_VOWIFI_11R
3021 if ( (csrRoamIsHandoffInProgress(pMac)) &&
3022 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
3023 {
3024 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05303025 vos_mem_copy(&bssId,
3026 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
3027 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003028 }
3029 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003030#endif
3031 if(pSession->pConnectBssDesc)
3032 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303033 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003035
Jeff Johnson295189b2012-06-20 16:38:30 -07003036
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05303037 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
3038 " subState = %s reason=%d"),
3039 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
3040 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08003041
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3043
3044 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
3045
3046 if(HAL_STATUS_SUCCESS(status))
3047 {
3048 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003049#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3050 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
3051 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
3052 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003053 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
3055 }
3056#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003057 }
3058 else
3059 {
3060 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
3061 }
3062
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 return (status);
3064}
Jeff Johnson295189b2012-06-20 16:38:30 -07003065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066/* ---------------------------------------------------------------------------
3067 \fn csrRoamIssueDisassociateStaCmd
3068 \brief csr function that HDD calls to disassociate a associated station
3069 \param sessionId - session Id for Soft AP
3070 \param pPeerMacAddr - MAC of associated station to delete
3071 \param reason - reason code, be one of the tSirMacReasonCodes
3072 \return eHalStatus
3073 ---------------------------------------------------------------------------*/
3074eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303075 tANI_U32 sessionId,
3076#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3077 const tANI_U8 *pPeerMacAddr,
3078#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05303080#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 tANI_U32 reason)
3082{
3083 eHalStatus status = eHAL_STATUS_SUCCESS;
3084 tSmeCmd *pCommand;
3085
3086 do
3087 {
3088 pCommand = csrGetCommandBuffer( pMac );
3089 if ( !pCommand )
3090 {
3091 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3092 status = eHAL_STATUS_RESOURCES;
3093 break;
3094 }
3095 pCommand->command = eSmeCommandRoam;
3096 pCommand->sessionId = (tANI_U8)sessionId;
3097 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
3098 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
3099 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
3100 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3101 if( !HAL_STATUS_SUCCESS( status ) )
3102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003103 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 csrReleaseCommandRoam( pMac, pCommand );
3105 }
3106 }while(0);
3107
3108 return status;
3109}
3110
3111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112/* ---------------------------------------------------------------------------
3113 \fn csrRoamIssueDeauthSta
3114 \brief csr function that HDD calls to delete a associated station
3115 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303116 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 \return eHalStatus
3118 ---------------------------------------------------------------------------*/
3119eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303120 tANI_U32 sessionId,
3121 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003122{
3123 eHalStatus status = eHAL_STATUS_SUCCESS;
3124 tSmeCmd *pCommand;
3125
3126 do
3127 {
3128 pCommand = csrGetCommandBuffer( pMac );
3129 if ( !pCommand )
3130 {
3131 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3132 status = eHAL_STATUS_RESOURCES;
3133 break;
3134 }
3135 pCommand->command = eSmeCommandRoam;
3136 pCommand->sessionId = (tANI_U8)sessionId;
3137 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303138 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3139 sizeof(tSirMacAddr));
3140 pCommand->u.roamCmd.reason =
3141 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3143 if( !HAL_STATUS_SUCCESS( status ) )
3144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003145 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 csrReleaseCommandRoam( pMac, pCommand );
3147 }
3148 }while(0);
3149
3150 return status;
3151}
Jeff Johnson295189b2012-06-20 16:38:30 -07003152eHalStatus
3153csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3154 tANI_BOOLEAN bEnable )
3155{
3156 eHalStatus status = eHAL_STATUS_FAILURE;
3157 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 if (!pSession)
3160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003161 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 return (status);
3163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 if (pSession->pConnectBssDesc)
3165 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303166 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 }
3168 else
3169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003170 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 return (status);
3172 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003173 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3174 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3176 return (status);
3177}
Jeff Johnson295189b2012-06-20 16:38:30 -07003178eHalStatus
3179csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3180 VOS_MODULE_ID modId, void *pUsrContext,
3181 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3182{
3183 eHalStatus status = eHAL_STATUS_SUCCESS;
3184 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3185 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 if (!pSession)
3187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003188 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 return (status);
3190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 if(pSession->pConnectBssDesc)
3192 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303193 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 }
3195 else
3196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003197 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 return (status);
3199 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003200 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3201 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3203 return (status);
3204}
Jeff Johnson295189b2012-06-20 16:38:30 -07003205eHalStatus
3206csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3207 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3208{
3209 eHalStatus status = eHAL_STATUS_SUCCESS;
3210 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3211 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3212
3213 if (!pSession)
3214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003215 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 return (status);
3217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 if(pSession->pConnectBssDesc)
3219 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303220 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222 else
3223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003224 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 return (status);
3226 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003227 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3228 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003229
3230 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3231
3232 return (status);
3233}
Jeff Johnson295189b2012-06-20 16:38:30 -07003234eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3235{
3236 eHalStatus status = eHAL_STATUS_SUCCESS;
3237 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3238 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003239
3240 if (!pSession)
3241 {
3242 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3243 return eHAL_STATUS_FAILURE;
3244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003245
3246 if(pSession->pConnectBssDesc)
3247 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303248 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003250 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3251 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3253
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303254 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303255 if(HAL_STATUS_SUCCESS(status))
3256 {
3257 csrRoamLinkDown(pMac, sessionId);
3258 }
3259 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003260 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303261 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3262 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003263 }
3264
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 return (status);
3266}
3267
Jeff Johnson295189b2012-06-20 16:38:30 -07003268eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3269{
3270 eHalStatus status = eHAL_STATUS_SUCCESS;
3271 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3272 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003273
3274 if(!pSession)
3275 {
3276 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3277 return eHAL_STATUS_FAILURE;
3278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279
3280 // If no BSS description was found in this connection (happens with start IBSS), then
3281 // nix the BSS description that we keep around for the connected BSS) and get out...
3282 if(NULL == pBssDesc)
3283 {
3284 csrFreeConnectBssDesc(pMac, sessionId);
3285 }
3286 else
3287 {
3288 size = pBssDesc->length + sizeof( pBssDesc->length );
3289 if(NULL != pSession->pConnectBssDesc)
3290 {
3291 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3292 {
3293 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3294 csrFreeConnectBssDesc(pMac, sessionId);
3295 }
3296 }
3297 if(NULL == pSession->pConnectBssDesc)
3298 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303299 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303301 if (NULL == pSession->pConnectBssDesc)
3302 status = eHAL_STATUS_FAILURE;
3303 else
3304 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 return (status);
3307}
3308
Jeff Johnson295189b2012-06-20 16:38:30 -07003309eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3310 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3311 tDot11fBeaconIEs *pIes)
3312{
3313 eHalStatus status = eHAL_STATUS_SUCCESS;
3314 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303316 if (pIes == NULL)
3317 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003318
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 do
3320 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303321 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3322 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 //get qos
3324 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3325 //get SSID
3326 if(pIes->SSID.present)
3327 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303328 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3330 }
3331 else
3332 pBssConfig->SSID.length = 0;
3333 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3334 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003335 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 //Return failed if profile doesn't have an SSID either.
3337 if(pProfile->SSIDs.numOfSSIDs == 0)
3338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003339 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 status = eHAL_STATUS_FAILURE;
3341 break;
3342 }
3343 }
3344 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3345 {
3346 pBssConfig->eBand = eCSR_BAND_5G;
3347 }
3348 else
3349 {
3350 pBssConfig->eBand = eCSR_BAND_24;
3351 }
3352 //phymode
3353 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3354 {
3355 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3356 }
3357 else
3358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003359 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 //force it
3361 if(eCSR_BAND_24 == pBssConfig->eBand)
3362 {
3363 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3364 }
3365 else
3366 {
3367 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3368 }
3369 }
Abhinav Kumar487e49e2019-07-22 14:46:18 +05303370 smsLog(pMac, LOG1,
3371 FL("phyMode %d uCfgDot11Mode %d negotiatedAuthType %d"),
3372 pProfile->phyMode, pBssConfig->uCfgDot11Mode,
3373 pProfile->negotiatedAuthType);
3374
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 //Qos
3376 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3377 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3378 {
3379 //Joining BSS is not 11n capable and WMM is disabled on client.
3380 //Disable QoS and WMM
3381 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3382 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303383
3384 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303385 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303386 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3387 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3388 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3389 {
3390 //Joining BSS is 11n capable and WMM is disabled on AP.
3391 //Assume all HT AP's are QOS AP's and enable WMM
3392 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3393 }
3394
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 //auth type
3396 switch( pProfile->negotiatedAuthType )
3397 {
3398 default:
3399 case eCSR_AUTH_TYPE_WPA:
3400 case eCSR_AUTH_TYPE_WPA_PSK:
3401 case eCSR_AUTH_TYPE_WPA_NONE:
3402 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3403 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 case eCSR_AUTH_TYPE_SHARED_KEY:
3406 pBssConfig->authType = eSIR_SHARED_KEY;
3407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 case eCSR_AUTH_TYPE_AUTOSWITCH:
3409 pBssConfig->authType = eSIR_AUTO_SWITCH;
3410 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303411 case eCSR_AUTH_TYPE_SAE:
3412 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
3413 break;
3414
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 }
3416 //short slot time
3417 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3418 {
3419 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3420 }
3421 else
3422 {
3423 pBssConfig->uShortSlotTime = 0;
3424 }
3425 if(pBssConfig->BssCap.ibss)
3426 {
3427 //We don't support 11h on IBSS
3428 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3429 }
3430 else
3431 {
3432 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3433 }
3434 //power constraint
3435 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3436 //heartbeat
3437 if ( CSR_IS_11A_BSS( pBssDesc ) )
3438 {
3439 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3440 }
3441 else
3442 {
3443 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3444 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303445 /*
3446 * Join timeout, if we find a BeaconInterval in the BssDescription,
3447 * then set the Join Timeout to be 3 BeaconInterval.
3448 */
3449 if (pBssDesc->beaconInterval)
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 {
3451 //Make sure it is bigger than the minimal
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303452 pBssConfig->uJoinTimeOut =
3453 CSR_ROAM_MAX(3 * pBssDesc->beaconInterval,
3454 CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 }
Abhishek Singh6e8ca792017-11-30 15:43:22 +05303456 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 {
3458 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3459 }
3460 //validate CB
3461 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Abhishek Singhe3beee22017-07-31 15:35:40 +05303462 if (CSR_IS_CHANNEL_24GHZ(pBssDesc->channelId) &&
3463 pProfile->force_24ghz_in_ht20) {
3464 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
3465 smsLog(pMac, LOG1,
3466 FL("force_24ghz_in_ht20 is set so set cbmode to 0"));
3467 }
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303468 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3469 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 return (status);
3472}
3473
Jeff Johnson295189b2012-06-20 16:38:30 -07003474static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3475 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3476{
3477 eHalStatus status = eHAL_STATUS_SUCCESS;
3478 tANI_U8 operationChannel = 0;
3479 tANI_U8 qAPisEnabled = FALSE;
3480 //SSID
3481 pBssConfig->SSID.length = 0;
3482 if(pProfile->SSIDs.numOfSSIDs)
3483 {
3484 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303485 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3486 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 }
3488 else
3489 {
3490 //SSID must present
3491 return eHAL_STATUS_FAILURE;
3492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 //Settomg up the capabilities
3494 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3495 {
3496 pBssConfig->BssCap.ibss = 1;
3497 }
3498 else
3499 {
3500 pBssConfig->BssCap.ess = 1;
3501 }
3502 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3503 {
3504 pBssConfig->BssCap.privacy = 1;
3505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 pBssConfig->eBand = pMac->roam.configParam.eBand;
3507 //phymode
3508 if(pProfile->ChannelInfo.ChannelList)
3509 {
3510 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3513 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 //QOS
3515 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 if ( pBssConfig->BssCap.ess == 1 )
3517 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 /*For Softap case enable WMM*/
3519 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3520 qAPisEnabled = TRUE;
3521 }
3522 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3524 qAPisEnabled = TRUE;
3525 } else {
3526 qAPisEnabled = FALSE;
3527 }
3528 } else {
3529 qAPisEnabled = TRUE;
3530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3532 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3533 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3534 )
3535 {
3536 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3537 } else {
3538 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3539 }
3540
3541 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003542 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 {
3544 default:
3545 case eCSR_AUTH_TYPE_WPA:
3546 case eCSR_AUTH_TYPE_WPA_PSK:
3547 case eCSR_AUTH_TYPE_WPA_NONE:
3548 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3549 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 case eCSR_AUTH_TYPE_SHARED_KEY:
3552 pBssConfig->authType = eSIR_SHARED_KEY;
3553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 case eCSR_AUTH_TYPE_AUTOSWITCH:
3555 pBssConfig->authType = eSIR_AUTO_SWITCH;
3556 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303557 case eCSR_AUTH_TYPE_SAE:
3558 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
3559 break;
3560
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 }
3562 //short slot time
3563 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3564 {
3565 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3566 }
3567 else
3568 {
3569 pBssConfig->uShortSlotTime = 0;
3570 }
3571 //power constraint. We don't support 11h on IBSS
3572 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3573 pBssConfig->uPowerLimit = 0;
3574 //heartbeat
3575 if ( eCSR_BAND_5G == pBssConfig->eBand )
3576 {
3577 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3578 }
3579 else
3580 {
3581 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3582 }
3583 //Join timeout
3584 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 return (status);
3587}
Jeff Johnson295189b2012-06-20 16:38:30 -07003588static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3589{
3590 eHalStatus status = eHAL_STATUS_FAILURE;
3591 tDot11fBeaconIEs *pIes = NULL;
3592
3593 do
3594 {
3595 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3596 {
3597 //err msg
3598 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003599 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 break;
3601 }
3602 //check if the AP is QAP & it supports APSD
3603 if( CSR_IS_QOS_BSS(pIes) )
3604 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303605 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 }
3607 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303608
3609 if (NULL != pIes)
3610 {
3611 vos_mem_free(pIes);
3612 }
3613
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 return status;
3615}
3616
Jeff Johnson295189b2012-06-20 16:38:30 -07003617void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3618{
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3620 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3621 // See !!Note: below in this function...
3622 tANI_U32 PrivacyEnabled = 0;
3623 tANI_U32 RsnEnabled = 0;
3624 tANI_U32 WepDefaultKeyId = 0;
3625 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3626 tANI_U32 Key0Length = 0;
3627 tANI_U32 Key1Length = 0;
3628 tANI_U32 Key2Length = 0;
3629 tANI_U32 Key3Length = 0;
3630
3631 // Reserve for the biggest key
3632 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3633 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3634 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3635 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3636
3637 switch ( pProfile->negotiatedUCEncryptionType )
3638 {
3639 case eCSR_ENCRYPT_TYPE_NONE:
3640
3641 // for NO encryption, turn off Privacy and Rsn.
3642 PrivacyEnabled = 0;
3643 RsnEnabled = 0;
3644
3645 // WEP key length and Wep Default Key ID don't matter in this case....
3646
3647 // clear out the WEP keys that may be hanging around.
3648 Key0Length = 0;
3649 Key1Length = 0;
3650 Key2Length = 0;
3651 Key3Length = 0;
3652
3653 break;
3654
3655 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303656 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003657
3658 // Privacy is ON. NO RSN for Wep40 static key.
3659 PrivacyEnabled = 1;
3660 RsnEnabled = 0;
3661
3662 // Set the Wep default key ID.
3663 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 // Wep key size if 5 bytes (40 bits).
3665 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3666
3667 // set encryption keys in the CFG database or clear those that are not present in this profile.
3668 if ( pProfile->Keys.KeyLength[0] )
3669 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303670 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3671 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3673 }
3674 else
3675 {
3676 Key0Length = 0;
3677 }
3678
3679 if ( pProfile->Keys.KeyLength[1] )
3680 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303681 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3682 WNI_CFG_WEP_KEY_LENGTH_5);
3683 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 }
3685 else
3686 {
3687 Key1Length = 0;
3688 }
3689
3690 if ( pProfile->Keys.KeyLength[2] )
3691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303692 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3693 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3695 }
3696 else
3697 {
3698 Key2Length = 0;
3699 }
3700
3701 if ( pProfile->Keys.KeyLength[3] )
3702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303703 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3704 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3706 }
3707 else
3708 {
3709 Key3Length = 0;
3710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 break;
3712
3713 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303714 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003715
3716 // Privacy is ON. NO RSN for Wep40 static key.
3717 PrivacyEnabled = 1;
3718 RsnEnabled = 0;
3719
3720 // Set the Wep default key ID.
3721 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3722
3723 // Wep key size if 13 bytes (104 bits).
3724 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3725
3726 // set encryption keys in the CFG database or clear those that are not present in this profile.
3727 if ( pProfile->Keys.KeyLength[0] )
3728 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303729 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3730 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3732 }
3733 else
3734 {
3735 Key0Length = 0;
3736 }
3737
3738 if ( pProfile->Keys.KeyLength[1] )
3739 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303740 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3741 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3743 }
3744 else
3745 {
3746 Key1Length = 0;
3747 }
3748
3749 if ( pProfile->Keys.KeyLength[2] )
3750 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303751 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3752 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3754 }
3755 else
3756 {
3757 Key2Length = 0;
3758 }
3759
3760 if ( pProfile->Keys.KeyLength[3] )
3761 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303762 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3763 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3765 }
3766 else
3767 {
3768 Key3Length = 0;
3769 }
3770
3771 break;
3772
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 case eCSR_ENCRYPT_TYPE_TKIP:
3774 case eCSR_ENCRYPT_TYPE_AES:
3775#ifdef FEATURE_WLAN_WAPI
3776 case eCSR_ENCRYPT_TYPE_WPI:
3777#endif /* FEATURE_WLAN_WAPI */
3778 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3779 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3780 PrivacyEnabled = (0 != fPrivacy);
3781
3782 // turn on RSN enabled for WPA associations
3783 RsnEnabled = 1;
3784
3785 // WEP key length and Wep Default Key ID don't matter in this case....
3786
3787 // clear out the static WEP keys that may be hanging around.
3788 Key0Length = 0;
3789 Key1Length = 0;
3790 Key2Length = 0;
3791 Key3Length = 0;
3792
3793 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 default:
3795 PrivacyEnabled = 0;
3796 RsnEnabled = 0;
3797 break;
3798 }
3799
3800 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3801 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3802 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3803 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3804 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3805 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3806 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3807 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3808}
3809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3811{
3812 tANI_U32 len = 0;
3813 if(pSSID->length <= WNI_CFG_SSID_LEN)
3814 {
3815 len = pSSID->length;
3816 }
3817 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3818}
3819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3821{
3822 eHalStatus status = eHAL_STATUS_SUCCESS;
3823 tANI_U32 QoSEnabled;
3824 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 // set the CFG enable/disable variables based on the qosType being configured...
3826 switch( qosType )
3827 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3829 QoSEnabled = FALSE;
3830 WmeEnabled = TRUE;
3831 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3833 QoSEnabled = FALSE;
3834 WmeEnabled = TRUE;
3835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3837 QoSEnabled = FALSE;
3838 WmeEnabled = TRUE;
3839 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3841 QoSEnabled = TRUE;
3842 WmeEnabled = FALSE;
3843 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 case eCSR_MEDIUM_ACCESS_11e_HCF:
3845 QoSEnabled = TRUE;
3846 WmeEnabled = FALSE;
3847 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 default:
3849 case eCSR_MEDIUM_ACCESS_DCF:
3850 QoSEnabled = FALSE;
3851 WmeEnabled = FALSE;
3852 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 }
3854 //save the WMM setting for later use
3855 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303856 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 return (status);
3858}
Jeff Johnson295189b2012-06-20 16:38:30 -07003859static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303860 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003861{
3862 eHalStatus status = eHAL_STATUS_FAILURE;
3863 int i;
3864 eCsrCfgDot11Mode cfgDot11Mode;
3865 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303866 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303867 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3868 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003870
3871 if( NULL != pIes )
3872 {
3873 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 // Originally, we thought that for 11a networks, the 11a rates are always
3875 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3876 // appear in the Operational Rate set. Consequently, in either case, we
3877 // would blindly put the rates we support into our Operational Rate set
3878 // (including the basic rates, which we have already verified are
3879 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 // However, it turns out that this is not always the case. Some AP's
3881 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3882 // too. Now, we're a little more careful:
3883 pDstRate = pOpRateSet->rate;
3884 if(pIes->SuppRates.present)
3885 {
3886 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3887 {
3888 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3889 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003890 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3891 {
3892 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3893 *pDstRate++ = pIes->SuppRates.rates[ i ];
3894 pOpRateSet->numRates++;
3895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 }
3897 }
3898 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303899 /* If there are Extended Rates in the beacon, we will reflect those
3900 * extended rates that we support in out Extended Operational Rate
3901 * set*/
3902 pDstRate = pExRateSet->rate;
3903 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303905 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303907 if (csrRatesIsDot11RateSupported(pMac,
3908 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303910 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3911 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303913 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3914 &rateBitmap);
3915 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3916 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 }
3918 }
3919 }
3920 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303921 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 }//Parsing BSSDesc
3923 else
3924 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003925 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 }
3927 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3928 return status;
3929}
3930
3931static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3932 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3933{
3934 int i;
3935 tANI_U8 *pDstRate;
3936 eCsrCfgDot11Mode cfgDot11Mode;
3937 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3938 tANI_U32 OperationalRatesLength = 0;
3939 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3940 tANI_U32 ExtendedOperationalRatesLength = 0;
3941 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3942 tANI_U32 ProprietaryOperationalRatesLength = 0;
3943 tANI_U32 PropRatesEnable = 0;
3944 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3945 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 if( NULL != pIes )
3948 {
3949 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 // Originally, we thought that for 11a networks, the 11a rates are always
3951 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3952 // appear in the Operational Rate set. Consequently, in either case, we
3953 // would blindly put the rates we support into our Operational Rate set
3954 // (including the basic rates, which we have already verified are
3955 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 // However, it turns out that this is not always the case. Some AP's
3957 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3958 // too. Now, we're a little more careful:
3959 pDstRate = OperationalRates;
3960 if(pIes->SuppRates.present)
3961 {
3962 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3963 {
3964 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3965 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3966 {
3967 *pDstRate++ = pIes->SuppRates.rates[ i ];
3968 OperationalRatesLength++;
3969 }
3970 }
3971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3973 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3974 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3975 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3976 {
3977 // If there are Extended Rates in the beacon, we will reflect those
3978 // extended rates that we support in out Extended Operational Rate
3979 // set:
3980 pDstRate = ExtendedOperationalRates;
3981 if(pIes->ExtSuppRates.present)
3982 {
3983 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3984 {
3985 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3986 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3987 {
3988 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3989 ExtendedOperationalRatesLength++;
3990 }
3991 }
3992 }
3993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 // Enable proprietary MAC features if peer node is Airgo node and STA
3995 // user wants to use them
3996 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3997 {
3998 PropRatesEnable = 1;
3999 }
4000 else
4001 {
4002 PropRatesEnable = 0;
4003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 // For ANI network companions, we need to populate the proprietary rate
4005 // set with any proprietary rates we found in the beacon, only if user
4006 // allows them...
4007 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
4008 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
4009 {
4010 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
4011 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
4012 {
4013 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
4014 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304015 vos_mem_copy(ProprietaryOperationalRates,
4016 pIes->Airgo.PropSuppRates.rates,
4017 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 }
4019 else {
4020 // No proprietary modes...
4021 ProprietaryOperationalRatesLength = 0;
4022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 /* Get MCS Rate */
4024 pDstRate = MCSRateIdxSet;
4025 if ( pIes->HTCaps.present )
4026 {
4027 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
4028 {
4029 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
4030 {
4031 MCSRateLength++;
4032 *pDstRate++ = i;
4033 }
4034 }
4035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 // Set the operational rate set CFG variables...
4037 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4038 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4039 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4040 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4041 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4042 ProprietaryOperationalRates,
4043 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4044 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
4045 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
4046 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
4047 }//Parsing BSSDesc
4048 else
4049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004050 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 }
4052}
4053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
4055 tCsrRoamProfile *pProfile )
4056{
4057 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4058 { 8,
4059 { SIR_MAC_RATE_6,
4060 SIR_MAC_RATE_9,
4061 SIR_MAC_RATE_12,
4062 SIR_MAC_RATE_18,
4063 SIR_MAC_RATE_24,
4064 SIR_MAC_RATE_36,
4065 SIR_MAC_RATE_48,
4066 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4068 { 4,
4069 { SIR_MAC_RATE_1,
4070 SIR_MAC_RATE_2,
4071 SIR_MAC_RATE_5_5,
4072 SIR_MAC_RATE_11 } } };
4073
4074
4075 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4076 { SIR_MAC_RATE_72,
4077 SIR_MAC_RATE_96,
4078 SIR_MAC_RATE_108 } };
4079 eCsrCfgDot11Mode cfgDot11Mode;
4080 eCsrBand eBand;
4081 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4082 tANI_U32 OperationalRatesLength = 0;
4083 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
4084 tANI_U32 ExtendedOperationalRatesLength = 0;
4085 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
4086 tANI_U32 ProprietaryOperationalRatesLength = 0;
4087 tANI_U32 PropRatesEnable = 0;
4088 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 if(pProfile->ChannelInfo.ChannelList)
4090 {
4091 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
4095 // networks, the 11b rates appear in the Operational Rate set. In either case,
4096 // we can blindly put the rates we support into our Operational Rate set
4097 // (including the basic rates, which we have already verified are supported
4098 // earlier in the roaming decision).
4099 if ( eCSR_BAND_5G == eBand )
4100 {
4101 // 11a rates into the Operational Rate Set.
4102 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4103 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304104 vos_mem_copy(OperationalRates,
4105 DefaultSupportedRates11a.supportedRateSet.rate,
4106 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004107
4108 // Nothing in the Extended rate set.
4109 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 // populate proprietary rates if user allows them
4111 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4112 {
4113 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4114 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304115 vos_mem_copy(ProprietaryOperationalRates,
4116 DefaultSupportedPropRates.propRate,
4117 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
4119 else
4120 {
4121 // No proprietary modes
4122 ProprietaryOperationalRatesLength = 0;
4123 }
4124 }
4125 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
4126 {
4127 // 11b rates into the Operational Rate Set.
4128 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4129 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304130 vos_mem_copy(OperationalRates,
4131 DefaultSupportedRates11b.supportedRateSet.rate,
4132 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 // Nothing in the Extended rate set.
4134 ExtendedOperationalRatesLength = 0;
4135 // No proprietary modes
4136 ProprietaryOperationalRatesLength = 0;
4137 }
4138 else
4139 {
4140 // 11G
4141
4142 // 11b rates into the Operational Rate Set.
4143 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4144 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304145 vos_mem_copy(OperationalRates,
4146 DefaultSupportedRates11b.supportedRateSet.rate,
4147 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004148
4149 // 11a rates go in the Extended rate set.
4150 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4151 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304152 vos_mem_copy(ExtendedOperationalRates,
4153 DefaultSupportedRates11a.supportedRateSet.rate,
4154 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004155
4156 // populate proprietary rates if user allows them
4157 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4158 {
4159 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4160 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304161 vos_mem_copy(ProprietaryOperationalRates,
4162 DefaultSupportedPropRates.propRate,
4163 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 }
4165 else
4166 {
4167 // No proprietary modes
4168 ProprietaryOperationalRatesLength = 0;
4169 }
4170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4172 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4173 {
4174 PropRatesEnable = 1;
4175 }
4176 else
4177 {
4178 PropRatesEnable = 0;
4179 }
4180
4181 // Set the operational rate set CFG variables...
4182 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4183 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4184 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4185 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4186 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4187 ProprietaryOperationalRates,
4188 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4189 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004190}
Jeff Johnson295189b2012-06-20 16:38:30 -07004191void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4192{
4193 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004194
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4196 tANI_U32 sessionId;
4197 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 if(NULL == pEntry)
4199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004200 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 return;
4202 }
4203 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4204 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304205 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4206 " current state : %d sub state : %d "),
4207 result, pMac->roam.curState[sessionId],
4208 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4210 {
4211 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4212 }
4213}
4214
Jeff Johnson295189b2012-06-20 16:38:30 -07004215//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4216tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4217{
4218 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4219 {
4220 return (WNI_CFG_PHY_MODE_11B);
4221 }
4222 else
4223 {
4224 if(eCSR_BAND_24 == band)
4225 return (WNI_CFG_PHY_MODE_11G);
4226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 return (WNI_CFG_PHY_MODE_11A);
4228}
Jeff Johnson295189b2012-06-20 16:38:30 -07004229
Jeff Johnsone7245742012-09-05 17:12:55 -07004230
4231#ifdef WLAN_FEATURE_11AC
4232ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4233{
4234 switch ( aniCBMode )
4235 {
4236 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4237 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4238 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4239 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4240 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4241 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4242 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4243 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4244 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004245 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004246 return PHY_SINGLE_CHANNEL_CENTERED;
4247 }
4248}
4249#endif
4250
Jeff Johnson295189b2012-06-20 16:38:30 -07004251//pIes may be NULL
4252eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4253 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304254 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004255{
4256 eHalStatus status = eHAL_STATUS_SUCCESS;
4257 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4258 tANI_U8 channel = 0;
4259 //Make sure we have the domain info for the BSS we try to connect to.
4260 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304261 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304263 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 {
4265 //Make sure the 11d info from this BSSDesc can be applied
4266 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304267 if (VOS_TRUE == resetCountry)
4268 {
4269 csrApplyCountryInformation(pMac, FALSE);
4270 }
4271 else
4272 {
4273 csrApplyCountryInformation(pMac, TRUE);
4274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 }
Kiran4a17ebe2013-01-31 10:43:43 -08004276 if ((csrIs11dSupported (pMac)) && pIes)
4277 {
4278 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004279 {
Kiran4a17ebe2013-01-31 10:43:43 -08004280 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004281 }
4282 else
4283 {
4284 //Let's also update the below to make sure we don't update CC while
4285 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304286 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004287 pBssDesc->bssId, sizeof(tSirMacAddr));
4288 }
Kiran4a17ebe2013-01-31 10:43:43 -08004289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 //Qos
4292 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4293 //SSID
4294 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4295 //fragment threshold
4296 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4297 //RTS threshold
4298 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4299
4300 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 //Auth type
4302 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4303 //encryption type
4304 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4305 //short slot time
4306 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 //11d
4308 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4309 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4310 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 /*//11h
4312 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4313 */
4314 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4315 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004316
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004317 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 {
4319 channel = pProfile->operationChannel;
4320 }
4321 else
4322 {
4323 if(pBssDesc)
4324 {
4325 channel = pBssDesc->channelId;
4326 }
4327 }
4328 if(0 != channel)
4329 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304330 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4331 !pMac->roam.configParam.channelBondingMode24GHz &&
4332 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4333 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304335 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4336 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4337 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 }
4339 else
4340 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004341 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 }
4343 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004344#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004345 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4346 // in function csrConvertCBIniValueToPhyCBState()
4347 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4348 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004349 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004350 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004351 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004352 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304353 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004354 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004355 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004356 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004357 }
4358 else
4359#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4361 //Rate
4362 //Fixed Rate
4363 if(pBssDesc)
4364 {
4365 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4366 }
4367 else
4368 {
4369 csrSetCfgRateSetFromProfile(pMac, pProfile);
4370 }
4371 //Make this the last CFG to set. The callback will trigger a join_req
4372 //Join time out
4373 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4374
4375 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 return (status);
4377}
4378
Jeff Johnson295189b2012-06-20 16:38:30 -07004379eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4380 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4381{
4382 eHalStatus status;
4383 tBssConfigParam *pBssConfig;
4384 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004385
4386 if(!pSession)
4387 {
4388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4389 return eHAL_STATUS_FAILURE;
4390 }
4391
Kiet Lam64c1b492013-07-12 13:56:44 +05304392 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4393 if ( NULL == pBssConfig )
4394 status = eHAL_STATUS_FAILURE;
4395 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304397 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4399 if(HAL_STATUS_SUCCESS(status))
4400 {
4401 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004402 /* This will allow to pass cbMode during join req */
4403 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 //For IBSS, we need to prepare some more information
4405 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 )
4408 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004409 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 }
4411 // If we are in an IBSS, then stop the IBSS...
4412 ////Not worry about WDS connection for now
4413 if ( csrIsConnStateIbss( pMac, sessionId ) )
4414 {
4415 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4416 }
4417 else
4418 {
4419 // if we are in an Infrastructure association....
4420 if ( csrIsConnStateInfra( pMac, sessionId ) )
4421 {
4422 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4423 // across SSIDs (roaming to a new SSID)... //
4424 //Not worry about WDS connection for now
4425 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304426 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 {
4428 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304429 status = csrRoamIssueDisassociate( pMac, sessionId,
4430 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304432 else
4433 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4435 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304436 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304438 // Set parameters for this Bss.
4439 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4440 pBssDesc, pBssConfig,
4441 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304445 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 {
4447 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4448 // Nothing to stop.
4449 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304451 )
4452 {
4453 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4454 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4455 // Set parameters for this Bss.
4456 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4457 pBssDesc, pBssConfig,
4458 pIes, is11rRoamingFlag);
4459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 }
4461 }
4462 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304463 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 return (status);
4466}
4467
Jeff Johnson295189b2012-06-20 16:38:30 -07004468eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4469 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4470{
4471 eCsrJoinState eRoamState = eCsrContinueRoaming;
4472 eHalStatus status;
4473 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4474 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4475 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004476
4477 if(!pSession)
4478 {
4479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4480 return (eCsrStopRoaming);
4481 }
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 if( CSR_IS_WDS_STA( pProfile ) )
4484 {
4485 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4486 if( !HAL_STATUS_SUCCESS( status ) )
4487 {
4488 eRoamState = eCsrStopRoaming;
4489 }
4490 }
4491 else
4492 {
4493 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4494 {
4495 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4496 return (eCsrStopRoaming);
4497 }
4498 if ( csrIsInfraBssDesc( pBssDesc ) )
4499 {
4500 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4501 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4502 // have changed and handle the changes (without disturbing the current association).
4503
4504 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4505 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4506 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4507 )
4508 {
4509 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4510 // with Authenticating first. To force this, stop the current association (Disassociate) and
4511 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4512 // a new Association.
4513 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4514 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004515 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4517 {
4518 eRoamState = eCsrReassocToSelfNoCapChange;
4519 }
4520 else
4521 {
4522 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304524 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4526 if(HAL_STATUS_SUCCESS(status))
4527 {
4528 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004529 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304531 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4532 pBssDesc, &bssConfig,
4533 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 if(!HAL_STATUS_SUCCESS(status))
4535 {
4536 eRoamState = eCsrStopRoaming;
4537 }
4538 }
4539 else
4540 {
4541 eRoamState = eCsrStopRoaming;
4542 }
4543 }//same profile
4544 }
4545 else
4546 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304547 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4549 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304550 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4551 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304555 }
4556 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 {
4558 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 // stop the existing network before attempting to join the new network...
4560 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4561 {
4562 eRoamState = eCsrStopRoaming;
4563 }
4564 }
4565 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304566 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 {
4568 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4569 {
4570 eRoamState = eCsrStopRoaming;
4571 }
4572 }
4573 if( pIesLocal && !pScanResult->pvIes )
4574 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304575 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 }
4577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 return( eRoamState );
4579}
4580
Jeff Johnson295189b2012-06-20 16:38:30 -07004581eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4582 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4583{
4584 eHalStatus status = eHAL_STATUS_SUCCESS;
4585 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304586 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 roamInfo.pBssDesc = pBssDesc;
4588 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4589 return (status);
4590}
Jeff Johnson295189b2012-06-20 16:38:30 -07004591//In case no matching BSS is found, use whatever default we can find
4592static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4593{
4594 //Need to get all negotiated types in place first
4595 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004596 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 {
4598 default:
4599 case eCSR_AUTH_TYPE_WPA:
4600 case eCSR_AUTH_TYPE_WPA_PSK:
4601 case eCSR_AUTH_TYPE_WPA_NONE:
4602 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4603 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4604 break;
4605
4606 case eCSR_AUTH_TYPE_SHARED_KEY:
4607 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4608 break;
4609
4610 case eCSR_AUTH_TYPE_AUTOSWITCH:
4611 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4612 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304613 case eCSR_AUTH_TYPE_SAE:
4614 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4615 eCSR_AUTH_TYPE_SAE;
4616 break;
4617
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 }
4619 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4620 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4621 //In this case, the multicast encryption needs to follow the uncast ones.
4622 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4623 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4624}
4625
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004626
4627static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4628{
4629 switch(pCommand->u.roamCmd.roamReason)
4630 {
4631 case eCsrLostLink1:
4632 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4633 break;
4634 case eCsrLostLink2:
4635 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4636 break;
4637 case eCsrLostLink3:
4638 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4639 break;
4640 default:
4641 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4642 pCommand->u.roamCmd.roamReason);
4643 break;
4644 }
4645}
4646
Jeff Johnson295189b2012-06-20 16:38:30 -07004647static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4648{
4649 eHalStatus status;
4650 tCsrScanResult *pScanResult = NULL;
4651 eCsrJoinState eRoamState = eCsrStopRoaming;
4652 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4653 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4654 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4655#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4656 v_U8_t acm_mask = 0;
4657#endif
4658 tANI_U32 sessionId = pCommand->sessionId;
4659 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4660 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4661 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004662
4663 if(!pSession)
4664 {
4665 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4666 return (eCsrStopRoaming);
4667 }
4668
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 do
4670 {
4671 // Check for Cardbus eject condition, before trying to Roam to any BSS
4672 //***if( !balIsCardPresent(pAdapter) ) break;
4673
Kiet Lam64c1b492013-07-12 13:56:44 +05304674 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304675 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 if(NULL != pBSSList)
4677 {
4678 // When handling AP's capability change, continue to associate to
4679 // same BSS and make sure pRoamBssEntry is not Null.
4680 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4681 {
4682 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4683 {
4684 //Try the first BSS
4685 pCommand->u.roamCmd.pLastRoamBss = NULL;
4686 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4687 }
4688 else
4689 {
4690 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4691 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4692 {
4693 //Done with all the BSSs
4694 //In this case, will tell HDD the completion
4695 break;
4696 }
4697 else
4698 {
4699 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304700 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4702 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4703 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4704 pRoamInfo = &roamInfo;
4705 }
4706 }
4707 while(pCommand->u.roamCmd.pRoamBssEntry)
4708 {
4709 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 /*If concurrency enabled take the concurrent connected channel first. */
4711 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304712 if (vos_concurrent_open_sessions_running() &&
4713 !csrIsValidMcConcurrentSession(pMac, sessionId,
4714 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 {
4716 concurrentChannel =
4717 csrGetConcurrentOperationChannel(pMac);
4718 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004719 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 if ((concurrentChannel) &&
4721 (concurrentChannel ==
4722 pScanResult->Result.BssDescriptor.channelId))
4723 {
4724 //make this 0 because we do not want the
4725 //below check to pass as we don't want to
4726 //connect on other channel
4727 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4728 FL("Concurrent channel match =%d"),
4729 concurrentChannel);
4730 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 }
4732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004733
4734 if (!concurrentChannel)
4735 {
4736
4737 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4738 sessionId, &pScanResult->Result.BssDescriptor,
4739 pCommand->u.roamCmd.roamId)))
4740 {
4741 //Ok to roam this
4742 break;
4743 }
4744 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004745 else
4746 {
4747 eRoamState = eCsrStopRoamingDueToConcurrency;
4748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4750 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4751 {
4752 //Done with all the BSSs
4753 fDone = eANI_BOOLEAN_TRUE;
4754 break;
4755 }
4756 }
4757 if(fDone)
4758 {
4759 break;
4760 }
4761 }
4762 }
4763 //We have something to roam, tell HDD when it is infra.
4764 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4765 //For WDS, the indication is eCSR_ROAM_WDS_IND
4766 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4767 {
4768 if(pRoamInfo)
4769 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004770 if(pSession->bRefAssocStartCnt)
4771 {
4772 pSession->bRefAssocStartCnt--;
4773 //Complete the last association attemp because a new one is about to be tried
4774 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4775 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004777 }
4778 }
4779 /* If the roaming has stopped, not to continue the roaming command*/
4780 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4781 {
4782 //No need to complete roaming here as it already completes
4783 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4784 pCommand->u.roamCmd.roamReason);
4785 eRoamState = eCsrStopRoaming;
4786 csrSetAbortRoamingCommand(pMac, pCommand);
4787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304789 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 if(pScanResult)
4791 {
4792 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004795 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 fDone = eANI_BOOLEAN_TRUE;
4797 eRoamState = eCsrStopRoaming;
4798 break;
4799 }
4800 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4801 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4802 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4803 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4804 CSR_IS_QOS_BSS(pIesLocal) &&
4805 CSR_IS_UAPSD_BSS(pIesLocal) )
4806 {
4807#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4809 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004810#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 }
4812 else
4813 {
4814 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4815 }
4816 if( pIesLocal && !pScanResult->Result.pvIes)
4817 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304818 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 }
4820 }
4821 else
4822 {
4823 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4824 }
4825 roamInfo.pProfile = pProfile;
4826 pSession->bRefAssocStartCnt++;
4827 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4828 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4831 {
4832 // If this is a start IBSS profile, then we need to start the IBSS.
4833 if ( CSR_IS_START_IBSS(pProfile) )
4834 {
4835 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 // Attempt to start this IBSS...
4837 csrRoamAssignDefaultParam( pMac, pCommand );
4838 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4839 if(HAL_STATUS_SUCCESS(status))
4840 {
4841 if ( fSameIbss )
4842 {
4843 eRoamState = eCsrStartIbssSameIbss;
4844 }
4845 else
4846 {
4847 eRoamState = eCsrContinueRoaming;
4848 }
4849 }
4850 else
4851 {
4852 //it somehow fail need to stop
4853 eRoamState = eCsrStopRoaming;
4854 }
4855 break;
4856 }
4857 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 )
4860 {
4861 // Attempt to start this WDS...
4862 csrRoamAssignDefaultParam( pMac, pCommand );
4863 /* For AP WDS, we dont have any BSSDescription */
4864 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4865 if(HAL_STATUS_SUCCESS(status))
4866 {
4867 eRoamState = eCsrContinueRoaming;
4868 }
4869 else
4870 {
4871 //it somehow fail need to stop
4872 eRoamState = eCsrStopRoaming;
4873 }
4874 }
4875 else
4876 {
4877 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004878 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 eRoamState = eCsrStopRoaming;
4880 break;
4881 }
4882 }
4883 else //We have BSS
4884 {
4885 //Need to assign these value because they are used in csrIsSameProfile
4886 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004887 /* The OSEN IE doesn't provide the cipher suite.
4888 * Therefore set to constant value of AES */
4889 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4890 {
4891 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4892 eCSR_ENCRYPT_TYPE_AES;
4893 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4894 eCSR_ENCRYPT_TYPE_AES;
4895 }
4896 else
4897 {
4898 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4899 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4900 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4901 pScanResult->mcEncryptionType;
4902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4904 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4905 {
4906 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4907 {
4908 eRoamState = eCsrStartIbssSameIbss;
4909 break;
4910 }
4911 }
4912 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4913 {
4914 //trying to connect to the one already connected
4915 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4916 eRoamState = eCsrReassocToSelfNoCapChange;
4917 break;
4918 }
4919 // Attempt to Join this Bss...
4920 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4921 break;
4922 }
4923
4924 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4926 {
4927 //Need to indicate association_completion if association_start has been done
4928 if(pSession->bRefAssocStartCnt > 0)
4929 {
4930 pSession->bRefAssocStartCnt--;
4931 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004932 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4934 eCSR_ROAM_ASSOCIATION_COMPLETION,
4935 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4936 }
4937 }
4938
4939 return( eRoamState );
4940}
4941
Jeff Johnson295189b2012-06-20 16:38:30 -07004942static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4943{
4944 eHalStatus status = eHAL_STATUS_SUCCESS;
4945 eCsrJoinState RoamState;
4946 tANI_U32 sessionId = pCommand->sessionId;
4947
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 //***if( hddIsRadioStateOn( pAdapter ) )
4949 {
4950 // Attept to join a Bss...
4951 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004952
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004954 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 {
4956 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 // and if connected in Infrastructure mode...
4958 if ( csrIsConnStateInfra(pMac, sessionId) )
4959 {
4960 //... then we need to issue a disassociation
4961 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4962 if(!HAL_STATUS_SUCCESS(status))
4963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004964 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 //roam command is completed by caller in the failed case
4966 fComplete = eANI_BOOLEAN_TRUE;
4967 }
4968 }
4969 else if( csrIsConnStateIbss(pMac, sessionId) )
4970 {
4971 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4972 if(!HAL_STATUS_SUCCESS(status))
4973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004974 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 //roam command is completed by caller in the failed case
4976 fComplete = eANI_BOOLEAN_TRUE;
4977 }
4978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4980 {
4981 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4982 if(!HAL_STATUS_SUCCESS(status))
4983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004984 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 //roam command is completed by caller in the failed case
4986 fComplete = eANI_BOOLEAN_TRUE;
4987 }
4988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 else
4990 {
4991 fComplete = eANI_BOOLEAN_TRUE;
4992 }
4993 if(fComplete)
4994 {
4995 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004996 if(eCsrStopRoamingDueToConcurrency == RoamState)
4997 {
4998 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4999 }
5000 else
5001 {
5002 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
5003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 }
5005 }
5006 else if ( eCsrReassocToSelfNoCapChange == RoamState )
5007 {
5008 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
5009 }
5010 else if ( eCsrStartIbssSameIbss == RoamState )
5011 {
5012 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
5013 }
5014 }//hddIsRadioStateOn
5015
5016 return status;
5017}
Jeff Johnson295189b2012-06-20 16:38:30 -07005018eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5019{
5020 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05305021 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 tCsrScanResult *pScanResult = NULL;
5023 tSirBssDescription *pBssDesc = NULL;
5024 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 sessionId = pCommand->sessionId;
5026 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005027
5028 if(!pSession)
5029 {
5030 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5031 return eHAL_STATUS_FAILURE;
5032 }
5033
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
5035 {
5036 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005037 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
5039 return eHAL_STATUS_FAILURE;
5040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 if (pCommand->u.roamCmd.pRoamBssEntry)
5042 {
5043 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5044 pBssDesc = &pScanResult->Result.BssDescriptor;
5045 }
5046 else
5047 {
5048 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005049 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
5051 return eHAL_STATUS_FAILURE;
5052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
5054 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
5055 return status;
5056}
5057
Jeff Johnson295189b2012-06-20 16:38:30 -07005058eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5059{
5060 eHalStatus status = eHAL_STATUS_SUCCESS;
5061 tCsrRoamInfo roamInfo;
5062 tANI_U32 sessionId = pCommand->sessionId;
5063 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005064
5065 if(!pSession)
5066 {
5067 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5068 return eHAL_STATUS_FAILURE;
5069 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05305070 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5071 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 switch ( pCommand->u.roamCmd.roamReason )
5073 {
5074 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005076 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 case eCsrSmeIssuedDisassocForHandoff:
5079 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
5080#if 0 // TODO : Confirm this change
5081 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
5082#else
5083 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
5084#endif
5085
5086 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005089 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005093 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 case eCsrHddIssuedReassocToSameAP:
5096 case eCsrSmeIssuedReassocToSameAP:
5097 {
5098 tDot11fBeaconIEs *pIes = NULL;
5099
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 if( pSession->pConnectBssDesc )
5101 {
5102 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
5103 if(!HAL_STATUS_SUCCESS(status) )
5104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005105 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 }
5107 else
5108 {
5109 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
5110 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
5111 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5113 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
5114 pSession->bRefAssocStartCnt++;
5115 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5116 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
5117
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005118 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005119 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
5120 &pCommand->u.roamCmd.roamProfile );
5121 if(!HAL_STATUS_SUCCESS(status))
5122 {
5123 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08005124 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005125 }
5126
Kiet Lam64c1b492013-07-12 13:56:44 +05305127 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 pIes = NULL;
5129 }
5130 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05305131 else
5132 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 break;
5134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005136 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5138 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005141 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5143 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005144
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 case eCsrStopBss:
5146 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5147 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5148 break;
5149
5150 case eCsrForcedDisassocSta:
5151 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5152 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5153 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5154 pCommand->u.roamCmd.reason);
5155 break;
5156
5157 case eCsrForcedDeauthSta:
5158 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5159 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5160 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5161 pCommand->u.roamCmd.reason);
5162 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005163
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005164 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005165 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005166 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5167 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005169
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305170#ifdef WLAN_FEATURE_LFR_MBB
5171 case ecsr_mbb_perform_preauth_reassoc:
5172 smsLog(pMac, LOG1, FL("Attempting MBB PreAuth/Reassoc Req"));
5173 status = csr_roam_issue_preauth_reassoc_req(pMac, sessionId,
5174 pCommand->u.roamCmd.pLastRoamBss);
Padma, Santhosh Kumar5a3054e2017-02-13 19:05:54 +05305175 if (eHAL_STATUS_SUCCESS != status)
5176 {
5177 pMac->ft.ftSmeContext.is_preauth_lfr_mbb = false;
5178 smsLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
5179 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
5180 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05305181 break;
5182#endif
5183
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 default:
5185 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5186
5187 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5188 {
5189 //Remember the roaming profile
5190 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305191 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5192 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305194 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5196 }
5197 }
5198
5199 //At this point, original uapsd_mask is saved in pCurRoamProfile
5200 //uapsd_mask in the pCommand may change from this point on.
5201
5202 // Attempt to roam with the new scan results (if we need to..)
5203 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005204 if(!HAL_STATUS_SUCCESS(status))
5205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005206 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 break;
5209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 return (status);
5211}
5212
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005213void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5214{
5215 pCommand->u.roamCmd.pLastRoamBss = NULL;
5216 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5217 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305218 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005219}
5220
Jeff Johnson295189b2012-06-20 16:38:30 -07005221void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5222{
5223 if(pCommand->u.roamCmd.fReleaseBssList)
5224 {
5225 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5226 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5227 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5228 }
5229 if(pCommand->u.roamCmd.fReleaseProfile)
5230 {
5231 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5232 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5233 }
5234 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5235 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305236 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005237}
5238
Jeff Johnson295189b2012-06-20 16:38:30 -07005239void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5240{
Kiet Lam64c1b492013-07-12 13:56:44 +05305241 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005242}
Jeff Johnson295189b2012-06-20 16:38:30 -07005243void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5244{
5245 tListElem *pEntry;
5246 tSmeCmd *pCommand;
5247 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005248 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5250 if ( pEntry )
5251 {
5252 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 // If the head of the queue is Active and it is a ROAM command, remove
5254 // and put this on the Free queue.
5255 if ( eSmeCommandRoam == pCommand->command )
5256 {
5257 //we need to process the result first before removing it from active list because state changes
5258 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5259 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5260 if( fReleaseCommand )
5261 {
5262 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5263 {
5264 csrReleaseCommandRoam( pMac, pCommand );
5265 }
5266 else
5267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005268 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005269 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 }
5271 }
5272 else
5273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005274 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005275 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 }
5277 }
5278 else
5279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005280 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 }
5282 }
5283 else
5284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005285 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 if( fReleaseCommand )
5288 {
5289 smeProcessPendingQueue( pMac );
5290 }
5291}
5292
Jeff Johnson295189b2012-06-20 16:38:30 -07005293void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5294{
5295 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005296 if(!pSession)
5297 {
5298 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5299 return;
5300 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305301 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5302 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 pSession->NumPmkidCandidate = 0;
5304}
Jeff Johnson295189b2012-06-20 16:38:30 -07005305#ifdef FEATURE_WLAN_WAPI
5306void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5307{
5308 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005309 if(!pSession)
5310 {
5311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5312 return;
5313 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305314 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5315 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 pSession->NumBkidCandidate = 0;
5317}
5318#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005319extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5320
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05305321eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac,
5322 tANI_U32 sessionId, eCsrAuthType authType,
5323 tSirBssDescription *pSirBssDesc,
5324 tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -07005325{
5326 eHalStatus status = eHAL_STATUS_SUCCESS;
5327 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5328 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005329
5330 if(!pSession)
5331 {
5332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5333 return eHAL_STATUS_FAILURE;
5334 }
5335
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 if((eCSR_AUTH_TYPE_WPA == authType) ||
5337 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5338 (eCSR_AUTH_TYPE_RSN == authType) ||
5339 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5340#if defined WLAN_FEATURE_VOWIFI_11R
5341 ||
5342 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5343 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5344#endif /* FEATURE_WLAN_WAPI */
5345#ifdef FEATURE_WLAN_WAPI
5346 ||
5347 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5348 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5349#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005350#ifdef WLAN_FEATURE_11W
5351 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305352 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5353 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005354#endif /* FEATURE_WLAN_WAPI */
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305355 || (eCSR_AUTH_TYPE_SAE == authType))
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005359 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 }
5361 if( pIesLocal )
5362 {
5363 tANI_U32 nIeLen;
5364 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 if((eCSR_AUTH_TYPE_RSN == authType) ||
5366#if defined WLAN_FEATURE_VOWIFI_11R
5367 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5368 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5369#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005370#if defined WLAN_FEATURE_11W
5371 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305372 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005373#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5375 {
5376 if(pIesLocal->RSN.present)
5377 {
5378 //Calculate the actual length
5379 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5380 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5381 + 2 //akm_suite_count
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305382 + pIesLocal->RSN.akm_suite_cnt * 4 //akm_suites
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 + 2; //reserved
5384 if( pIesLocal->RSN.pmkid_count )
5385 {
5386 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5387 }
5388 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305389 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5390 if (NULL == pSession->pWpaRsnRspIE)
5391 status = eHAL_STATUS_FAILURE;
5392 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305394 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5396 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305397 //copy upto akm_suite
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305399 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5400 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005401 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305402 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5403 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005404 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305405 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5406 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005407 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 if( pIesLocal->RSN.pwise_cipher_suite_count )
5409 {
5410 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305411 vos_mem_copy(pIeBuf,
5412 pIesLocal->RSN.pwise_cipher_suites,
5413 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5415 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305416 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_cnt, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 pIeBuf += 2;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305418 if( pIesLocal->RSN.akm_suite_cnt )
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 {
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305420 //copy akm_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305421 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305422 pIesLocal->RSN.akm_suite,
5423 pIesLocal->RSN.akm_suite_cnt * 4);
5424 pIeBuf += pIesLocal->RSN.akm_suite_cnt * 4;
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 }
5426 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305427 vos_mem_copy(pIeBuf,
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05305428 pIesLocal->RSN.akm_suite + pIesLocal->RSN.akm_suite_cnt * 4,
Kiet Lam64c1b492013-07-12 13:56:44 +05305429 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5431 }
5432 }
5433 }
5434 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5435 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5436 {
5437 if(pIesLocal->WPA.present)
5438 {
5439 //Calculate the actual length
5440 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5441 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5442 + 2 //auth_suite_count
5443 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5444 // The WPA capabilities follows the Auth Suite (two octects)--
5445 // this field is optional, and we always "send" zero, so just
5446 // remove it. This is consistent with our assumptions in the
5447 // frames compiler; c.f. bug 15234:
5448 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305449
5450 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5451 if ( NULL == pSession->pWpaRsnRspIE )
5452 status = eHAL_STATUS_FAILURE;
5453 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 {
5455 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5456 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5457 pIeBuf = pSession->pWpaRsnRspIE + 2;
5458 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305459 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305461 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5462 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305464 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5465 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5467 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5468 }
5469 }
5470 }
5471#ifdef FEATURE_WLAN_WAPI
5472 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5473 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5474 {
5475 if(pIesLocal->WAPI.present)
5476 {
5477 //Calculate the actual length
5478 nIeLen = 4 //version + akm_suite_count
5479 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5480 + 2 //pwise_cipher_suite_count
5481 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5482 + 6; //gp_cipher_suite + preauth + reserved
5483 if( pIesLocal->WAPI.bkid_count )
5484 {
5485 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5486 }
5487
5488 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305489 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5490 if ( NULL == pSession->pWapiRspIE )
5491 status = eHAL_STATUS_FAILURE;
5492 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 {
5494 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5495 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5496 pIeBuf = pSession->pWapiRspIE + 2;
5497 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305498 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 pIeBuf += 4;
5500 if( pIesLocal->WAPI.akm_suite_count )
5501 {
5502 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305503 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5504 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305506 }
5507 vos_mem_copy(pIeBuf,
5508 &pIesLocal->WAPI.unicast_cipher_suite_count,
5509 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5512 {
5513 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305514 vos_mem_copy( pIeBuf,
5515 pIesLocal->WAPI.unicast_cipher_suites,
5516 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5518 }
lukez3c809222013-05-03 10:23:02 -07005519 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305520 vos_mem_copy(pIeBuf,
5521 pIesLocal->WAPI.multicast_cipher_suite,
5522 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005523 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305524 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305525 vos_mem_copy(pIeBuf,
5526 pIesLocal->WAPI.multicast_cipher_suite + 4,
5527 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005528 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305529 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305531 //bkid_count
5532 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5533 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305535 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5536 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5538 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305539 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 }
5542 }
5543#endif /* FEATURE_WLAN_WAPI */
5544 if( !pIes )
5545 {
5546 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305547 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 }
5549 }
5550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 return (status);
5552}
5553
Jeff Johnson295189b2012-06-20 16:38:30 -07005554static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5555{
5556 v_U8_t bACWeights[WLANTL_MAX_AC];
5557 v_U8_t paramBk, paramBe, paramVi, paramVo;
5558 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5560 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5561 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5562 //This doesn't address the case where the lower AC needs a real higher weight
5563 if( pIEs->WMMParams.present )
5564 {
5565 //no change to the lowest ones
5566 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5567 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5568 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5569 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5570 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5571 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5572 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5573 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5574 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5575 {
5576 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5577 fWeightChange = VOS_TRUE;
5578 }
5579 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5580 {
5581 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5582 fWeightChange = VOS_TRUE;
5583 }
5584 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5585 {
5586 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5587 fWeightChange = VOS_TRUE;
5588 }
5589 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5590 {
5591 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5592 fWeightChange = VOS_TRUE;
5593 }
5594 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5595 {
5596 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5597 fWeightChange = VOS_TRUE;
5598 }
5599 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5600 {
5601 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5602 fWeightChange = VOS_TRUE;
5603 }
5604 if(fWeightChange)
5605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005606 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 bACWeights[2], bACWeights[3]);
5608 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5609 }
5610 }
5611}
Jeff Johnson295189b2012-06-20 16:38:30 -07005612#ifdef WLAN_FEATURE_VOWIFI_11R
5613//Returns whether the current association is a 11r assoc or not
5614tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5615{
5616#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5617 return csrNeighborRoamIs11rAssoc(pMac);
5618#else
5619 return eANI_BOOLEAN_FALSE;
5620#endif
5621}
5622#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005623#ifdef FEATURE_WLAN_ESE
5624//Returns whether the current association is a ESE assoc or not
5625tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005626{
5627#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005628 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005629#else
5630 return eANI_BOOLEAN_FALSE;
5631#endif
5632}
5633#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005634#ifdef FEATURE_WLAN_LFR
5635//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305636tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005637{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305638 tCsrRoamSession *pSession = NULL;
5639
5640 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5641 {
5642 pSession = CSR_GET_SESSION( pMac, sessionId );
5643 if (NULL != pSession->pCurRoamProfile)
5644 {
5645 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5646 {
5647 return eANI_BOOLEAN_FALSE;
5648 }
5649 }
5650 }
5651
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005652#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5653 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5654 {
5655 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5656 }
5657 else
5658#endif
5659 {
5660 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005661 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005662 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005663}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005664
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005665#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005666/* ---------------------------------------------------------------------------
5667
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005668 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005669
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005670 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005671
5672 \param pMac - The handle returned by macOpen.
5673
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005674 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005675
5676---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005677tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005678{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005679 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005680}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005681#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005682
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005683#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5684//Returns whether "FW based BG scan" is currently enabled...or not
5685tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5686{
5687 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5688}
5689#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005690#endif
5691
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005692#if defined(FEATURE_WLAN_ESE)
5693tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005694{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005695 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005696}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005697#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005698
Jeff Johnson295189b2012-06-20 16:38:30 -07005699//Return true means the command can be release, else not
5700static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5701 eCsrRoamCompleteResult Result, void *Context )
5702{
5703 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5704 tSirBssDescription *pSirBssDesc = NULL;
5705 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5706 tCsrScanResult *pScanResult = NULL;
5707 tCsrRoamInfo roamInfo;
5708 sme_QosAssocInfo assocInfo;
5709 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5710 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5711 tDot11fBeaconIEs *pIes = NULL;
5712 tANI_U32 sessionId = pCommand->sessionId;
5713 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5714 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5715 eRoamCmdStatus roamStatus;
5716 eCsrRoamResult roamResult;
5717 eHalStatus status;
5718 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005720
Jeff Johnson32d95a32012-09-10 13:15:23 -07005721 if(!pSession)
5722 {
5723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5724 return eANI_BOOLEAN_FALSE;
5725 }
5726
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005727 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 switch( Result )
5729 {
5730 case eCsrJoinSuccess:
5731 // reset the IDLE timer
5732 // !!
5733 // !! fall through to the next CASE statement here is intentional !!
5734 // !!
5735 case eCsrReassocSuccess:
5736 if(eCsrReassocSuccess == Result)
5737 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305738 roamInfo.reassoc = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5740 }
5741 else
5742 {
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305743 roamInfo.reassoc = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5745 }
5746 // Success Join Response from LIM. Tell NDIS we are connected and save the
5747 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005748 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305749 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 //always free the memory here
5751 if(pSession->pWpaRsnRspIE)
5752 {
5753 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305754 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 pSession->pWpaRsnRspIE = NULL;
5756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005757#ifdef FEATURE_WLAN_WAPI
5758 if(pSession->pWapiRspIE)
5759 {
5760 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305761 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 pSession->pWapiRspIE = NULL;
5763 }
5764#endif /* FEATURE_WLAN_WAPI */
5765#ifdef FEATURE_WLAN_BTAMP_UT_RF
5766 //Reset counter so no join retry is needed.
5767 pSession->maxRetryCount = 0;
5768 csrRoamStopJoinRetryTimer(pMac, sessionId);
5769#endif
5770 /* This creates problem since we have not saved the connected profile.
5771 So moving this after saving the profile
5772 */
5773 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305774
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305775 /* Reset full_power_till_set_key as it might have been set
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305776 * by last failed secured connection.
5777 * It should be set only for secured connection.
5778 */
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05305779 pMac->pmc.full_power_till_set_key = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5781 {
5782 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5783 }
5784 else
5785 {
5786 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 //Use the last connected bssdesc for reassoc-ing to the same AP.
5789 //NOTE: What to do when reassoc to a different AP???
5790 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5791 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5792 {
5793 pSirBssDesc = pSession->pConnectBssDesc;
5794 if(pSirBssDesc)
5795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305796 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5797 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 }
5799 }
5800 else
5801 {
5802
5803 if(pCommand->u.roamCmd.pRoamBssEntry)
5804 {
5805 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5806 if(pScanResult != NULL)
5807 {
5808 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5809 //this can be NULL
5810 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305811 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5812 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 }
5814 }
5815 }
5816 if( pSirBssDesc )
5817 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5820 //Save WPA/RSN IE
5821 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005822#ifdef FEATURE_WLAN_ESE
5823 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005824#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305825#ifdef WLAN_FEATURE_VOWIFI_11R
5826 if (pSirBssDesc->mdiePresent)
5827 {
5828 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5829#ifdef FEATURE_WLAN_ESE
5830 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5831 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5832#endif
5833 )
5834 {
5835 // is11Rconnection;
5836 roamInfo.is11rAssoc = VOS_TRUE;
5837 }
5838 else
5839 {
5840 // is11Rconnection;
5841 roamInfo.is11rAssoc = VOS_FALSE;
5842 }
5843 }
5844#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5846 // substate change.
5847 // Moving even save profile above so that below mentioned conditon is also met.
5848 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5849 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5851 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5852 // will be dropped for the security context may not be set properly.
5853 //
5854 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5855 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5856 //
5857 // this reordering was done on titan_prod_usb branch and is being replicated here.
5858 //
5859
5860 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5861 !pProfile->bWPSAssociation)
5862 {
5863 // Issue the set Context request to LIM to establish the Unicast STA context
5864 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5865 pProfile->negotiatedUCEncryptionType,
5866 pSirBssDesc, &(pSirBssDesc->bssId),
5867 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005869 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5871 }
5872 // Issue the set Context request to LIM to establish the Broadcast STA context
5873 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5874 pSirBssDesc, &BroadcastMac,
5875 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5876 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305877 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 {
5879 //Need to wait for supplicant authtication
5880 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 //Set the subestate to WaitForKey in case authentiation is needed
5882 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5883
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 if(pProfile->bWPSAssociation)
5885 {
5886 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5887 }
5888 else
5889 {
5890 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5891 }
5892
5893 //Save sessionId in case of timeout
5894 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5895 //This time should be long enough for the rest of the process plus setting key
5896 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5897 {
5898 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005899 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5901 }
5902 }
5903
5904 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5905 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 if(Context)
5907 {
5908 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5909 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5911 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5912#ifdef WLAN_FEATURE_VOWIFI_11R
5913 len += pJoinRsp->parsedRicRspLen;
5914#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005915#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 len += pJoinRsp->tspecIeLen;
5917#endif
5918 if(len)
5919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305920 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5921 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305923 vos_mem_copy(pSession->connectedInfo.pbFrames,
5924 pJoinRsp->frames, len);
5925 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5926 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5927 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305929 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005930#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005931#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305932 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005933#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305934 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5935 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5936 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5937 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 }
5939 }
5940 if(pCommand->u.roamCmd.fReassoc)
5941 {
5942 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5943 }
5944 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5945 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5946 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5947 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305948 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05305949 roamInfo.vht_caps = pJoinRsp->vht_caps;
5950 roamInfo.ht_caps = pJoinRsp->ht_caps;
5951 roamInfo.hs20vendor_ie = pJoinRsp->hs20vendor_ie;
5952 roamInfo.ht_operation = pJoinRsp->ht_operation;
5953 roamInfo.vht_operation = pJoinRsp->vht_operation;
5954
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 }
5956 else
5957 {
5958 if(pCommand->u.roamCmd.fReassoc)
5959 {
5960 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5961 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5962 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5963 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5964 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5965 }
5966 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305967 /* Update the staId from the previous connected profile info
5968 as the reassociation is triggred at SME/HDD */
5969 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5970 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5971 {
5972 roamInfo.staId = pSession->connectedInfo.staId;
5973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005974#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5975 // Indicate SME-QOS with reassoc success event, only after
5976 // copying the frames
5977 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 roamInfo.pBssDesc = pSirBssDesc;
5980 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5981 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5982#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5983 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5984#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5985 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5987 //It may be better to let QoS do this????
5988 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005990 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5992 pmcStartUapsd( pMac, NULL, NULL );
5993 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305994 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5996 if( pSession->bRefAssocStartCnt > 0 )
5997 {
5998 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005999 //Remove this code once SLM_Sessionization is supported
6000 //BMPS_WORKAROUND_NOT_NEEDED
6001 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006002 {
6003 pMac->roam.configParam.doBMPSWorkaround = 1;
6004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6006 }
6007
6008 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 // reset the PMKID candidate list
6010 csrResetPMKIDCandidateList( pMac, sessionId );
6011 //Update TL's AC weight base on the current EDCA parameters
6012 //These parameters may change in the course of the connection, that sictuation
6013 //is not taken care here. This change is mainly to address a WIFI WMM test where
6014 //BE has a equal or higher TX priority than VI.
6015 //We only do this for infra link
6016 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
6017 {
6018 csrCheckAndUpdateACWeight(pMac, pIes);
6019 }
6020#ifdef FEATURE_WLAN_WAPI
6021 // reset the BKID candidate list
6022 csrResetBKIDCandidateList( pMac, sessionId );
6023#endif /* FEATURE_WLAN_WAPI */
6024 }
6025 else
6026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006027 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 csrScanCancelIdleScan(pMac);
6030 //Not to signal link up because keys are yet to be set.
6031 //The linkup function will overwrite the sub-state that we need to keep at this point.
6032 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
6033 {
6034 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
6035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
6037 //enough to let security and DHCP handshake succeed before entry into BMPS
6038 if (pmcShouldBmpsTimerRun(pMac))
6039 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05306040 /* Set full_power_till_set_key to make sure we wait for
Abhishek Singh65d939e2014-04-25 13:33:07 +05306041 * until keys are set before going into BMPS.
6042 */
6043 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
6044 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +05306045 pMac->pmc.full_power_till_set_key = true;
6046 smsLog(pMac, LOG1,
6047 FL("Set full_power_till_set_key to make sure we wait until keys are set before going to BMPS"));
Abhishek Singh65d939e2014-04-25 13:33:07 +05306048 }
6049
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
6051 != eHAL_STATUS_SUCCESS)
6052 {
6053 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
6054 }
6055 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
6056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 break;
6058
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 case eCsrStartBssSuccess:
6060 // on the StartBss Response, LIM is returning the Bss Description that we
6061 // are beaconing. Add this Bss Description to our scan results and
6062 // chain the Profile to this Bss Description. On a Start BSS, there was no
6063 // detected Bss description (no partner) so we issued the Start Bss to
6064 // start the Ibss without any Bss description. Lim was kind enough to return
6065 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006066 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05306069 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 if( CSR_IS_IBSS( pProfile ) )
6071 {
6072 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 else if (CSR_IS_INFRA_AP(pProfile))
6075 {
6076 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 else
6079 {
6080 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6081 }
6082 if( !CSR_IS_WDS_STA( pProfile ) )
6083 {
6084 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
6087 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306088 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 roamInfo.pBssDesc = pSirBssDesc;
6090 //We need to associate_complete it first, becasue Associate_start already indicated.
6091 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6092 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
6093 break;
6094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07006097 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 }
6099 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6100 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6101 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6102 if(pSirBssDesc)
6103 {
6104 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05306105 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
6106 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 }
6108 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05306109 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006110#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6111 {
6112 vos_log_ibss_pkt_type *pIbssLog;
6113 tANI_U32 bi;
6114
6115 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6116 if(pIbssLog)
6117 {
6118 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
6119 {
6120 //We start the IBSS (didn't find any matched IBSS out there)
6121 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
6122 }
6123 else
6124 {
6125 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6126 }
6127 if(pSirBssDesc)
6128 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306129 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 pIbssLog->operatingChannel = pSirBssDesc->channelId;
6131 }
6132 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
6133 {
6134 //***U8 is not enough for beacon interval
6135 pIbssLog->beaconInterval = (v_U8_t)bi;
6136 }
6137 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6138 }
6139 }
6140#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6141 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
6142 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
6144 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
6146 csrRoamIssueSetContextReq( pMac, sessionId,
6147 pProfile->negotiatedMCEncryptionType,
6148 pSirBssDesc, &BroadcastMac,
6149 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
6150 }
6151 }
6152 else
6153 {
6154 //Keep the state to eCSR_ROAMING_STATE_JOINING
6155 //Need to send join_req.
6156 if(pCommand->u.roamCmd.pRoamBssEntry)
6157 {
6158 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6159 {
6160 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6161 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6162 // Set the roaming substate to 'join attempt'...
6163 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006164 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 }
6166 }
6167 else
6168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006169 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 VOS_ASSERT( 0 );
6171 }
6172 }
6173 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6174 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6175 //trigger the connection start indication in Vista
6176 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6177 {
6178 roamStatus = eCSR_ROAM_IBSS_IND;
6179 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6180 if( CSR_IS_WDS( pProfile ) )
6181 {
6182 roamStatus = eCSR_ROAM_WDS_IND;
6183 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 if( CSR_IS_INFRA_AP( pProfile ) )
6186 {
6187 roamStatus = eCSR_ROAM_INFRA_IND;
6188 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006190
6191 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6192 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6193 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306194 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6196 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006197 //We start the IBSS (didn't find any matched IBSS out there)
6198 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306200 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6201 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006202 //Remove this code once SLM_Sessionization is supported
6203 //BMPS_WORKAROUND_NOT_NEEDED
6204 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006205 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006206 {
6207 pMac->roam.configParam.doBMPSWorkaround = 1;
6208 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006209
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6211 }
6212
6213 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006214
6215 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 {
6217 //need to send stop BSS because we fail to send join_req
6218 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6219 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6220 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 case eCsrStartBssFailure:
6224#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6225 {
6226 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6228 if(pIbssLog)
6229 {
6230 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6231 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6232 }
6233 }
6234#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 roamStatus = eCSR_ROAM_IBSS_IND;
6236 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6237 if( CSR_IS_WDS( pProfile ) )
6238 {
6239 roamStatus = eCSR_ROAM_WDS_IND;
6240 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6241 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 if( CSR_IS_INFRA_AP( pProfile ) )
6243 {
6244 roamStatus = eCSR_ROAM_INFRA_IND;
6245 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 if(Context)
6248 {
6249 pSirBssDesc = (tSirBssDescription *)Context;
6250 }
6251 else
6252 {
6253 pSirBssDesc = NULL;
6254 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306255 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 roamInfo.pBssDesc = pSirBssDesc;
6257 //We need to associate_complete it first, becasue Associate_start already indicated.
6258 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6259 csrSetDefaultDot11Mode( pMac );
6260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 case eCsrSilentlyStopRoaming:
6262 // We are here because we try to start the same IBSS
6263 //No message to PE
6264 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006265 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6267 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306268 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6270 if( roamInfo.pBssDesc )
6271 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306272 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6273 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 }
6275 //Since there is no change in the current state, simply pass back no result otherwise
6276 //HDD may be mistakenly mark to disconnected state.
6277 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6278 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 case eCsrSilentlyStopRoamingSaveState:
6281 //We are here because we try to connect to the same AP
6282 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006283 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306284 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006285
6286 //to aviod resetting the substate to NONE
6287 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6288 //No need to change substate to wai_for_key because there is no state change
6289 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6290 if( roamInfo.pBssDesc )
6291 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306292 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6293 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6296 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6297 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6298 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6299 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6300 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6301 roamInfo.staId = pSession->connectedInfo.staId;
6302 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 pSession->bRefAssocStartCnt--;
6305 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6306 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6307 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6308 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 case eCsrReassocFailure:
6310#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6311 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6312#endif
6313 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006314 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 csrFreeConnectBssDesc(pMac, sessionId);
6316 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6317 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306318 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6320 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6321 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6322 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6323 eCSR_ROAM_WDS_IND,
6324 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6325 //Need to issue stop_bss
6326 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 case eCsrJoinFailure:
6328 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006329 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 default:
6331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006332 smsLog(pMac, LOGW, FL("receives no association indication"));
6333 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006334 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6336 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6337 {
6338 //do not free for the other profiles as we need to send down stop BSS later
6339 csrFreeConnectBssDesc(pMac, sessionId);
6340 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6341 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6342 csrSetDefaultDot11Mode( pMac );
6343 }
6344
6345 switch( pCommand->u.roamCmd.roamReason )
6346 {
6347 // If this transition is because of an 802.11 OID, then we transition
6348 // back to INIT state so we sit waiting for more OIDs to be issued and
6349 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006350 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 case eCsrSmeIssuedAssocToSimilarAP:
6352 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006353 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306355 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6357 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6358 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306359 vos_mem_copy(&roamInfo.bssid,
6360 &pSession->joinFailStatusCode.bssId,
6361 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006362
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 /* Defeaturize this later if needed */
6364#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6365 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6366 if (csrRoamIsHandoffInProgress(pMac))
6367 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 /* Should indicate neighbor roam algorithm about the connect failure here */
6369 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006371#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 if(pSession->bRefAssocStartCnt > 0)
6373 {
6374 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006375 if(eCsrJoinFailureDueToConcurrency == Result)
6376 {
6377 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6378 eCSR_ROAM_ASSOCIATION_COMPLETION,
6379 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6380 }
6381 else
6382 {
6383 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 eCSR_ROAM_ASSOCIATION_COMPLETION,
6385 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006388 else
6389 {
6390 /* bRefAssocStartCnt is not incremented when
6391 * eRoamState == eCsrStopRoamingDueToConcurrency
6392 * in csrRoamJoinNextBss API. so handle this in
6393 * else case by sending assoc failure
6394 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006395 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006396 pCommand->u.scanCmd.roamId,
6397 eCSR_ROAM_ASSOCIATION_FAILURE,
6398 eCSR_ROAM_RESULT_FAILURE);
6399 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006400 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006401#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306402 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6404#endif
6405 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6406 csrScanStartIdleScan(pMac);
6407#ifdef FEATURE_WLAN_BTAMP_UT_RF
6408 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6409 //BT activity and not able to recevie WLAN traffic. Retry the join
6410 if( CSR_IS_WDS_STA(pProfile) )
6411 {
6412 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6413 }
6414#endif
6415 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 case eCsrHddIssuedReassocToSameAP:
6417 case eCsrSmeIssuedReassocToSameAP:
6418 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6419
6420 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6421#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6422 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6423#endif
6424 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6425 csrScanStartIdleScan(pMac);
6426 break;
6427 case eCsrForcedDisassoc:
6428 case eCsrForcedDeauth:
6429 case eCsrSmeIssuedIbssJoinFailure:
6430 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6431
6432 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6433 {
6434 // Notify HDD that IBSS join failed
6435 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6436 }
6437 else
6438 {
6439 csrRoamCallCallback(pMac, sessionId, NULL,
6440 pCommand->u.roamCmd.roamId,
6441 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6442 }
6443#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6444 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6445#endif
6446 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006447 /*
6448 *DelSta not done FW still in conneced state so dont
6449 *issue IMPS req
6450 */
6451 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6452 {
6453 smsLog(pMac, LOGW, FL("FW still in connected state "));
6454 break;
6455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 csrScanStartIdleScan(pMac);
6457 break;
6458 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306459 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 csrRoamCallCallback(pMac, sessionId, NULL,
6461 pCommand->u.roamCmd.roamId,
6462 eCSR_ROAM_IBSS_LEAVE,
6463 eCSR_ROAM_RESULT_IBSS_STOP);
6464 break;
6465 case eCsrForcedDisassocMICFailure:
6466 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6467
6468 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6469#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6470 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6471#endif
6472 csrScanStartIdleScan(pMac);
6473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 case eCsrStopBss:
6475 csrRoamCallCallback(pMac, sessionId, NULL,
6476 pCommand->u.roamCmd.roamId,
6477 eCSR_ROAM_INFRA_IND,
6478 eCSR_ROAM_RESULT_INFRA_STOPPED);
6479 break;
6480 case eCsrForcedDisassocSta:
6481 case eCsrForcedDeauthSta:
6482 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306483 pSession = CSR_GET_SESSION(pMac, sessionId);
6484 if (pSession)
6485 {
6486 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 {
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306488 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6489 {
6490 roamInfo.u.pConnectedProfile =
6491 &pSession->connectedProfile;
6492 vos_mem_copy(roamInfo.peerMac,
6493 pCommand->u.roamCmd.peerMac,
6494 sizeof(tSirMacAddr));
6495 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6496 roamInfo.statusCode = eSIR_SME_SUCCESS;
6497 status = csrRoamCallCallback(pMac, sessionId,
6498 &roamInfo, pCommand->u.roamCmd.roamId,
6499 eCSR_ROAM_LOSTLINK,
6500 eCSR_ROAM_RESULT_FORCED);
6501 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306502 }
6503 else
6504 {
6505 smsLog(pMac, LOGE, FL("Inactive session %d"),
6506 sessionId);
6507 return eHAL_STATUS_FAILURE;
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05306508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 }
Nishank Aggarwal5657dd42017-04-06 16:10:19 +05306510 else
6511 {
6512 smsLog(pMac, LOGE, FL("Invalid session"));
6513 return eHAL_STATUS_FAILURE;
6514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 case eCsrLostLink1:
6517 // if lost link roam1 failed, then issue lost link Scan2 ...
6518 csrScanRequestLostLink2(pMac, sessionId);
6519 break;
6520 case eCsrLostLink2:
6521 // if lost link roam2 failed, then issue lost link scan3 ...
6522 csrScanRequestLostLink3(pMac, sessionId);
6523 break;
6524 case eCsrLostLink3:
6525 default:
6526 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6527
6528 //We are done with one round of lostlink roaming here
6529 csrScanHandleFailedLostlink3(pMac, sessionId);
6530 break;
6531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 break;
6533 }
6534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 return ( fReleaseCommand );
6536}
6537
Jeff Johnson295189b2012-06-20 16:38:30 -07006538eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6539{
6540 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 return (status);
6542}
6543
Jeff Johnson295189b2012-06-20 16:38:30 -07006544eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6545{
6546 eHalStatus status = eHAL_STATUS_SUCCESS;
6547 tANI_U32 size = 0;
6548
6549 do
6550 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306551 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6553 {
6554 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306555 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6556 if ( NULL == pDstProfile->BSSIDs.bssid )
6557 status = eHAL_STATUS_FAILURE;
6558 else
6559 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 if(!HAL_STATUS_SUCCESS(status))
6561 {
6562 break;
6563 }
6564 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306565 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6566 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 }
6568 if(pSrcProfile->SSIDs.numOfSSIDs)
6569 {
6570 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306571 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6572 if ( NULL == pDstProfile->SSIDs.SSIDList )
6573 status = eHAL_STATUS_FAILURE;
6574 else
6575 status = eHAL_STATUS_SUCCESS;
6576 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 {
6578 break;
6579 }
6580 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306581 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6582 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 }
6584 if(pSrcProfile->nWPAReqIELength)
6585 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306586 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6587 if ( NULL == pDstProfile->pWPAReqIE )
6588 status = eHAL_STATUS_FAILURE;
6589 else
6590 status = eHAL_STATUS_SUCCESS;
6591
6592 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 {
6594 break;
6595 }
6596 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306597 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6598 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 }
6600 if(pSrcProfile->nRSNReqIELength)
6601 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306602 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6603 if ( NULL == pDstProfile->pRSNReqIE )
6604 status = eHAL_STATUS_FAILURE;
6605 else
6606 status = eHAL_STATUS_SUCCESS;
6607
6608 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 {
6610 break;
6611 }
6612 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306613 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6614 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 }
6616#ifdef FEATURE_WLAN_WAPI
6617 if(pSrcProfile->nWAPIReqIELength)
6618 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306619 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6620 if ( NULL == pDstProfile->pWAPIReqIE )
6621 status = eHAL_STATUS_FAILURE;
6622 else
6623 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 if(!HAL_STATUS_SUCCESS(status))
6625 {
6626 break;
6627 }
6628 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306629 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6630 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 }
6632#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 if(pSrcProfile->nAddIEScanLength)
6634 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306635 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6636 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306638 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306639 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306640 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6641 }
6642 else
6643 {
6644 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6645 FL(" AddIEScanLength is not valid %u"),
6646 pSrcProfile->nAddIEScanLength);
6647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 if(pSrcProfile->nAddIEAssocLength)
6650 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306651 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6652 if ( NULL == pDstProfile->pAddIEAssoc )
6653 status = eHAL_STATUS_FAILURE;
6654 else
6655 status = eHAL_STATUS_SUCCESS;
6656
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 if(!HAL_STATUS_SUCCESS(status))
6658 {
6659 break;
6660 }
6661 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306662 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6663 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 if(pSrcProfile->ChannelInfo.ChannelList)
6666 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306667 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6668 pSrcProfile->ChannelInfo.numOfChannels);
6669 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6670 status = eHAL_STATUS_FAILURE;
6671 else
6672 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 if(!HAL_STATUS_SUCCESS(status))
6674 {
6675 break;
6676 }
6677 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306678 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6679 pSrcProfile->ChannelInfo.ChannelList,
6680 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 pDstProfile->AuthType = pSrcProfile->AuthType;
6683 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6684 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6685 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6686 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6687 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006688#ifdef WLAN_FEATURE_11W
6689 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6690 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6691 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6692#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 pDstProfile->BSSType = pSrcProfile->BSSType;
6694 pDstProfile->phyMode = pSrcProfile->phyMode;
6695 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6696
6697#ifdef FEATURE_WLAN_WAPI
6698 if(csrIsProfileWapi(pSrcProfile))
6699 {
6700 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6701 {
6702 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6703 }
6704 }
6705#endif /* FEATURE_WLAN_WAPI */
6706 pDstProfile->CBMode = pSrcProfile->CBMode;
6707 /*Save the WPS info*/
6708 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006709 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 pDstProfile->privacy = pSrcProfile->privacy;
6713 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6714 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6715 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6716 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6717 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6718 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6719 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6720 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6721 pDstProfile->wps_state = pSrcProfile->wps_state;
6722 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Abhishek Singhe3beee22017-07-31 15:35:40 +05306723 pDstProfile->force_24ghz_in_ht20 =
6724 pSrcProfile->force_24ghz_in_ht20;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05306725 pDstProfile->force_rsne_override = pSrcProfile->force_rsne_override;
Kiet Lam64c1b492013-07-12 13:56:44 +05306726 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6727 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006728#ifdef WLAN_FEATURE_VOWIFI_11R
6729 if (pSrcProfile->MDID.mdiePresent)
6730 {
6731 pDstProfile->MDID.mdiePresent = 1;
6732 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6733 }
6734#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 }while(0);
6736
6737 if(!HAL_STATUS_SUCCESS(status))
6738 {
6739 csrReleaseProfile(pMac, pDstProfile);
6740 pDstProfile = NULL;
6741 }
6742
6743 return (status);
6744}
Jeff Johnson295189b2012-06-20 16:38:30 -07006745eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6746{
6747 eHalStatus status = eHAL_STATUS_SUCCESS;
6748 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6749 do
6750 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306751 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 if(pSrcProfile->bssid)
6753 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306754 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6755 if ( NULL == pDstProfile->BSSIDs.bssid )
6756 status = eHAL_STATUS_FAILURE;
6757 else
6758 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 if(!HAL_STATUS_SUCCESS(status))
6760 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306761 smsLog( pMac, LOGE,
6762 FL("failed to allocate memory for BSSID"
6763 "%02x:%02x:%02x:%02x:%02x:%02x"),
6764 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6765 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 break;
6767 }
6768 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306769 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6770 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 }
6772 if(pSrcProfile->SSID.ssId)
6773 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306774 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6775 if ( NULL == pDstProfile->SSIDs.SSIDList )
6776 status = eHAL_STATUS_FAILURE;
6777 else
6778 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 if(!HAL_STATUS_SUCCESS(status))
6780 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306781 smsLog( pMac, LOGE,
6782 FL("failed to allocate memory for SSIDList"
6783 "%02x:%02x:%02x:%02x:%02x:%02x"),
6784 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6785 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006786 break;
6787 }
6788 pDstProfile->SSIDs.numOfSSIDs = 1;
6789 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6790 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306791 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6792 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006794 if(pSrcProfile->nAddIEAssocLength)
6795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306796 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6797 if ( NULL == pDstProfile->pAddIEAssoc)
6798 status = eHAL_STATUS_FAILURE;
6799 else
6800 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006801 if(!HAL_STATUS_SUCCESS(status))
6802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006803 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006804 break;
6805 }
6806 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306807 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6808 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006809 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306810 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6811 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6812 status = eHAL_STATUS_FAILURE;
6813 else
6814 status = eHAL_STATUS_SUCCESS;
6815
Jeff Johnson295189b2012-06-20 16:38:30 -07006816 if(!HAL_STATUS_SUCCESS(status))
6817 {
6818 break;
6819 }
6820 pDstProfile->ChannelInfo.numOfChannels = 1;
6821 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 pDstProfile->AuthType.numEntries = 1;
6823 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6824 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6825 pDstProfile->EncryptionType.numEntries = 1;
6826 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6827 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6828 pDstProfile->mcEncryptionType.numEntries = 1;
6829 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6830 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6831 pDstProfile->BSSType = pSrcProfile->BSSType;
6832 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306833 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6834 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306835#ifdef WLAN_FEATURE_11W
6836 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6837 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6838 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6839#endif
6840
Jeff Johnson295189b2012-06-20 16:38:30 -07006841#ifdef WLAN_FEATURE_VOWIFI_11R
6842 if (pSrcProfile->MDID.mdiePresent)
6843 {
6844 pDstProfile->MDID.mdiePresent = 1;
6845 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6846 }
6847#endif
6848
6849 }while(0);
6850
6851 if(!HAL_STATUS_SUCCESS(status))
6852 {
6853 csrReleaseProfile(pMac, pDstProfile);
6854 pDstProfile = NULL;
6855 }
6856
6857 return (status);
6858}
6859
Jeff Johnson295189b2012-06-20 16:38:30 -07006860eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6861 tScanResultHandle hBSSList,
6862 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6863 tANI_BOOLEAN fClearScan)
6864{
6865 eHalStatus status = eHAL_STATUS_SUCCESS;
6866 tSmeCmd *pCommand;
6867
6868 pCommand = csrGetCommandBuffer(pMac);
6869 if(NULL == pCommand)
6870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006871 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 status = eHAL_STATUS_RESOURCES;
6873 }
6874 else
6875 {
6876 if( fClearScan )
6877 {
6878 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306879 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 }
6881 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6882 if(NULL == pProfile)
6883 {
6884 //We can roam now
6885 //Since pProfile is NULL, we need to build our own profile, set everything to default
6886 //We can only support open and no encryption
6887 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6888 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6889 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6890 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6891 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6892 }
6893 else
6894 {
6895 //make a copy of the profile
6896 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6897 if(HAL_STATUS_SUCCESS(status))
6898 {
6899 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6900 }
6901 }
6902 pCommand->command = eSmeCommandRoam;
6903 pCommand->sessionId = (tANI_U8)sessionId;
6904 pCommand->u.roamCmd.hBSSList = hBSSList;
6905 pCommand->u.roamCmd.roamId = roamId;
6906 pCommand->u.roamCmd.roamReason = reason;
6907 //We need to free the BssList when the command is done
6908 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6909 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6911 FL("CSR PERSONA=%d"),
6912 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6914 if( !HAL_STATUS_SUCCESS( status ) )
6915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006916 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 csrReleaseCommandRoam( pMac, pCommand );
6918 }
6919 }
6920
6921 return (status);
6922}
Jeff Johnson295189b2012-06-20 16:38:30 -07006923eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6924 tCsrRoamModifyProfileFields *pMmodProfileFields,
6925 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6926{
6927 eHalStatus status = eHAL_STATUS_SUCCESS;
6928 tSmeCmd *pCommand;
6929
6930 pCommand = csrGetCommandBuffer(pMac);
6931 if(NULL == pCommand)
6932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006933 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 status = eHAL_STATUS_RESOURCES;
6935 }
6936 else
6937 {
6938 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306939 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006940 if(pProfile)
6941 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 //This is likely trying to reassoc to different profile
6943 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6944 //make a copy of the profile
6945 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6946 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 }
6948 else
6949 {
6950 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6951 //how to update WPA/WPA2 info in roamProfile??
6952 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 if(HAL_STATUS_SUCCESS(status))
6955 {
6956 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6957 }
6958 pCommand->command = eSmeCommandRoam;
6959 pCommand->sessionId = (tANI_U8)sessionId;
6960 pCommand->u.roamCmd.roamId = roamId;
6961 pCommand->u.roamCmd.roamReason = reason;
6962 //We need to free the BssList when the command is done
6963 //For reassoc there is no BSS list, so the boolean set to false
6964 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6965 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6966 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6968 if( !HAL_STATUS_SUCCESS( status ) )
6969 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006970 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6972 csrReleaseCommandRoam( pMac, pCommand );
6973 }
6974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 return (status);
6976}
6977
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006978eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6979 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306980// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006981{
6982 eHalStatus status = eHAL_STATUS_SUCCESS;
6983 tSmeCmd *pCommand;
6984
6985 pCommand = csrGetCommandBuffer(pMac);
6986 if(NULL == pCommand)
6987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006988 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006989 status = eHAL_STATUS_RESOURCES;
6990 }
6991 else
6992 {
6993 if(pBssDescription)
6994 {
6995 //copy over the parameters we need later
6996 pCommand->command = eSmeCommandRoam;
6997 pCommand->sessionId = (tANI_U8)sessionId;
6998 pCommand->u.roamCmd.roamReason = reason;
6999 //this is the important parameter
7000 //in this case we are using this field for the "next" BSS
7001 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
7002 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
7003 if( !HAL_STATUS_SUCCESS( status ) )
7004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007005 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007006 csrReleaseCommandPreauth( pMac, pCommand );
7007 }
7008 }
7009 else
7010 {
7011 //Return failure
7012 status = eHAL_STATUS_RESOURCES;
7013 }
7014 }
7015 return (status);
7016}
7017
7018eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
7019{
7020 tListElem *pEntry;
7021 tSmeCmd *pCommand;
7022 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7023 if ( pEntry )
7024 {
7025 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7026 if ( (eSmeCommandRoam == pCommand->command) &&
7027 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
7028 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007029 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007030 pCommand->command, pCommand->u.roamCmd.roamReason);
7031 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
7032 csrReleaseCommandPreauth( pMac, pCommand );
7033 }
7034 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007035 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007036 pCommand->command, pCommand->u.roamCmd.roamReason);
7037 }
7038 }
7039 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007040 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07007041 }
7042 smeProcessPendingQueue( pMac );
7043 return eHAL_STATUS_SUCCESS;
7044}
7045
Jeff Johnson295189b2012-06-20 16:38:30 -07007046eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7047 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7048{
7049 eHalStatus status = eHAL_STATUS_FAILURE;
7050 tScanResultHandle hBSSList;
7051 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
7053 if(HAL_STATUS_SUCCESS(status))
7054 {
7055 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7056 if(pRoamId)
7057 {
7058 *pRoamId = roamId;
7059 }
7060 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7061 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7062 if(!HAL_STATUS_SUCCESS(status))
7063 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007064 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 csrScanResultPurge(pMac, hBSSList);
7066 }
7067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 return (status);
7069}
7070
Jeff Johnson295189b2012-06-20 16:38:30 -07007071eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7072 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
7073{
7074 eHalStatus status = eHAL_STATUS_SUCCESS;
7075 tScanResultHandle hBSSList;
7076 tCsrScanResultFilter *pScanFilter;
7077 tANI_U32 roamId = 0;
7078 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
7079 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 if (NULL == pProfile)
7081 {
7082 smsLog(pMac, LOGP, FL("No profile specified"));
7083 return eHAL_STATUS_FAILURE;
7084 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307085 if(!pSession)
7086 {
7087 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7088 return eHAL_STATUS_FAILURE;
7089 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307090 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7091 "encryType = %d"),
7092 lim_BssTypetoString(pProfile->BSSType),
7093 pProfile->BSSType,
7094 pProfile->AuthType.authType[0],
7095 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 if( CSR_IS_WDS( pProfile ) &&
7097 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
7098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007099 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007100 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007101 return status;
7102 }
Abhishek Singh230371c2015-11-23 11:29:57 +05307103 /* Reset abortConnection for the fresh connection */
7104 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 csrRoamCancelRoaming(pMac, sessionId);
7106 csrScanRemoveFreshScanCommand(pMac, sessionId);
7107 csrScanCancelIdleScan(pMac);
7108 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307109 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307110
7111 if (!vos_concurrent_open_sessions_running() &&
7112 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307114 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 csrScanDisable(pMac);
7116 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05307117
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7119 //Check whether ssid changes
7120 if(csrIsConnStateConnected(pMac, sessionId))
7121 {
7122 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7123 {
7124 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7125 }
7126 }
7127#ifdef FEATURE_WLAN_BTAMP_UT_RF
7128 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7129#endif
Abhishek Singh5de9efd2017-06-15 10:22:39 +05307130
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
7132 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007133 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
7135 if(pRoamId)
7136 {
7137 roamId = *pRoamId;
7138 }
7139 if(!HAL_STATUS_SUCCESS(status))
7140 {
7141 fCallCallback = eANI_BOOLEAN_TRUE;
7142 }
7143 }
7144 else
7145 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307146 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7147 if ( NULL == pScanFilter )
7148 status = eHAL_STATUS_FAILURE;
7149 else
7150 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 if(HAL_STATUS_SUCCESS(status))
7152 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307153 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 //Try to connect to any BSS
7155 if(NULL == pProfile)
7156 {
7157 //No encryption
7158 pScanFilter->EncryptionType.numEntries = 1;
7159 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7160 }//we don't have a profile
7161 else
7162 {
7163 //Here is the profile we need to connect to
7164 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7165 }//We have a profile
7166 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7167 if(pRoamId)
7168 {
7169 *pRoamId = roamId;
7170 }
7171
7172 if(HAL_STATUS_SUCCESS(status))
7173 {
7174 /*Save the WPS info*/
7175 if(NULL != pProfile)
7176 {
7177 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007178 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 }
7180 else
7181 {
7182 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007183 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 do
7186 {
7187 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 )
7190 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007191 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7193 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7194 if(!HAL_STATUS_SUCCESS(status))
7195 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007196 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 fCallCallback = eANI_BOOLEAN_TRUE;
7198 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007199 else
7200 {
7201 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007203 break;
7204 }
7205 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007206 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 if(HAL_STATUS_SUCCESS(status))
7208 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7210 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7211 if(!HAL_STATUS_SUCCESS(status))
7212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007213 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 csrScanResultPurge(pMac, hBSSList);
7215 fCallCallback = eANI_BOOLEAN_TRUE;
7216 }
7217 }//Have scan result
7218 else if(NULL != pProfile)
7219 {
7220 //Check whether it is for start ibss
7221 if(CSR_IS_START_IBSS(pProfile))
7222 {
7223 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7224 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7225 if(!HAL_STATUS_SUCCESS(status))
7226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007227 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 fCallCallback = eANI_BOOLEAN_TRUE;
7229 }
7230 }
7231 else
7232 {
7233 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007234 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 if(!HAL_STATUS_SUCCESS(status))
7236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007237 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 fCallCallback = eANI_BOOLEAN_TRUE;
7239 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007240 else
7241 {
7242 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 }
7245 }
7246 else
7247 {
7248 fCallCallback = eANI_BOOLEAN_TRUE;
7249 }
7250 } while (0);
7251 if(NULL != pProfile)
7252 {
7253 //we need to free memory for filter if profile exists
7254 csrFreeScanFilter(pMac, pScanFilter);
7255 }
7256 }//Got the scan filter from profile
7257
Kiet Lam64c1b492013-07-12 13:56:44 +05307258 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 }//allocated memory for pScanFilter
7260 }//No Bsslist coming in
7261 //tell the caller if we fail to trigger a join request
7262 if( fCallCallback )
7263 {
7264 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7265 }
7266
7267 return (status);
7268}
Jeff Johnson295189b2012-06-20 16:38:30 -07007269eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7270 tCsrRoamModifyProfileFields modProfileFields,
7271 tANI_U32 *pRoamId)
7272{
7273 eHalStatus status = eHAL_STATUS_SUCCESS;
7274 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7275 tANI_U32 roamId = 0;
7276 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 if (NULL == pProfile)
7278 {
7279 smsLog(pMac, LOGP, FL("No profile specified"));
7280 return eHAL_STATUS_FAILURE;
7281 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307282 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7283 "encryType = %d"),
7284 lim_BssTypetoString(pProfile->BSSType),
7285 pProfile->BSSType,
7286 pProfile->AuthType.authType[0],
7287 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 csrRoamCancelRoaming(pMac, sessionId);
7289 csrScanRemoveFreshScanCommand(pMac, sessionId);
7290 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307291 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 if(csrIsConnStateConnected(pMac, sessionId))
7294 {
7295 if(pProfile)
7296 {
7297 if(pProfile->SSIDs.numOfSSIDs &&
7298 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7299 {
7300 fCallCallback = eANI_BOOLEAN_FALSE;
7301 }
7302 else
7303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007304 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 }
7306 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307307 else if (!vos_mem_compare(&modProfileFields,
7308 &pSession->connectedProfile.modifyProfileFields,
7309 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 {
7311 fCallCallback = eANI_BOOLEAN_FALSE;
7312 }
7313 else
7314 {
7315 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007316 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 }
7318 }
7319 else
7320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007321 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 if(!fCallCallback)
7324 {
7325 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7326 if(pRoamId)
7327 {
7328 *pRoamId = roamId;
7329 }
7330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7332 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 }
7334 else
7335 {
7336 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7337 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007339 return status;
7340}
Jeff Johnson295189b2012-06-20 16:38:30 -07007341eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7342{
7343 eHalStatus status = eHAL_STATUS_FAILURE;
7344 tScanResultHandle hBSSList = NULL;
7345 tCsrScanResultFilter *pScanFilter = NULL;
7346 tANI_U32 roamId;
7347 tCsrRoamProfile *pProfile = NULL;
7348 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007349
7350 if(!pSession)
7351 {
7352 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7353 return eHAL_STATUS_FAILURE;
7354 }
7355
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 do
7357 {
7358 if(pSession->pCurRoamProfile)
7359 {
7360 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307361 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307363 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7364 if ( NULL == pProfile )
7365 status = eHAL_STATUS_FAILURE;
7366 else
7367 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 if(!HAL_STATUS_SUCCESS(status))
7369 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307370 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307372 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307374 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7375 if ( NULL == pScanFilter )
7376 status = eHAL_STATUS_FAILURE;
7377 else
7378 status = eHAL_STATUS_SUCCESS;
7379
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 if(!HAL_STATUS_SUCCESS(status))
7381 {
7382 break;
7383 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307384 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7386 if(!HAL_STATUS_SUCCESS(status))
7387 {
7388 break;
7389 }
7390 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7391 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7392 if(HAL_STATUS_SUCCESS(status))
7393 {
7394 //we want to put the last connected BSS to the very beginning, if possible
7395 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7396 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7397 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7398 if(!HAL_STATUS_SUCCESS(status))
7399 {
7400 csrScanResultPurge(pMac, hBSSList);
7401 break;
7402 }
7403 }
7404 else
7405 {
7406 //Do a scan on this profile
7407 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007408 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 if(!HAL_STATUS_SUCCESS(status))
7410 {
7411 break;
7412 }
7413 }
7414 }//We have a profile
7415 else
7416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007417 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 break;
7419 }
7420 }while(0);
7421 if(pScanFilter)
7422 {
7423 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307424 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 }
7426 if(NULL != pProfile)
7427 {
7428 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307429 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 return (status);
7432}
Jeff Johnson295189b2012-06-20 16:38:30 -07007433eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7434{
7435 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007436 if(csrIsConnStateConnected(pMac, sessionId))
7437 {
7438 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7439 if(HAL_STATUS_SUCCESS(status))
7440 {
7441 status = csrRoamJoinLastProfile(pMac, sessionId);
7442 }
7443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 return (status);
7445}
7446
Jeff Johnson295189b2012-06-20 16:38:30 -07007447eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7448{
7449 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007450 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007451 csrRoamCancelRoaming(pMac, sessionId);
7452 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7453 if(csrIsConnStateDisconnected(pMac, sessionId))
7454 {
7455 status = csrRoamJoinLastProfile(pMac, sessionId);
7456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 return (status);
7458}
7459
Jeff Johnson295189b2012-06-20 16:38:30 -07007460eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7461{
7462 eHalStatus status = eHAL_STATUS_SUCCESS;
7463 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7464 eCsrRoamSubState NewSubstate;
7465 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307466
7467 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7468 {
7469 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7470 " eCSR_ROAM_SUBSTATE_NONE"));
7471 csrRoamStopWaitForKeyTimer( pMac );
7472 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 // change state to 'Roaming'...
7475 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7476
7477 if ( csrIsConnStateIbss( pMac, sessionId ) )
7478 {
7479 // If we are in an IBSS, then stop the IBSS...
7480 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7481 fComplete = (!HAL_STATUS_SUCCESS(status));
7482 }
7483 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007485 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7487 //Restore AC weight in case we change it
7488 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7489 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7490 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7491 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7492 {
7493 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7494 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307495 else
7496 {
7497 // If we are in neighbor preauth done state then on receiving
7498 // disassoc or deauth we dont roam instead we just disassoc
7499 // from current ap and then go to disconnected state
7500 // This happens for ESE and 11r FT connections ONLY.
7501#ifdef WLAN_FEATURE_VOWIFI_11R
7502 if (csrRoamIs11rAssoc(pMac) &&
7503 (csrNeighborRoamStatePreauthDone(pMac)))
7504 {
7505 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7506 }
7507#endif
7508#ifdef FEATURE_WLAN_ESE
7509 if (csrRoamIsESEAssoc(pMac) &&
7510 (csrNeighborRoamStatePreauthDone(pMac)))
7511 {
7512 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7513 }
7514#endif
7515#ifdef FEATURE_WLAN_LFR
7516 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7517 (csrNeighborRoamStatePreauthDone(pMac)))
7518 {
7519 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7520 }
7521#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05307522#ifdef WLAN_FEATURE_LFR_MBB
7523 csr_stop_preauth_reassoc_mbb_timer(pMac);
7524#endif
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307525 }
7526
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 if( fDisassoc )
7528 {
7529 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307530 if (pMac->roam.configParam.roamDelayStatsEnabled)
7531 {
7532 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007534 }
7535 else
7536 {
7537 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7538 }
7539 fComplete = (!HAL_STATUS_SUCCESS(status));
7540 }
7541 else if ( csrIsConnStateWds( pMac, sessionId ) )
7542 {
7543 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7544 {
7545 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7546 fComplete = (!HAL_STATUS_SUCCESS(status));
7547 }
7548 //This has to be WDS station
7549 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7550 {
7551
7552 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7553 if( fDisassoc )
7554 {
7555 status = csrRoamIssueDisassociate( pMac, sessionId,
7556 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7557 fComplete = (!HAL_STATUS_SUCCESS(status));
7558 }
7559 }
7560 } else {
7561 // we got a dis-assoc request while not connected to any peer
7562 // just complete the command
7563 fComplete = eANI_BOOLEAN_TRUE;
7564 status = eHAL_STATUS_FAILURE;
7565 }
7566 if(fComplete)
7567 {
7568 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7569 }
7570
7571 if(HAL_STATUS_SUCCESS(status))
7572 {
7573 if ( csrIsConnStateInfra( pMac, sessionId ) )
7574 {
7575 //Set the state to disconnect here
7576 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307577#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7578 //we don't need to run this timer any more
7579 if (VOS_TIMER_STATE_RUNNING ==
7580 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7581 {
7582 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7583 if (status != eHAL_STATUS_SUCCESS)
7584 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7585 }
7586#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 }
7588 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007589 else
7590 {
7591 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 return (status);
7594}
7595
Jeff Johnson295189b2012-06-20 16:38:30 -07007596/* This is been removed from latest code base */
7597/*
7598static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7599{
7600 eHalStatus status;
7601 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7603 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007604 return ( status );
7605}
7606*/
7607
Jeff Johnson295189b2012-06-20 16:38:30 -07007608eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7609{
7610 eHalStatus status = eHAL_STATUS_SUCCESS;
7611 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307612
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 do
7614 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 pCommand = csrGetCommandBuffer( pMac );
7616 if ( !pCommand )
7617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007618 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 status = eHAL_STATUS_RESOURCES;
7620 break;
7621 }
7622 //Change the substate in case it is wait-for-key
7623 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7624 {
7625 csrRoamStopWaitForKeyTimer( pMac );
7626 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7627 }
7628 pCommand->command = eSmeCommandRoam;
7629 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307630 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7631 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 switch ( reason )
7633 {
7634 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7635 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 case eCSR_DISCONNECT_REASON_DEAUTH:
7638 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7639 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7642 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7644 case eCSR_DISCONNECT_REASON_DISASSOC:
7645 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7648 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7651 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 default:
7654 break;
7655 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307656 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 if( !HAL_STATUS_SUCCESS( status ) )
7658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007659 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 csrReleaseCommandRoam( pMac, pCommand );
7661 }
7662 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 return( status );
7664}
7665
Jeff Johnson295189b2012-06-20 16:38:30 -07007666eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7667{
7668 eHalStatus status = eHAL_STATUS_SUCCESS;
7669 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 pCommand = csrGetCommandBuffer( pMac );
7671 if ( NULL != pCommand )
7672 {
7673 //Change the substate in case it is wait-for-key
7674 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7675 {
7676 csrRoamStopWaitForKeyTimer( pMac );
7677 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7678 }
7679 pCommand->command = eSmeCommandRoam;
7680 pCommand->sessionId = (tANI_U8)sessionId;
7681 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7682 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7683 if( !HAL_STATUS_SUCCESS( status ) )
7684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007685 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 csrReleaseCommandRoam( pMac, pCommand );
7687 }
7688 }
7689 else
7690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007691 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 status = eHAL_STATUS_RESOURCES;
7693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 return ( status );
7695}
7696
Jeff Johnson295189b2012-06-20 16:38:30 -07007697eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7698{
7699 eHalStatus status = eHAL_STATUS_SUCCESS;
7700 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007701
7702 if(!pSession)
7703 {
7704 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7705 return eHAL_STATUS_FAILURE;
7706 }
7707
Jeff Johnson295189b2012-06-20 16:38:30 -07007708#ifdef FEATURE_WLAN_BTAMP_UT_RF
7709 //Stop te retry
7710 pSession->maxRetryCount = 0;
7711 csrRoamStopJoinRetryTimer(pMac, sessionId);
7712#endif
7713 //Not to call cancel roaming here
7714 //Only issue disconnect when necessary
7715 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7716 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7717 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7718
7719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007720 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7722 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307723 else
7724 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307725 csrScanAbortScanForSSID(pMac, sessionId);
Mukul Sharma11841b42017-07-05 13:10:09 +05307726 csrScanStartIdleScan(pMac);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307727 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307728 smsLog(pMac, LOGE,
7729 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 return (status);
7732}
7733
Jeff Johnson295189b2012-06-20 16:38:30 -07007734eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7735{
7736 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007737
7738 if(!pSession)
7739 {
7740 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7741 return eHAL_STATUS_FAILURE;
7742 }
7743
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7746
7747 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7748}
7749
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307750void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7751{
7752 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7753 if(!pSession)
7754 {
7755 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7756 return;
7757 }
7758 pSession->abortConnection = TRUE;
7759 return;
7760}
7761
Jeff Johnson295189b2012-06-20 16:38:30 -07007762eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7763 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7764{
7765 eHalStatus status = eHAL_STATUS_SUCCESS;
7766 tDot11fBeaconIEs *pIesTemp = pIes;
7767 tANI_U8 index;
7768 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7769 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007770
7771 if(!pSession)
7772 {
7773 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7774 return eHAL_STATUS_FAILURE;
7775 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007776 if(pConnectProfile->pAddIEAssoc)
7777 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307778 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007779 pConnectProfile->pAddIEAssoc = NULL;
7780 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307781 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7783 pConnectProfile->AuthInfo = pProfile->AuthType;
7784 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7785 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7786 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7787 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7788 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7789 pConnectProfile->BSSType = pProfile->BSSType;
7790 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7791 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007792 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307793 if (!pConnectProfile->beaconInterval)
7794 {
7795 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7796 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307797 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007798 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7799 if(pProfile->nAddIEAssocLength)
7800 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307801 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7802 if ( NULL == pConnectProfile->pAddIEAssoc )
7803 status = eHAL_STATUS_FAILURE;
7804 else
7805 status = eHAL_STATUS_SUCCESS;
7806 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007807 {
7808 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7809 return eHAL_STATUS_FAILURE;
7810 }
7811 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307812 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7813 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007814 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307815
7816#ifdef WLAN_FEATURE_11W
7817 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7818 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7819 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7820#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007821
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 //Save bssid
7823 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7824#ifdef WLAN_FEATURE_VOWIFI_11R
7825 if (pSirBssDesc->mdiePresent)
7826 {
7827 pConnectProfile->MDID.mdiePresent = 1;
7828 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7829 }
7830#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007831 if( NULL == pIesTemp )
7832 {
7833 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7834 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007835#ifdef FEATURE_WLAN_ESE
7836 if ((csrIsProfileESE(pProfile) ||
7837 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307838 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7839 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7840 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7841 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7842#ifdef WLAN_FEATURE_11W
7843 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307844 || (pProfile->negotiatedAuthType ==
7845 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307846#endif
7847 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007848 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007850 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 }
7852#endif
7853 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 if(HAL_STATUS_SUCCESS(status))
7855 {
7856 if(pIesTemp->SSID.present)
7857 {
7858 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307859 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7860 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 }
7862
7863 //Save the bss desc
7864 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307865
7866 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307868 //Some HT AP's dont send WMM IE so in that case we assume all HT Ap's are Qos Enabled AP's
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 pConnectProfile->qap = TRUE;
7870 }
7871 else
7872 {
7873 pConnectProfile->qap = FALSE;
7874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 if ( NULL == pIes )
7876 {
7877 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307878 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 }
7880 }
7881 //Save Qos connection
7882 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7883
7884 if(!HAL_STATUS_SUCCESS(status))
7885 {
7886 csrFreeConnectBssDesc(pMac, sessionId);
7887 }
7888 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7889 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307890 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7891 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7892 pConnectProfile->SSID.ssId,
7893 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 {
7895 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7896 break;
7897 }
7898 pConnectProfile->handoffPermitted = FALSE;
7899 }
7900
7901 return (status);
7902}
7903
Jeff Johnson295189b2012-06-20 16:38:30 -07007904static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7905{
7906 tListElem *pEntry = NULL;
7907 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307908 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 //The head of the active list is the request we sent
7910 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7911 if(pEntry)
7912 {
7913 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7914 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307915 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7917 {
7918 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7919 {
7920#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7921 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7922#endif
7923 }
7924 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307925 if(!pSession)
7926 {
7927 smsLog(pMac, LOGE, FL(" session %d not found "),
7928 pSmeJoinRsp->sessionId);
7929 return;
7930 }
7931 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 }
7933 else
7934 {
7935 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007936 if(!pSession)
7937 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307938 smsLog(pMac, LOGE, FL(" session %d not found "),
7939 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007940 return;
7941 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307942 if (pSession->abortConnection)
7943 {
Abhinav Kumare548f1e2018-07-12 16:40:43 +05307944 smsLog(pMac, LOG1, FL("Disconnection in progess abort Join request"));
7945
7946 if (pSession->bRefAssocStartCnt)
7947 pSession->bRefAssocStartCnt--;
7948 csrRoamCallCallback(pMac, pSession->sessionId,
7949 NULL, roamId,
7950 eCSR_ROAM_ASSOCIATION_COMPLETION,
7951 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307952 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7953 pSession->abortConnection = FALSE;
7954 return;
7955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 //The head of the active list is the request we sent
7957 //Try to get back the same profile and roam again
7958 if(pCommand)
7959 {
7960 roamId = pCommand->u.roamCmd.roamId;
7961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7963 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007964 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007965#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7966 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7967 if (csrRoamIsHandoffInProgress(pMac))
7968 {
7969 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7970 /* Should indicate neighbor roam algorithm about the connect failure here */
7971 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7972 }
7973#endif
7974 if (pCommand)
7975 {
7976 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7977 {
7978 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7979 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7980 csrRoamReissueRoamCommand(pMac);
7981 }
7982 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7983 {
7984 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7985 }
7986 else
7987 {
7988 csrRoam(pMac, pCommand);
7989 }
7990 }
7991 else
7992 {
7993 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7994 }
7995 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7996}
7997
Jeff Johnson295189b2012-06-20 16:38:30 -07007998eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7999 tDot11fBeaconIEs *pIes,
8000 tCsrRoamProfile *pProfile, tANI_U32 roamId )
8001{
8002 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08008003 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
8004 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008005
8006 // Set the roaming substate to 'join attempt'...
8007 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08008009 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 return (status);
8011}
8012
Jeff Johnson295189b2012-06-20 16:38:30 -07008013static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
8014 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
8015{
8016 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 // Set the roaming substate to 'join attempt'...
8018 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
8019
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308020 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8021 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05308022 if (pMac->roam.configParam.roamDelayStatsEnabled)
8023 {
8024 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
8025 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
8026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08008028 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07008029}
8030
Jeff Johnson295189b2012-06-20 16:38:30 -07008031void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
8032{
8033 tListElem *pEntry;
8034 tSmeCmd *pCommand;
8035 tCsrRoamInfo roamInfo;
8036 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308037 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008038
8039 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8040 if(pEntry)
8041 {
8042 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8043 if ( eSmeCommandRoam == pCommand->command )
8044 {
8045 sessionId = pCommand->sessionId;
8046 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008047
8048 if(!pSession)
8049 {
8050 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8051 return;
8052 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05308053 /* While switching between two AP, csr will reissue roam command again
8054 to the nextbss if it was interrupted by the dissconnect req for the
8055 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
8056 so reset the bRefAssocStartCnt.
8057 */
8058 if(pSession->bRefAssocStartCnt > 0)
8059 {
8060 pSession->bRefAssocStartCnt--;
8061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 if( pCommand->u.roamCmd.fStopWds )
8063 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308064 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8066 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8067 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
8070 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8071 eCSR_ROAM_WDS_IND,
8072 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
8074 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8075 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
8076 eCSR_ROAM_INFRA_IND,
8077 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
8078 }
8079
Jeff Johnson295189b2012-06-20 16:38:30 -07008080
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
8082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008083 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8085 }
8086 }
8087 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
8088 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008089 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8091 }
8092 }
8093 else
8094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008095 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07008096 }
8097 }
8098 else
8099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008100 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 }
8102}
8103
Jeff Johnson295189b2012-06-20 16:38:30 -07008104tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
8105{
8106 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8107 tListElem *pEntry;
8108 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 //alwasy lock active list before locking pending list
8110 csrLLLock( &pMac->sme.smeCmdActiveList );
8111 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8112 if(pEntry)
8113 {
8114 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8115 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8116 {
8117 fRet = eANI_BOOLEAN_TRUE;
8118 }
8119 }
8120 if(eANI_BOOLEAN_FALSE == fRet)
8121 {
8122 csrLLLock(&pMac->sme.smeCmdPendingList);
8123 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8124 while(pEntry)
8125 {
8126 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8127 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8128 {
8129 fRet = eANI_BOOLEAN_TRUE;
8130 break;
8131 }
8132 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8133 }
8134 csrLLUnlock(&pMac->sme.smeCmdPendingList);
8135 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05308136 if (eANI_BOOLEAN_FALSE == fRet)
8137 {
8138 csrLLLock(&pMac->roam.roamCmdPendingList);
8139 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
8140 while (pEntry)
8141 {
8142 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8143 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
8144 {
8145 fRet = eANI_BOOLEAN_TRUE;
8146 break;
8147 }
8148 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
8149 }
8150 csrLLUnlock(&pMac->roam.roamCmdPendingList);
8151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 return (fRet);
8154}
8155
Jeff Johnson295189b2012-06-20 16:38:30 -07008156tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
8157{
8158 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8159 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
8161 {
8162 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
8163 {
8164 break;
8165 }
8166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 return ( fRet );
8168}
8169
Jeff Johnson295189b2012-06-20 16:38:30 -07008170tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
8171{
8172 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 //alwasy lock active list before locking pending list
8174 csrLLLock( &pMac->sme.smeCmdActiveList );
8175 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8176 if(eANI_BOOLEAN_FALSE == fRet)
8177 {
8178 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8179 }
8180 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 return (fRet);
8182}
8183
Jeff Johnson295189b2012-06-20 16:38:30 -07008184tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8185{
8186 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8187 tListElem *pEntry;
8188 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 //alwasy lock active list before locking pending list
8190 csrLLLock( &pMac->sme.smeCmdActiveList );
8191 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8192 if( pEntry )
8193 {
8194 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8195 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8196 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8197 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8198 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8199 {
8200 fRet = eANI_BOOLEAN_TRUE;
8201 }
8202 }
8203 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 return (fRet);
8205}
Jeff Johnson295189b2012-06-20 16:38:30 -07008206eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8207{
8208 eHalStatus status = eHAL_STATUS_SUCCESS;
8209 tSmeCmd *pCommand = NULL;
8210 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8211 tANI_BOOLEAN fRemoveCmd = FALSE;
8212 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 // Delete the old assoc command. All is setup for reassoc to be serialized
8214 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8215 if ( pEntry )
8216 {
8217 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8218 if ( !pCommand )
8219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008220 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 return eHAL_STATUS_RESOURCES;
8222 }
8223 if ( eSmeCommandRoam == pCommand->command )
8224 {
8225 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8226 {
8227 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8228 }
8229 else
8230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008231 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 }
8233 if (fRemoveCmd == FALSE)
8234 {
8235 // Implies we did not get the serialized assoc command we
8236 // were expecting
8237 pCommand = NULL;
8238 }
8239 }
8240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 if(NULL == pCommand)
8242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008243 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 return eHAL_STATUS_RESOURCES;
8245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 do
8247 {
8248 //Change the substate in case it is wait-for-key
8249 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8250 {
8251 csrRoamStopWaitForKeyTimer( pMac );
8252 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8253 }
8254 pCommand->command = eSmeCommandRoam;
8255 pCommand->sessionId = (tANI_U8)sessionId;
8256 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8258 if( !HAL_STATUS_SUCCESS( status ) )
8259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008260 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 csrReleaseCommandRoam( pMac, pCommand );
8262 }
8263 } while( 0 );
8264
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 return( status );
8266}
8267static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8268{
8269 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8270 tCsrScanResult *pScanResult = NULL;
8271 tSirBssDescription *pBssDesc = NULL;
8272 tSmeCmd *pCommand = NULL;
8273 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308274 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 if(NULL == pEntry)
8276 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308277 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 return;
8279 }
8280 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8281 sessionId = pCommand->sessionId;
8282 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008283
8284 if(!pSession)
8285 {
8286 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8287 return;
8288 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308289 smsLog(pMac, LOG1, FL("CFG return value is %d "
8290 " current state is : %d substate is : %d "),
8291 result, pMac->roam.curState[sessionId],
8292 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8294 {
8295 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008296 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8298 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008299 /* If the roaming has stopped, not to continue the roaming command*/
8300 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8301 {
8302 //No need to complete roaming here as it already completes
8303 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8304 pCommand->u.roamCmd.roamReason);
8305 csrSetAbortRoamingCommand( pMac, pCommand );
8306 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 else
8309 {
8310 if ( CCM_IS_RESULT_SUCCESS(result) )
8311 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308312 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 // Successfully set the configuration parameters for the new Bss. Attempt to
8314 // join the roaming Bss.
8315 if(pCommand->u.roamCmd.pRoamBssEntry)
8316 {
8317 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308318 if (!pScanResult)
8319 {
8320 smsLog(pMac, LOGE,
8321 FL("Failed to get base address for pScanResult"));
8322 return;
8323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 pBssDesc = &pScanResult->Result.BssDescriptor;
8325 }
8326 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8327 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008329 )
8330 {
8331 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8332 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8333 pBssDesc, pCommand->u.roamCmd.roamId )))
8334 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308335 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 //We need to complete the command
8337 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8338 }
8339 }
8340 else
8341 {
8342 if (!pCommand->u.roamCmd.pRoamBssEntry)
8343 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308344 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 //We need to complete the command
8346 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8347 return;
8348 }
8349 // If we are roaming TO an Infrastructure BSS...
8350 VOS_ASSERT(pScanResult != NULL);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +05308351 if( !pScanResult->Result.pvIes )
8352 {
8353 smsLog(pMac, LOGE, FL(" pvIes is NULL"));
8354 return;
8355 }
8356
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 if ( csrIsInfraBssDesc( pBssDesc ) )
8358 {
8359 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308360 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8362 {
8363 // ..and currently in an Infrastructure connection....
8364 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8365 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308366 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 // ...and the SSIDs are equal, then we Reassoc.
8368 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8369 pIesLocal ) )
8370 // ..and currently in an infrastructure connection
8371 {
8372 // then issue a Reassoc.
8373 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8374 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8375 &pCommand->u.roamCmd.roamProfile );
8376 }
8377 else
8378 {
8379
8380 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8381 // previously associated AP.
8382 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8383 pIesLocal,
8384 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8385 {
8386 //try something else
8387 csrRoam( pMac, pCommand );
8388 }
8389 }
8390 }
8391 else
8392 {
8393 eHalStatus status = eHAL_STATUS_SUCCESS;
8394
8395 /* We need to come with other way to figure out that this is because of HO in BMP
8396 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008397 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 * use join request */
8399#ifdef WLAN_FEATURE_VOWIFI_11R
8400 if (csrRoamIsHandoffInProgress(pMac) &&
8401 csrRoamIs11rAssoc(pMac))
8402 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308403 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8405 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8406 }
8407 else
8408#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008409#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008411 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308413 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 // Now serialize the reassoc command.
8415 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8416 }
8417 else
8418#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008419#ifdef FEATURE_WLAN_LFR
8420 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308421 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008422 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308423 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008424 // Now serialize the reassoc command.
8425 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8426 }
8427 else
8428#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 // else we are not connected and attempting to Join. Issue the
8430 // Join request.
8431 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308432 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008433 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8434 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8435 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8436 }
8437 if(!HAL_STATUS_SUCCESS(status))
8438 {
8439 //try something else
8440 csrRoam( pMac, pCommand );
8441 }
8442 }
8443 if( !pScanResult->Result.pvIes )
8444 {
8445 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308446 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 }
8448 }
8449 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8450 else
8451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008452 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 }
8454 }//else
8455 }//if ( WNI_CFG_SUCCESS == result )
8456 else
8457 {
8458 // In the event the configuration failed, for infra let the roam processor
8459 //attempt to join something else...
8460 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8461 {
8462 csrRoam(pMac, pCommand);
8463 }
8464 else
8465 {
8466 //We need to complete the command
8467 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8468 {
8469 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8470 }
8471 else
8472 {
8473 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8474 }
8475 }
8476 }
8477 }//we have active entry
8478}
8479
Jeff Johnson295189b2012-06-20 16:38:30 -07008480static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8481{
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008484 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8486 // join the new one...
8487 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8489 }
8490 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008491 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 /***profHandleLostLinkAfterReset(pAdapter);
8493 // In the event the authenticate fails, let the roam processor attempt to join something else...
8494 roamRoam( pAdapter );***/
8495 }
8496}
8497
Jeff Johnson295189b2012-06-20 16:38:30 -07008498static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8499{
8500 eCsrRoamCompleteResult result;
8501 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8502 tCsrRoamInfo roamInfo;
8503 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308504 tANI_U32 current_timestamp, max_time = -1;
Sen, Devendra8e4f8fc2016-09-07 12:42:46 +05308505 tANI_U32 candidateApCnt, oldestIndex = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308506 tANI_U8 nilMac[6] = {0};
8507
8508 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008510 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 /* Defeaturize this part later if needed */
8513#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8514 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8515 * we need the response contents while processing the result in csrRoamProcessResults() */
8516 if (csrRoamIsHandoffInProgress(pMac))
8517 {
8518 /* Need to dig more on indicating events to SME QoS module */
8519 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8520 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308521#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8522 /* Add previous BSSID to blacklist ; this will be in blacklised for
8523 * some period and score of this AP will be reduced if black listed
8524 * to avoid ping pong */
8525 if (pMac->PERroamCandidatesCnt)
8526 {
8527 current_timestamp = jiffies_to_msecs(jiffies);
8528 for (candidateApCnt = 0; candidateApCnt <
8529 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8530 {
8531 /* Find one blank entry */
8532 if (sirCompareMacAddr(nilMac,
8533 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8534 {
8535 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8536 bssAddr,
8537 pNeighborRoamInfo->prevConnProfile.bssid,
8538 sizeof(tSirMacAddr));
8539 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8540 current_timestamp;
8541 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8542 MAC_ADDR_ARRAY(
8543 pNeighborRoamInfo->prevConnProfile.bssid),
8544 candidateApCnt);
8545 break;
8546 }
8547 /* if already in the list */
8548 if (sirCompareMacAddr(pMac->previousRoamApInfo
8549 [candidateApCnt].bssAddr,
8550 pNeighborRoamInfo->prevConnProfile.bssid) &&
8551 ((current_timestamp -
8552 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8553 pMac->PERroamTimeout))
8554 {
8555 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8556 bssAddr,
8557 pNeighborRoamInfo->prevConnProfile.bssid,
8558 sizeof(tSirMacAddr));
8559 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8560 current_timestamp;
8561 break;
8562 } else
8563 {
8564 /* find oldest BSSID entry in the blacklist */
8565 if (max_time <
8566 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8567 {
8568 max_time =
8569 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8570 oldestIndex = candidateApCnt;
8571 }
8572 }
8573 }
8574 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8575 {
8576 smsLog(pMac, LOGW,
8577 "%s: Clearing out oldest roam results bssid="
8578 MAC_ADDRESS_STR,
8579 __func__,
8580 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8581 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8582 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8583 pNeighborRoamInfo->prevConnProfile.bssid,
8584 sizeof(tSirMacAddr));
8585 }
8586 }
8587#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 }
8589 else
8590#endif
8591 {
8592 csrRoamComplete( pMac, result, NULL );
8593 }
8594 }
8595 /* Should we handle this similar to handling the join failure? Is it ok
8596 * to call csrRoamComplete() with state as CsrJoinFailure */
8597 else
8598 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008599 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308601 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8602 WLAN_LOG_INDICATOR_HOST_DRIVER,
8603 WLAN_LOG_REASON_ROAM_FAIL,
8604 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008605#ifdef WLAN_FEATURE_VOWIFI_11R
8606 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308607 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8608 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 {
8610 // Inform HDD to turn off FT flag in HDD
8611 if (pNeighborRoamInfo)
8612 {
8613 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8614 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8615 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008616 /*
8617 * Since the above callback sends a disconnect
8618 * to HDD, we should clean-up our state
8619 * machine as well to be in sync with the upper
8620 * layers. There is no need to send a disassoc
8621 * since: 1) we will never reassoc to the current
8622 * AP in LFR, and 2) there is no need to issue a
8623 * disassoc to the AP with which we were trying
8624 * to reassoc.
8625 */
8626 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8627 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 }
8629 }
8630#endif
8631 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8632 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8633 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8634 //The disassoc rsp message will remove the command from active list
8635 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8636 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8637 {
8638 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8639 }
8640 }
8641}
8642
Jeff Johnson295189b2012-06-20 16:38:30 -07008643static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8644{
Jeff Johnson295189b2012-06-20 16:38:30 -07008645#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8646 {
8647 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008648 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8649 if(pIbssLog)
8650 {
8651 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8652 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8653 {
8654 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8655 }
8656 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8657 }
8658 }
8659#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8661 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8662 {
8663 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8664 }
8665 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8666 {
8667 csrRoamReissueRoamCommand(pMac);
8668 }
8669}
8670
Jeff Johnson295189b2012-06-20 16:38:30 -07008671void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8672{
8673 tSirResultCodes statusCode;
8674#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8675 tScanResultHandle hBSSList;
8676 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8677 eHalStatus status;
8678 tCsrRoamInfo roamInfo;
8679 tCsrScanResultFilter *pScanFilter = NULL;
8680 tANI_U32 roamId = 0;
8681 tCsrRoamProfile *pCurRoamProfile = NULL;
8682 tListElem *pEntry = NULL;
8683 tSmeCmd *pCommand = NULL;
8684#endif
8685 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308686 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008687
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 tSirSmeDisassocRsp SmeDisassocRsp;
8689
8690 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8691 sessionId = SmeDisassocRsp.sessionId;
8692 statusCode = SmeDisassocRsp.statusCode;
8693
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008694 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008695
8696 if ( csrIsConnStateInfra( pMac, sessionId ) )
8697 {
8698 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008701
8702 if(!pSession)
8703 {
8704 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8705 return;
8706 }
8707
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8709 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308710 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8712 }
8713 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8714 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8715 {
8716 if ( eSIR_SME_SUCCESS == statusCode )
8717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008718 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8720 }
8721 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008723 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8724 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308725 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8726 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008727#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008728 /*
8729 * First ensure if the roam profile is in the scan cache.
8730 * If not, post a reassoc failure and disconnect.
8731 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308732 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8733 if ( NULL == pScanFilter )
8734 status = eHAL_STATUS_FAILURE;
8735 else
8736 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008737 if(HAL_STATUS_SUCCESS(status))
8738 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308739 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008740 status = csrRoamPrepareFilterFromProfile(pMac,
8741 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8742 if(!HAL_STATUS_SUCCESS(status))
8743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008744 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008745 __func__, status);
8746 goto POST_ROAM_FAILURE;
8747 }
8748 else
8749 {
8750 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8751 if (!HAL_STATUS_SUCCESS(status))
8752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008753 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008754 __func__, status);
8755 goto POST_ROAM_FAILURE;
8756 }
8757 }
8758 }
8759 else
8760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008761 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008762 __func__, status);
8763 goto POST_ROAM_FAILURE;
8764 }
8765
8766 /*
8767 * After ensuring that the roam profile is in the scan result list,
8768 * dequeue the command from the active list.
8769 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8771 if ( pEntry )
8772 {
8773 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008774 /* If the head of the queue is Active and it is a ROAM command, remove
8775 * and put this on the Free queue.
8776 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 if ( eSmeCommandRoam == pCommand->command )
8778 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008779
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008780 /*
8781 * we need to process the result first before removing it from active list
8782 * because state changes still happening insides roamQProcessRoamResults so
8783 * no other roam command should be issued.
8784 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8786 if(pCommand->u.roamCmd.fReleaseProfile)
8787 {
8788 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8789 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008792 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 else
8794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008795 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008796 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 }
8798 }
8799 else
8800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008801 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 }
8803 }
8804 else
8805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008806 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008808
8809 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8811
Kiet Lam64c1b492013-07-12 13:56:44 +05308812 vos_mem_copy(roamInfo.bssid,
8813 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8814 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008815
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008816 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8817 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008818
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008819 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308820 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8821 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308823 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008824 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8825 //make sure to put it at the head of the cmd queue
8826 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8827 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8828 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8829
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 if(!HAL_STATUS_SUCCESS(status))
8831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008832 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008833 __func__, status);
8834 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008835 }
8836
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008837 /* Notify sub-modules like QoS etc. that handoff happening */
8838 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308839 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008840 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308841 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308843 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008844 return;
8845 }
8846
8847POST_ROAM_FAILURE:
8848 if (pScanFilter)
8849 {
8850 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308851 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008852 }
8853 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308854 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008855
8856 /* Inform the upper layers that the reassoc failed */
8857 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8858 csrRoamCallCallback(pMac, sessionId,
8859 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8860
8861 /*
8862 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8863 * Upon success, we would re-enter this routine after receiving the disassoc
8864 * response and will fall into the reassoc fail sub-state. And, eventually
8865 * call csrRoamComplete which would remove the roam command from SME active
8866 * queue.
8867 */
8868 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8869 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008871 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008872 __func__, status);
8873 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008875#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008876
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8878 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8879 {
8880 // Disassoc due to Reassoc failure falls into this codepath....
8881 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8882 }
8883 else
8884 {
8885 if ( eSIR_SME_SUCCESS == statusCode )
8886 {
8887 // Successfully disassociated from the 'old' Bss...
8888 //
8889 // We get Disassociate response in three conditions.
8890 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8891 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8892 // Infrastructure network.
8893 // - Third is where we are doing an Infra to Infra roam between networks with different
8894 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8895
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008896 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 }
8898 else
8899 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008900 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 }
8902 //We are not done yet. Get the data and continue roaming
8903 csrRoamReissueRoamCommand(pMac);
8904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008905}
8906
Jeff Johnson295189b2012-06-20 16:38:30 -07008907static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8908{
8909 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008911 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008912 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8913 {
8914 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8915 }
8916 else
8917 {
8918 if ( eSIR_SME_SUCCESS == statusCode )
8919 {
8920 // Successfully deauth from the 'old' Bss...
8921 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008922 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 }
8924 else
8925 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008926 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 }
8928 //We are not done yet. Get the data and continue roaming
8929 csrRoamReissueRoamCommand(pMac);
8930 }
8931}
8932
Jeff Johnson295189b2012-06-20 16:38:30 -07008933static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8934{
8935 eCsrRoamCompleteResult result;
8936
8937 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008939 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 result = eCsrStartBssSuccess;
8941 }
8942 else
8943 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008944 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 //Let csrRoamComplete decide what to do
8946 result = eCsrStartBssFailure;
8947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008948 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008949}
8950
Jeff Johnson295189b2012-06-20 16:38:30 -07008951/*
8952 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8953 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8954 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8955 For the messages where sender allocates memory for specific structures, then it can be
8956 cast accordingly.
8957*/
8958void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8959{
8960 tSirSmeRsp *pSmeRsp;
8961 tSmeIbssPeerInd *pIbssPeerInd;
8962 tCsrRoamInfo roamInfo;
8963 // TODO Session Id need to be acquired in this function
8964 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308966 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8967 pSmeRsp->messageType, pSmeRsp->messageType,
8968 macTraceGetcsrRoamSubState(
8969 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 pSmeRsp->messageType = (pSmeRsp->messageType);
8971 pSmeRsp->length = (pSmeRsp->length);
8972 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 switch (pSmeRsp->messageType)
8974 {
8975
8976 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8977 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8978 {
8979 //We sent a JOIN_REQ
8980 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8981 }
8982 break;
8983
8984 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8985 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8986 {
8987 //We sent a AUTH_REQ
8988 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8989 }
8990 break;
8991
8992 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8993 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8994 {
8995 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8996 }
8997 break;
8998
8999 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
9000 {
9001 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
9002 }
9003 break;
9004
9005 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
9006 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
9007 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
9008 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
9009 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
9010 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
9011//HO
9012 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
9013 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309014 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
9015 macTraceGetcsrRoamSubState(
9016 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05309018 if (pMac->roam.configParam.roamDelayStatsEnabled)
9019 {
9020 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
9021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 }
9023 break;
9024
9025 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
9026 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
9027 {
9028 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
9029 }
9030 break;
9031
9032 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
9033 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
9034 {
9035 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
9036 }
9037 break;
9038
9039 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
9040 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
9041 {
9042 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
9043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
9046 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9047 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009048 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05309049 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9050 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9052 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309053 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9054 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9056 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9057 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9058 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05309059 case eWNI_SME_LOST_LINK_PARAMS_IND:
9060 {
9061 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
9062 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9063 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9064 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
9065 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
9066 pRoamInfo = &roamInfo;
9067 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
9068 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
9069 break;
9070 }
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05309071 case eWNI_SME_TRIGGER_SAE:
9072 smsLog(pMac, LOG1, FL("Invoke SAE callback"));
9073 csr_sae_callback(pMac, pSmeRsp);
9074 break;
9075
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309077 smsLog(pMac, LOG1,
9078 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9079 pSmeRsp->messageType, pSmeRsp->messageType,
9080 macTraceGetcsrRoamSubState(
9081 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07009082
9083 //If we are connected, check the link status change
9084 if(!csrIsConnStateDisconnected(pMac, sessionId))
9085 {
9086 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
9087 }
9088 break;
9089 }
9090}
9091
Jeff Johnson295189b2012-06-20 16:38:30 -07009092void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
9093{
9094 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 switch (pSirMsg->messageType)
9096 {
9097 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009098 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009099 csrRoamStatsRspProcessor( pMac, pSirMsg );
9100 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9102 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309103 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9105 tCsrRoamInfo roamInfo;
9106 tCsrRoamInfo *pRoamInfo = NULL;
9107 tANI_U32 sessionId;
9108 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009109 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05309110 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
9113 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
9114 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009115
9116 if(!pSession)
9117 {
9118 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9119 return;
9120 }
9121
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9123 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
9125 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
9126 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
9128 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309129 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
9130 sizeof(tSirMacAddr));
9131 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
9132 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309134#ifdef WLAN_FEATURE_AP_HT40_24G
9135 pRoamInfo->HT40MHzIntoEnabledSta =
9136 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
9137 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9138 pRoamInfo->HT40MHzIntoEnabledSta);
9139#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309140 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05309141 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9142 pRoamInfo->chan_info = pUpperLayerAssocCnf->chan_info;
9143 if (pUpperLayerAssocCnf->HTCaps.present)
9144 pRoamInfo->ht_caps = pUpperLayerAssocCnf->HTCaps;
9145 if (pUpperLayerAssocCnf->VHTCaps.present)
9146 pRoamInfo->vht_caps = pUpperLayerAssocCnf->VHTCaps;
9147
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
9149 {
9150 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9151 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
9152 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9153 }
9154 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9155 {
9156 vos_sleep( 100 );
9157 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
9158 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
9159 }
9160
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 }
9162 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 default:
9164 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
9165 break;
9166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009167}
9168
Jeff Johnson295189b2012-06-20 16:38:30 -07009169eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
9170 tSirBssDescription *pBssDescription,
9171 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
9172 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
9173 tANI_U8 keyId, tANI_U16 keyLength,
9174 tANI_U8 *pKey, tANI_U8 paeRole )
9175{
9176 eHalStatus status = eHAL_STATUS_SUCCESS;
9177 tAniEdType edType;
9178
9179 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
9180 {
9181 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
9182 }
9183
9184 edType = csrTranslateEncryptTypeToEdType( EncryptType );
9185
9186 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
9187 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
9188 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
9189 addKey )
9190 {
9191 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 setKey.encType = EncryptType;
9193 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309194 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 setKey.paeRole = paeRole; //0 for supplicant
9196 setKey.keyId = keyId; // Kye index
9197 setKey.keyLength = keyLength;
9198 if( keyLength )
9199 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309200 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 }
9202 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 return (status);
9205}
9206
Jeff Johnson295189b2012-06-20 16:38:30 -07009207static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9208 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9209{
9210 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9211 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009212#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009214#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009215
9216 do
9217 {
9218 pCommand = csrGetCommandBuffer(pMac);
9219 if(NULL == pCommand)
9220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009221 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 status = eHAL_STATUS_RESOURCES;
9223 break;
9224 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309225 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 pCommand->command = eSmeCommandSetKey;
9227 pCommand->sessionId = (tANI_U8)sessionId;
9228 // validate the key length, Adjust if too long...
9229 // for static WEP the keys are not set thru' SetContextReq
9230 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9231 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9232 {
9233 //KeyLength maybe 0 for static WEP
9234 if( pSetKey->keyLength )
9235 {
9236 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009238 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 break;
9240 }
9241
9242 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309243 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9244 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 }
9246 }
9247 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9248 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9249 {
9250 //KeyLength maybe 0 for static WEP
9251 if( pSetKey->keyLength )
9252 {
9253 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009255 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 break;
9257 }
9258
9259 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309260 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9261 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 }
9263 }
9264 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9265 {
9266 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009268 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 break;
9270 }
9271 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309272 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9273 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009274 }
9275 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9276 {
9277 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9278 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009279 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 break;
9281 }
9282 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309283 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9284 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 }
9286#ifdef FEATURE_WLAN_WAPI
9287 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9288 {
9289 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009291 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 break;
9293 }
9294 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309295 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9296 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 }
9298#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009299#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9301 {
9302 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009304 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 break;
9306 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009307 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309308 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009309 pSession->eseCckmInfo.reassoc_req_num=1;
9310 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 status = eHAL_STATUS_SUCCESS;
9312 break;
9313 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009314#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009315
Jeff Johnson295189b2012-06-20 16:38:30 -07009316#ifdef WLAN_FEATURE_11W
9317 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009318 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009320 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009321 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009322 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 break;
9324 }
9325 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309326 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 }
9328#endif
9329 status = eHAL_STATUS_SUCCESS;
9330 pCommand->u.setKeyCmd.roamId = roamId;
9331 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9332 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309333 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9334 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9336 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309337 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 //Always put set key to the head of the Q because it is the only thing to get executed in case of WT_KEY state
9339
9340 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9341 if( !HAL_STATUS_SUCCESS( status ) )
9342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009343 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 }
9345 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009347 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009348 if ( ( NULL != pCommand ) &&
9349 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009350#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009352#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009353 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 {
9355 csrReleaseCommandSetKey( pMac, pCommand );
9356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 return( status );
9358}
9359
Jeff Johnson295189b2012-06-20 16:38:30 -07009360eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9361 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9362{
9363 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9364 tSmeCmd *pCommand = NULL;
9365 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 do
9367 {
9368 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009370 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009371 status = eHAL_STATUS_CSR_WRONG_STATE;
9372 break;
9373 }
9374 pCommand = csrGetCommandBuffer(pMac);
9375 if(NULL == pCommand)
9376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009377 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 status = eHAL_STATUS_RESOURCES;
9379 break;
9380 }
9381 pCommand->command = eSmeCommandRemoveKey;
9382 pCommand->sessionId = (tANI_U8)sessionId;
9383 pCommand->u.removeKeyCmd.roamId = roamId;
9384 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309385 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9386 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9388 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9389 {
9390 //in this case, put it to the end of the Q incase there is a set key pending.
9391 fImediate = eANI_BOOLEAN_FALSE;
9392 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009393 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009395 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009396 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9397 if( !HAL_STATUS_SUCCESS( status ) )
9398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009399 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 break;
9401 }
9402 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9404 {
9405 csrReleaseCommandRemoveKey( pMac, pCommand );
9406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009407 return (status );
9408}
9409
Jeff Johnson295189b2012-06-20 16:38:30 -07009410eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9411{
9412 eHalStatus status;
9413 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9414 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9415 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9416 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009417#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9418 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9419 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309420 if(!pSession)
9421 {
9422 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9423 return eHAL_STATUS_FAILURE;
9424 }
lukez3c809222013-05-03 10:23:02 -07009425 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309427 vos_mem_set(&setKeyEvent,
9428 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9430 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309431 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9433 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9434 }
9435 else
9436 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309437 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9439 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9440 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309441 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009442 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009443 {
9444 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 //It has to be static WEP here
9446 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9447 {
9448 setKeyEvent.keyId = (v_U8_t)defKeyId;
9449 }
9450 }
9451 else
9452 {
9453 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9454 }
9455 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9456 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9457 }
9458#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 if( csrIsSetKeyAllowed(pMac, sessionId) )
9460 {
9461 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9462 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9463 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9464 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9465 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9466 pCommand->u.setKeyCmd.keyRsc);
9467 }
9468 else
9469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009470 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009471 //Set this status so the error handling take care of the case.
9472 status = eHAL_STATUS_CSR_WRONG_STATE;
9473 }
9474 if( !HAL_STATUS_SUCCESS(status) )
9475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009476 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009478#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009479 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 {
9481 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9482 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309483 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 }
9485 else
9486 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309487 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 }
9489 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9490 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9491 }
9492#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 return ( status );
9495}
9496
Jeff Johnson295189b2012-06-20 16:38:30 -07009497eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9498{
9499 eHalStatus status;
9500 tpSirSmeRemoveKeyReq pMsg = NULL;
9501 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9502 tANI_U8 *p;
9503 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009504#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9505 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9506 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309507 if(!pSession)
9508 {
9509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9510 return eHAL_STATUS_FAILURE;
9511 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309512 vos_mem_set(&removeKeyEvent,
9513 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9515 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9516 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309517 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009518 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9519 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9520 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9521#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 if( csrIsSetKeyAllowed(pMac, sessionId) )
9523 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309524 pMsg = vos_mem_malloc(wMsgLen);
9525 if ( NULL == pMsg )
9526 status = eHAL_STATUS_FAILURE;
9527 else
9528 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 }
9530 else
9531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009532 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 //Set the error status so error handling kicks in below
9534 status = eHAL_STATUS_CSR_WRONG_STATE;
9535 }
9536 if( HAL_STATUS_SUCCESS( status ) )
9537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309538 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9540 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 pMsg->sessionId = (tANI_U8)sessionId;
9542 pMsg->transactionId = 0;
9543 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9544 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9545 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309546 vos_mem_copy(p,
9547 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9548 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 p += sizeof(tSirMacAddr);
9550 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309551 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 p += sizeof(tSirMacAddr);
9553 // edType
9554 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9555 p++;
9556 // weptype
9557 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9558 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9559 {
9560 *p = (tANI_U8)eSIR_WEP_STATIC;
9561 }
9562 else
9563 {
9564 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9565 }
9566 p++;
9567 //keyid
9568 *p = pCommand->u.removeKeyCmd.keyId;
9569 p++;
9570 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 status = palSendMBMessage(pMac->hHdd, pMsg);
9572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 if( !HAL_STATUS_SUCCESS( status ) )
9574 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009575 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009576#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9577 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009578 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9580#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 return ( status );
9584}
9585
Jeff Johnson295189b2012-06-20 16:38:30 -07009586eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9587{
9588 eHalStatus status;
9589
9590 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9591 {
9592 status = eHAL_STATUS_CSR_WRONG_STATE;
9593 }
9594 else
9595 {
9596 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 return ( status );
9599}
9600
Jeff Johnson295189b2012-06-20 16:38:30 -07009601/*
9602 Prepare a filter base on a profile for parsing the scan results.
9603 Upon successful return, caller MUST call csrFreeScanFilter on
9604 pScanFilter when it is done with the filter.
9605*/
9606eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9607 tCsrScanResultFilter *pScanFilter)
9608{
9609 eHalStatus status = eHAL_STATUS_SUCCESS;
9610 tANI_U32 size = 0;
9611 tANI_U8 index = 0;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309612 uint8_t i;
Jeff Johnson295189b2012-06-20 16:38:30 -07009613
9614 do
9615 {
9616 if(pProfile->BSSIDs.numOfBSSIDs)
9617 {
9618 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309619 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9620 if ( NULL == pScanFilter->BSSIDs.bssid )
9621 status = eHAL_STATUS_FAILURE;
9622 else
9623 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 if(!HAL_STATUS_SUCCESS(status))
9625 {
9626 break;
9627 }
9628 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309629 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 }
9631 if(pProfile->SSIDs.numOfSSIDs)
9632 {
9633 if( !CSR_IS_WDS_STA( pProfile ) )
9634 {
9635 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9636 }
9637 else
9638 {
9639 //For WDS station
9640 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9641 pScanFilter->SSIDs.numOfSSIDs = 1;
9642 }
9643 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309644 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9645 if ( NULL == pScanFilter->SSIDs.SSIDList )
9646 status = eHAL_STATUS_FAILURE;
9647 else
9648 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 if(!HAL_STATUS_SUCCESS(status))
9650 {
9651 break;
9652 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309653 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9654 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 }
9656 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9657 {
9658 pScanFilter->ChannelInfo.numOfChannels = 0;
9659 pScanFilter->ChannelInfo.ChannelList = NULL;
9660 }
9661 else if(pProfile->ChannelInfo.numOfChannels)
9662 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309663 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9664 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9665 pProfile->ChannelInfo.numOfChannels);
9666 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9667 status = eHAL_STATUS_FAILURE;
9668 else
9669 status = eHAL_STATUS_SUCCESS;
9670
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 pScanFilter->ChannelInfo.numOfChannels = 0;
9672 if(HAL_STATUS_SUCCESS(status))
9673 {
9674 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9675 {
9676 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9677 {
9678 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9679 = pProfile->ChannelInfo.ChannelList[index];
9680 pScanFilter->ChannelInfo.numOfChannels++;
9681 }
9682 else
9683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009684 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 }
9687 }
9688 else
9689 {
9690 break;
9691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 }
9693 else
9694 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309695 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 status = eHAL_STATUS_FAILURE;
9697 break;
9698 }
9699 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
Pragaspathi Thilagaraja2419962018-06-19 01:41:11 +05309700 if (pProfile->force_rsne_override) {
9701 smsLog(pMac, LOG1, FL("force_rsne_override enabled fill all auth type and enctype"));
9702
9703 pScanFilter->authType.numEntries = eCSR_NUM_OF_SUPPORT_AUTH_TYPE;
9704 for (i = 0; i < pScanFilter->authType.numEntries; i++)
9705 pScanFilter->authType.authType[i] = i;
9706 index = 0;
9707 for (i = 0; i < eCSR_NUM_OF_ENCRYPT_TYPE; i++) {
9708 if (i == eCSR_ENCRYPT_TYPE_TKIP ||
9709 i == eCSR_ENCRYPT_TYPE_AES) {
9710 pScanFilter->
9711 EncryptionType.encryptionType[index] = i;
9712 pScanFilter->
9713 mcEncryptionType.encryptionType[index] = i;
9714 index++;
9715 }
9716 }
9717 pScanFilter->EncryptionType.numEntries = index;
9718 pScanFilter->mcEncryptionType.numEntries = index;
9719 pScanFilter->ignore_pmf_cap = true;
9720 } else {
9721 pScanFilter->authType = pProfile->AuthType;
9722 pScanFilter->EncryptionType = pProfile->EncryptionType;
9723 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 pScanFilter->BSSType = pProfile->BSSType;
9726 pScanFilter->phyMode = pProfile->phyMode;
9727#ifdef FEATURE_WLAN_WAPI
9728 //check if user asked for WAPI with 11n or auto mode, in that case modify
9729 //the phymode to 11g
9730 if(csrIsProfileWapi(pProfile))
9731 {
9732 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9733 {
9734 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9735 }
9736 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9737 {
9738 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9739 }
9740 if(!pScanFilter->phyMode)
9741 {
9742 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9743 }
9744 }
9745#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 /*Save the WPS info*/
9747 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009748 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 if( pProfile->countryCode[0] )
9750 {
9751 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309752 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9753 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009754 }
9755#ifdef WLAN_FEATURE_VOWIFI_11R
9756 if (pProfile->MDID.mdiePresent)
9757 {
9758 pScanFilter->MDID.mdiePresent = 1;
9759 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9760 }
9761#endif
Abhishek Singhb3e376c2017-01-04 15:27:13 +05309762 vos_mem_copy(pScanFilter->bssid_hint,
9763 pProfile->bssid_hint, VOS_MAC_ADDR_SIZE);
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309764
9765#ifdef WLAN_FEATURE_11W
9766 // Management Frame Protection
9767 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9768 pScanFilter->MFPRequired = pProfile->MFPRequired;
9769 pScanFilter->MFPCapable = pProfile->MFPCapable;
9770#endif
9771
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 }while(0);
9773
9774 if(!HAL_STATUS_SUCCESS(status))
9775 {
9776 csrFreeScanFilter(pMac, pScanFilter);
9777 }
9778
9779 return(status);
9780}
9781
Jeff Johnson295189b2012-06-20 16:38:30 -07009782tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9783 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9784{
9785 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9786 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 do
9788 {
9789 // Validate the type is ok...
9790 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9791 pCommand = csrGetCommandBuffer( pMac );
9792 if ( !pCommand )
9793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009794 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 break;
9796 }
9797 //Change the substate in case it is waiting for key
9798 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9799 {
9800 csrRoamStopWaitForKeyTimer( pMac );
9801 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9802 }
9803 pCommand->command = eSmeCommandWmStatusChange;
9804 pCommand->sessionId = (tANI_U8)sessionId;
9805 pCommand->u.wmStatusChangeCmd.Type = Type;
9806 if ( eCsrDisassociated == Type )
9807 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309808 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9809 pSmeRsp,
9810 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 }
9812 else
9813 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309814 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9815 pSmeRsp,
9816 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009817 }
9818 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9819 {
9820 fCommandQueued = eANI_BOOLEAN_TRUE;
9821 }
9822 else
9823 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009824 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 csrReleaseCommandWmStatusChange( pMac, pCommand );
9826 }
9827
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9829 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 return( fCommandQueued );
9832}
9833
Jeff Johnson295189b2012-06-20 16:38:30 -07009834static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9835{
9836 v_S7_t rssi = 0;
9837 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9838 if(pGetRssiReq)
9839 {
9840 if(NULL != pGetRssiReq->pVosContext)
9841 {
9842 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9843 }
9844 else
9845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009846 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 return;
9848 }
9849
9850 if(NULL != pGetRssiReq->rssiCallback)
9851 {
9852 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9853 }
9854 else
9855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009856 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 return;
9858 }
9859 }
9860 else
9861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009862 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 }
9864 return;
9865}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309866
9867static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9868{
9869 tANI_S8 snr = 0;
9870 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9871
9872 if (pGetSnrReq)
9873 {
9874 if (VOS_STATUS_SUCCESS !=
9875 WDA_GetSnr(pGetSnrReq->staId, &snr))
9876 {
9877 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9878 return;
9879 }
9880
9881 if (pGetSnrReq->snrCallback)
9882 {
9883 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9884 pGetSnrReq->pDevContext);
9885 }
9886 else
9887 {
9888 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9889 return;
9890 }
9891 }
9892 else
9893 {
9894 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9895 }
9896 return;
9897}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009898#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009899void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9900{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009901 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9902
Jeff Johnson36d483b2013-04-08 11:08:53 -07009903 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009904 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009905 /* Get roam Rssi request is backed up and passed back to the response,
9906 Extract the request message to fetch callback */
9907 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9908 v_S7_t rssi = pRoamRssiRsp->rssi;
9909
9910 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009911 {
9912 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9913 reqBkp->rssiCallback = NULL;
9914 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009915 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009916 }
9917 else
9918 {
9919 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9920 if (NULL != reqBkp)
9921 {
9922 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009923 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009924 }
9925 }
9926 }
9927 else
9928 {
9929 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9930 }
9931 return;
9932}
9933#endif
9934
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009935
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009936#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009937void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9938{
9939 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9940
9941 if (NULL != pTsmStatsRsp)
9942 {
9943 /* Get roam Rssi request is backed up and passed back to the response,
9944 Extract the request message to fetch callback */
9945 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9946
9947 if (NULL != reqBkp)
9948 {
9949 if (NULL != reqBkp->tsmStatsCallback)
9950 {
9951 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9952 pTsmStatsRsp->staId, reqBkp->pDevContext);
9953 reqBkp->tsmStatsCallback = NULL;
9954 }
9955 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009956 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009957 }
9958 else
9959 {
9960 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9961 if (NULL != reqBkp)
9962 {
9963 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009964 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009965 }
9966 }
9967 }
9968 else
9969 {
9970 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9971 }
9972 return;
9973}
9974
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009975void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009976{
9977 tANI_U32 roamTS2 = 0;
9978 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009979 tpPESession pSessionEntry = NULL;
9980 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009981
9982 if (NULL == pSession)
9983 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009984 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009985 return;
9986 }
9987
9988 roamTS2 = vos_timer_get_system_time();
9989 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009990 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9991 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009992 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009993
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009994 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9995 if (NULL == pSessionEntry)
9996 {
9997 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9998 return;
9999 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010000 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010001 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010002 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010003}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010004#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010005
Jeff Johnsone7245742012-09-05 17:12:55 -070010006static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
10007{
10008 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
10009 if(pTlRssiInd)
10010 {
10011 if(NULL != pTlRssiInd->tlCallback)
10012 {
10013 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -080010014 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -070010015 }
10016 else
10017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010018 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010019 }
10020 }
10021 else
10022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010023 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010024 }
10025 return;
10026}
Jeff Johnson295189b2012-06-20 16:38:30 -070010027
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010028eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
10029{
10030 tpSirResetAPCapsChange pMsg;
10031 tANI_U16 len;
10032 eHalStatus status = eHAL_STATUS_SUCCESS;
10033
10034 /* Create the message and send to lim */
10035 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +053010036 pMsg = vos_mem_malloc(len);
10037 if ( NULL == pMsg )
10038 status = eHAL_STATUS_FAILURE;
10039 else
10040 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010041 if (HAL_STATUS_SUCCESS(status))
10042 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010043 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010044 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
10045 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +053010046 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080010047 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
10048 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010049 status = palSendMBMessage(pMac->hHdd, pMsg);
10050 }
10051 else
10052 {
10053 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
10054 }
10055 return status;
10056}
10057
Jeff Johnson295189b2012-06-20 16:38:30 -070010058void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
10059{
10060 tSirSmeAssocInd *pAssocInd;
10061 tSirSmeDisassocInd *pDisassocInd;
10062 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010063 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
10065 tSirSmeNewBssInfo *pNewBss;
10066 tSmeIbssPeerInd *pIbssPeerInd;
10067 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10068 tSirSmeApNewCaps *pApNewCaps;
10069 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10070 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
10071 tCsrRoamInfo *pRoamInfo = NULL;
10072 tCsrRoamInfo roamInfo;
10073 eHalStatus status;
10074 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
10075 tCsrRoamSession *pSession = NULL;
10076 tpSirSmeSwitchChannelInd pSwitchChnInd;
10077 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +053010078 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -080010079
10080
10081 if (NULL == pSirMsg)
10082 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
10083 return;
10084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 switch( pSirMsg->messageType )
10086 {
10087 case eWNI_SME_ASSOC_IND:
10088 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053010089 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053010090 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010091 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
10092 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
10093 if( HAL_STATUS_SUCCESS( status ) )
10094 {
10095 pSession = CSR_GET_SESSION(pMac, sessionId);
10096
Jeff Johnson32d95a32012-09-10 13:15:23 -070010097 if(!pSession)
10098 {
10099 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10100 return;
10101 }
10102
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 pRoamInfo = &roamInfo;
10104
10105 // Required for indicating the frames to upper layer
10106 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
10107 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
10108
10109 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
10110 pRoamInfo->beaconLength = pAssocInd->beaconLength;
10111 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
10112 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10113
10114 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
10115 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
10116 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10117
10118 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
10119 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +053010120 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
10121 sizeof(tSirMacAddr));
10122 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
10123 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +053010125 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053010126#ifdef WLAN_FEATURE_AP_HT40_24G
10127 pRoamInfo->HT40MHzIntoEnabledSta =
10128 pAssocInd->HT40MHzIntoEnabledSta;
10129 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
10130 pRoamInfo->HT40MHzIntoEnabledSta);
10131#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
10135 {
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010136#ifdef SAP_AUTH_OFFLOAD
10137 if (pMac->sap_auth_offload)
10138 {
10139 smsLog(pMac, LOGW, FL(" Auth is not required to set in Auth offload case \n"));
10140 pRoamInfo->fAuthRequired = FALSE;
10141 }
10142 else
10143 {
10144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
10146 {
10147 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
10148 pSession->pConnectBssDesc,
10149 &(pRoamInfo->peerMac),
10150 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10151 pRoamInfo->fAuthRequired = FALSE;
10152 }
10153 else
10154 {
10155 pRoamInfo->fAuthRequired = TRUE;
10156 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053010157#ifdef SAP_AUTH_OFFLOAD
10158 }
10159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
10161 if (!HAL_STATUS_SUCCESS(status))
10162 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
10163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 /* Send Association completion message to PE */
10165 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
10166
10167 /* send a message to CSR itself just to avoid the EAPOL frames going
10168 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
10170 {
10171 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
10174 {
10175 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
10176 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
10177 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
10178 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 }
10180 }
10181 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010184 // Check if AP dis-associated us because of MIC failure. If so,
10185 // then we need to take action immediately and not wait till the
10186 // the WmStatusChange requests is pushed and processed
10187 tSmeCmd *pCommand;
10188
10189 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
10190 status = csrRoamGetSessionIdFromBSSID( pMac,
10191 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
10192 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010194 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
10195 " for session %d "), sessionId);
10196 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
10197 MAC_ADDRESS_STR " "
10198 " reason = %d status = %d "),
10199 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
10200 pDisassocInd->reasonCode,
10201 pDisassocInd->statusCode);
10202 // If we are in neighbor preauth done state then on receiving
10203 // disassoc or deauth we dont roam instead we just disassoc
10204 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010205 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +053010206#ifdef WLAN_FEATURE_VOWIFI_11R
10207 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10208 {
10209 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10210 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010211#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010212#ifdef FEATURE_WLAN_ESE
10213 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +053010214 {
10215 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010217#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010218#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +053010219 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
10220 {
10221 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10222 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010223#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010224#ifdef WLAN_FEATURE_LFR_MBB
10225 csr_stop_preauth_reassoc_mbb_timer(pMac);
10226#endif
10227
Agarwal Ashish4f616132013-12-30 23:32:50 +053010228 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010229
Agarwal Ashish4f616132013-12-30 23:32:50 +053010230 if (!pSession)
10231 {
10232 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10233 return;
10234 }
Jeff Johnson32d95a32012-09-10 13:15:23 -070010235
Agarwal Ashish4f616132013-12-30 23:32:50 +053010236 if ( csrIsConnStateInfra( pMac, sessionId ) )
10237 {
10238 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010240#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010241 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010242#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010243 csrRoamLinkDown(pMac, sessionId);
10244 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10245 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10246 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010247 /*
10248 * STA/P2P client got disassociated so remove any pending deauth
10249 * commands in sme pending list
10250 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010251 pCommand = csrGetCommandBuffer(pMac);
10252 if (NULL == pCommand)
10253 {
10254 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10255 status = eHAL_STATUS_RESOURCES;
10256 return;
10257 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010258 pCommand->command = eSmeCommandRoam;
10259 pCommand->sessionId = (tANI_U8)sessionId;
10260 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10261 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10262 pDisassocInd->peerMacAddr,
10263 sizeof(tSirMacAddr));
10264 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10265 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010266
Agarwal Ashish4f616132013-12-30 23:32:50 +053010267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010269 else
10270 {
10271 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10272 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10273 }
Kiet Lam82004c62013-11-11 13:24:28 +053010274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010277 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10279 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10280 if( HAL_STATUS_SUCCESS( status ) )
10281 {
10282 // If we are in neighbor preauth done state then on receiving
10283 // disassoc or deauth we dont roam instead we just disassoc
10284 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010285 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010286#ifdef WLAN_FEATURE_VOWIFI_11R
10287 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10288 {
10289 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10290 }
10291#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010292#ifdef FEATURE_WLAN_ESE
10293 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 {
10295 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10296 }
10297#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010298#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010299 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010300 {
10301 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10302 }
10303#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053010304#ifdef WLAN_FEATURE_LFR_MBB
10305 csr_stop_preauth_reassoc_mbb_timer(pMac);
10306#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 pSession = CSR_GET_SESSION( pMac, sessionId );
10308
Jeff Johnson32d95a32012-09-10 13:15:23 -070010309 if(!pSession)
10310 {
10311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10312 return;
10313 }
10314
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 if ( csrIsConnStateInfra( pMac, sessionId ) )
10316 {
10317 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010319#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10320 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10321#endif
Yeshwanth Sriram Guntuka381bfa82018-11-06 18:29:50 +053010322#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
10323 csrRemoveNeighbourRoamPreauthCommand(pMac);
10324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 csrRoamLinkDown(pMac, sessionId);
10326 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010327 }
10328 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010329
10330 case eWNI_SME_DISCONNECT_DONE_IND:
10331 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10332 smsLog( pMac, LOG1,
10333 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10334 pDisConDoneInd->reasonCode);
10335 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10336 {
10337 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10338 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10339 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10340 sizeof(tSirMacAddr));
10341 status = csrRoamCallCallback(pMac,
10342 pDisConDoneInd->sessionId,
10343 &roamInfo, 0,
10344 eCSR_ROAM_LOSTLINK,
10345 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010346 pSession = CSR_GET_SESSION(pMac,
10347 pDisConDoneInd->sessionId);
10348 if (pSession &&
10349 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10350 csrRoamStateChange(pMac,
10351 eCSR_ROAMING_STATE_IDLE,
10352 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010353 }
10354 else
10355 {
10356 smsLog(pMac, LOGE, FL("Inactive session %d"),
10357 pDisConDoneInd->sessionId);
10358 }
10359 break;
10360
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010362 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010363
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10365 //Update with the new channel id.
10366 //The channel id is hidden in the statusCode.
10367 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10368 if( HAL_STATUS_SUCCESS( status ) )
10369 {
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010370 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010371 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010372 if(!pSession)
10373 {
10374 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10375 return;
10376 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10378 if(pSession->pConnectBssDesc)
10379 {
10380 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10381 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +053010382 pRoamInfo->chan_info.chan_id =
10383 (tANI_U8)pSwitchChnInd->newChannelId;
10384 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10385 eCSR_ROAM_STA_CHANNEL_SWITCH,
10386 eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 }
10388 break;
10389
10390 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010391 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 {
10393 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10394 sessionId = pDeauthRsp->sessionId;
10395 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10396 {
10397 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10399 {
10400 pRoamInfo = &roamInfo;
10401 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010402 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10403 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10405 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10406 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10407 }
10408 }
10409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 break;
10411
10412 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010413 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010414 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 {
10416 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10417 sessionId = pDisassocRsp->sessionId;
10418 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10419 {
10420 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010421 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10422 {
10423 pRoamInfo = &roamInfo;
10424 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010425 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10426 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10428 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10429 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10430 }
10431 }
10432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010433 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010434 case eWNI_SME_LOST_LINK_PARAMS_IND:
10435 {
10436 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10437 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10438 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10439 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10440 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10441 pRoamInfo = &roamInfo;
10442 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10443 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10444 break;
10445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010446 case eWNI_SME_MIC_FAILURE_IND:
10447 {
10448 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10449 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10450 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010451
10452 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10453 if( HAL_STATUS_SUCCESS( status ) )
10454 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010455 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010456 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10457 pRoamInfo = &roamInfo;
10458 if(pMicInd->info.multicast)
10459 {
10460 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10461 }
10462 else
10463 {
10464 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10465 }
10466 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10467 }
10468
Jeff Johnson295189b2012-06-20 16:38:30 -070010469#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10470 {
lukez3c809222013-05-03 10:23:02 -070010471 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010473 if(!pSession)
10474 {
10475 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10476 return;
10477 }
lukez3c809222013-05-03 10:23:02 -070010478
Kiet Lam64c1b492013-07-12 13:56:44 +053010479 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10481 secEvent.encryptionModeMulticast =
10482 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10483 secEvent.encryptionModeUnicast =
10484 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10485 secEvent.authMode =
10486 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010487 vos_mem_copy(secEvent.bssid,
10488 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10490 }
10491#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010492 }
10493 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10495 {
10496 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10497 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010498 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010499
10500 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10501 if( HAL_STATUS_SUCCESS( status ) )
10502 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010503 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10505 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10506 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10507 }
10508 }
10509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010510
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10512 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10513 switch( pStatusChangeMsg->statusChangeCode )
10514 {
10515 case eSIR_SME_IBSS_ACTIVE:
10516 sessionId = csrFindIbssSession( pMac );
10517 if( CSR_SESSION_ID_INVALID != sessionId )
10518 {
10519 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010520 if(!pSession)
10521 {
10522 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10523 return;
10524 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10526 if(pSession->pConnectBssDesc)
10527 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010528 vos_mem_copy(&roamInfo.bssid,
10529 pSession->pConnectBssDesc->bssId,
10530 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10532 pRoamInfo = &roamInfo;
10533 }
10534 else
10535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010536 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010537 }
10538 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10539 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10540 }
10541 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 case eSIR_SME_IBSS_INACTIVE:
10543 sessionId = csrFindIbssSession( pMac );
10544 if( CSR_SESSION_ID_INVALID != sessionId )
10545 {
10546 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010547 if(!pSession)
10548 {
10549 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10550 return;
10551 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10553 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10554 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10555 }
10556 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10558 sessionId = csrFindIbssSession( pMac );
10559 if( CSR_SESSION_ID_INVALID != sessionId )
10560 {
10561 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010562 if(!pSession)
10563 {
10564 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10565 return;
10566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 // update the connection state information
10568 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010569#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10570 {
10571 vos_log_ibss_pkt_type *pIbssLog;
10572 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10574 if(pIbssLog)
10575 {
10576 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10577 if(pNewBss)
10578 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010579 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Yeshwanth Sriram Guntuka7231db02018-08-10 15:18:21 +053010580 if(pNewBss->ssId.length >
10581 VOS_LOG_MAX_SSID_SIZE)
10582 pNewBss->ssId.length =
10583 VOS_LOG_MAX_SSID_SIZE;
10584
10585 vos_mem_copy(pIbssLog->ssid,
10586 pNewBss->ssId.ssId,
10587 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 pIbssLog->operatingChannel = pNewBss->channelNumber;
10589 }
10590 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10591 {
10592 //***U8 is not enough for beacon interval
10593 pIbssLog->beaconInterval = (v_U8_t)bi;
10594 }
10595 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10596 }
10597 }
10598#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010600
10601 if ((eCSR_ENCRYPT_TYPE_NONE ==
10602 pSession->connectedProfile.EncryptionType ))
10603 {
10604 csrRoamIssueSetContextReq( pMac, sessionId,
10605 pSession->connectedProfile.EncryptionType,
10606 pSession->pConnectBssDesc,
10607 &Broadcastaddr,
10608 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10611 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010612 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10613 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 pRoamInfo = &roamInfo;
10615 //This BSSID is th ereal BSSID, let's save it
10616 if(pSession->pConnectBssDesc)
10617 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010618 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10619 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010622 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 // detection by LIM that the capabilities of the associated AP have changed.
10625 case eSIR_SME_AP_CAPS_CHANGED:
10626 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010627 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10629 if( HAL_STATUS_SUCCESS( status ) )
10630 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010631 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10632 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010633 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010634 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10635 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10636 )
10637 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010638 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10639 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010640 }
10641 else
10642 {
10643 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010644 FL("Skipping csrScanForCapabilityChange as "
10645 "CSR is in state %s and sub-state %s"),
10646 macTraceGetcsrRoamState(
10647 pMac->roam.curState[sessionId]),
10648 macTraceGetcsrRoamSubState(
10649 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010650 /* We ignore the caps change event if CSR is not in full connected state.
10651 * Send one event to PE to reset limSentCapsChangeNtf
10652 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10653 * otherwise lim cannot send any CAPS change events to SME */
10654 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 }
10657 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010658
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 default:
10660 roamStatus = eCSR_ROAM_FAILED;
10661 result = eCSR_ROAM_RESULT_NONE;
10662 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 } // end switch on statusChangeCode
10664 if(eCSR_ROAM_RESULT_NONE != result)
10665 {
10666 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10667 }
10668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010669 case eWNI_SME_IBSS_NEW_PEER_IND:
10670 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010671#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10672 {
10673 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10675 if(pIbssLog)
10676 {
10677 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010678 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10680 }
10681 }
10682#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010683 sessionId = csrFindIbssSession( pMac );
10684 if( CSR_SESSION_ID_INVALID != sessionId )
10685 {
10686 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010687
10688 if(!pSession)
10689 {
10690 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10691 return;
10692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10694 if(pSession->pConnectBssDesc)
10695 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010696 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10697 sizeof(tCsrBssid));
10698 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10699 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010700 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10701 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010702 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10703 - sizeof(tSmeIbssPeerInd)));
10704 if ( NULL == roamInfo.pbFrames )
10705 status = eHAL_STATUS_FAILURE;
10706 else
10707 status = eHAL_STATUS_SUCCESS;
10708 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 {
10710 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010711 vos_mem_copy(roamInfo.pbFrames,
10712 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10713 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010714 }
10715 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10716 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10717 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010718 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10719 if ( NULL == roamInfo.pBssDesc )
10720 status = eHAL_STATUS_FAILURE;
10721 else
10722 status = eHAL_STATUS_SUCCESS;
10723 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010724 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010725 vos_mem_copy(roamInfo.pBssDesc,
10726 pSession->pConnectBssDesc,
10727 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010728 }
10729 if(HAL_STATUS_SUCCESS(status))
10730 {
10731 pRoamInfo = &roamInfo;
10732 }
10733 else
10734 {
10735 if(roamInfo.pbFrames)
10736 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010737 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010738 }
10739 if(roamInfo.pBssDesc)
10740 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010741 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 }
10743 }
10744 }
10745 else
10746 {
10747 pRoamInfo = &roamInfo;
10748 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010749 if ((eCSR_ENCRYPT_TYPE_NONE ==
10750 pSession->connectedProfile.EncryptionType ))
10751 {
10752 csrRoamIssueSetContextReq( pMac, sessionId,
10753 pSession->connectedProfile.EncryptionType,
10754 pSession->pConnectBssDesc,
10755 &(pIbssPeerInd->peerAddr),
10756 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 }
10759 else
10760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010761 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 }
10763 //send up the sec type for the new peer
10764 if (pRoamInfo)
10765 {
10766 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10767 }
10768 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10769 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10770 if(pRoamInfo)
10771 {
10772 if(roamInfo.pbFrames)
10773 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010774 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 }
10776 if(roamInfo.pBssDesc)
10777 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010778 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 }
10780 }
10781 }
10782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010783 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10784 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10785 sessionId = csrFindIbssSession( pMac );
10786 if( CSR_SESSION_ID_INVALID != sessionId )
10787 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010788#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10789 {
10790 vos_log_ibss_pkt_type *pIbssLog;
10791
10792 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10793 if(pIbssLog)
10794 {
10795 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10796 if(pIbssPeerInd)
10797 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010798 vos_mem_copy(pIbssLog->peerMacAddr,
10799 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 }
10801 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10802 }
10803 }
10804#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010805 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010806 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10807 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10808 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010809 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10810 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010811 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10812 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10813 }
10814 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 case eWNI_SME_SETCONTEXT_RSP:
10816 {
10817 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10818 tListElem *pEntry;
10819 tSmeCmd *pCommand;
10820
10821 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10822 if ( pEntry )
10823 {
10824 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10825 if ( eSmeCommandSetKey == pCommand->command )
10826 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010827 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010829
10830 if(!pSession)
10831 {
10832 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10833 return;
10834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010835
10836#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10837 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10838 {
10839 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010840 vos_mem_set(&setKeyEvent,
10841 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 if( pRsp->peerMacAddr[0] & 0x01 )
10843 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010844 setKeyEvent.eventId =
10845 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 }
10847 else
10848 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010849 setKeyEvent.eventId =
10850 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010852 if( pRsp->peerMacAddr[0] & 0x01 )
10853 {
Abhishek Singh2a04e9c2016-09-26 10:56:51 +053010854 pMac->pmc.full_power_till_set_key = false;
10855 smsLog(pMac, LOG1, FL("Reset full_power_till_set_key to allow BMPS"));
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 setKeyEvent.encryptionModeMulticast =
10858 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10859 setKeyEvent.encryptionModeUnicast =
10860 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010861 vos_mem_copy(setKeyEvent.bssid,
10862 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 setKeyEvent.authMode =
10864 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010865 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 {
10867 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10868 }
10869 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10870 }
10871#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10872 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10873 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010874 csrRoamStopWaitForKeyTimer( pMac );
10875
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 //We are done with authentication, whethere succeed or not
10877 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 //We do it here because this linkup function is not called after association
10879 //when a key needs to be set.
10880 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10881 {
10882 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10883 }
10884 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010885 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010886 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010887 vos_mem_copy(&roamInfo.peerMac,
10888 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010889 //Make sure we install the GTK before indicating to HDD as authenticated
10890 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010891 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10892 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010893 {
Yathish9f22e662012-12-10 14:21:35 -080010894#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10895 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10896 {
10897 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010898 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010899 if (NULL == pMsg)
10900 {
10901 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10902 return;
10903 }
10904
Yathish9f22e662012-12-10 14:21:35 -080010905 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010906 pMsg->length = pal_cpu_to_be16(sizeof(
10907 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010908 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010909 vos_mem_copy(pMsg->bssid,
10910 pSession->connectedProfile.bssid,
10911 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010912 status = palSendMBMessage(pMac->hHdd, pMsg );
10913 }
10914#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010915 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010916 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010917 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010918 && (pSession->connectState ==
10919 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10920 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010921 && (VOS_P2P_GO_MODE !=
10922 pSession->pCurRoamProfile->csrPersona
10923 && VOS_STA_SAP_MODE !=
10924 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010925 {
10926 tpSirSmeHT40OBSSScanInd pMsg;
10927 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
Nishank Aggarwal1543be72017-01-08 15:10:10 +053010928 if (NULL == pMsg)
10929 {
10930 smsLog(pMac, LOGE, FL("vos_mem_malloc failed"));
10931 return;
10932 }
10933
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010934 pMsg->messageType =
10935 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10936 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010937 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10938 vos_mem_copy(pMsg->peerMacAddr,
10939 pSession->connectedProfile.bssid,
10940 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010941 status = palSendMBMessage(pMac->hHdd,
10942 pMsg );
10943 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010944 else
10945 {
10946 smsLog( pMac, LOG1,FL("OBSS SCAN"
10947 "Indication not sent to FW"
10948 "channel %d OBSS_SCAN: %d"),
10949 pSession->connectedProfile.
10950 operationChannel,
10951 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10952 smsLog( pMac, LOG1,FL("connectState %d"
Jeff Johnson89477502017-09-19 08:35:23 -070010953 "pCurRoamProfile %pK"),
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010954 pSession->connectState,
10955 pSession->pCurRoamProfile);
10956 }
10957
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010958 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010959 }
10960 else
10961 {
10962 result = eCSR_ROAM_RESULT_NONE;
10963 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010964 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010965 }
10966 else
10967 {
10968 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010969 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10970 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10971 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010973 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010974 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10975 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10977 // can go ahead and initiate the TSPEC if any are pending
10978 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010979#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 //Send Adjacent AP repot to new AP.
10981 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10982 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010983 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010985#ifdef FEATURE_WLAN_ESE_UPLOAD
10986 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010987#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010988 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010989#endif
10990 pSession->isPrevApInfoValid = FALSE;
10991 }
10992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010993 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10994 {
10995 csrReleaseCommandSetKey( pMac, pCommand );
10996 }
10997 }
10998 else
10999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011000 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 }
11002 }
11003 else
11004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011005 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 smeProcessPendingQueue( pMac );
11008 }
11009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 case eWNI_SME_REMOVEKEY_RSP:
11011 {
11012 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
11013 tListElem *pEntry;
11014 tSmeCmd *pCommand;
11015
11016 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11017 if ( pEntry )
11018 {
11019 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11020 if ( eSmeCommandRemoveKey == pCommand->command )
11021 {
11022 sessionId = pCommand->sessionId;
11023 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011024
11025 if(!pSession)
11026 {
11027 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11028 return;
11029 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011030#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11031 {
11032 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011033 vos_mem_set(&removeKeyEvent,
11034 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
11036 removeKeyEvent.encryptionModeMulticast =
11037 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11038 removeKeyEvent.encryptionModeUnicast =
11039 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011040 vos_mem_copy( removeKeyEvent.bssid,
11041 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 removeKeyEvent.authMode =
11043 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070011044 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 {
11046 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
11047 }
11048 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
11049 }
11050#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070011051 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011053 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
11054 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 result = eCSR_ROAM_RESULT_NONE;
11056 pRoamInfo = &roamInfo;
11057 }
11058 else
11059 {
11060 result = eCSR_ROAM_RESULT_FAILURE;
11061 }
11062 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
11063 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
11064 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11065 {
11066 csrReleaseCommandRemoveKey( pMac, pCommand );
11067 }
11068 }
11069 else
11070 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011071 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011072 }
11073 }
11074 else
11075 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011076 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011078 smeProcessPendingQueue( pMac );
11079 }
11080 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011082 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 csrRoamStatsRspProcessor( pMac, pSirMsg );
11084 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011085#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011086 case eWNI_SME_GET_ROAM_RSSI_RSP:
11087 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
11088 csrRoamRssiRspProcessor( pMac, pSirMsg );
11089 break;
11090#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011091#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070011092 case eWNI_SME_GET_TSM_STATS_RSP:
11093 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
11094 csrTsmStatsRspProcessor( pMac, pSirMsg );
11095 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011096#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070011097 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011098 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 csrUpdateRssi( pMac, pSirMsg );
11100 break;
11101
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011102 case eWNI_SME_GET_SNR_REQ:
11103 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
11104 csrUpdateSnr(pMac, pSirMsg);
11105 break;
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107#ifdef WLAN_FEATURE_VOWIFI_11R
11108 case eWNI_SME_FT_PRE_AUTH_RSP:
11109 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
11110 break;
11111#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053011112#ifdef WLAN_FEATURE_LFR_MBB
11113 case eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP:
11114 csr_roam_preauth_rsp_mbb_processor(pMac,
11115 (tpSirFTPreAuthRsp)pSirMsg);
11116 break;
11117#endif
11118
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11120 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011121 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011122 sessionId = pSmeMaxAssocInd->sessionId;
11123 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011124 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
11125 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11127 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11128 break;
11129
11130 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011131 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011132#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 btampEstablishLogLinkHdlr( pSirMsg );
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053011134#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011135 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070011136 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011137 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011138 csrRoamRssiIndHdlr( pMac, pSirMsg );
11139 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011140#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
11141 case eWNI_SME_CANDIDATE_FOUND_IND:
11142 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
11143 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
11144 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070011145 case eWNI_SME_HANDOFF_REQ:
11146 smsLog( pMac, LOG2, FL("Handoff Req from self"));
11147 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
11148 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070011149#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011150
11151 default:
11152 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070011154}
11155
Jeff Johnson295189b2012-06-20 16:38:30 -070011156void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
11157 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
11158{
11159 if(pSession)
11160 {
11161 if(pSession->bRefAssocStartCnt)
11162 {
11163 pSession->bRefAssocStartCnt--;
11164 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
11165 //Need to call association_completion because there is an assoc_start pending.
11166 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
11167 eCSR_ROAM_ASSOCIATION_COMPLETION,
11168 eCSR_ROAM_RESULT_FAILURE);
11169 }
11170 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
11171 }
11172 else
11173 {
11174 smsLog(pMac, LOGW, FL(" pSession is NULL"));
11175 }
11176}
11177
11178
11179eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
11180{
11181 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011182 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11183 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
11184 {
11185 status = csrScanRequestLostLink1( pMac, sessionId );
11186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 return(status);
11188}
11189
Jeff Johnson295189b2012-06-20 16:38:30 -070011190//return a boolean to indicate whether roaming completed or continue.
11191tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
11192 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
11193{
11194 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
11195 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
11196 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11197 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011198 if(!pSession)
11199 {
11200 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11201 return eANI_BOOLEAN_FALSE;
11202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011203 //Check whether time is up
11204 if(pSession->fCancelRoaming || fForce ||
11205 ((curTime - pSession->roamingStartTime) > roamTime) ||
11206 eCsrReassocRoaming == pSession->roamingReason ||
11207 eCsrDynamicRoaming == pSession->roamingReason)
11208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011209 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
11211 {
11212 //roaming is cancelled, tell HDD to indicate disconnect
11213 //Because LIM overload deauth_ind for both deauth frame and missed beacon
11214 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
11215 //to be eSIR_BEACON_MISSED
11216 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
11217 {
11218 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11219 }
11220 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
11221 {
11222 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11223 }
11224 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
11225 {
11226 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11227 }
11228 else
11229 {
11230 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11231 }
11232 }
11233 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11234 pSession->roamingReason = eCsrNotRoaming;
11235 }
11236 else
11237 {
11238 pSession->roamResult = roamResult;
11239 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
11240 {
11241 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
11242 pSession->roamingReason = eCsrNotRoaming;
11243 }
11244 else
11245 {
11246 fCompleted = eANI_BOOLEAN_FALSE;
11247 }
11248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 return(fCompleted);
11250}
11251
Jeff Johnson295189b2012-06-20 16:38:30 -070011252void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
11253{
11254 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011255
11256 if(!pSession)
11257 {
11258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11259 return;
11260 }
11261
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 if(CSR_IS_ROAMING(pSession))
11263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011264 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
11266 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
11267 {
11268 //No need to do anything in here because the handler takes care of it
11269 }
11270 else
11271 {
11272 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11273 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11274 //Roaming is stopped after here
11275 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11276 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011277 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 csrRoamStopRoamingTimer(pMac, sessionId);
11279 }
11280 }
11281}
11282
Jeff Johnson295189b2012-06-20 16:38:30 -070011283void csrRoamRoamingTimerHandler(void *pv)
11284{
11285 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11286 tpAniSirGlobal pMac = pInfo->pMac;
11287 tANI_U32 sessionId = pInfo->sessionId;
11288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011289
11290 if(!pSession)
11291 {
11292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11293 return;
11294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011295
11296 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11297 {
11298 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11299 {
11300 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11301 pSession->roamingReason = eCsrNotRoaming;
11302 }
11303 }
11304}
11305
Jeff Johnson295189b2012-06-20 16:38:30 -070011306eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11307{
11308 eHalStatus status;
11309 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011310
11311 if(!pSession)
11312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011313 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011314 return eHAL_STATUS_FAILURE;
11315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011316
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011317 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011319 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011320
11321 return (status);
11322}
11323
Jeff Johnson295189b2012-06-20 16:38:30 -070011324eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11325{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011326 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011327}
11328
Jeff Johnson295189b2012-06-20 16:38:30 -070011329void csrRoamWaitForKeyTimeOutHandler(void *pv)
11330{
11331 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11332 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011333 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011334 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011335
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011336 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011337 macTraceGetNeighbourRoamState(
11338 pMac->roam.neighborRoamInfo.neighborRoamState),
11339 macTraceGetcsrRoamSubState(
11340 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011341
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011342 if (pSession)
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011344 vos_spin_lock_acquire(&pMac->roam.roam_state_lock);
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011345 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11346 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011347 //Change the substate so command queue is unblocked.
11348 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11349 pMac->roam.curSubState[pInfo->sessionId] =
11350 eCSR_ROAM_SUBSTATE_NONE;
11351 vos_spin_lock_release(&pMac->roam.roam_state_lock);
11352
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011353#ifdef FEATURE_WLAN_LFR
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011354 if (csrNeighborRoamIsHandoffInProgress(pMac))
11355 {
11356 /*
11357 * Enable heartbeat timer when hand-off is in progress
11358 * and Key Wait timer expired.
11359 */
11360 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
11361 " (nHBCount=%d)",
11362 pMac->roam.configParam.HeartbeatThresh24);
11363 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11364 pMac->roam.configParam.HeartbeatThresh24,
11365 NULL, eANI_BOOLEAN_FALSE);
11366 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011367#endif
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011368
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011369 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011370
Nishank Aggarwal760a2e42017-02-14 12:49:20 +053011371 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011372 {
11373 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11374 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011375 status = sme_AcquireGlobalLock(&pMac->sme);
11376 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011377 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011378 csrRoamDisconnect(pMac, pInfo->sessionId,
11379 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11380 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011381 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011382 }
11383 else
11384 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011385 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11386 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011387 }
11388 }
11389 else
11390 {
Padma, Santhosh Kumar9d35c462017-11-23 18:21:14 +053011391 vos_spin_lock_release(&pMac->roam.roam_state_lock);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011392 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 }
11395
11396}
11397
Jeff Johnson295189b2012-06-20 16:38:30 -070011398eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11399{
11400 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011401#ifdef FEATURE_WLAN_LFR
11402 if (csrNeighborRoamIsHandoffInProgress(pMac))
11403 {
11404 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011405 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11406 macTraceGetNeighbourRoamState(
11407 pMac->roam.neighborRoamInfo.neighborRoamState),
11408 macTraceGetcsrRoamSubState(
11409 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11410 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011411 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11412 }
11413#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011414 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011415 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011416
11417 return (status);
11418}
11419
Jeff Johnson295189b2012-06-20 16:38:30 -070011420eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11421{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011422 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11423 macTraceGetNeighbourRoamState(
11424 pMac->roam.neighborRoamInfo.neighborRoamState),
11425 macTraceGetcsrRoamSubState(
11426 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011427#ifdef FEATURE_WLAN_LFR
11428 if (csrNeighborRoamIsHandoffInProgress(pMac))
11429 {
11430 /*
11431 * Enable heartbeat timer when hand-off is in progress
11432 * and Key Wait timer got stopped for some reason
11433 */
11434 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011435 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011436 pMac->roam.configParam.HeartbeatThresh24);
11437 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11438 pMac->roam.configParam.HeartbeatThresh24,
11439 NULL, eANI_BOOLEAN_FALSE);
11440 }
11441#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011442 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011443}
11444
Jeff Johnson295189b2012-06-20 16:38:30 -070011445void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11446 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11447{
11448 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11449 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011450 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11451 /* To silence the KW tool Null chaeck is added */
11452 if(!pSession)
11453 {
11454 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11455 return;
11456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011457
11458 if(pCommand)
11459 {
11460 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11464 {
11465 //if success, force roaming completion
11466 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11467 }
11468 else
11469 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011470 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011471 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11473 }
11474}
11475
Jeff Johnson295189b2012-06-20 16:38:30 -070011476eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11477{
11478 eHalStatus status = eHAL_STATUS_SUCCESS;
11479 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11480 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11481 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 tCsrRoamInfo roamInfo;
11483 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011484 /* To silence the KW tool Null chaeck is added */
11485 if(!pSession)
11486 {
11487 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11488 return eHAL_STATUS_FAILURE;
11489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011491 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 if ( eWNI_SME_DISASSOC_IND == type )
11493 {
11494 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11495 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11496 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011497 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011498 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11499 sizeof(tSirMacAddr));
11500 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 }
11502 else if ( eWNI_SME_DEAUTH_IND == type )
11503 {
11504 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11505 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11506 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011507 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011508 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11509 sizeof(tSirMacAddr));
11510 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 }
11512 else
11513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011514 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011516 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053011518 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11519 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11520 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
11521
11522 if (type == eWNI_SME_DEAUTH_IND || type == eWNI_SME_DISASSOC_IND) {
11523 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
11524 eCSR_ROAM_LOSTLINK_DETECTED, result);
11525 } else if(!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11526 csrRoamCallCallback(pMac, sessionId, NULL, 0,
11527 eCSR_ROAM_LOSTLINK_DETECTED, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 }
11529
11530 if ( eWNI_SME_DISASSOC_IND == type )
11531 {
11532 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11533 }
11534 else if ( eWNI_SME_DEAUTH_IND == type )
11535 {
11536 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011538
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011539 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11540 {
Jingxiang Ge6298d0a2018-10-18 16:12:54 +080011541 //remove the connected BSS in infrastructure mode
11542 csrRoamRemoveConnectedBssFromScanCache(pMac,
11543 &pSession->connectedProfile);
11544
Yeshwanth Sriram Guntuka21ad1182018-07-30 12:22:30 +053011545 csrScanStartIdleScan(pMac);
11546 }
11547
Jeff Johnson295189b2012-06-20 16:38:30 -070011548 return (status);
11549}
11550
Jeff Johnson295189b2012-06-20 16:38:30 -070011551eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11552{
11553 eHalStatus status = eHAL_STATUS_SUCCESS;
11554 tListElem *pEntry = NULL;
11555 tSmeCmd *pCommand = NULL;
11556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011557
11558 if(!pSession)
11559 {
11560 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11561 return eHAL_STATUS_FAILURE;
11562 }
11563
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 //Only remove the connected BSS in infrastructure mode
11566 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11567 if(pMac->roam.configParam.nRoamingTime)
11568 {
11569 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11570 {
11571 //before starting the lost link logic release the roam command for handoff
11572 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11573 if(pEntry)
11574 {
11575 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11576 }
11577 if(pCommand)
11578 {
11579 if (( eSmeCommandRoam == pCommand->command ) &&
11580 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11581 {
11582 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11583 {
11584 csrReleaseCommandRoam( pMac, pCommand );
11585 }
11586 }
11587 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011588 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 }
11590 }
11591 else
11592 {
11593 //We are told not to roam, indicate lostlink
11594 status = eHAL_STATUS_FAILURE;
11595 }
11596
11597 return (status);
11598}
Jeff Johnson295189b2012-06-20 16:38:30 -070011599void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11600{
11601 tListElem *pEntry;
11602 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11604 if ( pEntry )
11605 {
11606 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11607 if ( eSmeCommandWmStatusChange == pCommand->command )
11608 {
11609 // Nothing to process in a Lost Link completion.... It just kicks off a
11610 // roaming sequence.
11611 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11612 {
11613 csrReleaseCommandWmStatusChange( pMac, pCommand );
11614 }
11615 else
11616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011617 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 }
11619
11620 }
11621 else
11622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011623 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 }
11625 }
11626 else
11627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011628 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 smeProcessPendingQueue( pMac );
11631}
11632
Jeff Johnson295189b2012-06-20 16:38:30 -070011633void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11634{
11635 eHalStatus status = eHAL_STATUS_FAILURE;
11636 tSirSmeRsp *pSirSmeMsg;
11637 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011638
11639 if(!pSession)
11640 {
11641 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11642 return;
11643 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011644 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11645 pCommand->sessionId,
11646 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011647 switch ( pCommand->u.wmStatusChangeCmd.Type )
11648 {
11649 case eCsrDisassociated:
11650 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11651 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011653 case eCsrDeauthenticated:
11654 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11655 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011658 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011659 break;
11660 }
11661 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11662 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11663 {
11664 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11665 {
11666 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011667 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 }
11669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11671 // command here since there is nothing else to do.
11672 csrRoamWmStatusChangeComplete( pMac );
11673}
11674
Jeff Johnson295189b2012-06-20 16:38:30 -070011675//This function returns band and mode information.
11676//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11677//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011678static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11679 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011680{
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11682 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11683 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011685
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 //If the global setting for dot11Mode is set to auto/abg, we overwrite the setting in the profile.
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11688 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11689 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11690 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011691 {
11692 switch( pMac->roam.configParam.uCfgDot11Mode )
11693 {
11694 case eCSR_CFG_DOT11_MODE_11A:
11695 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11696 eBand = eCSR_BAND_5G;
11697 break;
11698 case eCSR_CFG_DOT11_MODE_11B:
11699 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11700 eBand = eCSR_BAND_24;
11701 break;
11702 case eCSR_CFG_DOT11_MODE_11G:
11703 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11704 eBand = eCSR_BAND_24;
11705 break;
11706 case eCSR_CFG_DOT11_MODE_11N:
11707 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011708 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11709 break;
11710#ifdef WLAN_FEATURE_11AC
11711 case eCSR_CFG_DOT11_MODE_11AC:
11712 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11713 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011714 /* If the operating channel is in 2.4 GHz band, check for
11715 * INI item to disable VHT operation in 2.4 GHz band
11716 */
11717 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11718 !pMac->roam.configParam.enableVhtFor24GHz)
11719 {
11720 /* Disable 11AC operation */
11721 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11722 }
11723 else
11724 {
11725 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11726 }
11727 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011728 }
11729 else
11730 {
11731 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11732 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11733 }
11734 break;
11735 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11736 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11737 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011738 /* If the operating channel is in 2.4 GHz band, check for
11739 * INI item to disable VHT operation in 2.4 GHz band
11740 */
11741 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11742 !pMac->roam.configParam.enableVhtFor24GHz)
11743 {
11744 /* Disable 11AC operation */
11745 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11746 }
11747 else
11748 {
11749 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11750 }
11751 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011752 }
11753 else
11754 {
11755 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11756 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11757 }
11758 break;
11759#endif
11760 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011761#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011762 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11763 {
11764 /* If the operating channel is in 2.4 GHz band, check for
11765 * INI item to disable VHT operation in 2.4 GHz band
11766 */
11767 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11768 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011769 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011770 /* Disable 11AC operation */
11771 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011772 }
11773 else
11774 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011775 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11776 }
11777 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11778 }
11779 else
11780 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011781 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11782 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011783 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011784#else
11785 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11786 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11787#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 default:
11790 // Global dot11 Mode setting is 11a/b/g.
11791 // use the channel number to determine the Mode setting.
11792 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11793 {
11794 eBand = pMac->roam.configParam.eBand;
11795 if(eCSR_BAND_24 == eBand)
11796 {
11797 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11798 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11799 }
11800 else
11801 {
11802 //prefer 5GHz
11803 eBand = eCSR_BAND_5G;
11804 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11805 }
11806 }
11807 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11808 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011809 // WiFi tests require IBSS networks to start in 11b mode
11810 // without any change to the default parameter settings
11811 // on the adapter. We use ACU to start an IBSS through
11812 // creation of a startIBSS profile. This startIBSS profile
11813 // has Auto MACProtocol and the adapter property setting
11814 // for dot11Mode is also AUTO. So in this case, let's
11815 // start the IBSS network in 11b mode instead of 11g mode.
11816 // So this is for Auto=profile->MacProtocol && Auto=Global.
11817 // dot11Mode && profile->channel is < 14, then start the IBSS
11818 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011820 // Note: we used to have this start as an 11g IBSS for best
11821 // performance... now to specify that the user will have to
11822 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11824 eBand = eCSR_BAND_24;
11825 }
11826 else
11827 {
11828 // else, it's a 5.0GHz channel. Set mode to 11a.
11829 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11830 eBand = eCSR_BAND_5G;
11831 }
11832 break;
11833 }//switch
11834 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11835 else
11836 {
11837 //dot11 mode is set, lets pick the band
11838 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11839 {
11840 // channel is Auto also.
11841 eBand = pMac->roam.configParam.eBand;
11842 if(eCSR_BAND_ALL == eBand)
11843 {
11844 //prefer 5GHz
11845 eBand = eCSR_BAND_5G;
11846 }
11847 }
11848 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11849 {
11850 eBand = eCSR_BAND_24;
11851 }
11852 else
11853 {
11854 eBand = eCSR_BAND_5G;
11855 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 if(pBand)
11858 {
11859 *pBand = eBand;
11860 }
11861
11862 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011863 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11865 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011866
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011867 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
Agrawal Ashisha8e8a722016-10-18 19:07:45 +053011868 if (
11869#ifdef SAP_AUTH_OFFLOAD
11870 (!pMac->sap_auth_offload && !pMac->sap_auth_offload_sec_type) &&
11871#endif
11872 ((!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) ||
11873 ((pProfile->privacy == 1) &&
11874 (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)))) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011875 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011876#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011877 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011878#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011879 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11880 {
11881 //We cannot do 11n here
11882 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11883 {
11884 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11885 }
11886 else
11887 {
11888 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11889 }
11890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011891 return( cfgDot11Mode );
11892}
11893
Jeff Johnson295189b2012-06-20 16:38:30 -070011894eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11895{
11896 eHalStatus status;
11897 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011898
11899 if(!pSession)
11900 {
11901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11902 return eHAL_STATUS_FAILURE;
11903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011904
11905#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11906 {
11907 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011908 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11909 if(pIbssLog)
11910 {
11911 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11912 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11913 }
11914 }
11915#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 // Set the roaming substate to 'stop Bss request'...
11917 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11918
11919 // attempt to stop the Bss (reason code is ignored...)
11920 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011921 if(!HAL_STATUS_SUCCESS(status))
11922 {
11923 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 return (status);
11926}
11927
Jeff Johnson295189b2012-06-20 16:38:30 -070011928//pNumChan is a caller allocated space with the sizeof pChannels
11929eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11930{
11931
11932 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11933 (tANI_U8 *)pChannels,
11934 pNumChan));
11935}
11936
Kiran4a17ebe2013-01-31 10:43:43 -080011937tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11938{
11939 tANI_U32 cfgLength = 0;
11940 tANI_U16 cfgId = 0;
11941 tPowerdBm maxTxPwr = 0;
11942 tANI_U8 *pCountryInfo = NULL;
11943 eHalStatus status;
11944 tANI_U8 count = 0;
11945 tANI_U8 firstChannel;
11946 tANI_U8 maxChannels;
11947
11948 if (CSR_IS_CHANNEL_5GHZ(channel))
11949 {
11950 cfgId = WNI_CFG_MAX_TX_POWER_5;
11951 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11952 }
11953 else if (CSR_IS_CHANNEL_24GHZ(channel))
11954 {
11955 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11956 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11957 }
11958 else
11959 return maxTxPwr;
11960
Kiet Lam64c1b492013-07-12 13:56:44 +053011961 pCountryInfo = vos_mem_malloc(cfgLength);
11962 if ( NULL == pCountryInfo )
11963 status = eHAL_STATUS_FAILURE;
11964 else
11965 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011966 if (status != eHAL_STATUS_SUCCESS)
11967 {
11968 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011969 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011970 __FUNCTION__, status);
11971 goto error;
11972 }
11973 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11974 if (status != eHAL_STATUS_SUCCESS)
11975 {
11976 goto error;
11977 }
11978 /* Identify the channel and maxtxpower */
11979 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11980 {
11981 firstChannel = pCountryInfo[count++];
11982 maxChannels = pCountryInfo[count++];
11983 maxTxPwr = pCountryInfo[count++];
11984
11985 if ((channel >= firstChannel) &&
11986 (channel < (firstChannel + maxChannels)))
11987 {
11988 break;
11989 }
11990 }
11991
11992error:
11993 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011994 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011995
11996 return maxTxPwr;
11997}
11998
11999
Jeff Johnson295189b2012-06-20 16:38:30 -070012000tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
12001{
12002 tANI_BOOLEAN fValid = FALSE;
12003 tANI_U32 idxValidChannels;
12004 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12005
12006 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
12007 {
12008 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
12009 {
12010 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
12011 {
12012 fValid = TRUE;
12013 break;
12014 }
12015 }
12016 }
12017 pMac->roam.numValidChannels = len;
12018 return fValid;
12019}
12020
Jeff Johnson295189b2012-06-20 16:38:30 -070012021tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
12022{
12023 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
12024 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
12026 {
12027 if(channel == pMac->scan.base40MHzChannels.channelList[i])
12028 {
12029 fValid = eANI_BOOLEAN_TRUE;
12030 break;
12031 }
12032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 return (fValid);
12034}
12035
Jeff Johnson295189b2012-06-20 16:38:30 -070012036//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070012037 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012038{
Jeff Johnsone7245742012-09-05 17:12:55 -070012039 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 tANI_U8 centerChn;
12041 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053012042
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
12044 {
12045 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
12046 }
12047 else
12048 {
12049 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
12050 }
12051 //Figure what the other side's CB mode
12052 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
12053 {
12054 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
12055 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053012056 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
12057 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
12058 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
12059 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012060 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
12061 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053012062 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053012063 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053012064
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080012065 {
12066 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
12067 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12068 }
12069
12070 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 {
Jeff Johnsone7245742012-09-05 17:12:55 -070012072 /* This is called during INFRA STA/CLIENT and should use the merged value of
12073 * supported channel width and recommended tx width as per standard
12074 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012075 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070012076 pIes->HTCaps.supportedChannelWidthSet,
12077 pIes->HTInfo.recommendedTxWidthSet,
12078 pIes->HTInfo.secondaryChannelOffset);
12079
12080 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12081 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 else
Jeff Johnsone7245742012-09-05 17:12:55 -070012083 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12084 switch (eRet) {
12085 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12086 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12087 break;
12088 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12089 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12090 break;
12091 case PHY_SINGLE_CHANNEL_CENTERED:
12092 default:
12093 centerChn = primaryChn;
12094 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012095 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012096 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012098 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053012099 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053012101 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
12102 {
12103 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
12104 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 }
12107 }
12108 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 return eRet;
12110}
Jeff Johnson295189b2012-06-20 16:38:30 -070012111tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
12112{
12113 tANI_BOOLEAN fFound = FALSE;
12114 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 for( idx = 0; idx < pCipherList->numEntries; idx++ )
12116 {
12117 if( pCipherList->encryptionType[idx] == encryptionType )
12118 {
12119 fFound = TRUE;
12120 break;
12121 }
12122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 return fFound;
12124}
Jeff Johnson295189b2012-06-20 16:38:30 -070012125tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
12126{
12127 tANI_BOOLEAN fFound = FALSE;
12128 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012129 for( idx = 0; idx < pAuthList->numEntries; idx++ )
12130 {
12131 if( pAuthList->authType[idx] == authType )
12132 {
12133 fFound = TRUE;
12134 break;
12135 }
12136 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012137 return fFound;
12138}
Jeff Johnson295189b2012-06-20 16:38:30 -070012139tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
12140{
12141 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12142 tCsrScanResultFilter *pScanFilter = NULL;
12143 eHalStatus status = eHAL_STATUS_SUCCESS;
12144
12145 if(pProfile1 && pProfile2)
12146 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012147 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12148 if ( NULL == pScanFilter )
12149 status = eHAL_STATUS_FAILURE;
12150 else
12151 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 if(HAL_STATUS_SUCCESS(status))
12153 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012154 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
12156 if(HAL_STATUS_SUCCESS(status))
12157 {
12158 fCheck = eANI_BOOLEAN_FALSE;
12159 do
12160 {
12161 tANI_U32 i;
12162 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
12163 {
12164 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12165 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12166 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
12167 if ( fCheck ) break;
12168 }
12169 if(!fCheck)
12170 {
12171 break;
12172 }
12173 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
12174 || pProfile2->BSSType != pProfile1->BSSType
12175 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
12176 )
12177 {
12178 fCheck = eANI_BOOLEAN_FALSE;
12179 break;
12180 }
12181#ifdef WLAN_FEATURE_VOWIFI_11R
12182 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
12183 {
12184 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
12185 {
12186 fCheck = eANI_BOOLEAN_FALSE;
12187 break;
12188 }
12189 }
12190#endif
12191 //Match found
12192 fCheck = eANI_BOOLEAN_TRUE;
12193 }while(0);
12194 csrFreeScanFilter(pMac, pScanFilter);
12195 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012196 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012197 }
12198 }
12199
12200 return (fCheck);
12201}
12202
Jeff Johnson295189b2012-06-20 16:38:30 -070012203tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
12204{
12205 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
12206 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 do
12208 {
12209 //Only check for static WEP
12210 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
12211 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
12212 {
12213 fCheck = eANI_BOOLEAN_TRUE;
12214 break;
12215 }
12216 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
12217 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
12218 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12219 {
12220 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012221 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12222 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 {
12224 break;
12225 }
12226 }
12227 if( i == CSR_MAX_NUM_KEY)
12228 {
12229 fCheck = eANI_BOOLEAN_TRUE;
12230 }
12231 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 return (fCheck);
12233}
12234
Jeff Johnson295189b2012-06-20 16:38:30 -070012235//IBSS
12236
Jeff Johnson295189b2012-06-20 16:38:30 -070012237tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12238{
12239 tANI_U8 channel = 0;
12240 tANI_U32 idx;
12241 tANI_U32 idxValidChannels;
12242 tANI_BOOLEAN fFound = FALSE;
12243 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12244
12245 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12246 {
12247 channel = pMac->roam.configParam.AdHocChannel5G;
12248 if(!csrRoamIsChannelValid(pMac, channel))
12249 {
12250 channel = 0;
12251 }
12252 }
12253 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12254 {
12255 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12256 {
12257 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12258 {
12259 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12260 {
12261 fFound = TRUE;
12262 channel = csrStartIbssChannels50[ idx ];
12263 }
12264 }
12265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012266 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12267 if (!fFound)
12268 {
12269 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12270 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012271 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012273 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 break;
12275 }
12276 }
12277 }
12278 }//if
12279
12280 return( channel );
12281}
12282
Jeff Johnson295189b2012-06-20 16:38:30 -070012283tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12284{
12285 tANI_U8 channel = 1;
12286 tANI_U32 idx;
12287 tANI_U32 idxValidChannels;
12288 tANI_BOOLEAN fFound = FALSE;
12289 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12290
12291 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12292 {
12293 channel = pMac->roam.configParam.AdHocChannel24;
12294 if(!csrRoamIsChannelValid(pMac, channel))
12295 {
12296 channel = 0;
12297 }
12298 }
12299
12300 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12301 {
12302 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12303 {
12304 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12305 {
12306 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12307 {
12308 fFound = TRUE;
12309 channel = csrStartIbssChannels24[ idx ];
12310 }
12311 }
12312 }
12313 }
12314
12315 return( channel );
12316}
12317
Jeff Johnson295189b2012-06-20 16:38:30 -070012318static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12319 tCsrRoamStartBssParams *pParam )
12320{
12321 eCsrCfgDot11Mode cfgDot11Mode;
12322 eCsrBand eBand;
12323 tANI_U8 channel = 0;
12324 tSirNwType nwType;
12325 tANI_U8 operationChannel = 0;
12326
12327 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12328 {
12329 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12330 }
12331
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012333
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12335 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12336 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12337 )
12338 {
12339 /* This should never happen */
12340 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012341 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 pProfile->csrPersona);
12343 VOS_ASSERT(0);
12344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 switch( cfgDot11Mode )
12346 {
12347 case eCSR_CFG_DOT11_MODE_11G:
12348 nwType = eSIR_11G_NW_TYPE;
12349 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 case eCSR_CFG_DOT11_MODE_11B:
12351 nwType = eSIR_11B_NW_TYPE;
12352 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 case eCSR_CFG_DOT11_MODE_11A:
12354 nwType = eSIR_11A_NW_TYPE;
12355 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012356 default:
12357 case eCSR_CFG_DOT11_MODE_11N:
12358 case eCSR_CFG_DOT11_MODE_TAURUS:
12359 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12360 if(eCSR_BAND_24 == eBand)
12361 {
12362 nwType = eSIR_11G_NW_TYPE;
12363 }
12364 else
12365 {
12366 nwType = eSIR_11A_NW_TYPE;
12367 }
12368 break;
12369 }
12370
12371 pParam->extendedRateSet.numRates = 0;
12372
12373 switch ( nwType )
12374 {
12375 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012376 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 case eSIR_11A_NW_TYPE:
12378
12379 pParam->operationalRateSet.numRates = 8;
12380
12381 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12382 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12383 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12384 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12385 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12386 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12387 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12388 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12389
12390 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12391 {
12392 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12393 if( 0 == channel &&
12394 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12395 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12396 )
12397 {
12398 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12399 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12400 nwType = eSIR_11B_NW_TYPE;
12401 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12402 pParam->operationalRateSet.numRates = 4;
12403 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12404 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12405 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12406 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12407 }
12408 }
12409 else
12410 {
12411 channel = operationChannel;
12412 }
12413 break;
12414
12415 case eSIR_11B_NW_TYPE:
12416 pParam->operationalRateSet.numRates = 4;
12417 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12418 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12419 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12420 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12422 {
12423 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12424 }
12425 else
12426 {
12427 channel = operationChannel;
12428 }
12429
12430 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 /* For P2P Client and P2P GO, disable 11b rates */
12433 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12434 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12435 )
12436 {
12437 pParam->operationalRateSet.numRates = 8;
12438
12439 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12440 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12441 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12442 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12443 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12444 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12445 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12446 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12447 }
12448 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 {
12450 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12452 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12453 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12454 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12455
12456 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12458 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12459 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12460 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12461 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12462 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12463 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12464 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12465 }
12466
12467 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12468 {
12469 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12470 }
12471 else
12472 {
12473 channel = operationChannel;
12474 }
12475
12476 break;
12477 }
12478 pParam->operationChn = channel;
12479 pParam->sirNwType = nwType;
12480}
12481
Jeff Johnson295189b2012-06-20 16:38:30 -070012482static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12483 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12484{
12485
12486 if( pParam )
12487 {
12488 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012489 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012491 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012492
12493 if( pIes )
12494 {
12495 if(pIes->SuppRates.present)
12496 {
12497 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12498 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012500 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 pIes->SuppRates.num_rates);
12502 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12503 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012504 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12505 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012507 if (pIes->ExtSuppRates.present)
12508 {
12509 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012510 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012511 {
12512 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12513 SIR_MAC_RATESET_EID_MAX, resetting to \
12514 SIR_MAC_RATESET_EID_MAX"),
12515 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012516 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012517 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012518 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012519 pIes->ExtSuppRates.rates,
12520 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 if( pIes->SSID.present )
12523 {
12524 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012525 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12526 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 }
12528 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 }
12530 else
12531 {
12532 pParam->ssId.length = 0;
12533 pParam->operationalRateSet.numRates = 0;
12534 }
12535 }
12536}
12537
Jeff Johnson295189b2012-06-20 16:38:30 -070012538static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12539{
12540 tANI_U8 MaxRate = 0;
12541 tANI_U32 i;
12542 tANI_U8 *pRate;
12543
12544 pRate = pSirRateSet->rate;
12545 for ( i = 0; i < pSirRateSet->numRates; i++ )
12546 {
12547 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12548 }
12549
12550 // Save the max rate in the connected state information...
12551
12552 // modify LastRates variable as well
12553
12554 return;
12555}
12556
Jeff Johnson295189b2012-06-20 16:38:30 -070012557eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12558 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12559{
12560 eHalStatus status = eHAL_STATUS_SUCCESS;
12561 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 // Set the roaming substate to 'Start BSS attempt'...
12563 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012564#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12565 //Need to figure out whether we need to log WDS???
12566 if( CSR_IS_IBSS( pProfile ) )
12567 {
12568 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12570 if(pIbssLog)
12571 {
12572 if(pBssDesc)
12573 {
12574 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012575 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 }
12577 else
12578 {
12579 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12580 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012581 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 if(pProfile->ChannelInfo.numOfChannels == 0)
12583 {
12584 pIbssLog->channelSetting = AUTO_PICK;
12585 }
12586 else
12587 {
12588 pIbssLog->channelSetting = SPECIFIED;
12589 }
12590 pIbssLog->operatingChannel = pParam->operationChn;
12591 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12592 }
12593 }
12594#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12595 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012596 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12597 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012598
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 pParam->privacy = pProfile->privacy;
12600 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12601 pParam->authType = pProfile->csr80211AuthType;
12602 pParam->beaconInterval = pProfile->beaconInterval;
12603 pParam->dtimPeriod = pProfile->dtimPeriod;
12604 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12605 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12606 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12607 {
12608 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12609 {
12610 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12611 }
12612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 pParam->protEnabled = pProfile->protEnabled;
12614 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12615 pParam->ht_protection = pProfile->cfg_protection;
12616 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012617
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12619 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012621
12622#ifdef WLAN_FEATURE_11W
12623 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12624 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12625#endif
12626
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 // When starting an IBSS, start on the channel from the Profile.
12628 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012629 return (status);
12630}
12631
Jeff Johnson295189b2012-06-20 16:38:30 -070012632static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012633 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012634{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012635 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012636 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012638
12639 if(!pSession)
12640 {
12641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12642 return;
12643 }
12644
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 if( pBssDesc )
12646 {
12647 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12648 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12649 //The following code has to be do after that.
12650 //For WDS station, use selfMac as the self BSSID
12651 if( CSR_IS_WDS_STA( pProfile ) )
12652 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012653 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12654 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 }
12656 }
12657 else
12658 {
12659 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 //Use the first SSID
12661 if(pProfile->SSIDs.numOfSSIDs)
12662 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012663 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12664 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 }
12666 //For WDS station, use selfMac as the self BSSID
12667 if( CSR_IS_WDS_STA( pProfile ) )
12668 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012669 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12670 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 }
12672 //Use the first BSSID
12673 else if( pProfile->BSSIDs.numOfBSSIDs )
12674 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012675 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12676 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 }
12678 else
12679 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012680 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 }
12682 }
12683 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 //Set operating channel in pProfile which will be used
12685 //in csrRoamSetBssConfigCfg() to determine channel bonding
12686 //mode and will be configured in CFG later
12687 pProfile->operationChannel = Channel;
12688
12689 if(Channel == 0)
12690 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012691 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012692 }
12693 else
12694 {
12695
12696 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012697 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012698 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012699 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012700 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012701#ifdef WLAN_FEATURE_AP_HT40_24G
12702 if (CSR_IS_INFRA_AP(pProfile))
12703 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12704 else
12705 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12706#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012707 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012708#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012709 }
12710 else
12711 {
12712 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12713 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012714 pBssConfig->cbMode = cbMode;
12715 pSession->bssParams.cbMode = cbMode;
Abhishek Singh02b823e2017-10-30 17:53:20 +053012716 if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
12717 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
12718 else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
12719 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
12720 else
12721 pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
12722 smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
12723 pSession->bssParams.orig_ch_width);
Jeff Johnsone7245742012-09-05 17:12:55 -070012724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 }
12726}
12727
Jeff Johnson295189b2012-06-20 16:38:30 -070012728static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12729 tANI_BOOLEAN *pfSameIbss )
12730{
12731 eHalStatus status = eHAL_STATUS_SUCCESS;
12732 tANI_BOOLEAN fSameIbss = FALSE;
12733
12734 if ( csrIsConnStateIbss( pMac, sessionId ) )
12735 {
12736 // Check if any profile parameter has changed ? If any profile parameter
12737 // has changed then stop old BSS and start a new one with new parameters
12738 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12739 {
12740 fSameIbss = TRUE;
12741 }
12742 else
12743 {
12744 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12745 }
12746 }
12747 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12748 {
12749 // Disassociate from the connected Infrastructure network...
12750 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12751 }
12752 else
12753 {
12754 tBssConfigParam *pBssConfig;
12755
Kiet Lam64c1b492013-07-12 13:56:44 +053012756 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12757 if ( NULL == pBssConfig )
12758 status = eHAL_STATUS_FAILURE;
12759 else
12760 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 if(HAL_STATUS_SUCCESS(status))
12762 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012763 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 // there is no Bss description before we start an IBSS so we need to adopt
12765 // all Bss configuration parameters from the Profile.
12766 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12767 if(HAL_STATUS_SUCCESS(status))
12768 {
12769 //save dotMode
12770 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12771 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012772 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012773 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12774 NULL, pBssConfig,
12775 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012777
12778 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 }//Allocate memory
12780 }
12781
12782 if(pfSameIbss)
12783 {
12784 *pfSameIbss = fSameIbss;
12785 }
12786 return( status );
12787}
12788
Jeff Johnson295189b2012-06-20 16:38:30 -070012789static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12790 tSirSmeNewBssInfo *pNewBss )
12791{
12792 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012793
12794 if(!pSession)
12795 {
12796 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12797 return;
12798 }
12799
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 if( pNewBss )
12801 {
12802 // Set the operating channel.
12803 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12804 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012805 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12806 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 return;
12809}
12810
Jeff Johnson295189b2012-06-20 16:38:30 -070012811#ifdef FEATURE_WLAN_WAPI
12812eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12813 tANI_U32 numItems )
12814{
12815 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012816 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012819 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 return status;
12821 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012822 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 pSession = CSR_GET_SESSION( pMac, sessionId );
12824 if(numItems <= CSR_MAX_BKID_ALLOWED)
12825 {
12826 status = eHAL_STATUS_SUCCESS;
12827 //numItems may be 0 to clear the cache
12828 pSession->NumBkidCache = (tANI_U16)numItems;
12829 if(numItems && pBKIDCache)
12830 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012831 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12832 sizeof(tBkidCacheInfo) * numItems);
12833 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 }
12835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 return (status);
12837}
Jeff Johnson295189b2012-06-20 16:38:30 -070012838eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12839 tBkidCacheInfo *pBkidCache)
12840{
12841 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012842 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012845 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 return status;
12847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 pSession = CSR_GET_SESSION( pMac, sessionId );
12849 if(pNum && pBkidCache)
12850 {
12851 if(pSession->NumBkidCache == 0)
12852 {
12853 *pNum = 0;
12854 status = eHAL_STATUS_SUCCESS;
12855 }
12856 else if(*pNum >= pSession->NumBkidCache)
12857 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012858 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012860 smsLog(pMac, LOGE, FL("NumBkidCache :%d is more than CSR_MAX_BKID_ALLOWED, resetting to CSR_MAX_BKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012862 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012864 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12865 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 *pNum = pSession->NumBkidCache;
12867 status = eHAL_STATUS_SUCCESS;
12868 }
12869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871}
Jeff Johnson295189b2012-06-20 16:38:30 -070012872tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12873{
12874 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012875}
12876#endif /* FEATURE_WLAN_WAPI */
Abhinav Kumar8c122592019-08-07 15:43:20 +053012877
12878static void csr_update_pmk_cache(tCsrRoamSession *pSession,
12879 tPmkidCacheInfo *pmksa)
12880{
12881 uint16_t cache_idx = pSession->CurCacheIndex;
12882
12883 /* Add entry to the cache */
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053012884 pSession->PmkidCacheInfo[cache_idx].ssid_len = 0;
Abhinav Kumar8c122592019-08-07 15:43:20 +053012885 if (!pmksa->ssid_len) {
Abhinav Kumar8c122592019-08-07 15:43:20 +053012886 vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].ssid,
12887 pmksa->ssid, pmksa->ssid_len);
12888 pSession->PmkidCacheInfo[cache_idx].ssid_len =
12889 pmksa->ssid_len;
Abhinav Kumar8c122592019-08-07 15:43:20 +053012890 }
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053012891
12892 vos_copy_macaddr(
12893 (v_MACADDR_t *)pSession->PmkidCacheInfo[cache_idx].BSSID,
12894 (v_MACADDR_t *)pmksa->BSSID);
12895 vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].cache_id,
12896 pmksa->cache_id, CACHE_ID_LEN);
12897
Abhinav Kumar8c122592019-08-07 15:43:20 +053012898 vos_mem_copy(
12899 pSession->PmkidCacheInfo[cache_idx].PMKID,
12900 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12901
12902 if (pmksa->pmk_len)
12903 vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].pmk,
12904 pmksa->pmk, pmksa->pmk_len);
12905
12906 pSession->PmkidCacheInfo[cache_idx].pmk_len = pmksa->pmk_len;
12907
12908 /* Increment the CSR local cache index */
12909 if (cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
12910 pSession->CurCacheIndex++;
12911 else
12912 pSession->CurCacheIndex = 0;
12913
12914 pSession->NumPmkidCache++;
12915 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12916 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12917}
12918
Jeff Johnson295189b2012-06-20 16:38:30 -070012919eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012920 tPmkidCacheInfo *pPMKIDCache,
12921 tANI_U32 numItems,
12922 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012923{
12924 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12925 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012926
12927 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012928 {
12929 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12930 return eHAL_STATUS_FAILURE;
12931 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012932
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012933 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012934
12935 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 {
12937#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12938 {
12939 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012940 vos_mem_set(&secEvent,
12941 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12943 secEvent.encryptionModeMulticast =
12944 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12945 secEvent.encryptionModeUnicast =
12946 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012947 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 secEvent.authMode =
12949 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12950 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12951 }
12952#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012954 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012955 if (numItems && pPMKIDCache)
12956 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012957 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012958 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12959 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012960 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012961 }
12962 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012963 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012964 tPmkidCacheInfo *pmksa;
12965
12966 for (i = 0; i < numItems; i++) {
12967 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012968
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012969 /* Delete the entry if present */
Abhinav Kumar8c122592019-08-07 15:43:20 +053012970 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa,FALSE);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012971
Abhinav Kumar8c122592019-08-07 15:43:20 +053012972 csr_update_pmk_cache(pSession, pmksa);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012973
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012975 }
12976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 return (status);
12978}
12979
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012980eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012981#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
Abhinav Kumar8c122592019-08-07 15:43:20 +053012982 tPmkidCacheInfo *pmksa,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012983#else
Abhinav Kumar8c122592019-08-07 15:43:20 +053012984 tPmkidCacheInfo *pmksa,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012985#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012986 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012987{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012988 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12989 tANI_BOOLEAN fMatchFound = FALSE;
12990 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012991 tANI_U32 CurIndex;
12992 tANI_U32 i;
Abhinav Kumar8c122592019-08-07 15:43:20 +053012993 tPmkidCacheInfo *cached_pmksa;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012994
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012995 if(!pSession)
12996 {
12997 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12998 return eHAL_STATUS_FAILURE;
12999 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013000
13001 /* Check if there are no entries to delete */
13002 if (0 == pSession->NumPmkidCache) {
13003 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
13004 return eHAL_STATUS_SUCCESS;
13005 }
13006
13007 if (!flush_cache) {
13008 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Abhinav Kumar8c122592019-08-07 15:43:20 +053013009 cached_pmksa = &pSession->PmkidCacheInfo[Index];
13010 if (((!cached_pmksa->ssid_len) &&
13011 vos_is_macaddr_equal((v_MACADDR_t *)cached_pmksa->BSSID,
13012 (v_MACADDR_t *)pmksa->BSSID))) {
13013 fMatchFound = 1;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013014
Abhinav Kumar8c122592019-08-07 15:43:20 +053013015 } else if ((!vos_mem_compare(cached_pmksa->ssid,
13016 pmksa->ssid, pmksa->ssid_len)) &&
13017 (!vos_mem_compare(cached_pmksa->cache_id,
13018 pmksa->cache_id, CACHE_ID_LEN)))
13019 fMatchFound = 1;
13020
13021 if(fMatchFound) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013022 /* Clear this - the matched entry */
Abhinav Kumar8c122592019-08-07 15:43:20 +053013023 vos_mem_zero(cached_pmksa, sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013024 break;
13025 }
13026 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013027
13028 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
Abhinav Kumar8c122592019-08-07 15:43:20 +053013029 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "));
13030
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013031 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013032 else {
13033 /* Match Found */
13034 CurIndex = pSession->CurCacheIndex;
13035 if(Index < CurIndex) {
13036 for(i = Index; i < (CurIndex-1); i++) {
13037 vos_mem_copy(&pSession->PmkidCacheInfo[i],
13038 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
13039 }
13040 pSession->CurCacheIndex--;
13041 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
13042 sizeof(tPmkidCacheInfo));
13043 } else if(Index > CurIndex) {
13044 for(i = Index; i > (CurIndex); i--) {
13045 vos_mem_copy(&pSession->PmkidCacheInfo[i],
13046 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
13047 }
13048 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
13049 sizeof(tPmkidCacheInfo));
13050 }
13051 pSession->NumPmkidCache--;
13052 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013053 } else {
13054 /* Flush the entire cache */
13055 vos_mem_zero(pSession->PmkidCacheInfo,
13056 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
13057 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013058 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013059 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013060
13061 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013062}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013063
Jeff Johnson295189b2012-06-20 16:38:30 -070013064tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
13065{
13066 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
13067}
13068
Jeff Johnson295189b2012-06-20 16:38:30 -070013069eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
13070{
13071 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13072 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013073 tPmkidCacheInfo *pmksa;
13074 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013075
13076 if(!pSession)
13077 {
13078 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13079 return eHAL_STATUS_FAILURE;
13080 }
13081
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 if(pNum && pPmkidCache)
13083 {
13084 if(pSession->NumPmkidCache == 0)
13085 {
13086 *pNum = 0;
13087 status = eHAL_STATUS_SUCCESS;
13088 }
13089 else if(*pNum >= pSession->NumPmkidCache)
13090 {
13091 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
13092 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013093 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 pSession->NumPmkidCache);
13095 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13096 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013097
13098 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
13099 pmksa = &pSession->PmkidCacheInfo[i];
13100 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
13101 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
13102 pPmkidCache++;
13103 j++;
13104 }
13105 }
13106
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 *pNum = pSession->NumPmkidCache;
13108 status = eHAL_STATUS_SUCCESS;
13109 }
13110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013111 return (status);
13112}
13113
Jeff Johnson295189b2012-06-20 16:38:30 -070013114eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13115{
13116 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13117 tANI_U32 len;
13118 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013119
13120 if(!pSession)
13121 {
13122 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13123 return eHAL_STATUS_FAILURE;
13124 }
13125
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 if(pLen)
13127 {
13128 len = *pLen;
13129 *pLen = pSession->nWpaRsnReqIeLength;
13130 if(pBuf)
13131 {
13132 if(len >= pSession->nWpaRsnReqIeLength)
13133 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013134 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13135 pSession->nWpaRsnReqIeLength);
13136 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 }
13138 }
13139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 return (status);
13141}
13142
Jeff Johnson295189b2012-06-20 16:38:30 -070013143eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13144{
13145 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13146 tANI_U32 len;
13147 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013148
13149 if(!pSession)
13150 {
13151 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13152 return eHAL_STATUS_FAILURE;
13153 }
13154
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 if(pLen)
13156 {
13157 len = *pLen;
13158 *pLen = pSession->nWpaRsnRspIeLength;
13159 if(pBuf)
13160 {
13161 if(len >= pSession->nWpaRsnRspIeLength)
13162 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013163 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13164 pSession->nWpaRsnRspIeLength);
13165 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 }
13167 }
13168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 return (status);
13170}
Jeff Johnson295189b2012-06-20 16:38:30 -070013171#ifdef FEATURE_WLAN_WAPI
13172eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13173{
13174 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13175 tANI_U32 len;
13176 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013177
13178 if(!pSession)
13179 {
13180 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13181 return eHAL_STATUS_FAILURE;
13182 }
13183
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 if(pLen)
13185 {
13186 len = *pLen;
13187 *pLen = pSession->nWapiReqIeLength;
13188 if(pBuf)
13189 {
13190 if(len >= pSession->nWapiReqIeLength)
13191 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013192 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13193 pSession->nWapiReqIeLength);
13194 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 }
13196 }
13197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 return (status);
13199}
Jeff Johnson295189b2012-06-20 16:38:30 -070013200eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13201{
13202 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13203 tANI_U32 len;
13204 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013205
13206 if(!pSession)
13207 {
13208 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13209 return eHAL_STATUS_FAILURE;
13210 }
13211
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 if(pLen)
13213 {
13214 len = *pLen;
13215 *pLen = pSession->nWapiRspIeLength;
13216 if(pBuf)
13217 {
13218 if(len >= pSession->nWapiRspIeLength)
13219 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013220 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13221 pSession->nWapiRspIeLength);
13222 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 }
13224 }
13225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 return (status);
13227}
13228#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013229eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13230{
13231 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13232 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013233
13234 if(!pSession)
13235 {
13236 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13237 return (retStatus);
13238 }
13239
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 if(CSR_IS_ROAMING(pSession))
13241 {
13242 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13243 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 return (retStatus);
13246}
13247
Jeff Johnson295189b2012-06-20 16:38:30 -070013248//This function remove the connected BSS from te cached scan result
13249eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13250 tCsrRoamConnectedProfile *pConnProfile)
13251{
13252 eHalStatus status = eHAL_STATUS_FAILURE;
13253 tCsrScanResultFilter *pScanFilter = NULL;
13254 tListElem *pEntry;
13255 tCsrScanResult *pResult;
13256 tDot11fBeaconIEs *pIes;
13257 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13259 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13260 {
13261 do
13262 {
13263 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013264 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13265 if ( NULL == pScanFilter )
13266 status = eHAL_STATUS_FAILURE;
13267 else
13268 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013270 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13271 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13272 if ( NULL == pScanFilter->BSSIDs.bssid )
13273 status = eHAL_STATUS_FAILURE;
13274 else
13275 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013277 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13278 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13280 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013282 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13283 if ( NULL == pScanFilter->SSIDs.SSIDList )
13284 status = eHAL_STATUS_FAILURE;
13285 else
13286 status = eHAL_STATUS_SUCCESS;
13287 if (!HAL_STATUS_SUCCESS(status)) break;
13288 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13289 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 }
13291 pScanFilter->authType.numEntries = 1;
13292 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13293 pScanFilter->BSSType = pConnProfile->BSSType;
13294 pScanFilter->EncryptionType.numEntries = 1;
13295 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13296 pScanFilter->mcEncryptionType.numEntries = 1;
13297 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13298 //We ignore the channel for now, BSSID should be enough
13299 pScanFilter->ChannelInfo.numOfChannels = 0;
13300 //Also ignore the following fields
13301 pScanFilter->uapsd_mask = 0;
13302 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013303 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 pScanFilter->countryCode[0] = 0;
13305 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 csrLLLock(&pMac->scan.scanResultList);
13307 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13308 while( pEntry )
13309 {
13310 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13311 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13312 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13313 pScanFilter, NULL, NULL, NULL, &pIes);
13314 //Release the IEs allocated by csrMatchBSS is needed
13315 if( !pResult->Result.pvIes )
13316 {
13317 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 }
13320 if(fMatch)
13321 {
13322 //We found the one
13323 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13324 {
13325 //Free the memory
13326 csrFreeScanResultEntry( pMac, pResult );
13327 }
13328 break;
13329 }
13330 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13331 }//while
13332 csrLLUnlock(&pMac->scan.scanResultList);
13333 }while(0);
13334 if(pScanFilter)
13335 {
13336 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013337 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 }
13339 }
13340 return (status);
13341}
13342
Jeff Johnson295189b2012-06-20 16:38:30 -070013343//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013344eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13345{
13346 eHalStatus status = eHAL_STATUS_SUCCESS;
13347 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13349 {
13350 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13351 {
13352 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13353 {
13354 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013355 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 status = eHAL_STATUS_CSR_WRONG_STATE;
13357 break;
13358 }
13359 if( csrIsConnStateInfra( pMac, sessionId ) )
13360 {
13361 if( chnId &&
13362 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013364 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13366 status = eHAL_STATUS_CSR_WRONG_STATE;
13367 break;
13368 }
13369 }
13370 }
13371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 return ( status );
13373}
13374
Jeff Johnson295189b2012-06-20 16:38:30 -070013375static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13376{
13377 eHalStatus status = eHAL_STATUS_SUCCESS;
13378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13379 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013380
13381 if(!pSession)
13382 {
13383 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13384 return eHAL_STATUS_FAILURE;
13385 }
13386
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 if ( csrIsConnStateIbss( pMac, sessionId ) )
13388 {
13389 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13390 }
13391 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13392 {
13393 // Disassociate from the connected Infrastructure network...
13394 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13395 }
13396 else
13397 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13399 //Otherwise we need to add code to handle the
13400 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13401 //send stop_bss to PE, before we can continue.
13402 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013403 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013405 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13406 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 // there is no Bss description before we start an WDS so we need
13408 // to adopt all Bss configuration parameters from the Profile.
13409 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13410 if(HAL_STATUS_SUCCESS(status))
13411 {
13412 //Save profile for late use
13413 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013414 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13415 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013417 vos_mem_set(pSession->pCurRoamProfile,
13418 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013421 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013422 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013423 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13424 NULL, &bssConfig,
13425 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 }
13427 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013428
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 return( status );
13430}
13431
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013432#ifdef WLAN_FEATURE_SAE
13433/*
13434 * csr_update_sae_config: Copy SAE info to join request
13435 * @profile: pointer to profile
13436 * @csr_join_req: csr join request
13437 *
13438 * Return: None
13439 */
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013440static bool csr_update_sae_config(tSirMacAddr bssid, tpAniSirGlobal mac,
13441 tCsrRoamSession *session)
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013442{
13443 tPmkidCacheInfo pmkid_cache;
13444 uint32_t index;
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013445 bool sae_pmk_cached;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013446
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013447 vos_mem_copy(pmkid_cache.BSSID, bssid, VOS_MAC_ADDR_SIZE);
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013448
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013449 sae_pmk_cached =
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013450 csr_lookup_pmkid_using_bssid(mac, session, &pmkid_cache, &index);
13451
13452 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013453 "pmk_cached %d for BSSID=" MAC_ADDRESS_STR, sae_pmk_cached,
13454 MAC_ADDR_ARRAY(bssid));
13455
13456 return sae_pmk_cached;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013457}
13458#else
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013459static bool csr_update_sae_config(tSirMacAddr bssid, tpAniSirGlobal mac,
13460 tCsrRoamSession *session)
13461{
13462 return false;
13463}
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013464#endif
13465
Jeff Johnson295189b2012-06-20 16:38:30 -070013466////////////////////Mail box
13467
Jeff Johnson295189b2012-06-20 16:38:30 -070013468//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13469//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013470static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13471 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13473{
13474 tCsrChannelSet channelGroup;
13475 tSirMacCapabilityInfo *pAP_capabilityInfo;
13476 tAniBool fTmp;
13477 tANI_BOOLEAN found = FALSE;
13478 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013479 tANI_S8 pwrLimit = 0;
13480 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13482 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13483 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13484 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 // 802.11h
13486 //We can do this because it is in HOST CPU order for now.
13487 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013488 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13489 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13490 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 fTmp = (tAniBool)pal_cpu_to_be32(1);
13492 }
13493 else
13494 fTmp = (tAniBool)0;
13495
13496 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013497 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013499 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013500 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 // This is required for 11k test VoWiFi Ent: Test 2.
13502 // We need the power capabilities for Assoc Req.
13503 // This macro is provided by the halPhyCfg.h. We pick our
13504 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013505 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13506 if (0 != pwrLimit)
13507 {
13508 *pBuf++ = pwrLimit;
13509 }
13510 else
13511 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013512 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 size = sizeof(pMac->roam.validChannelList);
13515 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013516 {
13517 tANI_U8 *actualSize = pBuf++;
13518 *actualSize = 0;
13519
13520 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013522 /* Only add 5ghz channels*/
13523 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13524 {
13525 *actualSize +=1;
13526 *pBuf++ = pMac->roam.validChannelList[ i ];
13527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 }
13529 }
13530 else
13531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013532 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 *pBuf++ = 0; //tSirSupChnl->numChnl
13534 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 //Check whether it is ok to enter UAPSD
13536#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13537 if( btcIsReadyForUapsd(pMac) )
13538#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13539 {
13540 *pBuf++ = uapsdMask;
13541 }
13542#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13543 else
13544 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013545 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 *pBuf++ = 0;
13547 }
13548#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13549
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013551 vos_mem_copy(pBuf, pBssDescription,
13552 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13554}
13555
Jeff Johnson295189b2012-06-20 16:38:30 -070013556/*
13557 * The communication between HDD and LIM is thru mailbox (MB).
13558 * Both sides will access the data structure "tSirSmeJoinReq".
13559 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13560 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13561 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13562 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13563 */
13564eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013565 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013566{
13567 eHalStatus status = eHAL_STATUS_SUCCESS;
13568 tSirSmeJoinReq *pMsg;
13569 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013570 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 tANI_U16 msgLen, wTmp, ieLen;
13572 tSirMacRateSet OpRateSet;
13573 tSirMacRateSet ExRateSet;
13574 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13575 tANI_U32 dwTmp;
13576 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013577 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013578 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013579 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013580
13581 if(!pSession)
13582 {
13583 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13584 return eHAL_STATUS_FAILURE;
13585 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013586 /* To satisfy klockworks */
13587 if (NULL == pBssDescription)
13588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013589 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013590 return eHAL_STATUS_FAILURE;
13591 }
13592
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 do {
13594 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13595 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013596 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13598 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13599 // IE fields, but the length field in the bssDescription needs to be interpreted to
13600 // determine length of the IE fields.
13601 //
13602 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13603 // add in the length from the bssDescription (then add the size of the 'length' field
13604 // itself because that is NOT included in the length field).
13605 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13606 pBssDescription->length + sizeof( pBssDescription->length ) +
13607 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
Kiet Lam64c1b492013-07-12 13:56:44 +053013608 pMsg = vos_mem_malloc(msgLen);
13609 if (NULL == pMsg)
13610 status = eHAL_STATUS_FAILURE;
13611 else
13612 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013614 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013615 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 pMsg->length = pal_cpu_to_be16(msgLen);
13617 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 // sessionId
13619 *pBuf = (tANI_U8)sessionId;
13620 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 // transactionId
13622 *pBuf = 0;
13623 *( pBuf + 1 ) = 0;
13624 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 // ssId
13626 if( pIes->SSID.present && pIes->SSID.num_ssid )
13627 {
13628 // ssId len
13629 *pBuf = pIes->SSID.num_ssid;
13630 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 pBuf += pIes->SSID.num_ssid;
13633 }
13634 else
13635 {
13636 *pBuf = 0;
13637 pBuf++;
13638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013640 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13641 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 pBuf += sizeof(tSirMacAddr);
13643 // bsstype
13644 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13645 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pBuf += sizeof(tSirBssType);
13648 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013649 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13650 if (pBssDescription->channelId <= 14 &&
13651 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13652 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13653 {
13654 //Need to disable VHT operation in 2.4 GHz band
13655 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13656 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013657 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13658 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13659
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013660 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 //Persona
13663 *pBuf = (tANI_U8)pProfile->csrPersona;
13664 pBuf++;
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013665 *pBuf = csr_update_sae_config(pBssDescription->bssId, pMac, pSession);
13666 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013667 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13668 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013669 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13670 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013671 //CBMode
13672 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13673 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013674 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13675 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013676
13677 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013678 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13679 pProfile->csrPersona, pSession->bssParams.cbMode,
13680 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013681
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 // uapsdPerAcBitmask
13683 *pBuf = pProfile->uapsd_mask;
13684 pBuf++;
13685
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013686
13687
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013688 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013689 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 {
13691 // OperationalRateSet
13692 if (OpRateSet.numRates) {
13693 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013694 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 pBuf += OpRateSet.numRates;
13696 } else *pBuf++ = 0;
13697 // ExtendedRateSet
13698 if (ExRateSet.numRates) {
13699 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013700 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 pBuf += ExRateSet.numRates;
13702 } else *pBuf++ = 0;
13703 }
13704 else
13705 {
13706 *pBuf++ = 0;
13707 *pBuf++ = 0;
13708 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013709
13710 //rateBitmap
13711 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13712 pBuf += sizeof(tANI_U16);
13713
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 // rsnIE
13715 if ( csrIsProfileWpa( pProfile ) )
13716 {
13717 // Insert the Wpa IE into the join request
13718 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13719 (tCsrWpaIe *)( wpaRsnIE ) );
13720 }
13721 else if( csrIsProfileRSN( pProfile ) )
13722 {
13723 // Insert the RSN IE into the join request
13724 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13725 (tCsrRSNIe *)( wpaRsnIE ) );
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +053013726 pMsg->force_rsne_override =
13727 pProfile->force_rsne_override;
Jeff Johnson295189b2012-06-20 16:38:30 -070013728 }
13729#ifdef FEATURE_WLAN_WAPI
13730 else if( csrIsProfileWapi( pProfile ) )
13731 {
13732 // Insert the WAPI IE into the join request
13733 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13734 (tCsrWapiIe *)( wpaRsnIE ) );
13735 }
13736#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 else
13738 {
13739 ieLen = 0;
13740 }
13741 //remember the IE for future use
13742 if( ieLen )
13743 {
13744 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013746 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"), ieLen, DOT11F_IE_RSN_MAX_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 ieLen = DOT11F_IE_RSN_MAX_LEN;
13748 }
13749#ifdef FEATURE_WLAN_WAPI
13750 if( csrIsProfileWapi( pProfile ) )
13751 {
13752 //Check whether we need to allocate more memory
13753 if(ieLen > pSession->nWapiReqIeLength)
13754 {
13755 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13756 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013757 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013758 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013759 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13760 if (NULL == pSession->pWapiReqIE)
13761 status = eHAL_STATUS_FAILURE;
13762 else
13763 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 if(!HAL_STATUS_SUCCESS(status)) break;
13765 }
13766 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013767 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013769 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013771 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pBuf += ieLen;
13773 }
13774 else//should be WPA/WPA2 otherwise
13775#endif /* FEATURE_WLAN_WAPI */
13776 {
13777 //Check whether we need to allocate more memory
13778 if(ieLen > pSession->nWpaRsnReqIeLength)
13779 {
13780 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13781 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013782 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013784 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13785 if (NULL == pSession->pWpaRsnReqIE)
13786 status = eHAL_STATUS_FAILURE;
13787 else
13788 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 if(!HAL_STATUS_SUCCESS(status)) break;
13790 }
13791 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013792 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013794 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013796 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 pBuf += ieLen;
13798 }
13799 }
13800 else
13801 {
13802 //free whatever old info
13803 pSession->nWpaRsnReqIeLength = 0;
13804 if(pSession->pWpaRsnReqIE)
13805 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013806 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 pSession->pWpaRsnReqIE = NULL;
13808 }
13809#ifdef FEATURE_WLAN_WAPI
13810 pSession->nWapiReqIeLength = 0;
13811 if(pSession->pWapiReqIE)
13812 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013813 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 pSession->pWapiReqIE = NULL;
13815 }
13816#endif /* FEATURE_WLAN_WAPI */
13817 //length is two bytes
13818 *pBuf = 0;
13819 *(pBuf + 1) = 0;
13820 pBuf += 2;
13821 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013822#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013823 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013825 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 //length is two bytes
13827 *pBuf = 0;
13828 *(pBuf + 1) = 0;
13829 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013830 }
13831 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013833 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013834 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013835 {
13836 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013837#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013838 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013839 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013840 pSession->suppCckmIeInfo.cckmIe, ieLen);
13841#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013842 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013843 pSession,
13844 pProfile,
13845 pBssDescription,
13846 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 pSession->nWpaRsnReqIeLength,
13848 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013849#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013850 }
13851 else
13852 {
13853 ieLen = 0;
13854 }
13855 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13856 if( ieLen )
13857 {
13858 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13859 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013861 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013862 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013863 pBuf += ieLen;
13864 }
13865 else
13866 {
13867 //Indicate you have no CCKM IE
13868 //length is two bytes
13869 *pBuf = 0;
13870 *(pBuf + 1) = 0;
13871 pBuf += 2;
13872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013874#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013876 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 {
13878 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013879 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013881 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013883 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013885 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 pBuf += ieLen;
13887 }
13888 else
13889 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013890 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 *pBuf = 0;
13893 *(pBuf + 1) = 0;
13894 pBuf += 2;
13895 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 // addIEAssoc
13897 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13898 {
13899 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 if(ieLen > pSession->nAddIEAssocLength)
13901 {
13902 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013903 {
13904 vos_mem_free(pSession->pAddIEAssoc);
13905 }
13906 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13907 if (NULL == pSession->pAddIEAssoc)
13908 status = eHAL_STATUS_FAILURE;
13909 else
13910 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013914 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013916 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013918 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 pBuf += ieLen;
13920 }
13921 else
13922 {
13923 pSession->nAddIEAssocLength = 0;
13924 if(pSession->pAddIEAssoc)
13925 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013926 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 pSession->pAddIEAssoc = NULL;
13928 }
13929 *pBuf = 0;
13930 *(pBuf + 1) = 0;
13931 pBuf += 2;
13932 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013933
13934 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013936 //Unmask any AC in reassoc that is ACM-set
13937 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13938 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013940 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13941 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013942#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013943 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013944#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013945 }
13946 else
13947 {
13948 uapsd_mask = 0;
13949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 }
13951 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013952
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013954 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013955 pBuf += sizeof(tANI_U32);
13956
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013958 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013959 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013960#ifdef WLAN_FEATURE_11W
13961 //MgmtEncryption
13962 if (pProfile->MFPEnabled)
13963 {
13964 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13965 }
13966 else
13967 {
13968 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13969 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013970 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013971 pBuf += sizeof(tANI_U32);
13972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013973#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013974 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013975 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013976#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013977 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013978 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013979#endif
13980 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013981 {
13982 // is11Rconnection;
13983 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013984 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013985 pBuf += sizeof(tAniBool);
13986 }
13987 else
13988 {
13989 // is11Rconnection;
13990 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013991 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013992 pBuf += sizeof(tAniBool);
13993 }
13994#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013995#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013996
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013997 // isESEFeatureIniEnabled
13998 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013999 {
14000 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014001 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053014002 pBuf += sizeof(tAniBool);
14003 }
14004 else
14005 {
14006 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080014007 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053014008 pBuf += sizeof(tAniBool);
14009 }
14010
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014011 /* A profile can not be both ESE and 11R. But an 802.11R AP
14012 * may be advertising support for ESE as well. So if we are
14013 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014014 * If we are associating explictly 11R only then we will get
14015 * 11R.
14016 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014017 if ((csrIsProfileESE(pProfile) ||
14018 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014019 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14020 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14021 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14022 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14023#ifdef WLAN_FEATURE_11W
14024 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053014025 || (pProfile->negotiatedAuthType ==
14026 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014027#endif
14028 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014029 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014030 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014031 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014032 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014033 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014034 pBuf += sizeof(tAniBool);
14035 }
14036 else
14037 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014038 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014039 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014040 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014041 pBuf += sizeof(tAniBool);
14042 }
14043
14044 if (eWNI_SME_JOIN_REQ == messageType)
14045 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014046 tESETspecInfo eseTspec;
14047 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014048 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014049 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14050 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
14051 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014052 }
14053 else if (eWNI_SME_REASSOC_REQ == messageType)
14054 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014055 if ((csrIsProfileESE(pProfile) ||
14056 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014057 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14058 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14059 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14060 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14061#ifdef WLAN_FEATURE_11W
14062 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053014063 || (pProfile->negotiatedAuthType ==
14064 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014065#endif
14066 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014067 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014069 tESETspecInfo eseTspec;
14070 // ESE Tspec information
14071 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14072 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
14073 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014076 if (eseTspec.numTspecs) {
14077 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
14078 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014080 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014082 else
Jeff Johnson295189b2012-06-20 16:38:30 -070014083 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014084 tESETspecInfo eseTspec;
14085 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014087 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14088 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
14089 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 }
14091 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014092#endif // FEATURE_WLAN_ESE
14093#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014095 if (pMac->roam.configParam.isFastTransitionEnabled
14096#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053014097 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014098#endif
14099 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014101 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014102 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014103 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 }
14105 else
14106 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014107 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014108 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014109 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 }
14111#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070014112#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053014113 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070014114 {
14115 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014116 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014117 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014118 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014119 }
14120 else
14121 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014122 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014123 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014124 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014125 }
14126#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014127
14128 // txLdpcIniFeatureEnabled
14129 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
14130 pBuf++;
14131
Kiran4a17ebe2013-01-31 10:43:43 -080014132 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
14133 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
14134 {
14135 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
14136 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
14137 csrApplyPower2Current(pMac);
14138 }
14139
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014140#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014141 // txBFIniFeatureEnabled
14142 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14143 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014144
14145 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014146 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014147 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014148 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14149 if (pIes->VHTCaps.numSoundingDim)
14150 txBFCsnValue = CSR_ROAM_MIN
14151 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014152 }
14153 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014154 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014155
14156 /* Only enable MuBf if no other MuBF session exist
14157 * and FW and HOST is MuBF capable.
14158 */
14159 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14160 {
14161 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14162 pBuf++;
14163 }
14164 else
14165 {
14166 *pBuf = 0;
14167 pBuf++;
14168 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014169#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014170 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14171 pBuf++;
14172
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014173 // WME
14174 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14175 {
14176 //WME enabled
14177 dwTmp = pal_cpu_to_be32(TRUE);
14178 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14179 pBuf += sizeof(tAniBool);
14180 }
14181 else
14182 {
14183 dwTmp = pal_cpu_to_be32(FALSE);
14184 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14185 pBuf += sizeof(tAniBool);
14186 }
14187
14188 // QOS
14189 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14190 {
14191 //QOS enabled
14192 dwTmp = pal_cpu_to_be32(TRUE);
14193 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14194 pBuf += sizeof(tAniBool);
14195 }
14196 else
14197 {
14198 dwTmp = pal_cpu_to_be32(FALSE);
14199 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14200 pBuf += sizeof(tAniBool);
14201 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014202 //BssDesc
14203 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14204 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014205
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014206 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014207 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14208 pMsg = NULL;
14209
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014210 if(!HAL_STATUS_SUCCESS(status))
14211 {
14212 break;
14213 }
14214 else
14215 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014216#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014217 if (eWNI_SME_JOIN_REQ == messageType)
14218 {
14219 //Tush-QoS: notify QoS module that join happening
14220 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14221 }
14222 else if (eWNI_SME_REASSOC_REQ == messageType)
14223 {
14224 //Tush-QoS: notify QoS module that reassoc happening
14225 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014227#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014230
14231 if (pMsg != NULL)
14232 {
14233 vos_mem_free( pMsg );
14234 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014235 pMac->roam.roamSession[sessionId].connect_req_start_time =
14236 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014237
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014239}
14240
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014241#ifdef WLAN_FEATURE_LFR_MBB
14242/**
14243 * csr_prepare_reassoc_req () - Prepares reassoc request
14244 * @mac: MAC context
14245 * @session_id: session id
14246 * @pbss_description: bss description
14247 * @ies: pointer to beacon IE's
14248 * @reassoc_req: pointer to reassociation request
14249 *
14250 *Return: None
14251 */
14252eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14253 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14254 tSirSmeJoinReq **reassoc_req)
14255{
14256 eHalStatus status = eHAL_STATUS_SUCCESS;
14257 tSirSmeJoinReq *csr_join_req;
14258 tANI_U8 *buf;
14259 v_U8_t acm_mask = 0, uapsd_mask;
14260 tANI_U16 msg_len, w_tmp, ie_len;
14261 tSirMacRateSet op_rate_set;
14262 tSirMacRateSet ex_rate_set;
14263 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14264 tANI_U32 dw_tmp;
14265 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14266 tANI_U32 uc_dot11_mode = 0;
14267 tANI_U8 tx_bf_csn_value = 0;
14268 tANI_U16 rate_bitmap = 0;
14269 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014270 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014271
14272 if(!session) {
14273 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14274 return eHAL_STATUS_FAILURE;
14275 }
14276
14277 if (NULL == bss_description) {
14278 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14279 return eHAL_STATUS_FAILURE;
14280 }
14281
14282 smsLog(mac, LOG1,
14283 FL("session_id %d"), session_id);
14284
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014285 profile = vos_mem_malloc(sizeof(*profile));
14286 if (NULL == profile) {
14287 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14288 return eHAL_STATUS_RESOURCES;
14289 }
14290
14291 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014292 if(!HAL_STATUS_SUCCESS(status)) {
14293 smsLog(mac, LOGE, FL("Profile copy failed"));
14294 return eHAL_STATUS_FAILURE;
14295 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014296
14297 do {
14298 /*
14299 * There are a number of variable length fields to consider.
14300 * First, the tSirSmeJoinReq includes a single bssDescription.
14301 * bssDescription includes a single tANI_U32 for the IE fields,
14302 * but the length field in the bssDescription needs to be
14303 * interpreted to determine length of the IE fields.
14304 * So, take the size of the JoinReq, subtract the size of the
14305 * bssDescription and add in the length from the bssDescription
14306 * (then add the size of the 'length' field itself because that is
14307 * NOT included in the length field). msgLen =
14308 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14309 * pBssDescription->length + sizeof( pBssDescription->length ) +
14310 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14311 * add in the size of the WPA IE that we may build.
14312 */
14313
14314 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14315 bss_description->length + sizeof(bss_description->length) +
14316 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14317
14318 csr_join_req = vos_mem_malloc(msg_len);
14319 if (NULL == csr_join_req)
14320 status = eHAL_STATUS_FAILURE;
14321 else
14322 status = eHAL_STATUS_SUCCESS;
14323 if (!HAL_STATUS_SUCCESS(status)) break;
14324
14325 vos_mem_set(csr_join_req, msg_len, 0);
14326 *reassoc_req = csr_join_req;
14327
14328 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14329 csr_join_req->length = pal_cpu_to_be16(msg_len);
14330 buf = &csr_join_req->sessionId;
14331
14332 /* session_id */
14333 *buf = (tANI_U8)session_id;
14334 buf++;
14335
14336 /* transactionId */
14337 *buf = 0;
14338 *(buf + 1) = 0;
14339 buf += sizeof(tANI_U16);
14340
14341 /* ssId */
14342 if(ies->SSID.present && ies->SSID.num_ssid)
14343 {
14344 /* ssId len */
14345 *buf = ies->SSID.num_ssid;
14346 buf++;
14347 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14348 buf += ies->SSID.num_ssid;
14349 }
14350 else
14351 {
14352 *buf = 0;
14353 buf++;
14354 }
14355
14356 /* selfMacAddr */
14357 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14358 sizeof(tSirMacAddr));
14359 buf += sizeof(tSirMacAddr);
14360
14361 /* bsstype */
14362 dw_tmp =
14363 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14364 /* Override BssType for BTAMP */
14365 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14366 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14367 buf += sizeof(tSirBssType);
14368
14369 /* dot11mode */
14370 uc_dot11_mode =
14371 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14372 if (bss_description->channelId <= 14 &&
14373 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14374 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14375 {
14376 /* Need to disable VHT operation in 2.4 GHz band */
14377 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14378 }
14379 *buf = (tANI_U8)uc_dot11_mode;
14380 buf++;
14381
14382 /* Persona */
14383 *buf = (tANI_U8)profile->csrPersona;
14384 buf++;
14385 *buf = (tANI_U8)profile->bOSENAssociation;
14386 buf++;
14387 *buf = (tANI_U8)profile->bWPSAssociation;
14388 buf++;
14389
14390 /* CBMode */
14391 *buf = (tANI_U8)session->bssParams.cbMode;
14392 buf++;
14393
14394 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14395 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14396 session->bssParams.cbMode);
14397
14398 /* uapsdPerAcBitmask */
14399 *buf = profile->uapsd_mask;
14400 buf++;
14401
14402
14403 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14404 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14405 if (HAL_STATUS_SUCCESS(status))
14406 {
14407 /* OperationalRateSet */
14408 if (op_rate_set.numRates) {
14409 *buf++ = op_rate_set.numRates;
14410 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14411 buf += op_rate_set.numRates;
14412 } else *buf++ = 0;
14413
14414 /* ExtendedRateSet */
14415 if (ex_rate_set.numRates) {
14416 *buf++ = ex_rate_set.numRates;
14417 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14418 buf += ex_rate_set.numRates;
14419 } else *buf++ = 0;
14420 }
14421 else
14422 {
14423 *buf++ = 0;
14424 *buf++ = 0;
14425 }
14426
14427 /* rateBitmap */
14428 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14429 buf += sizeof(tANI_U16);
14430
14431 profile->negotiatedAuthType =
14432 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14433 profile->negotiatedUCEncryptionType =
14434 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14435
14436 /* rsnIE */
14437 if ( csrIsProfileWpa(profile))
14438 {
14439 /* Insert the Wpa IE into the join request */
14440 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14441 (tCsrWpaIe *)(wpa_rsn_ie));
14442 }
14443 else if( csrIsProfileRSN(profile))
14444 {
14445 /* Insert the RSN IE into the join request */
14446 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14447 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14448 }
14449#ifdef FEATURE_WLAN_WAPI
14450 else if( csrIsProfileWapi(profile))
14451 {
14452 /* Insert the WAPI IE into the join request */
14453 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14454 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14455 }
14456#endif
14457 else
14458 {
14459 ie_len = 0;
14460 }
14461 /* remember the IE for future use */
14462 if(ie_len)
14463 {
14464 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14465 {
14466 smsLog(mac, LOGE,
14467 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14468 ie_len, DOT11F_IE_RSN_MAX_LEN);
14469 ie_len = DOT11F_IE_RSN_MAX_LEN;
14470 }
14471#ifdef FEATURE_WLAN_WAPI
14472 if( csrIsProfileWapi(profile))
14473 {
14474 /* Check whether we need to allocate more memory */
14475 if(ie_len > session->nWapiReqIeLength)
14476 {
14477 if(session->pWapiReqIE && session->nWapiReqIeLength)
14478 {
14479 vos_mem_free(session->pWapiReqIE);
14480 }
14481 session->pWapiReqIE = vos_mem_malloc(ie_len);
14482 if (NULL == session->pWapiReqIE)
14483 status = eHAL_STATUS_FAILURE;
14484 else
14485 status = eHAL_STATUS_SUCCESS;
14486 if(!HAL_STATUS_SUCCESS(status)) break;
14487 }
14488 session->nWapiReqIeLength = ie_len;
14489 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14490 w_tmp = pal_cpu_to_be16(ie_len);
14491 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14492 buf += sizeof(tANI_U16);
14493 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14494 buf += ie_len;
14495 }
14496 else /* should be WPA/WPA2 otherwise */
14497#endif
14498 {
14499 /* Check whether we need to allocate more memory */
14500 if(ie_len > session->nWpaRsnReqIeLength)
14501 {
14502 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14503 {
14504 vos_mem_free(session->pWpaRsnReqIE);
14505 }
14506 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14507 if (NULL == session->pWpaRsnReqIE)
14508 status = eHAL_STATUS_FAILURE;
14509 else
14510 status = eHAL_STATUS_SUCCESS;
14511 if(!HAL_STATUS_SUCCESS(status)) break;
14512 }
14513 session->nWpaRsnReqIeLength = ie_len;
14514 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14515 w_tmp = pal_cpu_to_be16(ie_len);
14516 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14517 buf += sizeof(tANI_U16);
14518 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14519 buf += ie_len;
14520 }
14521 }
14522 else
14523 {
14524 /* free whatever old info */
14525 session->nWpaRsnReqIeLength = 0;
14526 if(session->pWpaRsnReqIE)
14527 {
14528 vos_mem_free(session->pWpaRsnReqIE);
14529 session->pWpaRsnReqIE = NULL;
14530 }
14531#ifdef FEATURE_WLAN_WAPI
14532 session->nWapiReqIeLength = 0;
14533 if(session->pWapiReqIE)
14534 {
14535 vos_mem_free(session->pWapiReqIE);
14536 session->pWapiReqIE = NULL;
14537 }
14538#endif
14539 /* length is two bytes */
14540 *buf = 0;
14541 *(buf + 1) = 0;
14542 buf += 2;
14543 }
14544#ifdef FEATURE_WLAN_ESE
14545 if(eWNI_SME_JOIN_REQ == message_type)
14546 {
14547 /*
14548 * Never include the cckmIE in an Join Request
14549 * length is two bytes
14550 */
14551 *buf = 0;
14552 *(buf + 1) = 0;
14553 buf += 2;
14554 }
14555 else if(eWNI_SME_REASSOC_REQ == message_type)
14556 {
14557 /* cckmIE */
14558 if( csrIsProfileESE(profile))
14559 {
14560 /* Insert the CCKM IE into the join request */
14561#ifdef FEATURE_WLAN_ESE_UPLOAD
14562 ie_len = session->suppCckmIeInfo.cckmIeLen;
14563 vos_mem_copy((void *) (wpa_rsn_ie),
14564 session->suppCckmIeInfo.cckmIe, ie_len);
14565#else
14566 ie_len = csrConstructEseCckmIe(mac,
14567 session,
14568 profile,
14569 bss_description,
14570 session->pWpaRsnReqIE,
14571 session->nWpaRsnReqIeLength,
14572 (void *)(wpa_rsn_ie));
14573#endif
14574 }
14575 else
14576 {
14577 ie_len = 0;
14578 }
14579 /*
14580 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14581 * message buffer
14582 */
14583 if(ie_len)
14584 {
14585 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14586 w_tmp = pal_cpu_to_be16(ie_len);
14587 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14588 buf += sizeof(tANI_U16);
14589 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14590 buf += ie_len;
14591 }
14592 else
14593 {
14594 /* Indicate you have no CCKM IE length is two bytes */
14595 *buf = 0;
14596 *(buf + 1) = 0;
14597 buf += 2;
14598 }
14599 }
14600#endif
14601 /* addIEScan */
14602 if (profile->nAddIEScanLength)
14603 {
14604 ie_len = profile->nAddIEScanLength;
14605 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14606 session->nAddIEScanLength = ie_len;
14607 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14608 w_tmp = pal_cpu_to_be16(ie_len);
14609 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14610 buf += sizeof(tANI_U16);
14611 vos_mem_copy(buf, profile->addIEScan, ie_len);
14612 buf += ie_len;
14613 }
14614 else
14615 {
14616 memset(session->addIEScan, 0, session->nAddIEScanLength);
14617 session->nAddIEScanLength = 0;
14618 *buf = 0;
14619 *(buf + 1) = 0;
14620 buf += 2;
14621 }
14622 /* addIEAssoc */
14623 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14624 {
14625 ie_len = profile->nAddIEAssocLength;
14626 if(ie_len > session->nAddIEAssocLength)
14627 {
14628 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14629 {
14630 vos_mem_free(session->pAddIEAssoc);
14631 }
14632 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14633 if (NULL == session->pAddIEAssoc)
14634 status = eHAL_STATUS_FAILURE;
14635 else
14636 status = eHAL_STATUS_SUCCESS;
14637 if(!HAL_STATUS_SUCCESS(status)) break;
14638 }
14639 session->nAddIEAssocLength = ie_len;
14640 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14641 w_tmp = pal_cpu_to_be16(ie_len);
14642 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14643 buf += sizeof(tANI_U16);
14644 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14645 buf += ie_len;
14646 }
14647 else
14648 {
14649 session->nAddIEAssocLength = 0;
14650 if(session->pAddIEAssoc)
14651 {
14652 vos_mem_free(session->pAddIEAssoc);
14653 session->pAddIEAssoc = NULL;
14654 }
14655 *buf = 0;
14656 *(buf + 1) = 0;
14657 buf += 2;
14658 }
14659
14660 if(eWNI_SME_REASSOC_REQ == message_type )
14661 {
14662 /*Unmask any AC in reassoc that is ACM-set */
14663 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14664 if( uapsd_mask && (NULL != bss_description))
14665 {
14666 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14667 {
14668#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14669 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14670#endif
14671 }
14672 else
14673 {
14674 uapsd_mask = 0;
14675 }
14676 }
14677 }
14678
14679 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14680 profile->negotiatedUCEncryptionType));
14681 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14682 buf += sizeof(tANI_U32);
14683
14684 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14685 profile->negotiatedMCEncryptionType));
14686 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14687 buf += sizeof(tANI_U32);
14688#ifdef WLAN_FEATURE_11W
14689 /* MgmtEncryption */
14690 if (profile->MFPEnabled)
14691 {
14692 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14693 }
14694 else
14695 {
14696 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14697 }
14698 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14699 buf += sizeof(tANI_U32);
14700#endif
14701#ifdef WLAN_FEATURE_VOWIFI_11R
14702 profile->MDID.mdiePresent = bss_description->mdiePresent;
14703 if (csrIsProfile11r(profile)
14704#ifdef FEATURE_WLAN_ESE
14705 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14706 (ies->ESEVersion.present) &&
14707 (mac->roam.configParam.isEseIniFeatureEnabled))
14708#endif
14709 )
14710 {
14711 /* is11Rconnection */
14712 dw_tmp = pal_cpu_to_be32(TRUE);
14713 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14714 buf += sizeof(tAniBool);
14715 }
14716 else
14717 {
14718 /* is11Rconnection */
14719 dw_tmp = pal_cpu_to_be32(FALSE);
14720 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14721 buf += sizeof(tAniBool);
14722 }
14723#endif
14724#ifdef FEATURE_WLAN_ESE
14725
14726 /* isESEFeatureIniEnabled */
14727 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14728 {
14729 dw_tmp = pal_cpu_to_be32(TRUE);
14730 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14731 buf += sizeof(tAniBool);
14732 }
14733 else
14734 {
14735 dw_tmp = pal_cpu_to_be32(FALSE);
14736 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14737 buf += sizeof(tAniBool);
14738 }
14739
14740 /* A profile can not be both ESE and 11R. But an 802.11R AP
14741 * may be advertising support for ESE as well. So if we are
14742 * associating Open or explicitly ESE then we will get ESE.
14743 * If we are associating explictly 11R only then we will get
14744 * 11R.
14745 */
14746 if ((csrIsProfileESE(profile) ||
14747 ((ies->ESEVersion.present)
14748 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14749 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14750 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14751 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14752#ifdef WLAN_FEATURE_11W
14753 || (profile->negotiatedAuthType ==
14754 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14755 || (profile->negotiatedAuthType ==
14756 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14757#endif
14758 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14759 && (mac->roam.configParam.isEseIniFeatureEnabled))
14760 {
14761 /* isESEconnection */
14762 dw_tmp = pal_cpu_to_be32(TRUE);
14763 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14764 buf += sizeof(tAniBool);
14765 }
14766 else
14767 {
14768 /* isESEconnection */
14769 dw_tmp = pal_cpu_to_be32(FALSE);
14770 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14771 buf += sizeof(tAniBool);
14772 }
14773
14774 if (eWNI_SME_JOIN_REQ == message_type)
14775 {
14776 tESETspecInfo eseTspec;
14777 /*
14778 * ESE-Tspec IEs in the ASSOC request is presently not supported
14779 * so nullify the TSPEC parameters
14780 */
14781 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14782 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14783 buf += sizeof(tESETspecInfo);
14784 }
14785 else if (eWNI_SME_REASSOC_REQ == message_type)
14786 {
14787 if ((csrIsProfileESE(profile) ||
14788 ((ies->ESEVersion.present)
14789 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14790 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14791 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14792 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14793#ifdef WLAN_FEATURE_11W
14794 || (profile->negotiatedAuthType ==
14795 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14796 || (profile->negotiatedAuthType ==
14797 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14798#endif
14799 || (profile->negotiatedAuthType ==
14800 eCSR_AUTH_TYPE_RSN_PSK))))
14801 && (mac->roam.configParam.isEseIniFeatureEnabled))
14802 {
14803 tESETspecInfo eseTspec;
14804 /* ESE Tspec information */
14805 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14806 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14807 (tTspecInfo *) &eseTspec.tspec[0]);
14808 *buf = eseTspec.numTspecs;
14809 buf += sizeof(tANI_U8);
14810 // Copy the TSPEC information only if present
14811 if (eseTspec.numTspecs) {
14812 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14813 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14814 }
14815 buf += sizeof(eseTspec.tspec);
14816 }
14817 else
14818 {
14819 tESETspecInfo eseTspec;
14820 /*
14821 * ESE-Tspec IEs in the ASSOC request is presently
14822 * not supported so nullify the TSPEC parameters
14823 */
14824 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14825 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14826 buf += sizeof(tESETspecInfo);
14827 }
14828 }
14829#endif
14830#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14831 /* Fill in isFastTransitionEnabled */
14832 if (mac->roam.configParam.isFastTransitionEnabled
14833#ifdef FEATURE_WLAN_LFR
14834 || csrRoamIsFastRoamEnabled(mac, session_id)
14835#endif
14836 )
14837 {
14838 dw_tmp = pal_cpu_to_be32(TRUE);
14839 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14840 buf += sizeof(tAniBool);
14841 }
14842 else
14843 {
14844 dw_tmp = pal_cpu_to_be32(FALSE);
14845 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14846 buf += sizeof(tAniBool);
14847 }
14848#endif
14849#ifdef FEATURE_WLAN_LFR
14850 if(csrRoamIsFastRoamEnabled(mac, session_id))
14851 {
14852 /* legacy fast roaming enabled */
14853 dw_tmp = pal_cpu_to_be32(TRUE);
14854 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14855 buf += sizeof(tAniBool);
14856 }
14857 else
14858 {
14859 dw_tmp = pal_cpu_to_be32(FALSE);
14860 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14861 buf += sizeof(tAniBool);
14862 }
14863#endif
14864
14865 /* txLdpcIniFeatureEnabled */
14866 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14867 buf++;
14868
14869 if ((csrIs11hSupported(mac)) &&
14870 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14871 (ies->Country.present) &&\
14872 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14873 {
14874 csrSaveToChannelPower2G_5G(mac,
14875 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14876 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14877 csrApplyPower2Current(mac);
14878 }
14879
14880#ifdef WLAN_FEATURE_11AC
14881 /* txBFIniFeatureEnabled */
14882 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14883 buf++;
14884
14885 /* txBFCsnValue */
14886 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14887 {
14888 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14889 if (ies->VHTCaps.numSoundingDim)
14890 tx_bf_csn_value = CSR_ROAM_MIN
14891 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14892 }
14893 *buf = tx_bf_csn_value;
14894 buf++;
14895
14896 /* Only enable MuBf if no other MuBF session exist
14897 * and FW and HOST is MuBF capable.
14898 */
14899 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14900 {
14901 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14902 buf++;
14903 }
14904 else
14905 {
14906 *buf = 0;
14907 buf++;
14908 }
14909#endif
14910 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14911 buf++;
14912
14913 /* WME */
14914 if(mac->roam.roamSession[session_id].fWMMConnection)
14915 {
14916 /* WME enabled */
14917 dw_tmp = pal_cpu_to_be32(TRUE);
14918 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14919 buf += sizeof(tAniBool);
14920 }
14921 else
14922 {
14923 dw_tmp = pal_cpu_to_be32(FALSE);
14924 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14925 buf += sizeof(tAniBool);
14926 }
14927
14928 /* QOS */
14929 if(mac->roam.roamSession[session_id].fQOSConnection)
14930 {
14931 /* QOS enabled */
14932 dw_tmp = pal_cpu_to_be32(TRUE);
14933 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14934 buf += sizeof(tAniBool);
14935 }
14936 else
14937 {
14938 dw_tmp = pal_cpu_to_be32(FALSE);
14939 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14940 buf += sizeof(tAniBool);
14941 }
14942 /* BssDesc */
14943 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14944 (tANI_U8)profile->uapsd_mask);
14945 } while( 0 );
14946
14947 smsLog(mac, LOG1, FL("status %d"), status);
14948
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014949 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014950 return status;
14951}
14952#endif
14953
Jeff Johnson295189b2012-06-20 16:38:30 -070014954//
14955eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14956{
14957 eHalStatus status = eHAL_STATUS_SUCCESS;
14958 tSirSmeDisassocReq *pMsg;
14959 tANI_U8 *pBuf;
14960 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14962 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14963 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014965 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14966 if (NULL == pMsg)
14967 status = eHAL_STATUS_FAILURE;
14968 else
14969 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014971 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14973 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 pBuf = &pMsg->sessionId;
14975 // sessionId
14976 *pBuf++ = (tANI_U8)sessionId;
14977 // transactionId
14978 *pBuf = 0;
14979 *( pBuf + 1 ) = 0;
14980 pBuf += sizeof(tANI_U16);
14981
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014982 if ( (pSession->pCurRoamProfile != NULL) &&
14983 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14984 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 {
14986 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014987 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14988 sizeof( tSirMacAddr ));
14989 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014992 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14993 //perMacAddr is passed as bssId for softAP
14994 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 pBuf = pBuf + sizeof ( tSirMacAddr );
14996 }
14997 else
14998 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015000 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
15001 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053015003 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
15004 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 if(!HAL_STATUS_SUCCESS(status))
15008 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015009 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 break;
15011 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 // reasonCode
15013 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015014 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
15015 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 if(!HAL_STATUS_SUCCESS(status))
15017 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015018 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 break;
15020 }
15021 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015022 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
15023 Here we should not send the disassoc over the air to the AP */
15024 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
15025#ifdef WLAN_FEATURE_VOWIFI_11R
15026 && csrRoamIs11rAssoc(pMac)
15027#endif
15028 )
15029 {
15030 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
15031 }
15032 pBuf += sizeof(tANI_U8);
15033 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 return( status );
15036}
Jeff Johnson295189b2012-06-20 16:38:30 -070015037eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
15038{
15039 eHalStatus status = eHAL_STATUS_SUCCESS;
15040 tSirSmeTkipCntrMeasReq *pMsg;
15041 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015042 do
15043 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015044 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
15045 if ( NULL == pMsg )
15046 status = eHAL_STATUS_FAILURE;
15047 else
15048 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015050 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
15052 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 pBuf = &pMsg->sessionId;
15054 // sessionId
15055 *pBuf++ = (tANI_U8)sessionId;
15056 // transactionId
15057 *pBuf = 0;
15058 *( pBuf + 1 ) = 0;
15059 pBuf += sizeof(tANI_U16);
15060 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015061 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
15062 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015063 pBuf = pBuf + sizeof ( tSirMacAddr );
15064 // bEnable
15065 *pBuf = (tANI_BOOLEAN)bEnable;
15066 if(!HAL_STATUS_SUCCESS(status))
15067 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015068 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015069 break;
15070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015072 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 return( status );
15074}
Jeff Johnson295189b2012-06-20 16:38:30 -070015075eHalStatus
15076csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
15077 VOS_MODULE_ID modId, tSirMacAddr bssId,
15078 void *pUsrContext, void *pfnSapEventCallback,
15079 tANI_U8 *pAssocStasBuf )
15080{
15081 eHalStatus status = eHAL_STATUS_SUCCESS;
15082 tSirSmeGetAssocSTAsReq *pMsg;
15083 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15084 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015085 do
15086 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015087 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
15088 if ( NULL == pMsg )
15089 status = eHAL_STATUS_FAILURE;
15090 else
15091 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015093 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015094 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 pBuf = (tANI_U8 *)&pMsg->bssId;
15096 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015098 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 // modId
15101 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015102 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015104 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015105 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
15106 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015107 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015108 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
15109 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080015111 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
15112 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 status = palSendMBMessage( pMac->hHdd, pMsg );
15115 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015116 return( status );
15117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015118eHalStatus
15119csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
15120 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
15121 {
15122 eHalStatus status = eHAL_STATUS_SUCCESS;
15123 tSirSmeGetWPSPBCSessionsReq *pMsg;
15124 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080015125
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 do
15127 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015128 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
15129 if ( NULL == pMsg )
15130 status = eHAL_STATUS_FAILURE;
15131 else
15132 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015134 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070015137 VOS_ASSERT(pBuf);
15138
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015141 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15142 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015144 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15145 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015147 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015150 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 return( status );
15156}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015157
15158eHalStatus
15159csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15160{
15161 tpSirChangeBIParams pMsg;
15162 tANI_U16 len = 0;
15163 eHalStatus status = eHAL_STATUS_SUCCESS;
15164 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15165
15166 if(!pSession)
15167 {
15168 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15169 return eHAL_STATUS_FAILURE;
15170 }
15171
15172 //NO need to update the Beacon Params if update beacon parameter flag is not set
15173 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15174 return eHAL_STATUS_SUCCESS;
15175
15176 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15177
15178 /* Create the message and send to lim */
15179 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015180 pMsg = vos_mem_malloc(len);
15181 if ( NULL == pMsg )
15182 status = eHAL_STATUS_FAILURE;
15183 else
15184 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015185 if(HAL_STATUS_SUCCESS(status))
15186 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015187 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015188 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15189 pMsg->length = len;
15190
15191 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015192 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15193 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015194 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15195 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015196 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015197 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015198 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15199 status = palSendMBMessage(pMac->hHdd, pMsg);
15200 }
15201 return status;
15202}
15203
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015204#ifdef WLAN_FEATURE_AP_HT40_24G
15205eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15206{
15207 tpSirSetHT2040Mode pMsg;
15208 tANI_U16 len = 0;
15209 eHalStatus status = eHAL_STATUS_SUCCESS;
15210 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15211
15212 if(!pSession)
15213 {
15214 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15215 return eHAL_STATUS_FAILURE;
15216 }
15217
15218 /* Create the message and send to lim */
15219 len = sizeof(tSirSetHT2040Mode);
15220 pMsg = vos_mem_malloc(len);
15221
15222 if ( NULL == pMsg )
15223 {
15224 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15225 status = eHAL_STATUS_FAILURE;
15226 }
15227 else
15228 status = eHAL_STATUS_SUCCESS;
15229
15230 if(HAL_STATUS_SUCCESS(status))
15231 {
15232 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15233 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15234 pMsg->length = len;
15235
15236 // bssId
15237 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15238 sizeof(tSirMacAddr));
15239
15240 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15241 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15242 MAC_ADDR_ARRAY(pMsg->bssId));
15243
15244 pMsg->sessionId = sessionId;
15245 pMsg->cbMode = cbMode;
15246
15247 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15248 sessionId, cbMode);
15249
15250 status = palSendMBMessage(pMac->hHdd, pMsg);
15251 }
15252 return status;
15253}
15254#endif
15255
Jeff Johnson295189b2012-06-20 16:38:30 -070015256eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15257{
15258 eHalStatus status = eHAL_STATUS_SUCCESS;
15259 tSirSmeDeauthReq *pMsg;
15260 tANI_U8 *pBuf;
15261 tANI_U16 wTmp;
15262 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15263 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15264 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015266 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15267 if ( NULL == pMsg )
15268 status = eHAL_STATUS_FAILURE;
15269 else
15270 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015271 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015272 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15274 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15275 //sessionId
15276 pBuf = &pMsg->sessionId;
15277 *pBuf++ = (tANI_U8)sessionId;
15278
15279 //tansactionId
15280 *pBuf = 0;
15281 *(pBuf + 1 ) = 0;
15282 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15286 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015287 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15288 sizeof( pMsg->peerMacAddr ) );
15289 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 pBuf = pBuf + sizeof(tSirMacAddr);
15291 }
15292 else
15293 {
15294 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015295 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15296 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 }
15299 if(!HAL_STATUS_SUCCESS(status))
15300 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015301 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 break;
15303 }
15304 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015305 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15306 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 pBuf = pBuf + sizeof(tSirMacAddr);
15308 if(!HAL_STATUS_SUCCESS(status))
15309 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015310 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 break;
15312 }
15313 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015314 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15315 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 if(!HAL_STATUS_SUCCESS(status))
15317 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015318 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 break;
15320 }
15321 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015322 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 return( status );
15324}
15325
Jeff Johnson295189b2012-06-20 16:38:30 -070015326eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15327{
15328 eHalStatus status = eHAL_STATUS_SUCCESS;
15329 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015331 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15332 if ( NULL == pMsg )
15333 status = eHAL_STATUS_FAILURE;
15334 else
15335 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015337 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15339 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15340 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015341 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015342 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15343 sizeof(pMsg->peerMacAddr));
15344 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 if(!HAL_STATUS_SUCCESS(status))
15346 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015347 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 break;
15349 }
15350//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015351 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15352 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015353 if(!HAL_STATUS_SUCCESS(status))
15354 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015355 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 break;
15357 }
15358//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 return( status );
15362}
15363
Jeff Johnson295189b2012-06-20 16:38:30 -070015364eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15365{
15366 eHalStatus status = eHAL_STATUS_SUCCESS;
15367 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015369 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15370 if ( NULL == pMsg )
15371 status = eHAL_STATUS_FAILURE;
15372 else
15373 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015374 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015375 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15377 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15378 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015379 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015380 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15381 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 if(!HAL_STATUS_SUCCESS(status))
15383 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015384 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 break;
15386 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015387 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15388 sizeof(pMsg->peerMacAddr));
15389 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015390 if(!HAL_STATUS_SUCCESS(status))
15391 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015392 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 break;
15394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 return( status );
15398}
Jeff Johnson295189b2012-06-20 16:38:30 -070015399eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15400{
15401 eHalStatus status = eHAL_STATUS_SUCCESS;
15402 tSirSmeAssocCnf *pMsg;
15403 tANI_U8 *pBuf;
15404 tSirResultCodes statusCode;
15405 tANI_U16 wTmp;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015406 vos_msg_t msg;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015407
15408 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15409 "HalStatus : %d"),
15410 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015412 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15413 if ( NULL == pMsg )
15414 status = eHAL_STATUS_FAILURE;
15415 else
15416 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015418 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15420 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 pBuf = (tANI_U8 *)&pMsg->statusCode;
15422 if(HAL_STATUS_SUCCESS(Halstatus))
15423 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15424 else
15425 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015426 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015427 pBuf += sizeof(tSirResultCodes);
15428 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015429 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15430 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 pBuf += sizeof (tSirMacAddr);
15432 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015433 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15434 sizeof(tSirMacAddr));
15435 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 pBuf += sizeof (tSirMacAddr);
15437 // aid
15438 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015439 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 pBuf += sizeof (tANI_U16);
15441 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015442 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15443 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 pBuf += sizeof (tSirMacAddr);
15445 // alternateChannelId
15446 *pBuf = 11;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015447 msg.type = pMsg->messageType;
15448 msg.bodyval = 0;
15449 msg.bodyptr = pMsg;
15450 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 if(!HAL_STATUS_SUCCESS(status))
15452 {
15453 //pMsg is freed by palSendMBMessage
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015454 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 break;
15456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015458 return( status );
15459}
Jeff Johnson295189b2012-06-20 16:38:30 -070015460eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15461 tpSirSmeAssocInd pAssocInd,
15462 eHalStatus Halstatus,
15463 tANI_U8 sessionId)
15464{
15465 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15467 tANI_U8 *pBuf;
15468 tSirResultCodes statusCode;
15469 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015471 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15472 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15473 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015474
Jeff Johnson295189b2012-06-20 16:38:30 -070015475 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15476 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15477
15478 pMsg->sessionId = sessionId;
15479
15480 pBuf = (tANI_U8 *)&pMsg->statusCode;
15481 if(HAL_STATUS_SUCCESS(Halstatus))
15482 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15483 else
15484 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015485 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 pBuf += sizeof(tSirResultCodes);
15487 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015488 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 pBuf += sizeof (tSirMacAddr);
15490 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015491 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15492 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015493 pBuf += sizeof (tSirMacAddr);
15494 // StaId
15495 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015496 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 pBuf += sizeof (tANI_U16);
15498 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015499 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015500 pBuf += sizeof (tSirMacAddr);
15501 // alternateChannelId
15502 *pBuf = 11;
15503 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015504 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 //Wmm
15506 *pBuf = pAssocInd->wmmEnabledSta;
15507 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015508 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015509 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015510 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015512 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015513 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 //reassocReq
15515 *pBuf = pAssocInd->reassocReq;
15516 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015517#ifdef WLAN_FEATURE_AP_HT40_24G
15518 // 40 MHz Intolerant
15519 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15520 pBuf += sizeof (tANI_U8);
15521#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015522 *pBuf = pAssocInd->rate_flags;
15523 pBuf += sizeof (uint32_t);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053015524
15525 pBuf = (tANI_U8 *)&pMsg->chan_info;
15526 vos_mem_copy((void *)pBuf, &pAssocInd->chan_info,
15527 sizeof(tSirSmeChanInfo));
15528
15529 pBuf = (tANI_U8 *)&pMsg->ch_width;
15530 *pBuf = pAssocInd->ch_width;
15531
15532 if (pAssocInd->HTCaps.present) {
15533 pBuf = (tANI_U8 *)&pMsg->HTCaps;
15534 vos_mem_copy(pBuf, &pAssocInd->HTCaps, sizeof(pMsg->HTCaps));
15535 }
15536
15537 if (pAssocInd->VHTCaps.present) {
15538 pBuf = (tANI_U8 *)&pMsg->VHTCaps;
15539 vos_mem_copy(pBuf, &pAssocInd->VHTCaps, sizeof(pMsg->VHTCaps));
15540 }
15541
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15543 msgQ.bodyptr = pMsg;
15544 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015547 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015548}
Jeff Johnson295189b2012-06-20 16:38:30 -070015549
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015550eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15552 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15553 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15554 tANI_U8 *pKeyRsc )
15555{
15556 tSirSmeSetContextReq *pMsg;
15557 tANI_U16 msgLen;
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015558 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 tAniEdType tmpEdType;
15560 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015561 tANI_U8 *pBuf = NULL;
15562 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015563 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015564 vos_msg_t msg;
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015565 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15566 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015568 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15570 // key set. Since we only support upto one key, we always allocate memory for 1 key
15571 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15572 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15573 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15574 ( sizeof( pMsg->keyMaterial.key ) );
15575
Kiet Lam64c1b492013-07-12 13:56:44 +053015576 pMsg = vos_mem_malloc(msgLen);
15577 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15578 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15580 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015581 //sessionId
15582 pBuf = &pMsg->sessionId;
15583 *pBuf = (tANI_U8)sessionId;
15584 pBuf++;
15585 // transactionId
15586 *pBuf = 0;
15587 *(pBuf + 1) = 0;
15588 pBuf += sizeof(tANI_U16);
15589 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015590 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015591
15592 pBuf += sizeof(tSirMacAddr);
15593
15594 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015595 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15596 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015597
15598 pBuf += sizeof(tSirMacAddr);
15599
15600 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15602 // in the tSirKeyMaterial keyMaterial; field).
15603 //
15604 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15605 // shorter than this max size. Is LIM interpreting this ok ?
15606 p = pal_set_U16( p, pal_cpu_to_be16((tANI_U16)( sizeof( pMsg->keyMaterial.numKeys ) + ( numKeys * sizeof( pMsg->keyMaterial.key ) ) )) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 // set pMsg->keyMaterial.edType
15608 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015609 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015610 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 // set the pMsg->keyMaterial.numKeys field
15612 *p = numKeys;
15613 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 // set pSirKey->keyId = keyId;
15615 *p = keyId;
15616 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 // set pSirKey->unicast = (tANI_U8)fUnicast;
15618 *p = (tANI_U8)fUnicast;
15619 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 // set pSirKey->keyDirection = aniKeyDirection;
15621 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015622 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015623 p += sizeof(tAniKeyDirection);
15624 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015625 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 // set pSirKey->paeRole
15628 *p = paeRole; // 0 is Supplicant
15629 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015630 // set pSirKey->keyLength = keyLength;
15631 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015632 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015633 vos_mem_copy(p, pKey, keyLength);
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015634 msg.type = pMsg->messageType;
15635 msg.bodyptr = pMsg;
15636 msg.bodyval = 0;
15637 if (fUnicast)
15638 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
15639 else
15640 status = vos_mq_post_message(VOS_MQ_ID_PE, &msg);
15641 if (!VOS_IS_STATUS_SUCCESS(status)) {
15642 vos_mem_free(pMsg);
15643 return eHAL_STATUS_FAILURE;
15644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015645 } while( 0 );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015646 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015647}
15648
Jeff Johnson295189b2012-06-20 16:38:30 -070015649eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15650 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15651{
15652 eHalStatus status;
15653 tSirSmeStartBssReq *pMsg;
15654 tANI_U8 *pBuf = NULL;
15655 tANI_U8 *wTmpBuf = NULL;
15656 tANI_U16 msgLen, wTmp;
15657 tANI_U32 dwTmp;
15658 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015659 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015660 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015661 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015662
15663 if(!pSession)
15664 {
15665 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15666 return eHAL_STATUS_FAILURE;
15667 }
15668
Jeff Johnson295189b2012-06-20 16:38:30 -070015669 do {
15670 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15671 pSession->joinFailStatusCode.reasonCode = 0;
15672 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015673 pMsg = vos_mem_malloc(msgLen);
15674 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15675 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015676 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 //sessionId
15680 *pBuf = (tANI_U8)sessionId;
15681 pBuf++;
15682 // transactionId
15683 *pBuf = 0;
15684 *(pBuf + 1) = 0;
15685 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015687 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 pBuf += sizeof(tSirMacAddr);
15689 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015690 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015691 pBuf += sizeof(tSirMacAddr);
15692 // beaconInterval
15693 if( pBssDesc && pBssDesc->beaconInterval )
15694 {
15695 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015697 else if(pParam->beaconInterval)
15698 {
15699 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015701 else
15702 {
15703 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15704 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015705 if(csrIsconcurrentsessionValid (pMac, sessionId,
15706 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015707 == eHAL_STATUS_SUCCESS )
15708 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015709 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015710 pParam->bssPersona);
15711 //Update the beacon Interval
15712 pParam->beaconInterval = wTmp;
15713 }
15714 else
15715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015716 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015717 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015718 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015719 return status;
15720 }
15721
Kiet Lam64c1b492013-07-12 13:56:44 +053015722 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015723 pBuf += sizeof(tANI_U16);
15724 // dot11mode
15725 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15726 pBuf += 1;
15727 // bssType
15728 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015729 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015730 pBuf += sizeof(tSirBssType);
15731 // ssId
15732 if( pParam->ssId.length )
15733 {
15734 // ssId len
15735 *pBuf = pParam->ssId.length;
15736 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015737 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015738 pBuf += pParam->ssId.length;
15739 }
15740 else
15741 {
15742 *pBuf = 0;
15743 pBuf++;
15744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015745 // set the channel Id
15746 *pBuf = pParam->operationChn;
15747 pBuf++;
15748 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015749 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015750 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015751 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015752
Jeff Johnson295189b2012-06-20 16:38:30 -070015753 // Set privacy
15754 *pBuf = pParam->privacy;
15755 pBuf++;
15756
15757 //Set Uapsd
15758 *pBuf = pParam->ApUapsdEnable;
15759 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015760 //Set SSID hidden
15761 *pBuf = pParam->ssidHidden;
15762 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015763 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15764 pBuf++;
15765
15766 //Ht protection Enable/Disable
15767 *pBuf = (tANI_U8)pParam->protEnabled;
15768 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015769 //Enable Beacons to Receive for OBSS protection Enable/Disable
15770 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15771 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015772 //set cfg related to protection
15773 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015774 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015775 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 // Set Auth type
15777 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015778 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 // Set DTIM
15781 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015782 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 // Set wps_state
15785 *pBuf = pParam->wps_state;
15786 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015787 // set isCoalesingInIBSSAllowed
15788 *pBuf = pMac->isCoalesingInIBSSAllowed;
15789 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015790 //Persona
15791 *pBuf = (tANI_U8)pParam->bssPersona;
15792 pBuf++;
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053015793
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015794 //txLdpcIniFeatureEnabled
15795 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15796 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015797
Chet Lanctot8cecea22014-02-11 19:09:36 -080015798#ifdef WLAN_FEATURE_11W
15799 // Set MFP capable/required
15800 *pBuf = (tANI_U8)pParam->mfpCapable;
15801 pBuf++;
15802 *pBuf = (tANI_U8)pParam->mfpRequired;
15803 pBuf++;
15804#endif
15805
krunal soni4f087d22013-07-29 16:32:26 -070015806 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015807 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15808 {
15809 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015810 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015811 break;
15812 }
15813 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015814 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 pBuf += sizeof(tANI_U16);
15816 if( wTmp )
15817 {
15818 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015819 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 pBuf += wTmp;
15821 }
15822 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015823 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015825 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15826 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015827 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15828 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015829 pBuf += pParam->operationalRateSet.numRates ;
15830 *pBuf++ = pParam->extendedRateSet.numRates;
15831 if(0 != pParam->extendedRateSet.numRates)
15832 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015833 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15834 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015835 pBuf += pParam->extendedRateSet.numRates;
15836 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015837#ifdef WLAN_FEATURE_AP_HT40_24G
15838 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15839#endif
krunal sonie9002db2013-11-25 14:24:17 -080015840
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15842 pMsg->length = pal_cpu_to_be16(msgLen);
15843
15844 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015845 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015846 return( status );
15847}
15848
Jeff Johnson295189b2012-06-20 16:38:30 -070015849eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15850{
15851 eHalStatus status = eHAL_STATUS_FAILURE;
15852 tSirSmeStopBssReq *pMsg;
15853 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15854 tANI_U8 *pBuf;
15855 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015856
15857 if(!pSession)
15858 {
15859 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15860 return eHAL_STATUS_FAILURE;
15861 }
15862
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015863 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15864 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15865 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15866 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15867 pBuf = &pMsg->sessionId;
15868 //sessionId
15869 *pBuf = (tANI_U8)sessionId;
15870 pBuf++;
15871 // transactionId
15872 *pBuf = 0;
15873 pBuf += sizeof(tANI_U16);
15874 //reason code
15875 *pBuf = 0;
15876 pBuf += sizeof(tSirResultCodes);
15877 // bssid
15878 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15879 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15880 {
15881 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15882 sizeof(tSirMacAddr));
15883 }
15884 else
15885 {
15886 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15887 sizeof(tSirMacAddr));
15888 }
15889 pBuf += sizeof(tSirMacAddr);
15890 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15891 pMsg->length = pal_cpu_to_be16(msgLen);
15892 status = palSendMBMessage( pMac->hHdd, pMsg );
15893
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 return( status );
15895}
15896
Jeff Johnson295189b2012-06-20 16:38:30 -070015897eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15898 tCsrRoamModifyProfileFields *pModProfileFields,
15899 tANI_U32 *pRoamId, v_BOOL_t fForce)
15900{
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 eHalStatus status = eHAL_STATUS_FAILURE;
15902 tANI_U32 roamId = 0;
15903 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015905 (fForce || (!vos_mem_compare( &pModProfileFields,
15906 &pSession->connectedProfile.modifyProfileFields,
15907 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015908 {
15909 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15910 if(pRoamId)
15911 {
15912 *pRoamId = roamId;
15913 }
15914
Jeff Johnson295189b2012-06-20 16:38:30 -070015915 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15916 eCsrSmeIssuedReassocToSameAP, roamId,
15917 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 return status;
15920}
Jeff Johnson295189b2012-06-20 16:38:30 -070015921static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15922{
15923 eHalStatus status = eHAL_STATUS_SUCCESS;
15924 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015925 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015926 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15927 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15928 return (status);
15929}
Jeff Johnson295189b2012-06-20 16:38:30 -070015930eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15931{
15932 eHalStatus status = eHAL_STATUS_SUCCESS;
15933 tListElem *pEntry = NULL;
15934 tSmeCmd *pCommand = NULL;
15935 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015936 do
15937 {
15938 if(pMsg == NULL)
15939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015940 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 status = eHAL_STATUS_FAILURE;
15942 break;
15943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015944 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15945 if(pEntry)
15946 {
15947 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15948 if(eSmeCommandAddStaSession == pCommand->command)
15949 {
15950 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015951 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015952 if (pRsp->status == eSIR_FAILURE) {
15953 VOS_ASSERT( 0 );
15954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015955 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015956 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 //Remove this command out of the active list
15958 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15959 {
15960 //Now put this command back on the avilable command list
15961 csrReleaseCommand(pMac, pCommand);
15962 }
15963 smeProcessPendingQueue( pMac );
15964 }
15965 else
15966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015967 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015968 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 status = eHAL_STATUS_FAILURE;
15970 break;
15971 }
15972 }
15973 else
15974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015975 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070015976 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 status = eHAL_STATUS_FAILURE;
15978 break;
15979 }
15980 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015981 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015982}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015983eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15984 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015985{
15986 tSirSmeAddStaSelfReq *pMsg;
15987 tANI_U16 msgLen;
15988 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015990 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015991 pMsg = vos_mem_malloc(msgLen);
15992 if ( NULL == pMsg ) break;
15993 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015994 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15995 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015996 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015997 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015998 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
15999
16000 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
16001
Arif Hussain24bafea2013-11-15 15:10:03 -080016002 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
16003 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016005 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016006 return( status );
16007}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016008eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
16009 tANI_U32 sessionId,
16010 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070016011{
16012 eHalStatus status = eHAL_STATUS_SUCCESS;
16013 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016014 pCommand = csrGetCommandBuffer(pMac);
16015 if(NULL == pCommand)
16016 {
16017 status = eHAL_STATUS_RESOURCES;
16018 }
16019 else
16020 {
16021 pCommand->command = eSmeCommandAddStaSession;
16022 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053016023 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
16024 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016025 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070016026 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
16027 if( !HAL_STATUS_SUCCESS( status ) )
16028 {
16029 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016030 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016031 }
16032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 return (status);
16034}
Jeff Johnson295189b2012-06-20 16:38:30 -070016035eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16036{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016037 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070016038}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016039eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
16040 csrRoamCompleteCallback callback,
16041 void *pContext, tANI_U8 *pSelfMacAddr,
16042 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070016043{
16044 eHalStatus status = eHAL_STATUS_SUCCESS;
16045 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053016046 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016047 *pbSessionId = CSR_SESSION_ID_INVALID;
16048 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16049 {
16050 if( !CSR_IS_SESSION_VALID( pMac, i ) )
16051 {
16052 pSession = CSR_GET_SESSION( pMac, i );
16053 status = eHAL_STATUS_SUCCESS;
16054 pSession->sessionActive = eANI_BOOLEAN_TRUE;
16055 pSession->sessionId = (tANI_U8)i;
16056 pSession->callback = callback;
16057 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016058 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016059 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016060 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
16061 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070016062 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016063 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016065 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 break;
16067 }
16068#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016069 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
16070 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016072 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016074 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016075 break;
16076 }
16077#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016078 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016079 break;
16080 }
16081 }
16082 if( CSR_ROAM_SESSION_MAX == i )
16083 {
16084 //No session is available
16085 status = eHAL_STATUS_RESOURCES;
16086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 return ( status );
16088}
Jeff Johnson295189b2012-06-20 16:38:30 -070016089eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
16090{
16091 eHalStatus status = eHAL_STATUS_SUCCESS;
16092 tListElem *pEntry = NULL;
16093 tSmeCmd *pCommand = NULL;
16094 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070016095 do
16096 {
16097 if(pMsg == NULL)
16098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016099 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016100 status = eHAL_STATUS_FAILURE;
16101 break;
16102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
16104 if(pEntry)
16105 {
16106 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16107 if(eSmeCommandDelStaSession == pCommand->command)
16108 {
16109 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016110 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016111 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016112 //This session is done.
16113 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016114 if(pCommand->u.delStaSessionCmd.callback)
16115 {
16116
16117 status = sme_ReleaseGlobalLock( &pMac->sme );
16118 if ( HAL_STATUS_SUCCESS( status ) )
16119 {
16120 pCommand->u.delStaSessionCmd.callback(
16121 pCommand->u.delStaSessionCmd.pContext);
16122 status = sme_AcquireGlobalLock( &pMac->sme );
16123 if (! HAL_STATUS_SUCCESS( status ) )
16124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016125 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016126 return status;
16127 }
16128 }
16129 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016130 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016131 }
16132 }
16133
16134 //Remove this command out of the active list
16135 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
16136 {
16137 //Now put this command back on the avilable command list
16138 csrReleaseCommand(pMac, pCommand);
16139 }
16140 smeProcessPendingQueue( pMac );
16141 }
16142 else
16143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016144 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016145 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016146 status = eHAL_STATUS_FAILURE;
16147 break;
16148 }
16149 }
16150 else
16151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016152 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070016153 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016154 status = eHAL_STATUS_FAILURE;
16155 break;
16156 }
16157 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016158 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016159}
Jeff Johnson295189b2012-06-20 16:38:30 -070016160eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16161{
16162 tSirSmeDelStaSelfReq *pMsg;
16163 tANI_U16 msgLen;
16164 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016166 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16167 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016168 pMsg = vos_mem_malloc(msgLen);
16169 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16170 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016171 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16172 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016173 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016174 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16175 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016176 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016177 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016178 return( status );
16179}
Jeff Johnson295189b2012-06-20 16:38:30 -070016180eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016181 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016182 tSirMacAddr sessionMacAddr,
16183 csrRoamSessionCloseCallback callback,
16184 void *pContext)
16185{
16186 eHalStatus status = eHAL_STATUS_SUCCESS;
16187 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016188 pCommand = csrGetCommandBuffer(pMac);
16189 if(NULL == pCommand)
16190 {
16191 status = eHAL_STATUS_RESOURCES;
16192 }
16193 else
16194 {
16195 pCommand->command = eSmeCommandDelStaSession;
16196 pCommand->sessionId = (tANI_U8)sessionId;
16197 pCommand->u.delStaSessionCmd.callback = callback;
16198 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016199 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16200 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016201 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016202 if( !HAL_STATUS_SUCCESS( status ) )
16203 {
16204 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016205 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016206 }
16207 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016208 return (status);
16209}
Jeff Johnson295189b2012-06-20 16:38:30 -070016210eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16211{
16212 return csrSendMBDelSelfStaReqMsg( pMac,
16213 pCommand->u.delStaSessionCmd.selfMacAddr );
16214}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016215static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16216 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016217{
16218 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16219 tListElem *pEntry, *pNext;
16220 tSmeCmd *pCommand;
16221 tDblLinkList localList;
16222
16223 vos_mem_zero(&localList, sizeof(tDblLinkList));
16224 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16225 {
16226 smsLog(pMac, LOGE, FL(" failed to open list"));
16227 return;
16228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016229 csrLLLock(pList);
16230 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16231 while(pEntry != NULL)
16232 {
16233 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16234 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016235
16236 if (!flush_all &&
16237 csr_is_disconnect_full_power_cmd(pCommand)) {
16238 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16239 pEntry = pNext;
16240 continue;
16241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016242 if(pCommand->sessionId == sessionId)
16243 {
16244 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16245 {
16246 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16247 }
16248 }
16249 pEntry = pNext;
16250 }
16251 csrLLUnlock(pList);
16252
16253 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16254 {
16255 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16256 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16257 }
16258 csrLLClose(&localList);
16259}
16260
Jeff Johnson295189b2012-06-20 16:38:30 -070016261void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16262{
16263 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16264 {
16265 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016266 csrRoamStop(pMac, sessionId);
16267 csrFreeConnectBssDesc(pMac, sessionId);
16268 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16269 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016270 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016271#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016272 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016273#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016274 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016275 csrInitSession(pMac, sessionId);
16276 }
16277}
16278
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016279void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16280 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016281{
16282 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016283 &pMac->sme.smeCmdPendingList,
16284 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016285 if (pMac->fScanOffload)
16286 {
16287 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016288 &pMac->sme.smeScanCmdPendingList,
16289 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016290 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016291 purgeCsrSessionCmdList(pMac, sessionId,
16292 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016293}
16294
Jeff Johnson295189b2012-06-20 16:38:30 -070016295eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016296 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016297 csrRoamSessionCloseCallback callback,
16298 void *pContext )
16299{
16300 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016301 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16302 {
16303 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16304 if(fSync)
16305 {
16306 csrCleanupSession(pMac, sessionId);
16307 }
16308 else
mukul sharmabab477d2015-06-11 17:14:55 +053016309 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016310 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016311 /* If bPurgeList is FALSE, it means HDD already free all the
16312 * cmd and later queue few essential cmd. Now sme should process
16313 * the cmd in pending queue order only.Hence we should
16314 * avoid DEL_SELF_STA as high priority cmd.
16315 */
16316 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016317 pSession->selfMacAddr, callback, pContext);
16318 }
16319 }
16320 else
16321 {
16322 status = eHAL_STATUS_INVALID_PARAMETER;
16323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016324 return ( status );
16325}
16326
Jeff Johnson295189b2012-06-20 16:38:30 -070016327static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16328{
16329 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016330
16331 if(!pSession)
16332 {
16333 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16334 return;
16335 }
16336
Jeff Johnson295189b2012-06-20 16:38:30 -070016337 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16338 pSession->sessionId = CSR_SESSION_ID_INVALID;
16339 pSession->callback = NULL;
16340 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016341 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16342 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16343 csrFreeRoamProfile( pMac, sessionId );
16344 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16345 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16346 csrFreeConnectBssDesc(pMac, sessionId);
16347 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016348 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16349 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016350 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016351 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016352 pSession->pWpaRsnReqIE = NULL;
16353 }
16354 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016355 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016356 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016357 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016358 pSession->pWpaRsnRspIE = NULL;
16359 }
16360 pSession->nWpaRsnRspIeLength = 0;
16361#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016362 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016363 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016364 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 pSession->pWapiReqIE = NULL;
16366 }
16367 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016368 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016370 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016371 pSession->pWapiRspIE = NULL;
16372 }
16373 pSession->nWapiRspIeLength = 0;
16374#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016375 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016377 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016378 }
16379 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016380
Kiet Lam64c1b492013-07-12 13:56:44 +053016381 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016382 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016383 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016384 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016386 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016387}
16388
Jeff Johnson295189b2012-06-20 16:38:30 -070016389eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16390{
16391 eHalStatus status = eHAL_STATUS_FAILURE;
16392 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016393 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16394 {
16395 if( CSR_IS_SESSION_VALID( pMac, i ) )
16396 {
16397 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16398 {
16399 //Found it
16400 status = eHAL_STATUS_SUCCESS;
16401 *pSessionId = i;
16402 break;
16403 }
16404 }
16405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 return( status );
16407}
16408
Jeff Johnson295189b2012-06-20 16:38:30 -070016409//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16410//session because for IBSS, the bssid changes.
16411static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16412{
16413 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16414 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016415 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16416 {
16417 if( CSR_IS_SESSION_VALID( pMac, i ) )
16418 {
16419 pSession = CSR_GET_SESSION( pMac, i );
16420 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16421 {
16422 //Found it
16423 nRet = i;
16424 break;
16425 }
16426 }
16427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016428 return (nRet);
16429}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016430void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016431{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016432 VOS_STATUS status = VOS_STATUS_SUCCESS;
16433
16434 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 profile info from pmac global structure */
16436
Arif Hussain24bafea2013-11-15 15:10:03 -080016437 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16438 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 /* Check for user misconfig of RSSI trigger threshold */
16440 pMac->roam.configParam.vccRssiThreshold =
16441 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16442 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16443 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016444 /* Check for user misconfig of UL MAC Loss trigger threshold */
16445 pMac->roam.configParam.vccUlMacLossThreshold =
16446 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16447 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016448#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16449 {
16450 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016451 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 /* Indicate the neighbor roal algorithm about the connect indication */
16453 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16454 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016455
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016456 /* Making sure we are roaming force fully to 5GHz AP only once and
16457 * only when we connected to 2.4GH AP only during initial association.
16458 */
16459 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16460 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16461 SIR_BAND_2_4_GHZ)
16462 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016463 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016464 status = vos_timer_start(
16465 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16466 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016467 if ( status != VOS_STATUS_SUCCESS )
16468 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016469 smsLog(pMac, LOGE,
16470 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16471 status);
16472 //Send RSO start because in case 5G roaming
16473 //host have not enabled at initial connection
16474 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016475 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016476 else
16477 {
16478 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16479 __func__);
16480 }
16481 }
16482 /*
16483 * Making ini value to false here only so we just roam to
16484 * only once for whole driver load to unload tenure
16485 * This feature is only applicable for first connection only
16486 */
16487 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16488 {
16489 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16490 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016492 }
16493#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016494}
16495
Jeff Johnson295189b2012-06-20 16:38:30 -070016496static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16497{
16498 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016499
16500 if(!pSession)
16501 {
16502 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16503 return;
16504 }
16505
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 //Only to handle the case for Handover on infra link
16507 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16508 {
16509 return;
16510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016511 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16512 csrRoamDeregStatisticsReq(pMac);
16513 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16514#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16515 /* Indicate the neighbor roal algorithm about the disconnect indication */
16516 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16517#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016518
16519 //Remove this code once SLM_Sessionization is supported
16520 //BMPS_WORKAROUND_NOT_NEEDED
16521 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016522 csrIsInfraApStarted( pMac ) &&
16523 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016524 {
16525 pMac->roam.configParam.doBMPSWorkaround = 0;
16526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016527}
16528
Jeff Johnson295189b2012-06-20 16:38:30 -070016529void csrRoamTlStatsTimerHandler(void *pv)
16530{
16531 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16532 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16534
Jeff Johnsone7245742012-09-05 17:12:55 -070016535 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16536
Jeff Johnson295189b2012-06-20 16:38:30 -070016537#if 0
16538 // TODO Persession .???
16539 //req TL for stats
16540 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016542 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016543 }
16544 else
16545 {
16546 //save in SME
16547 csrRoamSaveStatsFromTl(pMac, tlStats);
16548 }
16549#endif
16550 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16551 {
16552 if(pMac->roam.tlStatsReqInfo.periodicity)
16553 {
16554 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016555 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16556 pMac->roam.tlStatsReqInfo.periodicity);
16557 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016559 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016560 return;
16561 }
16562 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16563 }
16564 }
16565}
Jeff Johnson295189b2012-06-20 16:38:30 -070016566void csrRoamPeStatsTimerHandler(void *pv)
16567{
16568 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16569 eHalStatus status;
16570 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16571 VOS_STATUS vosStatus;
16572 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 pPeStatsReqListEntry->timerRunning = FALSE;
16574 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16575 {
16576 // If we entered here, meaning the timer could not be successfully
16577 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16578
16579 /* Destroy the timer */
16580 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16581 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016583 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 }
16585
16586 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016587 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016588 pPeStatsReqListEntry = NULL;
16589 }
16590 else
16591 {
16592 if(!pPeStatsReqListEntry->rspPending)
16593 {
16594 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16595 pPeStatsReqListEntry->staId);
16596 if(!HAL_STATUS_SUCCESS(status))
16597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016598 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016599 }
16600 else
16601 {
16602 pPeStatsReqListEntry->rspPending = TRUE;
16603 }
16604 }
16605
16606 //send down a req
16607 if(pPeStatsReqListEntry->periodicity &&
16608 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16609 {
16610 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16611 if(ePMC_FULL_POWER == powerState)
16612 {
16613 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16614 {
16615 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16616 }
16617 }
16618 else
16619 {
16620 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16621 {
16622 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16623 }
16624 }
16625 //start timer
16626 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16627 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016629 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016630 return;
16631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016632 pPeStatsReqListEntry->timerRunning = TRUE;
16633
16634 }
16635
16636 }
16637}
Jeff Johnson295189b2012-06-20 16:38:30 -070016638void csrRoamStatsClientTimerHandler(void *pv)
16639{
16640 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16642 {
16643#if 0
16644 // TODO Stats fix for multisession
16645 //start the timer
16646 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16647
16648 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016650 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016651 }
16652#endif
16653 }
16654#if 0
16655 //send up the stats report
16656 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16657 pStaEntry->staId, pStaEntry->pContext);
16658#endif
16659}
16660
16661
16662
Jeff Johnson295189b2012-06-20 16:38:30 -070016663eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16664{
16665 tAniGetPEStatsReq *pMsg;
16666 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016667 tSirMsgQ msgQ;
16668
Kiet Lam64c1b492013-07-12 13:56:44 +053016669 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16670 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016671 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016672 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016673 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016674 }
16675 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016676 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16678 pMsg->staId = staId;
16679 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016680
16681 msgQ.type = WDA_GET_STATISTICS_REQ;
16682 msgQ.reserved = 0;
16683 msgQ.bodyptr = pMsg;
16684 msgQ.bodyval = 0;
16685 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016686 if(!HAL_STATUS_SUCCESS(status))
16687 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016688 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016689 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016690 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016691 return status;
16692}
Jeff Johnson295189b2012-06-20 16:38:30 -070016693void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16694{
16695 tAniGetPEStatsRsp *pSmeStatsRsp;
16696 eHalStatus status = eHAL_STATUS_FAILURE;
16697 tListElem *pEntry = NULL;
16698 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16699 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16700 tANI_U32 tempMask = 0;
16701 tANI_U8 counter = 0;
16702 tANI_U8 *pStats = NULL;
16703 tANI_U32 length = 0;
16704 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016705 v_S7_t rssi = 0, snr = 0;
16706 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016707 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016708 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016709 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16710 if(pSmeStatsRsp->rc)
16711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016712 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016713 goto post_update;
16714 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016715 tempMask = pSmeStatsRsp->statsMask;
16716 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016717 /* subtract all statistics from this length, and after processing the entire
16718 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16719 * in this 'stats' message.
16720 */
16721 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016722 //new stats info from PE, fill up the stats strucutres in PMAC
16723 while(tempMask)
16724 {
16725 if(tempMask & 1)
16726 {
16727 switch(counter)
16728 {
16729 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016730 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016731 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16732 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016733 pStats += sizeof(tCsrSummaryStatsInfo);
16734 length -= sizeof(tCsrSummaryStatsInfo);
16735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016737 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016738 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16739 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16741 length -= sizeof(tCsrGlobalClassAStatsInfo);
16742 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016743 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016744 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016745 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16746 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16748 length -= sizeof(tCsrGlobalClassBStatsInfo);
16749 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016750 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016751 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016752 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16753 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16755 length -= sizeof(tCsrGlobalClassCStatsInfo);
16756 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016757 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016758 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016759 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16760 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016761 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016762 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16763 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 }
16765 else
16766 {
16767 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016768 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 VOS_ASSERT( 0 );
16770 }
16771 if(!HAL_STATUS_SUCCESS(status))
16772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016773 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016774 }
16775 pStats += sizeof(tCsrPerStaStatsInfo);
16776 length -= sizeof(tCsrPerStaStatsInfo);
16777 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016778 case eCsrPerPktStats:
16779 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16780 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16781 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16782 {
16783 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16784 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16785 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016786 /* for reserved bytes */
16787 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16788 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016789 }
16790 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016791 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016792 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016793 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 }
16795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 tempMask >>=1;
16797 counter++;
16798 }
16799 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16800 if (length != 0)
16801 {
16802 pRssi = (tANI_U32*)pStats;
16803 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016804 pStats += sizeof(tANI_U32);
16805 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 }
16807 else
16808 {
16809 /* If riva is not sending rssi, continue to use the hack */
16810 rssi = RSSI_HACK_BMPS;
16811 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016812 /* send positive value of rssi to wifi_hal */
16813 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016814 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016815 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016816
16817 if (length != 0)
16818 {
16819 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016820 pStats += sizeof(tANI_U32);
16821 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016822 }
16823 else
16824 {
16825 linkCapacity = 0;
16826 }
16827
16828 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016829
16830 if (length != 0)
16831 {
16832 pSnr = (tANI_U32*)pStats;
16833 snr = (v_S7_t)*pSnr;
16834 }
16835 else
16836 {
16837 snr = SNR_HACK_BMPS;
16838 }
16839
16840 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016841post_update:
16842 //make sure to update the pe stats req list
16843 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16844 if(pEntry)
16845 {
16846 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16847 pPeStaEntry->rspPending = FALSE;
16848
16849 }
16850 //check the one timer cases
16851 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16852 if(pEntry)
16853 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016854 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 if(pTempStaEntry->timerExpired)
16856 {
16857 //send up the stats report
16858 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16859 pTempStaEntry->staId, pTempStaEntry->pContext);
16860 //also remove from the client list
16861 csrRoamRemoveStatListEntry(pMac, pEntry);
16862 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016863 }
16864 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016865}
Jeff Johnson295189b2012-06-20 16:38:30 -070016866tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16867{
16868 tListElem *pEntry = NULL;
16869 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 if(!pEntry)
16872 {
16873 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016874 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 return NULL;
16876 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 while( pEntry )
16878 {
16879 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016880 if(pTempStaEntry->statsMask == statsMask)
16881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016882 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 break;
16884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 return pEntry;
16888}
16889
Jeff Johnson295189b2012-06-20 16:38:30 -070016890tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16891 tANI_BOOLEAN update)
16892{
16893 tListElem *pEntry;
16894 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 if(!pEntry)
16897 {
16898 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016899 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016900 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 return NULL;
16902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 while( pEntry )
16904 {
16905 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016906 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16907 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016909 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016910 if(update)
16911 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016912 pTempStaEntry->periodicity = pStaEntry->periodicity;
16913 pTempStaEntry->callback = pStaEntry->callback;
16914 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 }
16916 break;
16917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016918 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 return pEntry;
16921}
Jeff Johnson295189b2012-06-20 16:38:30 -070016922tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16923{
16924 tListElem *pEntry;
16925 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016926 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 if(!pEntry)
16928 {
16929 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016930 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016931 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016932 return NULL;
16933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016934 while( pEntry )
16935 {
16936 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016937 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016939 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016940 break;
16941 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016942 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016944 return pEntry;
16945}
Jeff Johnson295189b2012-06-20 16:38:30 -070016946eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16947 csrRoamLinkQualityIndCallback callback,
16948 void *pContext)
16949{
16950 pMac->roam.linkQualityIndInfo.callback = callback;
16951 pMac->roam.linkQualityIndInfo.context = pContext;
16952 if( NULL == callback )
16953 {
16954 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16955 }
16956 else
16957 {
16958 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016959 /* do we need to invoke the callback to notify client of initial value ?? */
16960 }
16961 return eHAL_STATUS_SUCCESS;
16962}
Jeff Johnson295189b2012-06-20 16:38:30 -070016963void csrRoamVccTrigger(tpAniSirGlobal pMac)
16964{
16965 eCsrRoamLinkQualityInd newVccLinkQuality;
16966 tANI_U32 ul_mac_loss = 0;
16967 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016968 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16969 /*-------------------------------------------------------------------------
16970 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016971 Check for a change in link quality and notify client if necessary
16972 -------------------------------------------------------------------------*/
16973 ul_mac_loss_trigger_threshold =
16974 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016975 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016976 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016977 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016980 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016981 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16982 }
16983 else
16984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016985 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016986 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016988 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16989 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016990 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016992 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016993 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016995 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016996 newVccLinkQuality );
16997
16998 /* we now invoke the callback once to notify client of initial value */
16999 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
17000 pMac->roam.linkQualityIndInfo.context );
17001 //event: EVENT_WLAN_VCC
17002 }
17003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017004 pMac->roam.vccLinkQuality = newVccLinkQuality;
17005
Jeff Johnson295189b2012-06-20 16:38:30 -070017006}
Jeff Johnson295189b2012-06-20 16:38:30 -070017007VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
17008 v_U8_t rssiNotification,
17009 void * context)
17010{
17011 tpAniSirGlobal pMac = PMAC_STRUCT( context );
17012 eCsrRoamLinkQualityInd newVccLinkQuality;
17013 // TODO : Session info unavailable
17014 tANI_U32 sessionId = 0;
17015 VOS_STATUS status = VOS_STATUS_SUCCESS;
17016 /*-------------------------------------------------------------------------
17017 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070017018 Check for a change in link quality and notify client if necessary
17019 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017020 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017021 pMac->roam.configParam.vccRssiThreshold);
17022 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
17023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017024 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070017025 return VOS_STATUS_SUCCESS;
17026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017027 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
17028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017029 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070017030 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
17031 }
17032 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
17033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017034 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070017035 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
17036 }
17037 else
17038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017039 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070017040 //Set to this so the code below won't do anything
17041 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 VOS_ASSERT(0);
17043 }
17044
Jeff Johnson295189b2012-06-20 16:38:30 -070017045 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
17046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017047 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070017048 if(NULL != pMac->roam.linkQualityIndInfo.callback)
17049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017050 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017051 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070017052 /* we now invoke the callback once to notify client of initial value */
17053 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
17054 pMac->roam.linkQualityIndInfo.context );
17055 //event: EVENT_WLAN_VCC
17056 }
17057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017058 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 return status;
17060}
Jeff Johnson295189b2012-06-20 16:38:30 -070017061tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
17062 tDblLinkList *pStaList,
17063 tCsrStatsClientReqInfo *pStaEntry)
17064{
17065 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017066 //if same entity requested for same set of stats with different periodicity &
17067 // callback update it
17068 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
17069 {
17070
Kiet Lam64c1b492013-07-12 13:56:44 +053017071 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
17072 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017073 {
17074 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017075 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070017076 return NULL;
17077 }
17078
Jeff Johnson295189b2012-06-20 16:38:30 -070017079 pNewStaEntry->callback = pStaEntry->callback;
17080 pNewStaEntry->pContext = pStaEntry->pContext;
17081 pNewStaEntry->periodicity = pStaEntry->periodicity;
17082 pNewStaEntry->requesterId = pStaEntry->requesterId;
17083 pNewStaEntry->statsMask = pStaEntry->statsMask;
17084 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
17085 pNewStaEntry->pMac = pStaEntry->pMac;
17086 pNewStaEntry->staId = pStaEntry->staId;
17087 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
17088
17089 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
17090 }
17091 return pNewStaEntry;
17092}
17093
Jeff Johnson295189b2012-06-20 16:38:30 -070017094tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
17095 tDblLinkList *pStaList,
17096 tCsrPeStatsReqInfo *pStaEntry)
17097{
17098 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053017099 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
17100 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017101 {
17102 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017103 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070017104 return NULL;
17105 }
17106
Jeff Johnson295189b2012-06-20 16:38:30 -070017107 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
17108 pNewStaEntry->numClient = pStaEntry->numClient;
17109 pNewStaEntry->periodicity = pStaEntry->periodicity;
17110 pNewStaEntry->statsMask = pStaEntry->statsMask;
17111 pNewStaEntry->pMac = pStaEntry->pMac;
17112 pNewStaEntry->staId = pStaEntry->staId;
17113 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
17114 pNewStaEntry->rspPending = pStaEntry->rspPending;
17115
17116 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017117 return pNewStaEntry;
17118}
Jeff Johnson295189b2012-06-20 16:38:30 -070017119eHalStatus csrGetRssi(tpAniSirGlobal pMac,
17120 tCsrRssiCallback callback,
17121 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17122{
17123 eHalStatus status = eHAL_STATUS_SUCCESS;
17124 vos_msg_t msg;
17125 tANI_U32 sessionId;
17126
17127 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017128 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017129 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17130 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070017131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017132 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017133 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017135 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17136
17137 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
17138 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17139 pMsg->sessionId = sessionId;
17140 pMsg->staId = staId;
17141 pMsg->rssiCallback = callback;
17142 pMsg->pDevContext = pContext;
17143 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070017144 msg.type = eWNI_SME_GET_RSSI_REQ;
17145 msg.bodyptr = pMsg;
17146 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017147 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017149 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017150 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017151 status = eHAL_STATUS_FAILURE;
17152 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017153 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017154 return status;
17155}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017156
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017157eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17158 tCsrSnrCallback callback,
17159 tANI_U8 staId, tCsrBssid bssId,
17160 void *pContext)
17161{
17162 eHalStatus status = eHAL_STATUS_SUCCESS;
17163 vos_msg_t msg;
17164 tANI_U32 sessionId;
17165
17166 tAniGetSnrReq *pMsg;
17167
17168 smsLog(pMac, LOG2, FL("called"));
17169
17170 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17171 if (NULL == pMsg )
17172 {
17173 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17174 return status;
17175 }
17176
17177 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17178
17179 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17180 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17181 pMsg->sessionId = sessionId;
17182 pMsg->staId = staId;
17183 pMsg->snrCallback = callback;
17184 pMsg->pDevContext = pContext;
17185 msg.type = eWNI_SME_GET_SNR_REQ;
17186 msg.bodyptr = pMsg;
17187 msg.reserved = 0;
17188
17189 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17190 {
17191 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17192 vos_mem_free((v_VOID_t *)pMsg);
17193 status = eHAL_STATUS_FAILURE;
17194 }
17195
17196 smsLog(pMac, LOG2, FL("returned"));
17197 return status;
17198}
17199
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017200#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017201eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17202 tCsrRssiCallback callback,
17203 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17204{
17205 eHalStatus status = eHAL_STATUS_SUCCESS;
17206 tAniGetRssiReq *pMsg;
17207
Kiet Lam64c1b492013-07-12 13:56:44 +053017208 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17209 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017210 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017211 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017212 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017213 }
17214 // need to initiate a stats request to PE
17215 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17216 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17217 pMsg->staId = staId;
17218 pMsg->rssiCallback = callback;
17219 pMsg->pDevContext = pContext;
17220 pMsg->pVosContext = pVosContext;
17221 status = palSendMBMessage(pMac->hHdd, pMsg );
17222 if(!HAL_STATUS_SUCCESS(status))
17223 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017224 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017225 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017226 status = eHAL_STATUS_FAILURE;
17227 }
17228 return status;
17229}
17230#endif
17231
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017232
17233
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017234#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017235eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17236 tCsrTsmStatsCallback callback,
17237 tANI_U8 staId,
17238 tCsrBssid bssId,
17239 void *pContext,
17240 void* pVosContext,
17241 tANI_U8 tid)
17242{
17243 eHalStatus status = eHAL_STATUS_SUCCESS;
17244 tAniGetTsmStatsReq *pMsg = NULL;
17245
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017246 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17247 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017248 {
17249 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017250 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017251 }
17252 // need to initiate a stats request to PE
17253 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17254 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17255 pMsg->staId = staId;
17256 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017257 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017258 pMsg->tsmStatsCallback = callback;
17259 pMsg->pDevContext = pContext;
17260 pMsg->pVosContext = pVosContext;
17261 status = palSendMBMessage(pMac->hHdd, pMsg );
17262 if(!HAL_STATUS_SUCCESS(status))
17263 {
17264 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17265 //pMsg is freed by palSendMBMessage
17266 status = eHAL_STATUS_FAILURE;
17267 }
17268 return status;
17269}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017270#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017271
17272
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017273/* ---------------------------------------------------------------------------
17274 \fn csrGetTLSTAState
17275 \helper function to get teh TL STA State whenever the function is called.
17276
17277 \param staId - The staID to be passed to the TL
17278 to get the relevant TL STA State
17279 \return the state as tANI_U16
17280 ---------------------------------------------------------------------------*/
17281tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17282{
17283 WLANTL_STAStateType tlSTAState;
17284 tlSTAState = WLANTL_STA_INIT;
17285
17286 //request TL for STA State
17287 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17288 {
17289 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17290 }
17291
17292 return tlSTAState;
17293}
17294
Jeff Johnson295189b2012-06-20 16:38:30 -070017295eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17296 tANI_U32 statsMask,
17297 tCsrStatsCallback callback,
17298 tANI_U32 periodicity, tANI_BOOLEAN cache,
17299 tANI_U8 staId, void *pContext)
17300{
17301 tCsrStatsClientReqInfo staEntry;
17302 tCsrStatsClientReqInfo *pStaEntry = NULL;
17303 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17304 tListElem *pEntry = NULL;
17305 tANI_BOOLEAN found = FALSE;
17306 eHalStatus status = eHAL_STATUS_SUCCESS;
17307 tANI_BOOLEAN insertInClientList = FALSE;
17308 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017309 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017310
17311 if( csrIsAllSessionDisconnected(pMac) )
17312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017313 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017314 return eHAL_STATUS_FAILURE;
17315 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017316
17317 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17318 {
17319 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17320 return eHAL_STATUS_FAILURE;
17321 }
17322
Jeff Johnson295189b2012-06-20 16:38:30 -070017323 if((!statsMask) && (!callback))
17324 {
17325 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017326 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017327 return eHAL_STATUS_FAILURE;
17328 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017329 //for the search list method for deregister
17330 staEntry.requesterId = requesterId;
17331 staEntry.statsMask = statsMask;
17332 //requester wants to deregister or just an error
17333 if((statsMask) && (!callback))
17334 {
17335 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17336 if(!pEntry)
17337 {
17338 //msg
17339 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017340 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017341 return eHAL_STATUS_FAILURE;
17342 }
17343 else
17344 {
17345 //clean up & return
17346 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017347 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017348 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017349 pStaEntry->pPeStaEntry->numClient--;
17350 //check if we need to delete the entry from peStatsReqList too
17351 if(!pStaEntry->pPeStaEntry->numClient)
17352 {
17353 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17354 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017355 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017356
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 //check if we need to stop the tl stats timer too
17358 pMac->roam.tlStatsReqInfo.numClient--;
17359 if(!pMac->roam.tlStatsReqInfo.numClient)
17360 {
17361 if(pMac->roam.tlStatsReqInfo.timerRunning)
17362 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017363 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17364 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017366 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017367 return eHAL_STATUS_FAILURE;
17368 }
17369 }
17370 pMac->roam.tlStatsReqInfo.periodicity = 0;
17371 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17372 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017373 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017374 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017375 vos_timer_stop(&pStaEntry->timer);
17376 // Destroy the vos timer
17377 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17378 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17379 {
17380 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017383 csrRoamRemoveStatListEntry(pMac, pEntry);
17384 pStaEntry = NULL;
17385 return eHAL_STATUS_SUCCESS;
17386 }
17387 }
17388
17389 if(cache && !periodicity)
17390 {
17391 //return the cached stats
17392 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17393 }
17394 else
17395 {
17396 //add the request in the client req list
17397 staEntry.callback = callback;
17398 staEntry.pContext = pContext;
17399 staEntry.periodicity = periodicity;
17400 staEntry.pPeStaEntry = NULL;
17401 staEntry.staId = staId;
17402 staEntry.pMac = pMac;
17403 staEntry.timerExpired = FALSE;
17404
17405
Jeff Johnson295189b2012-06-20 16:38:30 -070017406 //if periodic report requested with non cached result from PE/TL
17407 if(periodicity)
17408 {
17409
17410 //if looking for stats from PE
17411 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17412 {
17413
17414 //check if same request made already & waiting for rsp
17415 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17416 periodicity, &found, staId);
17417 if(!pPeStaEntry)
17418 {
17419 //bail out, maxed out on number of req for PE
17420 return eHAL_STATUS_FAILURE;
17421 }
17422 else
17423 {
17424 staEntry.pPeStaEntry = pPeStaEntry;
17425 }
17426
17427 }
17428 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17429 if(statsMask & (1 << eCsrGlobalClassDStats))
17430 {
17431 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017433 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 }
17435 else
17436 {
17437
17438 //update periodicity
17439 if(pMac->roam.tlStatsReqInfo.periodicity)
17440 {
17441 pMac->roam.tlStatsReqInfo.periodicity =
17442 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17443 }
17444 else
17445 {
17446 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17447 }
17448 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17449 {
17450 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17451 }
17452
17453 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17454 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017455 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017456 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017457 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017458 //req TL for class D stats
17459 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017461 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017462 }
17463 else
17464 {
17465 //save in SME
17466 csrRoamSaveStatsFromTl(pMac, pTlStats);
17467 }
17468 vos_mem_free(pTlStats);
17469 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017470 }
17471 else
17472 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017473 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017474 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017475
Jeff Johnson295189b2012-06-20 16:38:30 -070017476 if(pMac->roam.tlStatsReqInfo.periodicity)
17477 {
17478 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017479 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17480 pMac->roam.tlStatsReqInfo.periodicity);
17481 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017483 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017484 return eHAL_STATUS_FAILURE;
17485 }
17486 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17487 }
17488 }
17489 }
17490 pMac->roam.tlStatsReqInfo.numClient++;
17491 }
17492
17493 insertInClientList = TRUE;
17494 }
17495 //if one time report requested with non cached result from PE/TL
17496 else if(!cache && !periodicity)
17497 {
17498 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17499 {
17500 //send down a req
17501 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17502 if(!HAL_STATUS_SUCCESS(status))
17503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017504 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017505 }
17506 //so that when the stats rsp comes back from PE we respond to upper layer
17507 //right away
17508 staEntry.timerExpired = TRUE;
17509 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017510 }
17511 if(statsMask & (1 << eCsrGlobalClassDStats))
17512 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017513 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017514 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017515 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017516 //req TL for class D stats
17517 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017519 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017520 }
17521 else
17522 {
17523 //save in SME
17524 csrRoamSaveStatsFromTl(pMac, pTlStats);
17525 }
17526 vos_mem_free(pTlStats);
17527 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017528 }
17529 else
17530 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017531 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017532 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017533
17534 }
17535 //if looking for stats from TL only
17536 if(!insertInClientList)
17537 {
17538 //return the stats
17539 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017542 if(insertInClientList)
17543 {
17544 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17545 if(!pStaEntry)
17546 {
17547 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017548 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017549 return eHAL_STATUS_FAILURE;
17550 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017551 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017552 //Init & start timer if needed
17553 if(periodicity)
17554 {
17555 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17556 csrRoamStatsClientTimerHandler, pStaEntry );
17557 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017559 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017560 return eHAL_STATUS_FAILURE;
17561 }
17562 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17563 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017565 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017566 return eHAL_STATUS_FAILURE;
17567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017570 }
17571 return eHAL_STATUS_SUCCESS;
17572}
17573
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017574#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17575
17576static tSirRetStatus
17577csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17578 tANI_U8* pBD,
17579 tANI_U8 type,
17580 tANI_U8 subType,
17581 tSirMacAddr peerAddr,
17582 tSirMacAddr selfMacAddr)
17583{
17584 tSirRetStatus statusCode = eSIR_SUCCESS;
17585 tpSirMacMgmtHdr pMacHdr;
17586
17587 /* Prepare MAC management header */
17588 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17589
17590 /* Prepare FC */
17591 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17592 pMacHdr->fc.type = type;
17593 pMacHdr->fc.subType = subType;
17594
17595 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017596 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17597 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017598
17599 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17600
17601 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017602 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17603 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017604 return statusCode;
17605} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17606
17607static tSirRetStatus
17608csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17609 tANI_U8 nChannelNum,
17610 tANI_U32 dot11mode,
17611 tSirMacAddr selfMacAddr,
17612 tANI_U8 *pFrame,
17613 tANI_U16 *pusLen)
17614{
17615 tDot11fProbeRequest pr;
17616 tANI_U32 nStatus, nBytes, nPayload;
17617 tSirRetStatus nSirStatus;
17618 /*Bcast tx*/
17619 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17620 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17621
17622
Kiet Lam64c1b492013-07-12 13:56:44 +053017623 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017624
17625 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17626
17627 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17628 {
17629 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17630 }
17631
17632
17633 if (IS_DOT11_MODE_HT(dot11mode))
17634 {
17635 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17636 }
17637
17638
17639 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17640 if ( DOT11F_FAILED( nStatus ) )
17641 {
17642 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17643 "Failed to calculate the packed size f"
17644 "or a Probe Request (0x%08x).\n", nStatus );
17645
17646
17647 nPayload = sizeof( tDot11fProbeRequest );
17648 }
17649 else if ( DOT11F_WARNED( nStatus ) )
17650 {
17651 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17652 "There were warnings while calculating"
17653 "the packed size for a Probe Request ("
17654 "0x%08x).\n", nStatus );
17655 }
17656
17657 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17658
17659 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017660 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017661
17662
17663 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017664 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017665
17666 if ( eSIR_SUCCESS != nSirStatus )
17667 {
17668 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17669 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17670 nSirStatus );
17671 return nSirStatus;
17672 }
17673
17674
17675 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17676 sizeof( tSirMacMgmtHdr ),
17677 nPayload, &nPayload );
17678 if ( DOT11F_FAILED( nStatus ) )
17679 {
17680 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17681 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17682 return eSIR_FAILURE;
17683 }
17684 else if ( DOT11F_WARNED( nStatus ) )
17685 {
17686 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017687 "There were warnings while packing a Probe Request (0x%08x).\n",
17688 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017689 }
17690
17691 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17692 return eSIR_SUCCESS;
17693}
17694
Mukul Sharmad68cda62015-03-20 21:25:41 +053017695/*
17696 * Below Table describe whether RSO command can be send down to fimrware or not.
17697 * Host check it on the basis of previous RSO command sent down to firmware.
17698||===========================================================================||
17699|| New cmd | LAST SENT COMMAND ---> ||
17700||====|======================================================================||
17701|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17702|| --------------------------------------------------------------------------||
17703|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017704|| RSO_STOP | YES | NO | YES | YES ||
17705|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017706|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17707||===========================================================================||
17708*/
17709
17710#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17711#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17712#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17713#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17714
17715#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17716#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017717 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017718#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17719 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017720#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017721 RSO_START_BIT)
17722
17723tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17724{
17725 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17726 tANI_U8 desiredMask = 0;
17727 switch(command)
17728 {
17729 case ROAM_SCAN_OFFLOAD_START:
17730 desiredMask = RSO_START_ALLOW_MASK;
17731 break;
17732 case ROAM_SCAN_OFFLOAD_STOP:
17733 desiredMask = RSO_STOP_ALLOW_MASK;
17734 break;
17735 case ROAM_SCAN_OFFLOAD_RESTART:
17736 desiredMask = RSO_RESTART_ALLOW_MASK;
17737 break;
17738 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17739 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17740 break;
17741 default:
17742 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17743 FL("Wrong RSO command %d, not allowed"), command);
17744 return 0;/*Cmd Not allowed*/
17745 }
17746 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17747}
17748
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017749eCsrBand GetCurrentBand(tANI_U8 channel)
17750{
17751 tSirRFBand Rfband;
17752 eCsrBand band;
17753
17754 Rfband = GetRFBand(channel);
17755
17756 if (Rfband == SIR_BAND_5_GHZ)
17757 band = eCSR_BAND_5G;
17758 else if (Rfband == SIR_BAND_2_4_GHZ)
17759 band = eCSR_BAND_24;
17760 else if (Rfband == SIR_BAND_UNKNOWN)
17761 band = eCSR_BAND_MAX;
17762
17763 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17764 "channel %d Rfband %d band %d", channel, Rfband, band);
17765
17766 return band;
17767}
17768
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017769eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17770{
17771 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017772 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017773 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017774 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017775 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017776 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017777 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017778 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017779 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017780 eHalStatus status = eHAL_STATUS_SUCCESS;
17781 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017782 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017783 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017784 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017785 tSirBssDescription *pBssDesc = NULL;
17786 tDot11fBeaconIEs *pIes = NULL;
17787 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017788 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017789
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017790 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17791
Abhinav Kumarb72f8ce2019-08-07 16:11:54 +053017792 pSession = CSR_GET_SESSION( pMac, sessionId );
17793 if (!pSession) {
17794 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17795 "%s:pSession is null", __func__);
17796 return eHAL_STATUS_FAILURE;
17797 }
17798
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017799 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017800 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017801 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017802 return eHAL_STATUS_FAILURE;
17803 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017804
17805 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17806 {
17807 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17808 return eHAL_STATUS_FAILURE;
17809 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017810
Abhinav Kumarb72f8ce2019-08-07 16:11:54 +053017811 /* Roaming is not supported currently for SAE authentication */
17812 if (pSession->pCurRoamProfile &&
17813 CSR_IS_AUTH_TYPE_SAE(pSession->pCurRoamProfile->AuthType.authType[0])) {
17814 smsLog(pMac, LOGE, "Roaming not suppprted for SAE connection");
17815 return eHAL_STATUS_SUCCESS;
17816 }
17817
Abhinav Kumara70b3cf2019-07-22 15:13:06 +053017818 /* Roaming is not supported currently for OWE akm */
17819 if (pSession->pCurRoamProfile &&
17820 (pSession->pCurRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_OWE))
17821 {
17822 smsLog(pMac, LOGE, "Roaming not suppprted for OWE connection");
17823 return eHAL_STATUS_SUCCESS;
17824 }
17825
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017826 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17827 * It is important to ensure that the command is passed down to the FW only
17828 * if the Infra Station is in a connected state.A connected station could also be
17829 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17830 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17831 * irrespective of whichever state we are in.*/
17832 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17833 (command != ROAM_SCAN_OFFLOAD_STOP))
17834 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17836 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17837 macTraceGetNeighbourRoamState(
17838 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017839 return eHAL_STATUS_FAILURE;
17840 }
17841
Mukul Sharmad68cda62015-03-20 21:25:41 +053017842 if (!CsrIsRSOCommandAllowed(pMac, command))
17843 {
17844 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17845 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17846 command, pNeighborRoamInfo->lastSentCmd);
17847 return eHAL_STATUS_FAILURE;
17848 }
17849
Abhishek Singh3e915632014-11-01 17:14:50 +053017850 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17851 * Also there are cases where pNeighborRoamInfo->currAPbssid
17852 * is set to 0 during disconnect and so we might return without stopping
17853 * the roam scan. So no need to find the session if command is
17854 * ROAM_SCAN_OFFLOAD_STOP.
17855 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017856 status = csrRoamGetSessionIdFromBSSID(pMac,
17857 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17858 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017859 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017860 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017861 if ( !HAL_STATUS_SUCCESS( status ) )
17862 {
17863 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17864 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17865 return eHAL_STATUS_FAILURE;
17866 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017867 pBssDesc = pSession->pConnectBssDesc;
17868 if (pBssDesc == NULL)
17869 {
17870 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17871 "%s: pBssDesc not found for current session", __func__);
17872 return eHAL_STATUS_FAILURE;
17873 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017874
17875 operationChannel = pSession->connectedProfile.operationChannel;
17876 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17877 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017878 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017879 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17880 if (NULL == pRequestBuf)
17881 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017882 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17883 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17884 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017885 }
17886
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017887#ifdef FEATURE_WLAN_DIAG_SUPPORT
17888 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17889 eSIR_SUCCESS, eSIR_SUCCESS);
17890#endif
17891
Abhishek Singh3e915632014-11-01 17:14:50 +053017892 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17893 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17894 * host driver reloads, but Riva still up and running*/
17895 pRequestBuf->Command = command;
17896 if(command == ROAM_SCAN_OFFLOAD_STOP)
17897 {
17898 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017899 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017900 /*For a STOP Command, there is no need to
17901 * go through filling up all the below parameters
17902 * since they are not required for the STOP command*/
17903 goto send_roam_scan_offload_cmd;
17904 }
17905 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017906 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017907 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17908 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017909 sizeof(tCsrBssid));
17910 pRequestBuf->ConnectedNetwork.ssId.length =
17911 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17912 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17913 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17914 pRequestBuf->ConnectedNetwork.ssId.length);
17915 pRequestBuf->ConnectedNetwork.authentication =
17916 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17917 pRequestBuf->ConnectedNetwork.encryption =
17918 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17919 pRequestBuf->ConnectedNetwork.mcencryption =
17920 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017921 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17922 {
17923 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017924 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017925 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17926 }
17927 else
17928 {
17929 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017930
17931 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17932 {
17933 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17934 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17935 vos_mem_free(pRequestBuf);
17936 return eHAL_STATUS_FAILURE;
17937 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017938 if(NULL == pIes)
17939 {
17940 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17941 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017942 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017943 return eHAL_STATUS_FAILURE;
17944 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017945 if (pIes->SuppRates.present)
17946 {
17947 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17948 /*Check for both basic rates and extended rates.*/
17949 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17950 {
17951 /*Check if the Rate is Mandatory or Not*/
17952 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17953 && (pIes->SuppRates.rates[i] & 0x80))
17954 {
17955 /*Retrieve the actual data rate*/
17956 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17957 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17958 if (minRate == 0)
17959 minRate = dataRate;
17960 else
17961 minRate = (minRate < dataRate) ? minRate:dataRate;
17962 }
17963 }
17964
17965 if (pIes->ExtSuppRates.present)
17966 {
17967 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17968 {
17969 /*Check if the Rate is Mandatory or Not*/
17970 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17971 && (pIes->ExtSuppRates.rates[i] & 0x80))
17972 {
17973 /*Retrieve the actual data rate*/
17974 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17975 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17976 if (minRate == 0)
17977 minRate = dataRate;
17978 else
17979 minRate = (minRate < dataRate) ? minRate:dataRate;
17980 }
17981 }
17982 }
17983 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17984 }
17985 else
17986 {
17987 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17988 "%s: Supp Rates not present in pIes", __func__);
17989 vos_mem_free(pRequestBuf);
17990 return eHAL_STATUS_FAILURE;
17991 }
17992 if (NULL != pIes)
17993 {
17994 vos_mem_free(pIes);
17995 pIes = NULL;
17996 }
17997 switch (minRate)
17998 {
17999 case 1:
18000 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
18001 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
18002 break;
18003 case 2:
18004 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
18005 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
18006 break;
18007 case 5:
18008 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
18009 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
18010 break;
18011 case 6:
18012 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
18013 {
18014 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
18015 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
18016 }
18017 else
18018 {
18019 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
18020 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
18021 }
18022 break;
18023 case 11:
18024 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
18025 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
18026 break;
18027 case 12:
18028 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
18029 {
18030 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
18031 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
18032 }
18033 else
18034 {
18035 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
18036 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
18037 }
18038 break;
18039 case 24:
18040 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
18041 {
18042 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
18043 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
18044 }
18045 else
18046 {
18047 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
18048 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
18049 }
18050 break;
18051 default:
18052 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
18053 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
18054 break;
18055 }
18056 }
18057 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18058 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
18059 operationChannel, minRate,
18060 pRequestBuf->RxSensitivityThreshold,
18061 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018062 pRequestBuf->RoamRssiDiff =
18063 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018064 pRequestBuf->StartScanReason = reason;
18065 pRequestBuf->NeighborScanTimerPeriod =
18066 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
18067 pRequestBuf->NeighborRoamScanRefreshPeriod =
18068 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
18069 pRequestBuf->NeighborScanChannelMinTime =
18070 pNeighborRoamInfo->cfgParams.minChannelScanTime;
18071 pRequestBuf->NeighborScanChannelMaxTime =
18072 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
18073 pRequestBuf->EmptyRefreshScanPeriod =
18074 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080018075 /* MAWC feature */
18076 pRequestBuf->MAWCEnabled =
18077 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018078
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018079#ifdef FEATURE_WLAN_ESE
18080 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018081#endif
18082 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018083#ifdef FEATURE_WLAN_ESE
18084 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018085 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
18086 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018087 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
18088#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018089 currChannelListInfo->numOfChannels == 0)
18090 {
18091
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018092 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
18093 * Give Preference to INI Channels.*/
18094 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
18095 {
18096 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
18097 /*The INI channels need to be filtered with respect to the current
18098 * band that is supported.*/
18099 eBand = pMac->roam.configParam.bandCapability;
18100 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018101 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018102 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18103 "Invalid band, No operation carried out (Band %d)", eBand);
18104 vos_mem_free(pRequestBuf);
18105 return eHAL_STATUS_FAILURE;
18106 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018107
18108 if (pMac->roam.configParam.nRoamIntraBand)
18109 {
18110 eBand = GetCurrentBand(operationChannel);
18111 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18112 "Current Band %d", eBand);
18113 }
18114
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018115 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
18116 {
18117 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18118 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18119 (eCSR_BAND_ALL == eBand))
18120 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018121 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
18122 ((pMac->roam.configParam.allowDFSChannelRoam) ||
18123 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
18124 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018125 {
18126 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
18127 }
18128 }
18129 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018130 }
18131 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18132 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018133 }
18134 else
18135 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018136 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018137
18138 if (pMac->roam.configParam.nRoamIntraBand)
18139 {
18140 Rfband = GetCurrentBand(operationChannel);
18141 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18142 "Current Band %d", Rfband);
18143 }
18144
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018145 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
18146 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018147 if(((eCSR_BAND_24 == Rfband) &&
18148 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18149 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18150 || (eCSR_BAND_ALL == Rfband))
18151 {
18152 /* Allow DFS channels only if the DFS channel roam flag is
18153 * enabled
18154 */
18155 if(*ChannelList && ((pMac->roam.configParam.
18156 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
18157 && (num_channels < SIR_ROAM_MAX_CHANNELS))
18158 {
18159 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
18160 = *ChannelList;
18161 }
18162 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018163 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018164 }
18165 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18166 /* If the profile changes as to what it was earlier, inform the FW through
18167 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
18168 * for the earlier profile and try to learn them afresh.*/
18169 if (reason == REASON_FLUSH_CHANNEL_LIST)
18170 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18171 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018172 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18173 (pMac->roam.configParam.nRoamIntraBand))
18174 pRequestBuf->ChannelCacheType =
18175 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018176 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018177 pRequestBuf->ChannelCacheType =
18178 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018179 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018180 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018181 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018182#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018183 else
18184 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018185 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018186 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018187 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018188 if (currChannelListInfo->numOfChannels != 0)
18189 {
18190 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018191
18192 if (pMac->roam.configParam.nRoamIntraBand)
18193 {
18194 Rfband = GetCurrentBand(operationChannel);
18195 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18196 "Current Band %d", Rfband);
18197 }
18198
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018199 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018200 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018201 if(((eCSR_BAND_24 == Rfband) &&
18202 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18203 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18204 || (eCSR_BAND_ALL == Rfband))
18205 {
18206 if(*ChannelList && ((pMac->roam.configParam.
18207 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18208 {
18209 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018210 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018211 }
18212 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018213 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018214 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018215 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018216 if (pMac->roam.configParam.nRoamIntraBand)
18217 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18218 else
18219 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018220 }
18221 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018222#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018223 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18224 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018225 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018226 if (j < sizeof(ChannelCacheStr))
18227 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018228 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18229 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018230 }
18231 else
18232 {
18233 break;
18234 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018235 }
18236 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18237 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18238 pRequestBuf->ChannelCacheType,
18239 pRequestBuf->ConnectedNetwork.ChannelCount,
18240 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018241 num_channels = 0;
18242 ChannelList = NULL;
18243
18244 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018245 host_channels = sizeof(pMac->roam.validChannelList);
18246 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018247 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018248 ChannelList = pMac->roam.validChannelList;
18249 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018250 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018251 else
18252 {
18253 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18254 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018255 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018256 return eHAL_STATUS_FAILURE;
18257 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018258
18259 if (pMac->roam.configParam.nRoamIntraBand)
18260 {
18261 Rfband = GetCurrentBand(operationChannel);
18262 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18263 Rfband);
18264 }
18265
Srinivas Girigowda56076852013-08-20 14:00:50 -070018266 for(i=0; i<pMac->roam.numValidChannels; i++)
18267 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018268 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18269 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18270 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018271 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018272 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18273 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18274 {
18275 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18276 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018277 }
18278 ChannelList++;
18279 }
18280 pRequestBuf->ValidChannelCount = num_channels;
18281
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018282 pRequestBuf->MDID.mdiePresent =
18283 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18284 pRequestBuf->MDID.mobilityDomain =
18285 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018286 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18287
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018288 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018289 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18290 * where RFS is the RF Switching time. It is twice RFS to consider the
18291 * time to go off channel and return to the home channel. */
18292 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18293 {
18294 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18295 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18296 " Hence enforcing home away time to disable (0)",
18297 __func__, pRequestBuf->HomeAwayTime,
18298 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18299 pRequestBuf->HomeAwayTime = 0;
18300 }
18301 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018302
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018303 pRequestBuf->WeakZoneRssiThresholdForRoam =
18304 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018305 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18306 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18307 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18308 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18309 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18310
18311 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18312 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018313send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018314 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018315 msg.reserved = 0;
18316 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018317 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18318 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018319 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18320 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018321 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18322 vos_mem_free(pRequestBuf);
18323 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018324 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018325 else
18326 {
18327 if (ROAM_SCAN_OFFLOAD_START == command)
18328 bRoamScanOffloadStarted = VOS_TRUE;
18329 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18330 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018331
18332 /*update the last sent cmd*/
18333 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018334 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018335
18336 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
Kapil Gupta04ab1992016-06-26 13:36:51 +053018337
18338 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018339 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18340 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018341 {
18342
18343 /* PER ROAM SCAN */
18344 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18345 if (!PERRoamReqBuf)
18346 {
18347 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18348 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18349 return eHAL_STATUS_FAILURE;
18350 }
18351 /* PER Roam Config */
18352 PERRoamReqBuf->rateUpThreshold =
18353 pMac->roam.configParam.rateUpThreshold;
18354 PERRoamReqBuf->rateDownThreshold =
18355 pMac->roam.configParam.rateDownThreshold;
18356 PERRoamReqBuf->waitPeriodForNextPERScan =
18357 pMac->roam.configParam.waitPeriodForNextPERScan;
18358 PERRoamReqBuf->PERtimerThreshold =
18359 pMac->roam.configParam.PERtimerThreshold;
18360 PERRoamReqBuf->isPERRoamCCAEnabled =
18361 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018362 PERRoamReqBuf->PERRoamFullScanThreshold =
18363 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018364 PERRoamReqBuf->PERroamTriggerPercent =
18365 pMac->roam.configParam.PERroamTriggerPercent;
18366 PERRoamReqBuf->sessionId = sessionId;
18367
18368 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18369 PERroamScanConfigMsg.reserved = 0;
18370 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18371 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18372 &PERroamScanConfigMsg))) {
18373 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18374 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18375 vos_mem_free(PERRoamReqBuf);
18376 return eHAL_STATUS_FAILURE;
18377 }
18378 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18379 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18380 PERRoamReqBuf->rateUpThreshold,
18381 PERRoamReqBuf->rateDownThreshold,
18382 PERRoamReqBuf->waitPeriodForNextPERScan,
18383 PERRoamReqBuf->PERtimerThreshold);
18384 }
18385
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018386 return status;
18387}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018388
18389eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18390{
18391 switch(reason)
18392 {
18393 case 0:
18394 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18395 break;
18396 case REASON_OS_REQUESTED_ROAMING_NOW:
18397 csrNeighborRoamProceedWithHandoffReq(pMac);
18398 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018399 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18400 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18401 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018402 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018403 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Rsp for Roam Scan Offload with reason %d", reason);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018404 }
18405 return eHAL_STATUS_SUCCESS;
18406}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018407#endif
18408
Jeff Johnson295189b2012-06-20 16:38:30 -070018409tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18410 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18411{
18412 tANI_BOOLEAN found = FALSE;
18413 eHalStatus status = eHAL_STATUS_SUCCESS;
18414 tCsrPeStatsReqInfo staEntry;
18415 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18416 tListElem *pStaEntry = NULL;
18417 VOS_STATUS vosStatus;
18418 tPmcPowerState powerState;
18419 *pFound = FALSE;
18420
18421 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18422 if(pStaEntry)
18423 {
18424 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18425 if(pTempStaEntry->periodicity)
18426 {
18427 pTempStaEntry->periodicity =
18428 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18429 }
18430 else
18431 {
18432 pTempStaEntry->periodicity = periodicity;
18433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018434 pTempStaEntry->numClient++;
18435 found = TRUE;
18436 }
18437 else
18438 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018439 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018440 staEntry.numClient = 1;
18441 staEntry.periodicity = periodicity;
18442 staEntry.pMac = pMac;
18443 staEntry.rspPending = FALSE;
18444 staEntry.staId = staId;
18445 staEntry.statsMask = statsMask;
18446 staEntry.timerRunning = FALSE;
18447 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18448 if(!pTempStaEntry)
18449 {
18450 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018451 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018452 return NULL;
18453 }
18454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018455 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18456 if(ePMC_FULL_POWER == powerState)
18457 {
18458 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18459 {
18460 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18461 }
18462 }
18463 else
18464 {
18465 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18466 {
18467 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18468 }
18469 }
18470 if(!pTempStaEntry->timerRunning)
18471 {
18472 //send down a req in case of one time req, for periodic ones wait for timer to expire
18473 if(!pTempStaEntry->rspPending &&
18474 !pTempStaEntry->periodicity)
18475 {
18476 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18477 if(!HAL_STATUS_SUCCESS(status))
18478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018479 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018480 }
18481 else
18482 {
18483 pTempStaEntry->rspPending = TRUE;
18484 }
18485 }
18486 if(pTempStaEntry->periodicity)
18487 {
18488 if(!found)
18489 {
18490
18491 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18492 csrRoamPeStatsTimerHandler, pTempStaEntry );
18493 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018495 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018496 return NULL;
18497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018498 }
18499 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018500 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018501 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18502 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018504 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018505 return NULL;
18506 }
18507 pTempStaEntry->timerRunning = TRUE;
18508 }
18509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018510 *pFound = found;
18511 return pTempStaEntry;
18512}
18513
Jeff Johnson295189b2012-06-20 16:38:30 -070018514/*
18515 pStaEntry is no longer invalid upon the return of this function.
18516*/
18517static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18518{
18519 if(pEntry)
18520 {
18521 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18522 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018523 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018524 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018525 }
18526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018527
18528void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18529{
18530 tListElem *pEntry;
18531 tCsrPeStatsReqInfo *pTempStaEntry;
18532 VOS_STATUS vosStatus;
18533 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018534 if(!pEntry)
18535 {
18536 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018537 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018538 return;
18539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018540 while( pEntry )
18541 {
18542 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018543 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18544 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018545 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018546 if(pTempStaEntry->timerRunning)
18547 {
18548 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18549 /* If we are not able to stop the timer here, just remove
18550 * the entry from the linked list. Destroy the timer object
18551 * and free the memory in the timer CB
18552 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018553 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018554 {
18555 /* the timer is successfully stopped */
18556 pTempStaEntry->timerRunning = FALSE;
18557
18558 /* Destroy the timer */
18559 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18560 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018562 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018563 }
18564 }
18565 else
18566 {
18567 // the timer could not be stopped. Hence destroy and free the
18568 // memory for the PE stat entry in the timer CB.
18569 pTempStaEntry->timerStopFailed = TRUE;
18570 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018572
18573 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18574 {
18575 // Only free the memory if we could stop the timer successfully
18576 if(!pTempStaEntry->timerStopFailed)
18577 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018578 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018579 pTempStaEntry = NULL;
18580 }
18581 break;
18582 }
18583
18584 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18585 }
18586 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018587 return;
18588}
18589
18590
Jeff Johnsone7245742012-09-05 17:12:55 -070018591void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018592{
18593
Jeff Johnsone7245742012-09-05 17:12:55 -070018594 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18595 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18596 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18597 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18598 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18599 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18600 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018601 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018602 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18603 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18604 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18605 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18606 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18607 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018608 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018609 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18610 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018611
18612}
18613
Jeff Johnson295189b2012-06-20 16:38:30 -070018614void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18615 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18616{
18617 tANI_U8 stats[500];
18618 tANI_U8 *pStats = NULL;
18619 tANI_U32 tempMask = 0;
18620 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018621 if(!callback)
18622 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018623 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018624 return;
18625 }
18626 if(!statsMask)
18627 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018628 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018629 return;
18630 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018631 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018632 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018633 while(tempMask)
18634 {
18635 if(tempMask & 1)
18636 {
18637 //new stats info from PE, fill up the stats strucutres in PMAC
18638 switch(counter)
18639 {
18640 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018641 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018642 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18643 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018644 pStats += sizeof(tCsrSummaryStatsInfo);
18645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018646 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018647 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018648 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18649 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018650 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018652 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018653 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018654 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18655 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018656 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018658 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018659 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018660 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18661 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018662 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018663 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018664 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018665 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018666 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18667 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018668 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018670 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018671 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018672 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18673 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018674 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018675 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018676 case eCsrPerPktStats:
18677 smsLog( pMac, LOG2, FL("PerPkt stats"));
18678 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18679 sizeof(tPerTxPacketFrmFw));
18680 pStats += sizeof(tPerTxPacketFrmFw);
18681 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018682 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018683 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018685 }
18686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018687 tempMask >>=1;
18688 counter++;
18689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018690 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018691}
18692
Jeff Johnson295189b2012-06-20 16:38:30 -070018693eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18694{
18695 tListElem *pEntry = NULL;
18696 tListElem *pPrevEntry = NULL;
18697 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18698 eHalStatus status = eHAL_STATUS_SUCCESS;
18699 VOS_STATUS vosStatus;
18700 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018701 if(!pEntry)
18702 {
18703 //list empty
18704 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018705 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018706 return status;
18707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018708 while( pEntry )
18709 {
18710 if(pPrevEntry)
18711 {
18712 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18713 //send up the stats report
18714 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18715 pTempStaEntry->staId, pTempStaEntry->pContext);
18716 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018718 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018719 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18720 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018721 pTempStaEntry->pPeStaEntry->numClient--;
18722 //check if we need to delete the entry from peStatsReqList too
18723 if(!pTempStaEntry->pPeStaEntry->numClient)
18724 {
18725 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018728 //check if we need to stop the tl stats timer too
18729 pMac->roam.tlStatsReqInfo.numClient--;
18730 if(!pMac->roam.tlStatsReqInfo.numClient)
18731 {
18732 if(pMac->roam.tlStatsReqInfo.timerRunning)
18733 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018734 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18735 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018736 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018737 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018738 //we will continue
18739 }
18740 }
18741 pMac->roam.tlStatsReqInfo.periodicity = 0;
18742 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018744 if (pTempStaEntry->periodicity)
18745 {
18746 //While creating StaEntry in csrGetStatistics,
18747 //Initializing and starting timer only when periodicity is set.
18748 //So Stop and Destroy timer only when periodicity is set.
18749
Jeff Johnsone7245742012-09-05 17:12:55 -070018750 vos_timer_stop( &pTempStaEntry->timer );
18751 // Destroy the vos timer...
18752 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18753 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018755 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018756 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018757 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018758
Jeff Johnson295189b2012-06-20 16:38:30 -070018759
18760 pPrevEntry = pEntry;
18761 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18762 }
18763 //the last one
18764 if(pPrevEntry)
18765 {
18766 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18767 //send up the stats report
18768 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18769 pTempStaEntry->staId, pTempStaEntry->pContext);
18770 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018772 return status;
18773
18774}
18775
Jeff Johnson295189b2012-06-20 16:38:30 -070018776eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18777 tRequestFullPowerReason *pReason,
18778 tANI_BOOLEAN *pfNeedPower )
18779{
18780 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18781 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18782 tPmcState pmcState;
18783 eHalStatus status = eHAL_STATUS_SUCCESS;
18784 // TODO : Session info unavailable
18785 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018786 if( pfNeedPower )
18787 {
18788 *pfNeedPower = eANI_BOOLEAN_FALSE;
18789 }
18790 //We only handle CSR commands
18791 if( !(eSmeCsrCommandMask & pCommand->command) )
18792 {
18793 return eHAL_STATUS_SUCCESS;
18794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018795 //Check PMC state first
18796 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018797 switch( pmcState )
18798 {
18799 case REQUEST_IMPS:
18800 case IMPS:
18801 if( eSmeCommandScan == pCommand->command )
18802 {
18803 switch( pCommand->u.scanCmd.reason )
18804 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018805#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18806 case eCsrScanGetLfrResult:
18807#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018808 case eCsrScanGetResult:
18809 case eCsrScanBGScanAbort:
18810 case eCsrScanBGScanEnable:
18811 case eCsrScanGetScanChnInfo:
18812 //Internal process, no need for full power
18813 fNeedFullPower = eANI_BOOLEAN_FALSE;
18814 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018815 default:
18816 //Other scans are real scan, ask for power
18817 fNeedFullPower = eANI_BOOLEAN_TRUE;
18818 break;
18819 } //switch
18820 }
18821 else
18822 {
18823 //ask for power for roam and status change
18824 fNeedFullPower = eANI_BOOLEAN_TRUE;
18825 }
18826 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018827 case REQUEST_BMPS:
18828 case BMPS:
18829 case REQUEST_START_UAPSD:
18830 case UAPSD:
18831 //We treat WOWL same as BMPS
18832 case REQUEST_ENTER_WOWL:
18833 case WOWL:
18834 if( eSmeCommandRoam == pCommand->command )
18835 {
18836 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18837 tCsrScanResult *pScanResult;
18838 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018839 switch ( pCommand->u.roamCmd.roamReason )
18840 {
18841 case eCsrForcedDisassoc:
18842 case eCsrForcedDisassocMICFailure:
18843 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18844 fNeedFullPower = eANI_BOOLEAN_TRUE;
18845 break;
18846 case eCsrSmeIssuedDisassocForHandoff:
18847 case eCsrForcedDeauth:
18848 case eCsrHddIssuedReassocToSameAP:
18849 case eCsrSmeIssuedReassocToSameAP:
18850 fNeedFullPower = eANI_BOOLEAN_TRUE;
18851 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018852 case eCsrCapsChange:
18853 fNeedFullPower = eANI_BOOLEAN_TRUE;
18854 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018855 case eCsrForcedDisassocSta:
18856 case eCsrForcedDeauthSta:
18857 fNeedFullPower = eANI_BOOLEAN_FALSE;
18858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018859 default:
18860 //Check whether the profile is already connected. If so, no need for full power
18861 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18862 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18863 {
18864 //Only need to check the first one
18865 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18866 if( pEntry )
18867 {
18868 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18869#if 0
18870 // TODO : Session Specific info pConnectBssDesc
18871 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18872 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18873 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18874 {
18875 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18876 // with Authenticating first. To force this, stop the current association (Disassociate) and
18877 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18878 // a new Association.
18879 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18880 {
18881 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18882 {
18883 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18884 //No need for full power
18885 //Set the flag so the code later can avoid to do the above
18886 //check again.
18887 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18888 break;
18889 }
18890 }
18891 }
18892#endif
18893 }
18894 }
18895 //If we are here, full power is needed
18896 fNeedFullPower = eANI_BOOLEAN_TRUE;
18897 break;
18898 }
18899 }
18900 else if( eSmeCommandWmStatusChange == pCommand->command )
18901 {
18902 //need full power for all
18903 fNeedFullPower = eANI_BOOLEAN_TRUE;
18904 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18905 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018906#ifdef FEATURE_WLAN_TDLS
18907 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18908 {
18909 //TDLS link is getting established. need full power
18910 fNeedFullPower = eANI_BOOLEAN_TRUE;
18911 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18912 }
18913#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018914 else if (eSmeCommandDelStaSession == pCommand->command)
18915 {
18916 //need full power for all
18917 fNeedFullPower = eANI_BOOLEAN_TRUE;
18918 }
18919
Jeff Johnson295189b2012-06-20 16:38:30 -070018920 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018921 case REQUEST_STOP_UAPSD:
18922 case REQUEST_EXIT_WOWL:
18923 if( eSmeCommandRoam == pCommand->command )
18924 {
18925 fNeedFullPower = eANI_BOOLEAN_TRUE;
18926 switch ( pCommand->u.roamCmd.roamReason )
18927 {
18928 case eCsrForcedDisassoc:
18929 case eCsrForcedDisassocMICFailure:
18930 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18931 break;
18932 default:
18933 break;
18934 }
18935 }
18936 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018937 case STOPPED:
18938 case REQUEST_STANDBY:
18939 case STANDBY:
18940 case LOW_POWER:
18941 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018942 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18943 " stopped/standby state %s (%d)" ),
18944 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018945 status = eHAL_STATUS_FAILURE;
18946 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018947 case FULL_POWER:
18948 case REQUEST_FULL_POWER:
18949 default:
18950 //No need to ask for full power. This has to be FULL_POWER state
18951 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018952 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018953 if( pReason )
18954 {
18955 *pReason = reason;
18956 }
18957 if( pfNeedPower )
18958 {
18959 *pfNeedPower = fNeedFullPower;
18960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018961 return ( status );
18962}
18963
Jeff Johnson295189b2012-06-20 16:38:30 -070018964static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18965{
18966 eHalStatus status = eHAL_STATUS_SUCCESS;
18967 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18968 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018969 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018970 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18971 {
18972 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018974 return ( status );
18975}
18976
Jeff Johnson295189b2012-06-20 16:38:30 -070018977tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18978{
18979 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018980 if( pCmd )
18981 {
18982 pMac->roam.sPendingCommands++;
18983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018984 return ( pCmd );
18985}
18986
Jeff Johnson295189b2012-06-20 16:38:30 -070018987void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18988{
18989 if (pMac->roam.sPendingCommands > 0)
18990 {
18991 //All command allocated through csrGetCommandBuffer need to
18992 //decrement the pending count when releasing.
18993 pMac->roam.sPendingCommands--;
18994 smeReleaseCommand( pMac, pCommand );
18995 }
18996 else
18997 {
18998 smsLog(pMac, LOGE, FL( "no pending commands"));
18999 VOS_ASSERT(0);
19000 }
19001}
19002
Jeff Johnson295189b2012-06-20 16:38:30 -070019003//Return SUCCESS is the command is queued, failed
19004eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
19005{
19006 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053019007
19008 if (!SME_IS_START(pMac))
19009 {
19010 smsLog( pMac, LOGE, FL("Sme in stop state"));
19011 return eHAL_STATUS_FAILURE;
19012 }
19013
Jeff Johnson295189b2012-06-20 16:38:30 -070019014 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
19015 {
19016 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
19017 pCommand->u.scanCmd.reason);
19018 return eHAL_STATUS_CSR_WRONG_STATE;
19019 }
19020
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019021 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
19022 {
19023 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
19024 &pCommand->Link, LL_ACCESS_LOCK);
19025 // process the command queue...
19026 smeProcessPendingQueue(pMac);
19027 status = eHAL_STATUS_SUCCESS;
19028 goto end;
19029 }
19030
Jeff Johnson295189b2012-06-20 16:38:30 -070019031 //We can call request full power first before putting the command into pending Q
19032 //because we are holding SME lock at this point.
19033 status = csrRequestFullPower( pMac, pCommand );
19034 if( HAL_STATUS_SUCCESS( status ) )
19035 {
19036 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070019037 //make sure roamCmdPendingList is not empty first
19038 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
19039 if( fNoCmdPending )
19040 {
19041 smePushCommand( pMac, pCommand, fHighPriority );
19042 }
19043 else
19044 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019045 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070019046 //no list lock is needed since SME lock is held
19047 if( !fHighPriority )
19048 {
19049 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19050 }
19051 else {
19052 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19053 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019055 }
19056 else if( eHAL_STATUS_PMC_PENDING == status )
19057 {
19058 //no list lock is needed since SME lock is held
19059 if( !fHighPriority )
19060 {
19061 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19062 }
19063 else {
19064 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19065 }
19066 //Let caller know the command is queue
19067 status = eHAL_STATUS_SUCCESS;
19068 }
19069 else
19070 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019071 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070019072 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019073 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070019074 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019075end:
Jeff Johnson295189b2012-06-20 16:38:30 -070019076 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070019077}
Jeff Johnson295189b2012-06-20 16:38:30 -070019078eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
19079{
19080 eHalStatus status = eHAL_STATUS_SUCCESS;
19081 tSirUpdateAPWPSIEsReq *pMsg;
19082 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
19083
19084 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19085 if (NULL == pSession)
19086 {
19087 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
19088 return eHAL_STATUS_FAILURE;
19089 }
19090
Jeff Johnson295189b2012-06-20 16:38:30 -070019091 do
19092 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019093 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
19094 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19095 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070019096 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
19097
19098 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070019099 VOS_ASSERT(pBuf);
19100
Jeff Johnson295189b2012-06-20 16:38:30 -070019101 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070019102 // transactionId
19103 *pBuf = 0;
19104 *( pBuf + 1 ) = 0;
19105 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070019106 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019107 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19108 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019109 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019110 //sessionId
19111 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019112 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019113 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070019114 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070019115 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019116 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019117 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019118 return ( status );
19119}
Jeff Johnson295189b2012-06-20 16:38:30 -070019120eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
19121{
19122 eHalStatus status = eHAL_STATUS_SUCCESS;
19123 tSirUpdateAPWPARSNIEsReq *pMsg;
19124 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070019125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19126 if (NULL == pSession)
19127 {
19128 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
19129 return eHAL_STATUS_FAILURE;
19130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019131 do
19132 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019133 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
19134 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19135 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070019136 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070019137 pBuf = (tANI_U8 *)&pMsg->transactionId;
19138 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070019139 // transactionId
19140 *pBuf = 0;
19141 *( pBuf + 1 ) = 0;
19142 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070019143 VOS_ASSERT(pBuf);
19144
Jeff Johnson295189b2012-06-20 16:38:30 -070019145 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019146 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19147 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019148 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019149 // sessionId
19150 *pBuf++ = (tANI_U8)sessionId;
19151
19152 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019153 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070019154 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070019155 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019156 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019157 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019158 return ( status );
19159}
Jeff Johnson295189b2012-06-20 16:38:30 -070019160
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019161tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
19162 tpSirBssDescription pBssDescription)
19163{
19164 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19165 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19166 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
19167 eHalStatus status;
19168 tDot11fBeaconIEs *ies_local = NULL;
19169 tANI_U32 dot11mode = 0;
19170
19171 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19172
19173 /* Get IE's */
19174 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19175 if (!HAL_STATUS_SUCCESS(status)) {
19176 smsLog(pMac, LOGE,
19177 FL("csrGetParsedBssDescriptionIEs failed"));
19178 return 0;
19179 }
19180 if(ies_local == NULL) {
19181 smsLog(pMac, LOGE,
19182 FL("ies_local is NULL"));
19183 return 0;
19184 }
19185
19186 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19187 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19188 uCfgDot11Mode = cfgDot11Mode;
19189 else
19190 {
19191 smsLog(pMac, LOGE, "Can not find match phy mode");
19192 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19193 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19194 else
19195 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19196 }
19197
19198 /* dot11mode */
19199 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19200 smsLog(pMac, LOG1,
19201 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19202
19203 if (pBssDescription->channelId <= 14 &&
19204 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19205 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19206 {
19207 /* Need to disable VHT operation in 2.4 GHz band */
19208 dot11mode = WNI_CFG_DOT11_MODE_11N;
19209 }
19210 vos_mem_free(ies_local);
19211 return dot11mode;
19212}
19213
Jeff Johnson295189b2012-06-20 16:38:30 -070019214#ifdef WLAN_FEATURE_VOWIFI_11R
19215//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19216eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19217{
19218 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19219 tpSirFTPreAuthReq pftPreAuthReq;
19220 tANI_U16 auth_req_len = 0;
19221 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019222 auth_req_len = sizeof(tSirFTPreAuthReq);
19223 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019224 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019225 {
19226 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19227 return eHAL_STATUS_RESOURCES;
19228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019229 // Save the SME Session ID here. We need it while processing the preauth response
19230 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019231 vos_mem_zero(pftPreAuthReq, auth_req_len);
19232
19233 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19234 sizeof(pBssDescription->length) + pBssDescription->length);
19235
19236 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19237
19238 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019239 pftPreAuthReq->dot11mode =
19240 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19241 if (!pftPreAuthReq->dot11mode)
19242 {
19243 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19244 vos_mem_free(pftPreAuthReq);
19245 return eHAL_STATUS_FAILURE;
19246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019247
Kiet Lam64c1b492013-07-12 13:56:44 +053019248 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19249 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19250 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19251 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019252
Jeff Johnson295189b2012-06-20 16:38:30 -070019253#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019254 if (csrRoamIs11rAssoc(pMac) &&
19255 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019256 {
19257 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019258 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19259 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019260 }
19261 else
19262#endif
19263 {
19264 pftPreAuthReq->ft_ies_length = 0;
19265 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019266 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19267 sizeof(pBssDescription->length) + pBssDescription->length);
19268 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019269 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19270}
Jeff Johnson295189b2012-06-20 16:38:30 -070019271/*--------------------------------------------------------------------------
19272 * This will receive and process the FT Pre Auth Rsp from the current
19273 * associated ap.
19274 *
19275 * This will invoke the hdd call back. This is so that hdd can now
19276 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19277 ------------------------------------------------------------------------*/
19278void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19279{
19280 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19281 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019282#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019283 tCsrRoamInfo roamInfo;
19284#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019285 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019286
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019287#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019288 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019289 if (status != eHAL_STATUS_SUCCESS) {
19290 /*
19291 * Bail out if pre-auth was not even processed.
19292 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019293 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19294 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019295 return;
19296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019298 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19299 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19300 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019301 // Implies a success
19302 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019303 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19304 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019305 /* No need to notify qos module if this is a non 11r & ESE roam*/
19306 if (csrRoamIs11rAssoc(pMac)
19307#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19308 || csrRoamIsESEAssoc(pMac)
19309#endif
19310 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019311 {
19312 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19313 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019314 if (pMac->roam.configParam.roamDelayStatsEnabled)
19315 {
19316 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019318 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19319 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019320 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19321 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019322 if (pMac->roam.configParam.roamDelayStatsEnabled)
19323 {
19324 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19325 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019326 if (eHAL_STATUS_SUCCESS != status)
19327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019328 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019329 return;
19330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019331 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019332 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19333 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019334 if (csrRoamIs11rAssoc(pMac))
19335 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19336 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19337
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019338#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19339 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019340 {
19341 /* read TSF */
19342 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19343
19344 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019345 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019346 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19347 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019348#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019349#ifdef FEATURE_WLAN_LFR
19350 // If Legacy Fast Roaming is enabled, signal the supplicant
19351 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019352 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019353 {
19354 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019355 vos_mem_copy((void *)&roamInfo.bssid,
19356 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019357 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19358 }
19359
19360#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019361
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019362 // If its an Open Auth, FT IEs are not provided by supplicant
19363 // Hence populate them here
19364 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19365 pMac->ft.ftSmeContext.addMDIE = FALSE;
19366 if( csrRoamIs11rAssoc(pMac) &&
19367 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19368 {
19369 tANI_U16 ft_ies_length;
19370 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19371
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019372 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19373 connectedProfile.MDID.mdiePresent)
19374 pMac->ft.ftSmeContext.addMDIE = TRUE;
19375
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019376 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19377 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19378 {
19379 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19380 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19381 }
19382
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019383 if (!ft_ies_length)
19384 {
19385 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19386 return;
19387 }
19388
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019389 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19390 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19391 {
19392 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19393 }
19394 else
19395 {
19396 // Copy the RIC IEs to reassoc IEs
19397 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19398 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19399 pFTPreAuthRsp->ric_ies_length);
19400 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19401 pMac->ft.ftSmeContext.addMDIE = TRUE;
19402 }
19403 }
19404
Jeff Johnson295189b2012-06-20 16:38:30 -070019405 // Done with it, init it.
19406 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19407}
19408#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019409
Jeff Johnson295189b2012-06-20 16:38:30 -070019410#ifdef FEATURE_WLAN_BTAMP_UT_RF
19411void csrRoamJoinRetryTimerHandler(void *pv)
19412{
19413 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19414 tpAniSirGlobal pMac = pInfo->pMac;
19415 tANI_U32 sessionId = pInfo->sessionId;
19416 tCsrRoamSession *pSession;
19417
19418 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019420 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019421 pSession = CSR_GET_SESSION( pMac, sessionId );
19422 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19423 {
19424 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019426 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019427 }
19428 }
19429 }
19430}
Jeff Johnson295189b2012-06-20 16:38:30 -070019431eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19432{
19433 eHalStatus status = eHAL_STATUS_FAILURE;
19434 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19435
19436 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019438 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019439 pSession->maxRetryCount--;
19440 pSession->joinRetryTimerInfo.pMac = pMac;
19441 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019442 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19443 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019445 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019446 }
19447 }
19448 else
19449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019450 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019451 pSession->maxRetryCount);
19452 }
19453
19454 return (status);
19455}
Jeff Johnson295189b2012-06-20 16:38:30 -070019456eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19457{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019458 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019459 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19460 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019461 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019462 }
19463
19464 return eHAL_STATUS_SUCCESS;
19465}
19466#endif
19467
19468
19469/*
19470 pBuf points to the beginning of the message
19471 LIM packs disassoc rsp as below,
19472 messageType - 2 bytes
19473 messageLength - 2 bytes
19474 sessionId - 1 byte
19475 transactionId - 2 bytes (tANI_U16)
19476 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19477 peerMacAddr - 6 bytes
19478 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19479*/
19480static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19481{
19482 if(pBuf && pRsp)
19483 {
19484 pBuf += 4; //skip type and length
19485 pRsp->sessionId = *pBuf++;
19486 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19487 pBuf += 2;
19488 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19489 pBuf += 4;
19490 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19491 }
19492}
19493
Jeff Johnsond13512a2012-07-17 11:42:19 -070019494eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19495{
19496 static uNvTables nvTables;
19497 eHalStatus status = eHAL_STATUS_SUCCESS;
19498 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19499
19500 /* read the country code from NV and use it */
19501 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19502 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019503 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19504 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019505 return status;
19506 }
19507 else
19508 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019509 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019510 status = eHAL_STATUS_FAILURE;
19511 return status;
19512 }
19513}
19514
19515eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19516{
Kiet Lam64c1b492013-07-12 13:56:44 +053019517 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019518 return eHAL_STATUS_SUCCESS;
19519}
schang86c22c42013-03-13 18:41:24 -070019520
19521eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19522{
19523 tSirSetTxPowerReq *pMsg = NULL;
19524 eHalStatus status = eHAL_STATUS_SUCCESS;
19525 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19526
19527 if (!pSession)
19528 {
19529 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19530 return eHAL_STATUS_FAILURE;
19531 }
19532
Kiet Lam64c1b492013-07-12 13:56:44 +053019533 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19534 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19535 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19536 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19537 pMsg->length = sizeof(tSirSetTxPowerReq);
19538 pMsg->mwPower = mW;
19539 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19540 sizeof(tSirMacAddr));
19541 status = palSendMBMessage(pMac->hHdd, pMsg);
19542 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019543 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019544 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19545 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019546 }
19547 return status;
19548}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019549
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019550eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19551{
19552 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19553 eHalStatus status = eHAL_STATUS_SUCCESS;
19554 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19555
19556 if (!pSession)
19557 {
19558 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19559 return eHAL_STATUS_FAILURE;
19560 }
19561 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19562 {
19563 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019564
19565 if( NULL == pMsg )
19566 {
19567 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19568 return eHAL_STATUS_FAILURE;
19569 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019570 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19571 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019572 pMsg->length =
19573 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019574 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019575 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19576 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019577 status = palSendMBMessage(pMac->hHdd, pMsg);
19578 if (!HAL_STATUS_SUCCESS(status))
19579 {
19580 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19581 //pMsg is freed by palSendMBMessage
19582 }
19583 }
19584 else
19585 {
19586 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19587 status = eHAL_STATUS_FAILURE;
19588 }
19589 return status;
19590}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019591/* Returns whether a session is in VOS_STA_MODE...or not */
19592tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19593{
19594 tCsrRoamSession *pSession = NULL;
19595 pSession = CSR_GET_SESSION ( pMac, sessionId );
19596 if(!pSession)
19597 {
19598 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19599 return eANI_BOOLEAN_FALSE;
19600 }
19601 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19602 {
19603 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19604 return eANI_BOOLEAN_FALSE;
19605 }
19606 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19607 {
19608 return eANI_BOOLEAN_FALSE;
19609 }
19610 /* There is a possibility that the above check may fail,because
19611 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19612 * when it is connected.So,we may sneak through the above check even
19613 * if we are not a STA mode INFRA station. So, if we sneak through
19614 * the above condition, we can use the following check if we are
19615 * really in STA Mode.*/
19616
19617 if ( NULL != pSession->pCurRoamProfile )
19618 {
19619 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19620 {
19621 return eANI_BOOLEAN_TRUE;
19622 } else {
19623 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19624 return eANI_BOOLEAN_FALSE;
19625 }
19626 }
19627
19628 return eANI_BOOLEAN_FALSE;
19629}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019630
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019631/**
19632 * csr_set_src_handoff_request() - Set handoff source to
19633 * SME handoff request
19634 * @pHandoffInfo: Pointer to Handoff info
19635 * @pMsg: Pointer to SME handoff request message
19636 *
19637 * Return: None
19638 */
19639#ifndef QCA_WIFI_ISOC
19640static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19641 tCsrHandoffRequest *pHandoffInfo)
19642{
19643 pMsg->handoff_src = pHandoffInfo->src;
19644}
19645#else
19646static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19647 tCsrHandoffRequest *pHandoffInfo)
19648{
19649}
19650#endif
19651
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019652#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19653eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19654 tCsrHandoffRequest *pHandoffInfo)
19655{
19656 eHalStatus status = eHAL_STATUS_SUCCESS;
19657 vos_msg_t msg;
19658
19659 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019660 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19661 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019662 {
19663 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019664 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019665 }
19666 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19667 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19668 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19669 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019670 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019671 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019672 pHandoffInfo->bssid,
19673 6);
19674 msg.type = eWNI_SME_HANDOFF_REQ;
19675 msg.bodyptr = pMsg;
19676 msg.reserved = 0;
19677 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19678 {
19679 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019680 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019681 status = eHAL_STATUS_FAILURE;
19682 }
19683 return status;
19684}
19685#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019686
Abhishek Singh00b71972016-01-07 10:51:04 +053019687#ifdef WLAN_FEATURE_RMC
19688eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19689{
19690 tSirSetRMCReq *pMsg = NULL;
19691 eHalStatus status = eHAL_STATUS_SUCCESS;
19692 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19693
19694 if (!pSession)
19695 {
19696 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19697 return eHAL_STATUS_FAILURE;
19698 }
19699
19700 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19701 if (NULL != pMsg)
19702 {
19703 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19704 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19705 pMsg->msgLen = sizeof(tSirSetRMCReq);
19706 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19707 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19708
19709 status = palSendMBMessage(pMac->hHdd, pMsg);
19710 if (!HAL_STATUS_SUCCESS(status))
19711 {
19712 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19713 //pMsg is freed by palSendMBMessage
19714 }
19715 }
19716 else
19717 {
19718 return eHAL_STATUS_FAILURE;
19719 }
19720 return status;
19721}
19722
19723eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19724{
19725 tSirSetRMCReq *pMsg = NULL;
19726 eHalStatus status = eHAL_STATUS_SUCCESS;
19727 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19728
19729 if (!pSession)
19730 {
19731 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19732 return eHAL_STATUS_FAILURE;
19733 }
19734
19735 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19736 if (NULL != pMsg)
19737 {
19738 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19739 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19740 pMsg->msgLen = sizeof(tSirSetRMCReq);
19741 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19742 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19743
19744 status = palSendMBMessage(pMac->hHdd, pMsg);
19745 if (!HAL_STATUS_SUCCESS(status))
19746 {
19747 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19748 //pMsg is freed by palSendMBMessage
19749 }
19750 }
19751 else
19752 {
19753 return eHAL_STATUS_FAILURE;
19754 }
19755 return status;
19756}
19757
19758#endif /* WLAN_FEATURE_RMC */
19759
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019760
19761#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019762/* ---------------------------------------------------------------------------
19763 \fn csrSetCCKMIe
19764 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19765 data structure and this IE will be packed inside reassociation request
19766 \param pMac - pMac global structure
19767 \param sessionId - Current session id
19768 \param pCckmIe - pointer to CCKM IE data
19769 \param ccKmIeLen - length of the CCKM IE
19770 \- return Success or failure
19771 -------------------------------------------------------------------------*/
19772VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19773 const tANI_U8 *pCckmIe,
19774 const tANI_U8 ccKmIeLen)
19775{
19776 eHalStatus status = eHAL_STATUS_SUCCESS;
19777 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19778
19779 if (!pSession)
19780 {
19781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19782 return eHAL_STATUS_FAILURE;
19783 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019784 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019785 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19786 return status;
19787}
19788
19789/* ---------------------------------------------------------------------------
19790 \fn csrRoamReadTSF
19791 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19792 probe response reception from the hand off AP to arrive at the latest TSF value.
19793 \param pMac - pMac global structure
19794 \param pTimestamp - output TSF timestamp
19795 \- return Success or failure
19796 -------------------------------------------------------------------------*/
19797VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19798{
19799 eHalStatus status = eHAL_STATUS_SUCCESS;
19800 tCsrNeighborRoamBSSInfo handoffNode;
19801 tANI_U32 timer_diff = 0;
19802 tANI_U32 timeStamp[2];
19803 tpSirBssDescription pBssDescription = NULL;
19804
19805 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19806 pBssDescription = handoffNode.pBssDescription;
19807
19808 // Get the time diff in milli seconds
19809 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19810 // Convert msec to micro sec timer
19811 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19812
19813 timeStamp[0] = pBssDescription->timeStamp[0];
19814 timeStamp[1] = pBssDescription->timeStamp[1];
19815
19816 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19817
Kiet Lamf2f201e2013-11-16 21:24:16 +053019818 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019819 sizeof (tANI_U32) * 2);
19820 return status;
19821}
19822
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019823#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019824
Agarwal Ashish738843c2014-09-25 12:27:56 +053019825/* ---------------------------------------------------------------------------
19826 \fn csrDisableDfsChannel
19827 \brief This function will call csrApplyChannelPowerCountryInfo to
19828 \ to trim the list on basis of NO_DFS flag.
19829 \param pMac - pMac global structure
19830 \- return void
19831 -------------------------------------------------------------------------*/
19832void csrDisableDfsChannel(tpAniSirGlobal pMac)
19833{
19834 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19835 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19836}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019837
19838/* ---------------------------------------------------------------------------
19839 \fn csrGetStaticUapsdMask
19840 \brief This function will get the static uapsd settings for an existing
19841 \ Infra session.
19842 \param pMac - pMac global structure
19843 \- return void
19844 -------------------------------------------------------------------------*/
19845void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19846{
19847 tANI_S8 sessionId;
19848 tCsrRoamSession *pSession = NULL;
19849
19850 *staticUapsdMask = 0;
19851 sessionId = csrGetInfraSessionId(pMac);
19852 if(sessionId == -1)
19853 smsLog(pMac, LOGE, FL("Valid session not present."));
19854 else
19855 pSession = CSR_GET_SESSION(pMac, sessionId);
19856
19857 if(!pSession || !pSession->pCurRoamProfile)
19858 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019859 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019860 else
19861 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19862}
19863
Abhishek Singh02605092017-10-25 14:06:12 +053019864VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19865 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19866{
19867 VOS_STATUS status = VOS_STATUS_SUCCESS;
19868 struct sir_ecsa_ie_req *msg;
19869
19870 msg = vos_mem_malloc(sizeof(*msg));
19871 if (!msg) {
19872 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19873 return VOS_STATUS_E_NOMEM;
19874 }
19875
19876 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19877 msg->len = sizeof(*msg);
19878
19879 msg->new_chan = new_chan;
19880 msg->cb_mode = cb_mode;
19881 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19882
19883 status = palSendMBMessage(mac_ctx->hHdd, msg);
19884 if (!VOS_IS_STATUS_SUCCESS(status))
19885 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019886 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019887 return status;
19888}
19889
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019890VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19891 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19892{
19893 VOS_STATUS status = VOS_STATUS_SUCCESS;
19894 struct sir_channel_chanege_req *msg;
19895 tCsrRoamStartBssParams param;
19896
19897 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19898
19899 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19900
19901 msg = vos_mem_malloc(sizeof(*msg));
19902 if (!msg) {
19903 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19904 return VOS_STATUS_E_NOMEM;
19905 }
19906
19907 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19908 msg->len = sizeof(*msg);
19909
19910 msg->new_chan = new_chan;
19911 msg->cb_mode = cb_mode;
19912 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19913 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19914 mac_ctx->roam.configParam.uCfgDot11Mode);
19915 if (IS_24G_CH(msg->new_chan) &&
19916 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19917 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19918 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19919 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19920
19921 vos_mem_copy(&msg->operational_rateset,
19922 &param.operationalRateSet, sizeof(msg->operational_rateset));
19923 vos_mem_copy(&msg->extended_rateset,
19924 &param.extendedRateSet, sizeof(msg->extended_rateset));
19925
19926 status = palSendMBMessage(mac_ctx->hHdd, msg);
19927 if (!VOS_IS_STATUS_SUCCESS(status))
19928 smsLog(mac_ctx, LOGE,
19929 FL(" channel switch req fauiled status %d "), status);
19930 return status;
19931}