blob: 110c606314b820048e3d32dd941af80f2f6f3d19 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
gaurank kathpaliab654f702020-01-03 15:07:17 +05302 * Copyright (c) 2012-2020 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
gaurank kathpaliab654f702020-01-03 15:07:17 +053012902 pSession->PmkidCacheInfo[cache_idx].pmk_len = 0;
12903 if (pmksa->pmk_len && pmksa->pmk_len <= CSR_RSN_MAX_PMK_LEN) {
Abhinav Kumar8c122592019-08-07 15:43:20 +053012904 vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].pmk,
12905 pmksa->pmk, pmksa->pmk_len);
gaurank kathpaliab654f702020-01-03 15:07:17 +053012906 pSession->PmkidCacheInfo[cache_idx].pmk_len = pmksa->pmk_len;
12907 }
Abhinav Kumar8c122592019-08-07 15:43:20 +053012908
12909 /* Increment the CSR local cache index */
12910 if (cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
12911 pSession->CurCacheIndex++;
12912 else
12913 pSession->CurCacheIndex = 0;
12914
12915 pSession->NumPmkidCache++;
12916 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12917 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12918}
12919
Jeff Johnson295189b2012-06-20 16:38:30 -070012920eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012921 tPmkidCacheInfo *pPMKIDCache,
12922 tANI_U32 numItems,
12923 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012924{
12925 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12926 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012927
12928 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012929 {
12930 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12931 return eHAL_STATUS_FAILURE;
12932 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012933
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012934 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012935
12936 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 {
12938#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12939 {
12940 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012941 vos_mem_set(&secEvent,
12942 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012943 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12944 secEvent.encryptionModeMulticast =
12945 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12946 secEvent.encryptionModeUnicast =
12947 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012948 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 secEvent.authMode =
12950 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12951 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12952 }
12953#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012955 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012956 if (numItems && pPMKIDCache)
12957 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012958 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012959 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12960 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012961 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012962 }
12963 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012964 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012965 tPmkidCacheInfo *pmksa;
12966
12967 for (i = 0; i < numItems; i++) {
12968 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012969
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012970 /* Delete the entry if present */
Abhinav Kumar8c122592019-08-07 15:43:20 +053012971 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa,FALSE);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012972
Abhinav Kumar8c122592019-08-07 15:43:20 +053012973 csr_update_pmk_cache(pSession, pmksa);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012974
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 }
12977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 return (status);
12979}
12980
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012981eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012982#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
Abhinav Kumar8c122592019-08-07 15:43:20 +053012983 tPmkidCacheInfo *pmksa,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012984#else
Abhinav Kumar8c122592019-08-07 15:43:20 +053012985 tPmkidCacheInfo *pmksa,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012986#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012987 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012988{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012989 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12990 tANI_BOOLEAN fMatchFound = FALSE;
12991 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012992 tANI_U32 CurIndex;
12993 tANI_U32 i;
Abhinav Kumar8c122592019-08-07 15:43:20 +053012994 tPmkidCacheInfo *cached_pmksa;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012995
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012996 if(!pSession)
12997 {
12998 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12999 return eHAL_STATUS_FAILURE;
13000 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013001
13002 /* Check if there are no entries to delete */
13003 if (0 == pSession->NumPmkidCache) {
13004 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
13005 return eHAL_STATUS_SUCCESS;
13006 }
13007
13008 if (!flush_cache) {
13009 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Abhinav Kumar8c122592019-08-07 15:43:20 +053013010 cached_pmksa = &pSession->PmkidCacheInfo[Index];
13011 if (((!cached_pmksa->ssid_len) &&
13012 vos_is_macaddr_equal((v_MACADDR_t *)cached_pmksa->BSSID,
13013 (v_MACADDR_t *)pmksa->BSSID))) {
13014 fMatchFound = 1;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013015
Abhinav Kumar8c122592019-08-07 15:43:20 +053013016 } else if ((!vos_mem_compare(cached_pmksa->ssid,
13017 pmksa->ssid, pmksa->ssid_len)) &&
13018 (!vos_mem_compare(cached_pmksa->cache_id,
13019 pmksa->cache_id, CACHE_ID_LEN)))
13020 fMatchFound = 1;
13021
13022 if(fMatchFound) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013023 /* Clear this - the matched entry */
Abhinav Kumar8c122592019-08-07 15:43:20 +053013024 vos_mem_zero(cached_pmksa, sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013025 break;
13026 }
13027 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013028
13029 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
Abhinav Kumar8c122592019-08-07 15:43:20 +053013030 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "));
13031
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013032 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013033 else {
13034 /* Match Found */
13035 CurIndex = pSession->CurCacheIndex;
13036 if(Index < CurIndex) {
13037 for(i = Index; i < (CurIndex-1); i++) {
13038 vos_mem_copy(&pSession->PmkidCacheInfo[i],
13039 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
13040 }
13041 pSession->CurCacheIndex--;
13042 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
13043 sizeof(tPmkidCacheInfo));
13044 } else if(Index > CurIndex) {
13045 for(i = Index; i > (CurIndex); i--) {
13046 vos_mem_copy(&pSession->PmkidCacheInfo[i],
13047 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
13048 }
13049 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
13050 sizeof(tPmkidCacheInfo));
13051 }
13052 pSession->NumPmkidCache--;
13053 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013054 } else {
13055 /* Flush the entire cache */
13056 vos_mem_zero(pSession->PmkidCacheInfo,
13057 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
13058 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013059 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013060 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013061
13062 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070013063}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013064
Jeff Johnson295189b2012-06-20 16:38:30 -070013065tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
13066{
13067 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
13068}
13069
Jeff Johnson295189b2012-06-20 16:38:30 -070013070eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
13071{
13072 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13073 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013074 tPmkidCacheInfo *pmksa;
13075 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013076
13077 if(!pSession)
13078 {
13079 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13080 return eHAL_STATUS_FAILURE;
13081 }
13082
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 if(pNum && pPmkidCache)
13084 {
13085 if(pSession->NumPmkidCache == 0)
13086 {
13087 *pNum = 0;
13088 status = eHAL_STATUS_SUCCESS;
13089 }
13090 else if(*pNum >= pSession->NumPmkidCache)
13091 {
13092 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
13093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013094 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 -070013095 pSession->NumPmkidCache);
13096 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13097 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053013098
13099 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
13100 pmksa = &pSession->PmkidCacheInfo[i];
13101 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
13102 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
13103 pPmkidCache++;
13104 j++;
13105 }
13106 }
13107
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 *pNum = pSession->NumPmkidCache;
13109 status = eHAL_STATUS_SUCCESS;
13110 }
13111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 return (status);
13113}
13114
Jeff Johnson295189b2012-06-20 16:38:30 -070013115eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13116{
13117 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13118 tANI_U32 len;
13119 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013120
13121 if(!pSession)
13122 {
13123 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13124 return eHAL_STATUS_FAILURE;
13125 }
13126
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 if(pLen)
13128 {
13129 len = *pLen;
13130 *pLen = pSession->nWpaRsnReqIeLength;
13131 if(pBuf)
13132 {
13133 if(len >= pSession->nWpaRsnReqIeLength)
13134 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013135 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
13136 pSession->nWpaRsnReqIeLength);
13137 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 }
13139 }
13140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 return (status);
13142}
13143
Jeff Johnson295189b2012-06-20 16:38:30 -070013144eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13145{
13146 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13147 tANI_U32 len;
13148 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013149
13150 if(!pSession)
13151 {
13152 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13153 return eHAL_STATUS_FAILURE;
13154 }
13155
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 if(pLen)
13157 {
13158 len = *pLen;
13159 *pLen = pSession->nWpaRsnRspIeLength;
13160 if(pBuf)
13161 {
13162 if(len >= pSession->nWpaRsnRspIeLength)
13163 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013164 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
13165 pSession->nWpaRsnRspIeLength);
13166 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 }
13168 }
13169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013170 return (status);
13171}
Jeff Johnson295189b2012-06-20 16:38:30 -070013172#ifdef FEATURE_WLAN_WAPI
13173eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13174{
13175 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13176 tANI_U32 len;
13177 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013178
13179 if(!pSession)
13180 {
13181 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13182 return eHAL_STATUS_FAILURE;
13183 }
13184
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 if(pLen)
13186 {
13187 len = *pLen;
13188 *pLen = pSession->nWapiReqIeLength;
13189 if(pBuf)
13190 {
13191 if(len >= pSession->nWapiReqIeLength)
13192 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013193 vos_mem_copy(pBuf, pSession->pWapiReqIE,
13194 pSession->nWapiReqIeLength);
13195 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013196 }
13197 }
13198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 return (status);
13200}
Jeff Johnson295189b2012-06-20 16:38:30 -070013201eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
13202{
13203 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
13204 tANI_U32 len;
13205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013206
13207 if(!pSession)
13208 {
13209 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13210 return eHAL_STATUS_FAILURE;
13211 }
13212
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 if(pLen)
13214 {
13215 len = *pLen;
13216 *pLen = pSession->nWapiRspIeLength;
13217 if(pBuf)
13218 {
13219 if(len >= pSession->nWapiRspIeLength)
13220 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013221 vos_mem_copy(pBuf, pSession->pWapiRspIE,
13222 pSession->nWapiRspIeLength);
13223 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 }
13225 }
13226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 return (status);
13228}
13229#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013230eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
13231{
13232 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13233 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013234
13235 if(!pSession)
13236 {
13237 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13238 return (retStatus);
13239 }
13240
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 if(CSR_IS_ROAMING(pSession))
13242 {
13243 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13244 pSession->fRoaming = eANI_BOOLEAN_FALSE;
13245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 return (retStatus);
13247}
13248
Jeff Johnson295189b2012-06-20 16:38:30 -070013249//This function remove the connected BSS from te cached scan result
13250eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
13251 tCsrRoamConnectedProfile *pConnProfile)
13252{
13253 eHalStatus status = eHAL_STATUS_FAILURE;
13254 tCsrScanResultFilter *pScanFilter = NULL;
13255 tListElem *pEntry;
13256 tCsrScanResult *pResult;
13257 tDot11fBeaconIEs *pIes;
13258 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
13260 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
13261 {
13262 do
13263 {
13264 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013265 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13266 if ( NULL == pScanFilter )
13267 status = eHAL_STATUS_FAILURE;
13268 else
13269 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013271 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13272 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13273 if ( NULL == pScanFilter->BSSIDs.bssid )
13274 status = eHAL_STATUS_FAILURE;
13275 else
13276 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013278 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13279 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13281 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13282 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013283 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13284 if ( NULL == pScanFilter->SSIDs.SSIDList )
13285 status = eHAL_STATUS_FAILURE;
13286 else
13287 status = eHAL_STATUS_SUCCESS;
13288 if (!HAL_STATUS_SUCCESS(status)) break;
13289 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13290 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 }
13292 pScanFilter->authType.numEntries = 1;
13293 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13294 pScanFilter->BSSType = pConnProfile->BSSType;
13295 pScanFilter->EncryptionType.numEntries = 1;
13296 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13297 pScanFilter->mcEncryptionType.numEntries = 1;
13298 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13299 //We ignore the channel for now, BSSID should be enough
13300 pScanFilter->ChannelInfo.numOfChannels = 0;
13301 //Also ignore the following fields
13302 pScanFilter->uapsd_mask = 0;
13303 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013304 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 pScanFilter->countryCode[0] = 0;
13306 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 csrLLLock(&pMac->scan.scanResultList);
13308 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13309 while( pEntry )
13310 {
13311 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13312 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13313 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13314 pScanFilter, NULL, NULL, NULL, &pIes);
13315 //Release the IEs allocated by csrMatchBSS is needed
13316 if( !pResult->Result.pvIes )
13317 {
13318 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013319 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 }
13321 if(fMatch)
13322 {
13323 //We found the one
13324 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13325 {
13326 //Free the memory
13327 csrFreeScanResultEntry( pMac, pResult );
13328 }
13329 break;
13330 }
13331 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13332 }//while
13333 csrLLUnlock(&pMac->scan.scanResultList);
13334 }while(0);
13335 if(pScanFilter)
13336 {
13337 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013338 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 }
13340 }
13341 return (status);
13342}
13343
Jeff Johnson295189b2012-06-20 16:38:30 -070013344//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013345eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13346{
13347 eHalStatus status = eHAL_STATUS_SUCCESS;
13348 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13350 {
13351 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13352 {
13353 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13354 {
13355 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013356 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 status = eHAL_STATUS_CSR_WRONG_STATE;
13358 break;
13359 }
13360 if( csrIsConnStateInfra( pMac, sessionId ) )
13361 {
13362 if( chnId &&
13363 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013365 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13367 status = eHAL_STATUS_CSR_WRONG_STATE;
13368 break;
13369 }
13370 }
13371 }
13372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 return ( status );
13374}
13375
Jeff Johnson295189b2012-06-20 16:38:30 -070013376static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13377{
13378 eHalStatus status = eHAL_STATUS_SUCCESS;
13379 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13380 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013381
13382 if(!pSession)
13383 {
13384 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13385 return eHAL_STATUS_FAILURE;
13386 }
13387
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 if ( csrIsConnStateIbss( pMac, sessionId ) )
13389 {
13390 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13391 }
13392 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13393 {
13394 // Disassociate from the connected Infrastructure network...
13395 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13396 }
13397 else
13398 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13400 //Otherwise we need to add code to handle the
13401 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13402 //send stop_bss to PE, before we can continue.
13403 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013404 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013406 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13407 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 // there is no Bss description before we start an WDS so we need
13409 // to adopt all Bss configuration parameters from the Profile.
13410 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13411 if(HAL_STATUS_SUCCESS(status))
13412 {
13413 //Save profile for late use
13414 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013415 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13416 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013418 vos_mem_set(pSession->pCurRoamProfile,
13419 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013423 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013424 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13425 NULL, &bssConfig,
13426 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 }
13428 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013429
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 return( status );
13431}
13432
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013433#ifdef WLAN_FEATURE_SAE
13434/*
13435 * csr_update_sae_config: Copy SAE info to join request
13436 * @profile: pointer to profile
13437 * @csr_join_req: csr join request
13438 *
13439 * Return: None
13440 */
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013441static bool csr_update_sae_config(tSirMacAddr bssid, tpAniSirGlobal mac,
13442 tCsrRoamSession *session)
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013443{
13444 tPmkidCacheInfo pmkid_cache;
13445 uint32_t index;
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013446 bool sae_pmk_cached;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013447
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013448 vos_mem_copy(pmkid_cache.BSSID, bssid, VOS_MAC_ADDR_SIZE);
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013449
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013450 sae_pmk_cached =
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013451 csr_lookup_pmkid_using_bssid(mac, session, &pmkid_cache, &index);
13452
13453 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013454 "pmk_cached %d for BSSID=" MAC_ADDRESS_STR, sae_pmk_cached,
13455 MAC_ADDR_ARRAY(bssid));
13456
13457 return sae_pmk_cached;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013458}
13459#else
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013460static bool csr_update_sae_config(tSirMacAddr bssid, tpAniSirGlobal mac,
13461 tCsrRoamSession *session)
13462{
13463 return false;
13464}
Abhinav Kumar6920f5a2019-08-05 18:55:11 +053013465#endif
13466
Jeff Johnson295189b2012-06-20 16:38:30 -070013467////////////////////Mail box
13468
Jeff Johnson295189b2012-06-20 16:38:30 -070013469//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13470//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013471static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13472 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13474{
13475 tCsrChannelSet channelGroup;
13476 tSirMacCapabilityInfo *pAP_capabilityInfo;
13477 tAniBool fTmp;
13478 tANI_BOOLEAN found = FALSE;
13479 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013480 tANI_S8 pwrLimit = 0;
13481 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13483 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13484 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13485 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 // 802.11h
13487 //We can do this because it is in HOST CPU order for now.
13488 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013489 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13490 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13491 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 fTmp = (tAniBool)pal_cpu_to_be32(1);
13493 }
13494 else
13495 fTmp = (tAniBool)0;
13496
13497 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013498 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013499 pBuf += sizeof(tAniBool);
Agrawal Ashish01c66342017-01-27 12:52:25 +053013500 *pBuf++ = MIN_TX_PWR_CAP; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013501 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 // This is required for 11k test VoWiFi Ent: Test 2.
13503 // We need the power capabilities for Assoc Req.
13504 // This macro is provided by the halPhyCfg.h. We pick our
13505 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013506 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13507 if (0 != pwrLimit)
13508 {
13509 *pBuf++ = pwrLimit;
13510 }
13511 else
13512 {
Agrawal Ashish01c66342017-01-27 12:52:25 +053013513 *pBuf++ = MAX_TX_PWR_CAP;
Kiran4a17ebe2013-01-31 10:43:43 -080013514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 size = sizeof(pMac->roam.validChannelList);
13516 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013517 {
13518 tANI_U8 *actualSize = pBuf++;
13519 *actualSize = 0;
13520
13521 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013523 /* Only add 5ghz channels*/
13524 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13525 {
13526 *actualSize +=1;
13527 *pBuf++ = pMac->roam.validChannelList[ i ];
13528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 }
13530 }
13531 else
13532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013533 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 *pBuf++ = 0; //tSirSupChnl->numChnl
13535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 //Check whether it is ok to enter UAPSD
13537#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13538 if( btcIsReadyForUapsd(pMac) )
13539#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13540 {
13541 *pBuf++ = uapsdMask;
13542 }
13543#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13544 else
13545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013546 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 *pBuf++ = 0;
13548 }
13549#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13550
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013552 vos_mem_copy(pBuf, pBssDescription,
13553 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13555}
13556
Jeff Johnson295189b2012-06-20 16:38:30 -070013557/*
13558 * The communication between HDD and LIM is thru mailbox (MB).
13559 * Both sides will access the data structure "tSirSmeJoinReq".
13560 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13561 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13562 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13563 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13564 */
13565eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013566 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013567{
13568 eHalStatus status = eHAL_STATUS_SUCCESS;
13569 tSirSmeJoinReq *pMsg;
13570 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013571 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 tANI_U16 msgLen, wTmp, ieLen;
13573 tSirMacRateSet OpRateSet;
13574 tSirMacRateSet ExRateSet;
13575 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13576 tANI_U32 dwTmp;
13577 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013578 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013579 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013580 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013581
13582 if(!pSession)
13583 {
13584 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13585 return eHAL_STATUS_FAILURE;
13586 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013587 /* To satisfy klockworks */
13588 if (NULL == pBssDescription)
13589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013590 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013591 return eHAL_STATUS_FAILURE;
13592 }
13593
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 do {
13595 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13596 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013597 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13599 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13600 // IE fields, but the length field in the bssDescription needs to be interpreted to
13601 // determine length of the IE fields.
13602 //
13603 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13604 // add in the length from the bssDescription (then add the size of the 'length' field
13605 // itself because that is NOT included in the length field).
13606 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13607 pBssDescription->length + sizeof( pBssDescription->length ) +
13608 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 +053013609 pMsg = vos_mem_malloc(msgLen);
13610 if (NULL == pMsg)
13611 status = eHAL_STATUS_FAILURE;
13612 else
13613 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013615 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013616 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 pMsg->length = pal_cpu_to_be16(msgLen);
13618 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 // sessionId
13620 *pBuf = (tANI_U8)sessionId;
13621 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 // transactionId
13623 *pBuf = 0;
13624 *( pBuf + 1 ) = 0;
13625 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 // ssId
13627 if( pIes->SSID.present && pIes->SSID.num_ssid )
13628 {
13629 // ssId len
13630 *pBuf = pIes->SSID.num_ssid;
13631 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 pBuf += pIes->SSID.num_ssid;
13634 }
13635 else
13636 {
13637 *pBuf = 0;
13638 pBuf++;
13639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013641 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13642 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 pBuf += sizeof(tSirMacAddr);
13644 // bsstype
13645 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13646 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013647 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 pBuf += sizeof(tSirBssType);
13649 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013650 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13651 if (pBssDescription->channelId <= 14 &&
13652 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13653 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13654 {
13655 //Need to disable VHT operation in 2.4 GHz band
13656 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13657 }
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053013658 smsLog(pMac, LOG1, FL("dot11mode %d uCfgDot11Mode %d"),
13659 ucDot11Mode, pSession->bssParams.uCfgDot11Mode);
13660
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013661 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 //Persona
13664 *pBuf = (tANI_U8)pProfile->csrPersona;
13665 pBuf++;
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053013666 *pBuf = csr_update_sae_config(pBssDescription->bssId, pMac, pSession);
13667 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013668 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13669 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013670 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13671 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013672 //CBMode
13673 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13674 pBuf++;
Abhishek Singhe3beee22017-07-31 15:35:40 +053013675 *pBuf = (tANI_U8)pProfile->force_24ghz_in_ht20;
13676 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013677
13678 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +053013679 FL("CSR PERSONA=%d CSR CbMode %d force_24ghz_in_ht20 %d"),
13680 pProfile->csrPersona, pSession->bssParams.cbMode,
13681 pProfile->force_24ghz_in_ht20);
Jeff Johnsone7245742012-09-05 17:12:55 -070013682
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 // uapsdPerAcBitmask
13684 *pBuf = pProfile->uapsd_mask;
13685 pBuf++;
13686
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013687
13688
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013689 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013690 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 {
13692 // OperationalRateSet
13693 if (OpRateSet.numRates) {
13694 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013695 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 pBuf += OpRateSet.numRates;
13697 } else *pBuf++ = 0;
13698 // ExtendedRateSet
13699 if (ExRateSet.numRates) {
13700 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013701 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 pBuf += ExRateSet.numRates;
13703 } else *pBuf++ = 0;
13704 }
13705 else
13706 {
13707 *pBuf++ = 0;
13708 *pBuf++ = 0;
13709 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013710
13711 //rateBitmap
13712 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13713 pBuf += sizeof(tANI_U16);
13714
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 // rsnIE
13716 if ( csrIsProfileWpa( pProfile ) )
13717 {
13718 // Insert the Wpa IE into the join request
13719 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13720 (tCsrWpaIe *)( wpaRsnIE ) );
13721 }
13722 else if( csrIsProfileRSN( pProfile ) )
13723 {
13724 // Insert the RSN IE into the join request
13725 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13726 (tCsrRSNIe *)( wpaRsnIE ) );
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +053013727 pMsg->force_rsne_override =
13728 pProfile->force_rsne_override;
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 }
13730#ifdef FEATURE_WLAN_WAPI
13731 else if( csrIsProfileWapi( pProfile ) )
13732 {
13733 // Insert the WAPI IE into the join request
13734 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13735 (tCsrWapiIe *)( wpaRsnIE ) );
13736 }
13737#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 else
13739 {
13740 ieLen = 0;
13741 }
13742 //remember the IE for future use
13743 if( ieLen )
13744 {
13745 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013747 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 -070013748 ieLen = DOT11F_IE_RSN_MAX_LEN;
13749 }
13750#ifdef FEATURE_WLAN_WAPI
13751 if( csrIsProfileWapi( pProfile ) )
13752 {
13753 //Check whether we need to allocate more memory
13754 if(ieLen > pSession->nWapiReqIeLength)
13755 {
13756 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13757 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013758 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013760 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13761 if (NULL == pSession->pWapiReqIE)
13762 status = eHAL_STATUS_FAILURE;
13763 else
13764 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 if(!HAL_STATUS_SUCCESS(status)) break;
13766 }
13767 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013770 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013772 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 pBuf += ieLen;
13774 }
13775 else//should be WPA/WPA2 otherwise
13776#endif /* FEATURE_WLAN_WAPI */
13777 {
13778 //Check whether we need to allocate more memory
13779 if(ieLen > pSession->nWpaRsnReqIeLength)
13780 {
13781 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13782 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013783 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013785 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13786 if (NULL == pSession->pWpaRsnReqIE)
13787 status = eHAL_STATUS_FAILURE;
13788 else
13789 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 if(!HAL_STATUS_SUCCESS(status)) break;
13791 }
13792 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013795 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013797 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 pBuf += ieLen;
13799 }
13800 }
13801 else
13802 {
13803 //free whatever old info
13804 pSession->nWpaRsnReqIeLength = 0;
13805 if(pSession->pWpaRsnReqIE)
13806 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013807 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 pSession->pWpaRsnReqIE = NULL;
13809 }
13810#ifdef FEATURE_WLAN_WAPI
13811 pSession->nWapiReqIeLength = 0;
13812 if(pSession->pWapiReqIE)
13813 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013814 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 pSession->pWapiReqIE = NULL;
13816 }
13817#endif /* FEATURE_WLAN_WAPI */
13818 //length is two bytes
13819 *pBuf = 0;
13820 *(pBuf + 1) = 0;
13821 pBuf += 2;
13822 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013823#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013824 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013826 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 //length is two bytes
13828 *pBuf = 0;
13829 *(pBuf + 1) = 0;
13830 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013831 }
13832 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013834 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013835 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013836 {
13837 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013838#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013839 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013840 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013841 pSession->suppCckmIeInfo.cckmIe, ieLen);
13842#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013843 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013844 pSession,
13845 pProfile,
13846 pBssDescription,
13847 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 pSession->nWpaRsnReqIeLength,
13849 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013850#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013851 }
13852 else
13853 {
13854 ieLen = 0;
13855 }
13856 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13857 if( ieLen )
13858 {
13859 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13860 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013861 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013862 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013863 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013864 pBuf += ieLen;
13865 }
13866 else
13867 {
13868 //Indicate you have no CCKM IE
13869 //length is two bytes
13870 *pBuf = 0;
13871 *(pBuf + 1) = 0;
13872 pBuf += 2;
13873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013875#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013877 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 {
13879 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013880 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013882 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013884 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013886 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 pBuf += ieLen;
13888 }
13889 else
13890 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013891 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 *pBuf = 0;
13894 *(pBuf + 1) = 0;
13895 pBuf += 2;
13896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 // addIEAssoc
13898 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13899 {
13900 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 if(ieLen > pSession->nAddIEAssocLength)
13902 {
13903 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013904 {
13905 vos_mem_free(pSession->pAddIEAssoc);
13906 }
13907 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13908 if (NULL == pSession->pAddIEAssoc)
13909 status = eHAL_STATUS_FAILURE;
13910 else
13911 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013915 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013919 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 pBuf += ieLen;
13921 }
13922 else
13923 {
13924 pSession->nAddIEAssocLength = 0;
13925 if(pSession->pAddIEAssoc)
13926 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013927 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 pSession->pAddIEAssoc = NULL;
13929 }
13930 *pBuf = 0;
13931 *(pBuf + 1) = 0;
13932 pBuf += 2;
13933 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013934
13935 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013937 //Unmask any AC in reassoc that is ACM-set
13938 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13939 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013941 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13942 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013943#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013944 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013945#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013946 }
13947 else
13948 {
13949 uapsd_mask = 0;
13950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013951 }
13952 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013953
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013955 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013956 pBuf += sizeof(tANI_U32);
13957
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013959 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013960 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013961#ifdef WLAN_FEATURE_11W
13962 //MgmtEncryption
13963 if (pProfile->MFPEnabled)
13964 {
13965 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13966 }
13967 else
13968 {
13969 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13970 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013971 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013972 pBuf += sizeof(tANI_U32);
13973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013974#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013975 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013976 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013977#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013978 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013979 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013980#endif
13981 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013982 {
13983 // is11Rconnection;
13984 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013985 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013986 pBuf += sizeof(tAniBool);
13987 }
13988 else
13989 {
13990 // is11Rconnection;
13991 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013992 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013993 pBuf += sizeof(tAniBool);
13994 }
13995#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013996#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013997
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013998 // isESEFeatureIniEnabled
13999 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053014000 {
14001 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014002 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053014003 pBuf += sizeof(tAniBool);
14004 }
14005 else
14006 {
14007 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080014008 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053014009 pBuf += sizeof(tAniBool);
14010 }
14011
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014012 /* A profile can not be both ESE and 11R. But an 802.11R AP
14013 * may be advertising support for ESE as well. So if we are
14014 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014015 * If we are associating explictly 11R only then we will get
14016 * 11R.
14017 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014018 if ((csrIsProfileESE(pProfile) ||
14019 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014020 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14021 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14022 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14023 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14024#ifdef WLAN_FEATURE_11W
14025 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053014026 || (pProfile->negotiatedAuthType ==
14027 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014028#endif
14029 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014030 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014031 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014032 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014033 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014034 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014035 pBuf += sizeof(tAniBool);
14036 }
14037 else
14038 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014039 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014040 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014041 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014042 pBuf += sizeof(tAniBool);
14043 }
14044
14045 if (eWNI_SME_JOIN_REQ == messageType)
14046 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014047 tESETspecInfo eseTspec;
14048 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014049 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014050 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14051 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
14052 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014053 }
14054 else if (eWNI_SME_REASSOC_REQ == messageType)
14055 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014056 if ((csrIsProfileESE(pProfile) ||
14057 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014058 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14059 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14060 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14061 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14062#ifdef WLAN_FEATURE_11W
14063 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053014064 || (pProfile->negotiatedAuthType ==
14065 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053014066#endif
14067 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014068 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014070 tESETspecInfo eseTspec;
14071 // ESE Tspec information
14072 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14073 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
14074 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014077 if (eseTspec.numTspecs) {
14078 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
14079 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014081 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014083 else
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014085 tESETspecInfo eseTspec;
14086 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014088 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14089 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
14090 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 }
14092 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080014093#endif // FEATURE_WLAN_ESE
14094#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014096 if (pMac->roam.configParam.isFastTransitionEnabled
14097#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053014098 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014099#endif
14100 )
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014102 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014103 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014104 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 }
14106 else
14107 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014108 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014109 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014110 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 }
14112#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070014113#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053014114 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070014115 {
14116 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014117 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014118 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014119 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014120 }
14121 else
14122 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014123 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053014124 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014125 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070014126 }
14127#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014128
14129 // txLdpcIniFeatureEnabled
14130 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
14131 pBuf++;
14132
Kiran4a17ebe2013-01-31 10:43:43 -080014133 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
14134 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
14135 {
14136 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
14137 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
14138 csrApplyPower2Current(pMac);
14139 }
14140
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014141#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080014142 // txBFIniFeatureEnabled
14143 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
14144 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014145
14146 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014147 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014148 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053014149 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
14150 if (pIes->VHTCaps.numSoundingDim)
14151 txBFCsnValue = CSR_ROAM_MIN
14152 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053014153 }
14154 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080014155 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053014156
14157 /* Only enable MuBf if no other MuBF session exist
14158 * and FW and HOST is MuBF capable.
14159 */
14160 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
14161 {
14162 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
14163 pBuf++;
14164 }
14165 else
14166 {
14167 *pBuf = 0;
14168 pBuf++;
14169 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080014170#endif
krunal soni5afa96c2013-09-06 22:19:02 -070014171 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
14172 pBuf++;
14173
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053014174 // WME
14175 if(pMac->roam.roamSession[sessionId].fWMMConnection)
14176 {
14177 //WME enabled
14178 dwTmp = pal_cpu_to_be32(TRUE);
14179 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14180 pBuf += sizeof(tAniBool);
14181 }
14182 else
14183 {
14184 dwTmp = pal_cpu_to_be32(FALSE);
14185 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14186 pBuf += sizeof(tAniBool);
14187 }
14188
14189 // QOS
14190 if(pMac->roam.roamSession[sessionId].fQOSConnection)
14191 {
14192 //QOS enabled
14193 dwTmp = pal_cpu_to_be32(TRUE);
14194 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14195 pBuf += sizeof(tAniBool);
14196 }
14197 else
14198 {
14199 dwTmp = pal_cpu_to_be32(FALSE);
14200 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
14201 pBuf += sizeof(tAniBool);
14202 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014203 //BssDesc
14204 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
14205 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070014206
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014207 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053014208 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
14209 pMsg = NULL;
14210
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014211 if(!HAL_STATUS_SUCCESS(status))
14212 {
14213 break;
14214 }
14215 else
14216 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014217#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014218 if (eWNI_SME_JOIN_REQ == messageType)
14219 {
14220 //Tush-QoS: notify QoS module that join happening
14221 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
14222 }
14223 else if (eWNI_SME_REASSOC_REQ == messageType)
14224 {
14225 //Tush-QoS: notify QoS module that reassoc happening
14226 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
14227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014228#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080014229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053014231
14232 if (pMsg != NULL)
14233 {
14234 vos_mem_free( pMsg );
14235 }
Abhishek Singh78c691f2017-11-30 13:48:44 +053014236 pMac->roam.roamSession[sessionId].connect_req_start_time =
14237 vos_timer_get_system_time();
Girish Gowlicc337b12014-07-31 19:10:35 +053014238
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014240}
14241
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014242#ifdef WLAN_FEATURE_LFR_MBB
14243/**
14244 * csr_prepare_reassoc_req () - Prepares reassoc request
14245 * @mac: MAC context
14246 * @session_id: session id
14247 * @pbss_description: bss description
14248 * @ies: pointer to beacon IE's
14249 * @reassoc_req: pointer to reassociation request
14250 *
14251 *Return: None
14252 */
14253eHalStatus csr_fill_reassoc_req(tpAniSirGlobal mac, tANI_U32 session_id,
14254 tSirBssDescription *bss_description, tDot11fBeaconIEs *ies,
14255 tSirSmeJoinReq **reassoc_req)
14256{
14257 eHalStatus status = eHAL_STATUS_SUCCESS;
14258 tSirSmeJoinReq *csr_join_req;
14259 tANI_U8 *buf;
14260 v_U8_t acm_mask = 0, uapsd_mask;
14261 tANI_U16 msg_len, w_tmp, ie_len;
14262 tSirMacRateSet op_rate_set;
14263 tSirMacRateSet ex_rate_set;
14264 tCsrRoamSession *session = CSR_GET_SESSION(mac, session_id);
14265 tANI_U32 dw_tmp;
14266 tANI_U8 wpa_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
14267 tANI_U32 uc_dot11_mode = 0;
14268 tANI_U8 tx_bf_csn_value = 0;
14269 tANI_U16 rate_bitmap = 0;
14270 tANI_U16 message_type = eWNI_SME_REASSOC_REQ;
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014271 tCsrRoamProfile *profile;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014272
14273 if(!session) {
14274 smsLog(mac, LOGE, FL(" session %d not found "), session_id);
14275 return eHAL_STATUS_FAILURE;
14276 }
14277
14278 if (NULL == bss_description) {
14279 smsLog(mac, LOGE, FL(" pBssDescription is NULL"));
14280 return eHAL_STATUS_FAILURE;
14281 }
14282
14283 smsLog(mac, LOG1,
14284 FL("session_id %d"), session_id);
14285
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014286 profile = vos_mem_malloc(sizeof(*profile));
14287 if (NULL == profile) {
14288 smsLog(mac, LOGE, FL("Memory allocation failure for profile"));
14289 return eHAL_STATUS_RESOURCES;
14290 }
14291
14292 status = csrRoamCopyProfile(mac, profile, session->pCurRoamProfile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014293 if(!HAL_STATUS_SUCCESS(status)) {
14294 smsLog(mac, LOGE, FL("Profile copy failed"));
14295 return eHAL_STATUS_FAILURE;
14296 }
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014297
14298 do {
14299 /*
14300 * There are a number of variable length fields to consider.
14301 * First, the tSirSmeJoinReq includes a single bssDescription.
14302 * bssDescription includes a single tANI_U32 for the IE fields,
14303 * but the length field in the bssDescription needs to be
14304 * interpreted to determine length of the IE fields.
14305 * So, take the size of the JoinReq, subtract the size of the
14306 * bssDescription and add in the length from the bssDescription
14307 * (then add the size of the 'length' field itself because that is
14308 * NOT included in the length field). msgLen =
14309 * sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
14310 * pBssDescription->length + sizeof( pBssDescription->length ) +
14311 * sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 );
14312 * add in the size of the WPA IE that we may build.
14313 */
14314
14315 msg_len = sizeof(tSirSmeJoinReq) - sizeof(*bss_description) +
14316 bss_description->length + sizeof(bss_description->length) +
14317 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) + sizeof(tANI_U16);
14318
14319 csr_join_req = vos_mem_malloc(msg_len);
14320 if (NULL == csr_join_req)
14321 status = eHAL_STATUS_FAILURE;
14322 else
14323 status = eHAL_STATUS_SUCCESS;
14324 if (!HAL_STATUS_SUCCESS(status)) break;
14325
14326 vos_mem_set(csr_join_req, msg_len, 0);
14327 *reassoc_req = csr_join_req;
14328
14329 csr_join_req->messageType = pal_cpu_to_be16(eWNI_SME_REASSOC_REQ);
14330 csr_join_req->length = pal_cpu_to_be16(msg_len);
14331 buf = &csr_join_req->sessionId;
14332
14333 /* session_id */
14334 *buf = (tANI_U8)session_id;
14335 buf++;
14336
14337 /* transactionId */
14338 *buf = 0;
14339 *(buf + 1) = 0;
14340 buf += sizeof(tANI_U16);
14341
14342 /* ssId */
14343 if(ies->SSID.present && ies->SSID.num_ssid)
14344 {
14345 /* ssId len */
14346 *buf = ies->SSID.num_ssid;
14347 buf++;
14348 vos_mem_copy(buf, ies->SSID.ssid, ies->SSID.num_ssid);
14349 buf += ies->SSID.num_ssid;
14350 }
14351 else
14352 {
14353 *buf = 0;
14354 buf++;
14355 }
14356
14357 /* selfMacAddr */
14358 vos_mem_copy((tSirMacAddr *)buf, &session->selfMacAddr,
14359 sizeof(tSirMacAddr));
14360 buf += sizeof(tSirMacAddr);
14361
14362 /* bsstype */
14363 dw_tmp =
14364 pal_cpu_to_be32(csrTranslateBsstypeToMacType(profile->BSSType));
14365 /* Override BssType for BTAMP */
14366 if (dw_tmp == eSIR_BTAMP_STA_MODE) dw_tmp = eSIR_BTAMP_AP_MODE;
14367 vos_mem_copy(buf, &dw_tmp, sizeof(tSirBssType));
14368 buf += sizeof(tSirBssType);
14369
14370 /* dot11mode */
14371 uc_dot11_mode =
14372 csrTranslateToWNICfgDot11Mode(mac, session->bssParams.uCfgDot11Mode);
14373 if (bss_description->channelId <= 14 &&
14374 FALSE == mac->roam.configParam.enableVhtFor24GHz &&
14375 WNI_CFG_DOT11_MODE_11AC == uc_dot11_mode)
14376 {
14377 /* Need to disable VHT operation in 2.4 GHz band */
14378 uc_dot11_mode = WNI_CFG_DOT11_MODE_11N;
14379 }
14380 *buf = (tANI_U8)uc_dot11_mode;
14381 buf++;
14382
14383 /* Persona */
14384 *buf = (tANI_U8)profile->csrPersona;
14385 buf++;
14386 *buf = (tANI_U8)profile->bOSENAssociation;
14387 buf++;
14388 *buf = (tANI_U8)profile->bWPSAssociation;
14389 buf++;
14390
14391 /* CBMode */
14392 *buf = (tANI_U8)session->bssParams.cbMode;
14393 buf++;
14394
14395 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
14396 FL("CSR PERSONA=%d CSR CbMode %d"), profile->csrPersona,
14397 session->bssParams.cbMode);
14398
14399 /* uapsdPerAcBitmask */
14400 *buf = profile->uapsd_mask;
14401 buf++;
14402
14403
14404 status = csrGetRateSet(mac, profile, (eCsrPhyMode)profile->phyMode,
14405 bss_description, ies, &op_rate_set, &ex_rate_set,&rate_bitmap);
14406 if (HAL_STATUS_SUCCESS(status))
14407 {
14408 /* OperationalRateSet */
14409 if (op_rate_set.numRates) {
14410 *buf++ = op_rate_set.numRates;
14411 vos_mem_copy(buf, op_rate_set.rate, op_rate_set.numRates);
14412 buf += op_rate_set.numRates;
14413 } else *buf++ = 0;
14414
14415 /* ExtendedRateSet */
14416 if (ex_rate_set.numRates) {
14417 *buf++ = ex_rate_set.numRates;
14418 vos_mem_copy(buf, ex_rate_set.rate, ex_rate_set.numRates);
14419 buf += ex_rate_set.numRates;
14420 } else *buf++ = 0;
14421 }
14422 else
14423 {
14424 *buf++ = 0;
14425 *buf++ = 0;
14426 }
14427
14428 /* rateBitmap */
14429 vos_mem_copy(buf, &rate_bitmap, sizeof(tANI_U16));
14430 buf += sizeof(tANI_U16);
14431
14432 profile->negotiatedAuthType =
14433 mac->roam.roamSession[session_id].connectedProfile.AuthType;
14434 profile->negotiatedUCEncryptionType =
14435 mac->roam.roamSession[session_id].connectedProfile.EncryptionType;
14436
14437 /* rsnIE */
14438 if ( csrIsProfileWpa(profile))
14439 {
14440 /* Insert the Wpa IE into the join request */
14441 ie_len = csrRetrieveWpaIe(mac, profile, bss_description, ies,
14442 (tCsrWpaIe *)(wpa_rsn_ie));
14443 }
14444 else if( csrIsProfileRSN(profile))
14445 {
14446 /* Insert the RSN IE into the join request */
14447 ie_len = csrRetrieveRsnIe(mac, session_id, profile, bss_description,
14448 ies, (tCsrRSNIe *)(wpa_rsn_ie));
14449 }
14450#ifdef FEATURE_WLAN_WAPI
14451 else if( csrIsProfileWapi(profile))
14452 {
14453 /* Insert the WAPI IE into the join request */
14454 ie_len = csrRetrieveWapiIe(mac, session_id, profile,
14455 bss_description, ies, (tCsrWapiIe *)(wpa_rsn_ie));
14456 }
14457#endif
14458 else
14459 {
14460 ie_len = 0;
14461 }
14462 /* remember the IE for future use */
14463 if(ie_len)
14464 {
14465 if(ie_len > DOT11F_IE_RSN_MAX_LEN)
14466 {
14467 smsLog(mac, LOGE,
14468 FL("WPA RSN IE length :%d is more than RSN_MAX_LEN %d"),
14469 ie_len, DOT11F_IE_RSN_MAX_LEN);
14470 ie_len = DOT11F_IE_RSN_MAX_LEN;
14471 }
14472#ifdef FEATURE_WLAN_WAPI
14473 if( csrIsProfileWapi(profile))
14474 {
14475 /* Check whether we need to allocate more memory */
14476 if(ie_len > session->nWapiReqIeLength)
14477 {
14478 if(session->pWapiReqIE && session->nWapiReqIeLength)
14479 {
14480 vos_mem_free(session->pWapiReqIE);
14481 }
14482 session->pWapiReqIE = vos_mem_malloc(ie_len);
14483 if (NULL == session->pWapiReqIE)
14484 status = eHAL_STATUS_FAILURE;
14485 else
14486 status = eHAL_STATUS_SUCCESS;
14487 if(!HAL_STATUS_SUCCESS(status)) break;
14488 }
14489 session->nWapiReqIeLength = ie_len;
14490 vos_mem_copy(session->pWapiReqIE, wpa_rsn_ie, ie_len);
14491 w_tmp = pal_cpu_to_be16(ie_len);
14492 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14493 buf += sizeof(tANI_U16);
14494 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14495 buf += ie_len;
14496 }
14497 else /* should be WPA/WPA2 otherwise */
14498#endif
14499 {
14500 /* Check whether we need to allocate more memory */
14501 if(ie_len > session->nWpaRsnReqIeLength)
14502 {
14503 if(session->pWpaRsnReqIE && session->nWpaRsnReqIeLength)
14504 {
14505 vos_mem_free(session->pWpaRsnReqIE);
14506 }
14507 session->pWpaRsnReqIE = vos_mem_malloc(ie_len);
14508 if (NULL == session->pWpaRsnReqIE)
14509 status = eHAL_STATUS_FAILURE;
14510 else
14511 status = eHAL_STATUS_SUCCESS;
14512 if(!HAL_STATUS_SUCCESS(status)) break;
14513 }
14514 session->nWpaRsnReqIeLength = ie_len;
14515 vos_mem_copy(session->pWpaRsnReqIE, wpa_rsn_ie, ie_len);
14516 w_tmp = pal_cpu_to_be16(ie_len);
14517 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14518 buf += sizeof(tANI_U16);
14519 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14520 buf += ie_len;
14521 }
14522 }
14523 else
14524 {
14525 /* free whatever old info */
14526 session->nWpaRsnReqIeLength = 0;
14527 if(session->pWpaRsnReqIE)
14528 {
14529 vos_mem_free(session->pWpaRsnReqIE);
14530 session->pWpaRsnReqIE = NULL;
14531 }
14532#ifdef FEATURE_WLAN_WAPI
14533 session->nWapiReqIeLength = 0;
14534 if(session->pWapiReqIE)
14535 {
14536 vos_mem_free(session->pWapiReqIE);
14537 session->pWapiReqIE = NULL;
14538 }
14539#endif
14540 /* length is two bytes */
14541 *buf = 0;
14542 *(buf + 1) = 0;
14543 buf += 2;
14544 }
14545#ifdef FEATURE_WLAN_ESE
14546 if(eWNI_SME_JOIN_REQ == message_type)
14547 {
14548 /*
14549 * Never include the cckmIE in an Join Request
14550 * length is two bytes
14551 */
14552 *buf = 0;
14553 *(buf + 1) = 0;
14554 buf += 2;
14555 }
14556 else if(eWNI_SME_REASSOC_REQ == message_type)
14557 {
14558 /* cckmIE */
14559 if( csrIsProfileESE(profile))
14560 {
14561 /* Insert the CCKM IE into the join request */
14562#ifdef FEATURE_WLAN_ESE_UPLOAD
14563 ie_len = session->suppCckmIeInfo.cckmIeLen;
14564 vos_mem_copy((void *) (wpa_rsn_ie),
14565 session->suppCckmIeInfo.cckmIe, ie_len);
14566#else
14567 ie_len = csrConstructEseCckmIe(mac,
14568 session,
14569 profile,
14570 bss_description,
14571 session->pWpaRsnReqIE,
14572 session->nWpaRsnReqIeLength,
14573 (void *)(wpa_rsn_ie));
14574#endif
14575 }
14576 else
14577 {
14578 ie_len = 0;
14579 }
14580 /*
14581 * If present, copy the IE into the eWNI_SME_REASSOC_REQ
14582 * message buffer
14583 */
14584 if(ie_len)
14585 {
14586 /* Copy the CCKM IE over from the temp buffer (wpaRsnIE) */
14587 w_tmp = pal_cpu_to_be16(ie_len);
14588 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14589 buf += sizeof(tANI_U16);
14590 vos_mem_copy(buf, wpa_rsn_ie, ie_len);
14591 buf += ie_len;
14592 }
14593 else
14594 {
14595 /* Indicate you have no CCKM IE length is two bytes */
14596 *buf = 0;
14597 *(buf + 1) = 0;
14598 buf += 2;
14599 }
14600 }
14601#endif
14602 /* addIEScan */
14603 if (profile->nAddIEScanLength)
14604 {
14605 ie_len = profile->nAddIEScanLength;
14606 memset(session->addIEScan, 0 , session->nAddIEScanLength);
14607 session->nAddIEScanLength = ie_len;
14608 vos_mem_copy(session->addIEScan, profile->addIEScan, ie_len);
14609 w_tmp = pal_cpu_to_be16(ie_len);
14610 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14611 buf += sizeof(tANI_U16);
14612 vos_mem_copy(buf, profile->addIEScan, ie_len);
14613 buf += ie_len;
14614 }
14615 else
14616 {
14617 memset(session->addIEScan, 0, session->nAddIEScanLength);
14618 session->nAddIEScanLength = 0;
14619 *buf = 0;
14620 *(buf + 1) = 0;
14621 buf += 2;
14622 }
14623 /* addIEAssoc */
14624 if(profile->nAddIEAssocLength && profile->pAddIEAssoc)
14625 {
14626 ie_len = profile->nAddIEAssocLength;
14627 if(ie_len > session->nAddIEAssocLength)
14628 {
14629 if(session->pAddIEAssoc && session->nAddIEAssocLength)
14630 {
14631 vos_mem_free(session->pAddIEAssoc);
14632 }
14633 session->pAddIEAssoc = vos_mem_malloc(ie_len);
14634 if (NULL == session->pAddIEAssoc)
14635 status = eHAL_STATUS_FAILURE;
14636 else
14637 status = eHAL_STATUS_SUCCESS;
14638 if(!HAL_STATUS_SUCCESS(status)) break;
14639 }
14640 session->nAddIEAssocLength = ie_len;
14641 vos_mem_copy(session->pAddIEAssoc, profile->pAddIEAssoc, ie_len);
14642 w_tmp = pal_cpu_to_be16(ie_len);
14643 vos_mem_copy(buf, &w_tmp, sizeof(tANI_U16));
14644 buf += sizeof(tANI_U16);
14645 vos_mem_copy(buf, profile->pAddIEAssoc, ie_len);
14646 buf += ie_len;
14647 }
14648 else
14649 {
14650 session->nAddIEAssocLength = 0;
14651 if(session->pAddIEAssoc)
14652 {
14653 vos_mem_free(session->pAddIEAssoc);
14654 session->pAddIEAssoc = NULL;
14655 }
14656 *buf = 0;
14657 *(buf + 1) = 0;
14658 buf += 2;
14659 }
14660
14661 if(eWNI_SME_REASSOC_REQ == message_type )
14662 {
14663 /*Unmask any AC in reassoc that is ACM-set */
14664 uapsd_mask = (v_U8_t)profile->uapsd_mask;
14665 if( uapsd_mask && (NULL != bss_description))
14666 {
14667 if( CSR_IS_QOS_BSS(ies) && CSR_IS_UAPSD_BSS(ies) )
14668 {
14669#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14670 acm_mask = sme_QosGetACMMask(mac, bss_description, ies);
14671#endif
14672 }
14673 else
14674 {
14675 uapsd_mask = 0;
14676 }
14677 }
14678 }
14679
14680 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14681 profile->negotiatedUCEncryptionType));
14682 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14683 buf += sizeof(tANI_U32);
14684
14685 dw_tmp = pal_cpu_to_be32(csrTranslateEncryptTypeToEdType(
14686 profile->negotiatedMCEncryptionType));
14687 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14688 buf += sizeof(tANI_U32);
14689#ifdef WLAN_FEATURE_11W
14690 /* MgmtEncryption */
14691 if (profile->MFPEnabled)
14692 {
14693 dw_tmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
14694 }
14695 else
14696 {
14697 dw_tmp = pal_cpu_to_be32(eSIR_ED_NONE);
14698 }
14699 vos_mem_copy(buf, &dw_tmp, sizeof(tANI_U32));
14700 buf += sizeof(tANI_U32);
14701#endif
14702#ifdef WLAN_FEATURE_VOWIFI_11R
14703 profile->MDID.mdiePresent = bss_description->mdiePresent;
14704 if (csrIsProfile11r(profile)
14705#ifdef FEATURE_WLAN_ESE
14706 && !((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
14707 (ies->ESEVersion.present) &&
14708 (mac->roam.configParam.isEseIniFeatureEnabled))
14709#endif
14710 )
14711 {
14712 /* is11Rconnection */
14713 dw_tmp = pal_cpu_to_be32(TRUE);
14714 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool)) ;
14715 buf += sizeof(tAniBool);
14716 }
14717 else
14718 {
14719 /* is11Rconnection */
14720 dw_tmp = pal_cpu_to_be32(FALSE);
14721 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14722 buf += sizeof(tAniBool);
14723 }
14724#endif
14725#ifdef FEATURE_WLAN_ESE
14726
14727 /* isESEFeatureIniEnabled */
14728 if (TRUE == mac->roam.configParam.isEseIniFeatureEnabled)
14729 {
14730 dw_tmp = pal_cpu_to_be32(TRUE);
14731 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14732 buf += sizeof(tAniBool);
14733 }
14734 else
14735 {
14736 dw_tmp = pal_cpu_to_be32(FALSE);
14737 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14738 buf += sizeof(tAniBool);
14739 }
14740
14741 /* A profile can not be both ESE and 11R. But an 802.11R AP
14742 * may be advertising support for ESE as well. So if we are
14743 * associating Open or explicitly ESE then we will get ESE.
14744 * If we are associating explictly 11R only then we will get
14745 * 11R.
14746 */
14747 if ((csrIsProfileESE(profile) ||
14748 ((ies->ESEVersion.present)
14749 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14750 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14751 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14752 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14753#ifdef WLAN_FEATURE_11W
14754 || (profile->negotiatedAuthType ==
14755 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14756 || (profile->negotiatedAuthType ==
14757 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14758#endif
14759 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
14760 && (mac->roam.configParam.isEseIniFeatureEnabled))
14761 {
14762 /* isESEconnection */
14763 dw_tmp = pal_cpu_to_be32(TRUE);
14764 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14765 buf += sizeof(tAniBool);
14766 }
14767 else
14768 {
14769 /* isESEconnection */
14770 dw_tmp = pal_cpu_to_be32(FALSE);
14771 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14772 buf += sizeof(tAniBool);
14773 }
14774
14775 if (eWNI_SME_JOIN_REQ == message_type)
14776 {
14777 tESETspecInfo eseTspec;
14778 /*
14779 * ESE-Tspec IEs in the ASSOC request is presently not supported
14780 * so nullify the TSPEC parameters
14781 */
14782 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14783 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14784 buf += sizeof(tESETspecInfo);
14785 }
14786 else if (eWNI_SME_REASSOC_REQ == message_type)
14787 {
14788 if ((csrIsProfileESE(profile) ||
14789 ((ies->ESEVersion.present)
14790 && ((profile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
14791 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
14792 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
14793 || (profile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
14794#ifdef WLAN_FEATURE_11W
14795 || (profile->negotiatedAuthType ==
14796 eCSR_AUTH_TYPE_RSN_PSK_SHA256)
14797 || (profile->negotiatedAuthType ==
14798 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
14799#endif
14800 || (profile->negotiatedAuthType ==
14801 eCSR_AUTH_TYPE_RSN_PSK))))
14802 && (mac->roam.configParam.isEseIniFeatureEnabled))
14803 {
14804 tESETspecInfo eseTspec;
14805 /* ESE Tspec information */
14806 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14807 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(mac, session_id,
14808 (tTspecInfo *) &eseTspec.tspec[0]);
14809 *buf = eseTspec.numTspecs;
14810 buf += sizeof(tANI_U8);
14811 // Copy the TSPEC information only if present
14812 if (eseTspec.numTspecs) {
14813 vos_mem_copy(buf, (void*)&eseTspec.tspec[0],
14814 (eseTspec.numTspecs*sizeof(tTspecInfo)));
14815 }
14816 buf += sizeof(eseTspec.tspec);
14817 }
14818 else
14819 {
14820 tESETspecInfo eseTspec;
14821 /*
14822 * ESE-Tspec IEs in the ASSOC request is presently
14823 * not supported so nullify the TSPEC parameters
14824 */
14825 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14826 vos_mem_copy(buf, &eseTspec, sizeof(tESETspecInfo));
14827 buf += sizeof(tESETspecInfo);
14828 }
14829 }
14830#endif
14831#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
14832 /* Fill in isFastTransitionEnabled */
14833 if (mac->roam.configParam.isFastTransitionEnabled
14834#ifdef FEATURE_WLAN_LFR
14835 || csrRoamIsFastRoamEnabled(mac, session_id)
14836#endif
14837 )
14838 {
14839 dw_tmp = pal_cpu_to_be32(TRUE);
14840 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14841 buf += sizeof(tAniBool);
14842 }
14843 else
14844 {
14845 dw_tmp = pal_cpu_to_be32(FALSE);
14846 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14847 buf += sizeof(tAniBool);
14848 }
14849#endif
14850#ifdef FEATURE_WLAN_LFR
14851 if(csrRoamIsFastRoamEnabled(mac, session_id))
14852 {
14853 /* legacy fast roaming enabled */
14854 dw_tmp = pal_cpu_to_be32(TRUE);
14855 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14856 buf += sizeof(tAniBool);
14857 }
14858 else
14859 {
14860 dw_tmp = pal_cpu_to_be32(FALSE);
14861 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14862 buf += sizeof(tAniBool);
14863 }
14864#endif
14865
14866 /* txLdpcIniFeatureEnabled */
14867 *buf = (tANI_U8)mac->roam.configParam.txLdpcEnable;
14868 buf++;
14869
14870 if ((csrIs11hSupported(mac)) &&
14871 (CSR_IS_CHANNEL_5GHZ(bss_description->channelId)) &&
14872 (ies->Country.present) &&\
14873 (!mac->roam.configParam.fSupplicantCountryCodeHasPriority))
14874 {
14875 csrSaveToChannelPower2G_5G(mac,
14876 ies->Country.num_triplets * sizeof(tSirMacChanInfo),
14877 (tSirMacChanInfo *)(&ies->Country.triplets[0]));
14878 csrApplyPower2Current(mac);
14879 }
14880
14881#ifdef WLAN_FEATURE_11AC
14882 /* txBFIniFeatureEnabled */
14883 *buf = (tANI_U8)mac->roam.configParam.txBFEnable;
14884 buf++;
14885
14886 /* txBFCsnValue */
14887 if (IS_BSS_VHT_CAPABLE(ies->VHTCaps))
14888 {
14889 tx_bf_csn_value = (tANI_U8)mac->roam.configParam.txBFCsnValue;
14890 if (ies->VHTCaps.numSoundingDim)
14891 tx_bf_csn_value = CSR_ROAM_MIN
14892 (tx_bf_csn_value, ies->VHTCaps.numSoundingDim);
14893 }
14894 *buf = tx_bf_csn_value;
14895 buf++;
14896
14897 /* Only enable MuBf if no other MuBF session exist
14898 * and FW and HOST is MuBF capable.
14899 */
14900 if (IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == mac->isMuBfsessionexist))
14901 {
14902 *buf = (tANI_U8)mac->roam.configParam.txMuBformee;
14903 buf++;
14904 }
14905 else
14906 {
14907 *buf = 0;
14908 buf++;
14909 }
14910#endif
14911 *buf = (tANI_U8)mac->roam.configParam.isAmsduSupportInAMPDU;
14912 buf++;
14913
14914 /* WME */
14915 if(mac->roam.roamSession[session_id].fWMMConnection)
14916 {
14917 /* WME enabled */
14918 dw_tmp = pal_cpu_to_be32(TRUE);
14919 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14920 buf += sizeof(tAniBool);
14921 }
14922 else
14923 {
14924 dw_tmp = pal_cpu_to_be32(FALSE);
14925 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14926 buf += sizeof(tAniBool);
14927 }
14928
14929 /* QOS */
14930 if(mac->roam.roamSession[session_id].fQOSConnection)
14931 {
14932 /* QOS enabled */
14933 dw_tmp = pal_cpu_to_be32(TRUE);
14934 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14935 buf += sizeof(tAniBool);
14936 }
14937 else
14938 {
14939 dw_tmp = pal_cpu_to_be32(FALSE);
14940 vos_mem_copy(buf, &dw_tmp, sizeof(tAniBool));
14941 buf += sizeof(tAniBool);
14942 }
14943 /* BssDesc */
14944 csrPrepareJoinReassocReqBuffer(mac, bss_description, buf,
14945 (tANI_U8)profile->uapsd_mask);
14946 } while( 0 );
14947
14948 smsLog(mac, LOG1, FL("status %d"), status);
14949
Padma, Santhosh Kumar65082492017-02-07 19:30:45 +053014950 vos_mem_free(profile);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053014951 return status;
14952}
14953#endif
14954
Jeff Johnson295189b2012-06-20 16:38:30 -070014955//
14956eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14957{
14958 eHalStatus status = eHAL_STATUS_SUCCESS;
14959 tSirSmeDisassocReq *pMsg;
14960 tANI_U8 *pBuf;
14961 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14963 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14964 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014966 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
14967 if (NULL == pMsg)
14968 status = eHAL_STATUS_FAILURE;
14969 else
14970 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014971 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014972 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
14974 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 pBuf = &pMsg->sessionId;
14976 // sessionId
14977 *pBuf++ = (tANI_U8)sessionId;
14978 // transactionId
14979 *pBuf = 0;
14980 *( pBuf + 1 ) = 0;
14981 pBuf += sizeof(tANI_U16);
14982
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053014983 if ( (pSession->pCurRoamProfile != NULL) &&
14984 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
14985 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 {
14987 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014988 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
14989 sizeof( tSirMacAddr ));
14990 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014993 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
14994 //perMacAddr is passed as bssId for softAP
14995 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 pBuf = pBuf + sizeof ( tSirMacAddr );
14997 }
14998 else
14999 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015001 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
15002 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053015004 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
15005 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 if(!HAL_STATUS_SUCCESS(status))
15009 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015010 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 break;
15012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 // reasonCode
15014 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015015 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
15016 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 if(!HAL_STATUS_SUCCESS(status))
15018 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015019 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 break;
15021 }
15022 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
15024 Here we should not send the disassoc over the air to the AP */
15025 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
15026#ifdef WLAN_FEATURE_VOWIFI_11R
15027 && csrRoamIs11rAssoc(pMac)
15028#endif
15029 )
15030 {
15031 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
15032 }
15033 pBuf += sizeof(tANI_U8);
15034 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015036 return( status );
15037}
Jeff Johnson295189b2012-06-20 16:38:30 -070015038eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
15039{
15040 eHalStatus status = eHAL_STATUS_SUCCESS;
15041 tSirSmeTkipCntrMeasReq *pMsg;
15042 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 do
15044 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015045 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
15046 if ( NULL == pMsg )
15047 status = eHAL_STATUS_FAILURE;
15048 else
15049 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015050 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015051 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015052 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
15053 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015054 pBuf = &pMsg->sessionId;
15055 // sessionId
15056 *pBuf++ = (tANI_U8)sessionId;
15057 // transactionId
15058 *pBuf = 0;
15059 *( pBuf + 1 ) = 0;
15060 pBuf += sizeof(tANI_U16);
15061 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015062 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
15063 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 pBuf = pBuf + sizeof ( tSirMacAddr );
15065 // bEnable
15066 *pBuf = (tANI_BOOLEAN)bEnable;
15067 if(!HAL_STATUS_SUCCESS(status))
15068 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015069 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 break;
15071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015072 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015074 return( status );
15075}
Jeff Johnson295189b2012-06-20 16:38:30 -070015076eHalStatus
15077csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
15078 VOS_MODULE_ID modId, tSirMacAddr bssId,
15079 void *pUsrContext, void *pfnSapEventCallback,
15080 tANI_U8 *pAssocStasBuf )
15081{
15082 eHalStatus status = eHAL_STATUS_SUCCESS;
15083 tSirSmeGetAssocSTAsReq *pMsg;
15084 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15085 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015086 do
15087 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015088 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
15089 if ( NULL == pMsg )
15090 status = eHAL_STATUS_FAILURE;
15091 else
15092 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015093 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015094 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 pBuf = (tANI_U8 *)&pMsg->bssId;
15097 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015098 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015099 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 // modId
15102 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015103 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015104 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015106 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
15107 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015109 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
15110 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080015112 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
15113 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015115 status = palSendMBMessage( pMac->hHdd, pMsg );
15116 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015117 return( status );
15118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015119eHalStatus
15120csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
15121 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
15122 {
15123 eHalStatus status = eHAL_STATUS_SUCCESS;
15124 tSirSmeGetWPSPBCSessionsReq *pMsg;
15125 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080015126
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 do
15128 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015129 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
15130 if ( NULL == pMsg )
15131 status = eHAL_STATUS_FAILURE;
15132 else
15133 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015134 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015135 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070015138 VOS_ASSERT(pBuf);
15139
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080015142 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
15143 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080015145 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
15146 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015148 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053015151 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 return( status );
15157}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015158
15159eHalStatus
15160csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
15161{
15162 tpSirChangeBIParams pMsg;
15163 tANI_U16 len = 0;
15164 eHalStatus status = eHAL_STATUS_SUCCESS;
15165 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15166
15167 if(!pSession)
15168 {
15169 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15170 return eHAL_STATUS_FAILURE;
15171 }
15172
15173 //NO need to update the Beacon Params if update beacon parameter flag is not set
15174 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
15175 return eHAL_STATUS_SUCCESS;
15176
15177 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
15178
15179 /* Create the message and send to lim */
15180 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053015181 pMsg = vos_mem_malloc(len);
15182 if ( NULL == pMsg )
15183 status = eHAL_STATUS_FAILURE;
15184 else
15185 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015186 if(HAL_STATUS_SUCCESS(status))
15187 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015188 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015189 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15190 pMsg->length = len;
15191
15192 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015193 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15194 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080015195 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
15196 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015197 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015198 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015199 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
15200 status = palSendMBMessage(pMac->hHdd, pMsg);
15201 }
15202 return status;
15203}
15204
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053015205#ifdef WLAN_FEATURE_AP_HT40_24G
15206eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
15207{
15208 tpSirSetHT2040Mode pMsg;
15209 tANI_U16 len = 0;
15210 eHalStatus status = eHAL_STATUS_SUCCESS;
15211 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15212
15213 if(!pSession)
15214 {
15215 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15216 return eHAL_STATUS_FAILURE;
15217 }
15218
15219 /* Create the message and send to lim */
15220 len = sizeof(tSirSetHT2040Mode);
15221 pMsg = vos_mem_malloc(len);
15222
15223 if ( NULL == pMsg )
15224 {
15225 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
15226 status = eHAL_STATUS_FAILURE;
15227 }
15228 else
15229 status = eHAL_STATUS_SUCCESS;
15230
15231 if(HAL_STATUS_SUCCESS(status))
15232 {
15233 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
15234 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15235 pMsg->length = len;
15236
15237 // bssId
15238 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
15239 sizeof(tSirMacAddr));
15240
15241 smsLog( pMac, LOGW, FL("CSR Attempting to set "
15242 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
15243 MAC_ADDR_ARRAY(pMsg->bssId));
15244
15245 pMsg->sessionId = sessionId;
15246 pMsg->cbMode = cbMode;
15247
15248 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
15249 sessionId, cbMode);
15250
15251 status = palSendMBMessage(pMac->hHdd, pMsg);
15252 }
15253 return status;
15254}
15255#endif
15256
Jeff Johnson295189b2012-06-20 16:38:30 -070015257eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
15258{
15259 eHalStatus status = eHAL_STATUS_SUCCESS;
15260 tSirSmeDeauthReq *pMsg;
15261 tANI_U8 *pBuf;
15262 tANI_U16 wTmp;
15263 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15264 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
15265 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015266 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015267 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
15268 if ( NULL == pMsg )
15269 status = eHAL_STATUS_FAILURE;
15270 else
15271 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015273 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
15275 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
15276 //sessionId
15277 pBuf = &pMsg->sessionId;
15278 *pBuf++ = (tANI_U8)sessionId;
15279
15280 //tansactionId
15281 *pBuf = 0;
15282 *(pBuf + 1 ) = 0;
15283 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
15287 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015288 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
15289 sizeof( pMsg->peerMacAddr ) );
15290 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 pBuf = pBuf + sizeof(tSirMacAddr);
15292 }
15293 else
15294 {
15295 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015296 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15297 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 }
15300 if(!HAL_STATUS_SUCCESS(status))
15301 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015302 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 break;
15304 }
15305 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053015306 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
15307 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015308 pBuf = pBuf + sizeof(tSirMacAddr);
15309 if(!HAL_STATUS_SUCCESS(status))
15310 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015311 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 break;
15313 }
15314 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015315 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
15316 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 if(!HAL_STATUS_SUCCESS(status))
15318 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015319 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 break;
15321 }
15322 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 return( status );
15325}
15326
Jeff Johnson295189b2012-06-20 16:38:30 -070015327eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
15328{
15329 eHalStatus status = eHAL_STATUS_SUCCESS;
15330 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015332 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
15333 if ( NULL == pMsg )
15334 status = eHAL_STATUS_FAILURE;
15335 else
15336 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015338 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
15340 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15341 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015342 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015343 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
15344 sizeof(pMsg->peerMacAddr));
15345 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 if(!HAL_STATUS_SUCCESS(status))
15347 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015348 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 break;
15350 }
15351//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053015352 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
15353 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 if(!HAL_STATUS_SUCCESS(status))
15355 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015356 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 break;
15358 }
15359//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 return( status );
15363}
15364
Jeff Johnson295189b2012-06-20 16:38:30 -070015365eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
15366{
15367 eHalStatus status = eHAL_STATUS_SUCCESS;
15368 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070015369 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015370 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
15371 if ( NULL == pMsg )
15372 status = eHAL_STATUS_FAILURE;
15373 else
15374 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015376 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
15378 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15379 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080015380 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015381 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
15382 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 if(!HAL_STATUS_SUCCESS(status))
15384 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015385 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 break;
15387 }
Kiet Lam64c1b492013-07-12 13:56:44 +053015388 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
15389 sizeof(pMsg->peerMacAddr));
15390 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 if(!HAL_STATUS_SUCCESS(status))
15392 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015393 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015394 break;
15395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 return( status );
15399}
Jeff Johnson295189b2012-06-20 16:38:30 -070015400eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
15401{
15402 eHalStatus status = eHAL_STATUS_SUCCESS;
15403 tSirSmeAssocCnf *pMsg;
15404 tANI_U8 *pBuf;
15405 tSirResultCodes statusCode;
15406 tANI_U16 wTmp;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015407 vos_msg_t msg;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053015408
15409 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
15410 "HalStatus : %d"),
15411 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070015412 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015413 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
15414 if ( NULL == pMsg )
15415 status = eHAL_STATUS_FAILURE;
15416 else
15417 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053015419 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
15421 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 pBuf = (tANI_U8 *)&pMsg->statusCode;
15423 if(HAL_STATUS_SUCCESS(Halstatus))
15424 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15425 else
15426 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015427 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 pBuf += sizeof(tSirResultCodes);
15429 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015430 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15431 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015432 pBuf += sizeof (tSirMacAddr);
15433 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015434 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15435 sizeof(tSirMacAddr));
15436 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 pBuf += sizeof (tSirMacAddr);
15438 // aid
15439 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053015440 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 pBuf += sizeof (tANI_U16);
15442 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015443 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
15444 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 pBuf += sizeof (tSirMacAddr);
15446 // alternateChannelId
15447 *pBuf = 11;
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015448 msg.type = pMsg->messageType;
15449 msg.bodyval = 0;
15450 msg.bodyptr = pMsg;
15451 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015452 if(!HAL_STATUS_SUCCESS(status))
15453 {
15454 //pMsg is freed by palSendMBMessage
Abhinav Kumarc00a7842018-06-13 16:07:31 +053015455 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 break;
15457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015458 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 return( status );
15460}
Jeff Johnson295189b2012-06-20 16:38:30 -070015461eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
15462 tpSirSmeAssocInd pAssocInd,
15463 eHalStatus Halstatus,
15464 tANI_U8 sessionId)
15465{
15466 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15468 tANI_U8 *pBuf;
15469 tSirResultCodes statusCode;
15470 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053015472 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15473 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15474 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070015475
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
15477 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
15478
15479 pMsg->sessionId = sessionId;
15480
15481 pBuf = (tANI_U8 *)&pMsg->statusCode;
15482 if(HAL_STATUS_SUCCESS(Halstatus))
15483 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
15484 else
15485 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053015486 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 pBuf += sizeof(tSirResultCodes);
15488 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015489 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015490 pBuf += sizeof (tSirMacAddr);
15491 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015492 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15493 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 pBuf += sizeof (tSirMacAddr);
15495 // StaId
15496 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053015497 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015498 pBuf += sizeof (tANI_U16);
15499 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015500 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 pBuf += sizeof (tSirMacAddr);
15502 // alternateChannelId
15503 *pBuf = 11;
15504 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015505 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 //Wmm
15507 *pBuf = pAssocInd->wmmEnabledSta;
15508 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015510 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053015513 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 //reassocReq
15516 *pBuf = pAssocInd->reassocReq;
15517 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053015518#ifdef WLAN_FEATURE_AP_HT40_24G
15519 // 40 MHz Intolerant
15520 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
15521 pBuf += sizeof (tANI_U8);
15522#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053015523 *pBuf = pAssocInd->rate_flags;
15524 pBuf += sizeof (uint32_t);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +053015525
15526 pBuf = (tANI_U8 *)&pMsg->chan_info;
15527 vos_mem_copy((void *)pBuf, &pAssocInd->chan_info,
15528 sizeof(tSirSmeChanInfo));
15529
15530 pBuf = (tANI_U8 *)&pMsg->ch_width;
15531 *pBuf = pAssocInd->ch_width;
15532
15533 if (pAssocInd->HTCaps.present) {
15534 pBuf = (tANI_U8 *)&pMsg->HTCaps;
15535 vos_mem_copy(pBuf, &pAssocInd->HTCaps, sizeof(pMsg->HTCaps));
15536 }
15537
15538 if (pAssocInd->VHTCaps.present) {
15539 pBuf = (tANI_U8 *)&pMsg->VHTCaps;
15540 vos_mem_copy(pBuf, &pAssocInd->VHTCaps, sizeof(pMsg->VHTCaps));
15541 }
15542
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15544 msgQ.bodyptr = pMsg;
15545 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015547 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053015548 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070015549}
Jeff Johnson295189b2012-06-20 16:38:30 -070015550
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015551eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
15553 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
15554 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
15555 tANI_U8 *pKeyRsc )
15556{
15557 tSirSmeSetContextReq *pMsg;
15558 tANI_U16 msgLen;
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015559 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015560 tAniEdType tmpEdType;
15561 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053015562 tANI_U8 *pBuf = NULL;
15563 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015565 vos_msg_t msg;
Sushant Kaushike7de85f2014-06-16 17:13:30 +053015566 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
15567 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015568 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
15571 // key set. Since we only support upto one key, we always allocate memory for 1 key
15572 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
15573 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
15574 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
15575 ( sizeof( pMsg->keyMaterial.key ) );
15576
Kiet Lam64c1b492013-07-12 13:56:44 +053015577 pMsg = vos_mem_malloc(msgLen);
15578 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15579 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
15581 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 //sessionId
15583 pBuf = &pMsg->sessionId;
15584 *pBuf = (tANI_U8)sessionId;
15585 pBuf++;
15586 // transactionId
15587 *pBuf = 0;
15588 *(pBuf + 1) = 0;
15589 pBuf += sizeof(tANI_U16);
15590 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015591 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015592
15593 pBuf += sizeof(tSirMacAddr);
15594
15595 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053015596 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15597 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015598
15599 pBuf += sizeof(tSirMacAddr);
15600
15601 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
15603 // in the tSirKeyMaterial keyMaterial; field).
15604 //
15605 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
15606 // shorter than this max size. Is LIM interpreting this ok ?
15607 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 -070015608 // set pMsg->keyMaterial.edType
15609 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015610 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 // set the pMsg->keyMaterial.numKeys field
15613 *p = numKeys;
15614 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070015615 // set pSirKey->keyId = keyId;
15616 *p = keyId;
15617 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015618 // set pSirKey->unicast = (tANI_U8)fUnicast;
15619 *p = (tANI_U8)fUnicast;
15620 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 // set pSirKey->keyDirection = aniKeyDirection;
15622 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053015623 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 p += sizeof(tAniKeyDirection);
15625 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053015626 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070015628 // set pSirKey->paeRole
15629 *p = paeRole; // 0 is Supplicant
15630 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 // set pSirKey->keyLength = keyLength;
15632 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 if ( keyLength && pKey )
Kiet Lam64c1b492013-07-12 13:56:44 +053015634 vos_mem_copy(p, pKey, keyLength);
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015635 msg.type = pMsg->messageType;
15636 msg.bodyptr = pMsg;
15637 msg.bodyval = 0;
15638 if (fUnicast)
15639 status = vos_mq_post_message_high_pri(VOS_MQ_ID_PE, &msg);
15640 else
15641 status = vos_mq_post_message(VOS_MQ_ID_PE, &msg);
15642 if (!VOS_IS_STATUS_SUCCESS(status)) {
15643 vos_mem_free(pMsg);
15644 return eHAL_STATUS_FAILURE;
15645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015646 } while( 0 );
Yeshwanth Sriram Guntuka32935562018-08-24 15:41:18 +053015647 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015648}
15649
Jeff Johnson295189b2012-06-20 16:38:30 -070015650eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
15651 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
15652{
15653 eHalStatus status;
15654 tSirSmeStartBssReq *pMsg;
15655 tANI_U8 *pBuf = NULL;
15656 tANI_U8 *wTmpBuf = NULL;
15657 tANI_U16 msgLen, wTmp;
15658 tANI_U32 dwTmp;
15659 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070015660 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070015661 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070015662 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015663
15664 if(!pSession)
15665 {
15666 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15667 return eHAL_STATUS_FAILURE;
15668 }
15669
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 do {
15671 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15672 pSession->joinFailStatusCode.reasonCode = 0;
15673 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015674 pMsg = vos_mem_malloc(msgLen);
15675 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15676 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015680 //sessionId
15681 *pBuf = (tANI_U8)sessionId;
15682 pBuf++;
15683 // transactionId
15684 *pBuf = 0;
15685 *(pBuf + 1) = 0;
15686 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015687 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053015688 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 pBuf += sizeof(tSirMacAddr);
15690 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053015691 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015692 pBuf += sizeof(tSirMacAddr);
15693 // beaconInterval
15694 if( pBssDesc && pBssDesc->beaconInterval )
15695 {
15696 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
15697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015698 else if(pParam->beaconInterval)
15699 {
15700 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
15701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015702 else
15703 {
15704 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
15705 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070015706 if(csrIsconcurrentsessionValid (pMac, sessionId,
15707 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070015708 == eHAL_STATUS_SUCCESS )
15709 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080015710 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070015711 pParam->bssPersona);
15712 //Update the beacon Interval
15713 pParam->beaconInterval = wTmp;
15714 }
15715 else
15716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015717 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015718 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053015719 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070015720 return status;
15721 }
15722
Kiet Lam64c1b492013-07-12 13:56:44 +053015723 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015724 pBuf += sizeof(tANI_U16);
15725 // dot11mode
15726 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
15727 pBuf += 1;
15728 // bssType
15729 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053015730 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 pBuf += sizeof(tSirBssType);
15732 // ssId
15733 if( pParam->ssId.length )
15734 {
15735 // ssId len
15736 *pBuf = pParam->ssId.length;
15737 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015738 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070015739 pBuf += pParam->ssId.length;
15740 }
15741 else
15742 {
15743 *pBuf = 0;
15744 pBuf++;
15745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015746 // set the channel Id
15747 *pBuf = pParam->operationChn;
15748 pBuf++;
15749 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070015750 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053015751 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070015752 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015753
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 // Set privacy
15755 *pBuf = pParam->privacy;
15756 pBuf++;
15757
15758 //Set Uapsd
15759 *pBuf = pParam->ApUapsdEnable;
15760 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015761 //Set SSID hidden
15762 *pBuf = pParam->ssidHidden;
15763 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015764 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
15765 pBuf++;
15766
15767 //Ht protection Enable/Disable
15768 *pBuf = (tANI_U8)pParam->protEnabled;
15769 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015770 //Enable Beacons to Receive for OBSS protection Enable/Disable
15771 *pBuf = (tANI_U8)pParam->obssProtEnabled;
15772 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015773 //set cfg related to protection
15774 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053015775 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070015776 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 // Set Auth type
15778 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015779 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 // Set DTIM
15782 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053015783 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015785 // Set wps_state
15786 *pBuf = pParam->wps_state;
15787 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080015788 // set isCoalesingInIBSSAllowed
15789 *pBuf = pMac->isCoalesingInIBSSAllowed;
15790 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 //Persona
15792 *pBuf = (tANI_U8)pParam->bssPersona;
15793 pBuf++;
Abhinav Kumar0ee145b2019-09-12 20:13:58 +053015794
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080015795 //txLdpcIniFeatureEnabled
15796 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
15797 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070015798
Chet Lanctot8cecea22014-02-11 19:09:36 -080015799#ifdef WLAN_FEATURE_11W
15800 // Set MFP capable/required
15801 *pBuf = (tANI_U8)pParam->mfpCapable;
15802 pBuf++;
15803 *pBuf = (tANI_U8)pParam->mfpRequired;
15804 pBuf++;
15805#endif
15806
krunal soni4f087d22013-07-29 16:32:26 -070015807 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
15809 {
15810 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053015811 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015812 break;
15813 }
15814 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053015815 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 pBuf += sizeof(tANI_U16);
15817 if( wTmp )
15818 {
15819 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053015820 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 pBuf += wTmp;
15822 }
15823 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053015824 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070015825 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070015826 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
15827 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053015828 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
15829 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070015830 pBuf += pParam->operationalRateSet.numRates ;
15831 *pBuf++ = pParam->extendedRateSet.numRates;
15832 if(0 != pParam->extendedRateSet.numRates)
15833 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015834 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
15835 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 pBuf += pParam->extendedRateSet.numRates;
15837 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053015838#ifdef WLAN_FEATURE_AP_HT40_24G
15839 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
15840#endif
krunal sonie9002db2013-11-25 14:24:17 -080015841
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
15843 pMsg->length = pal_cpu_to_be16(msgLen);
15844
15845 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015846 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015847 return( status );
15848}
15849
Jeff Johnson295189b2012-06-20 16:38:30 -070015850eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
15851{
15852 eHalStatus status = eHAL_STATUS_FAILURE;
15853 tSirSmeStopBssReq *pMsg;
15854 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15855 tANI_U8 *pBuf;
15856 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070015857
15858 if(!pSession)
15859 {
15860 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15861 return eHAL_STATUS_FAILURE;
15862 }
15863
Abhishek Singhe2bb7842015-03-12 17:34:03 +053015864 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
15865 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15866 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
15867 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
15868 pBuf = &pMsg->sessionId;
15869 //sessionId
15870 *pBuf = (tANI_U8)sessionId;
15871 pBuf++;
15872 // transactionId
15873 *pBuf = 0;
15874 pBuf += sizeof(tANI_U16);
15875 //reason code
15876 *pBuf = 0;
15877 pBuf += sizeof(tSirResultCodes);
15878 // bssid
15879 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
15880 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
15881 {
15882 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
15883 sizeof(tSirMacAddr));
15884 }
15885 else
15886 {
15887 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
15888 sizeof(tSirMacAddr));
15889 }
15890 pBuf += sizeof(tSirMacAddr);
15891 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
15892 pMsg->length = pal_cpu_to_be16(msgLen);
15893 status = palSendMBMessage( pMac->hHdd, pMsg );
15894
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 return( status );
15896}
15897
Jeff Johnson295189b2012-06-20 16:38:30 -070015898eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
15899 tCsrRoamModifyProfileFields *pModProfileFields,
15900 tANI_U32 *pRoamId, v_BOOL_t fForce)
15901{
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 eHalStatus status = eHAL_STATUS_FAILURE;
15903 tANI_U32 roamId = 0;
15904 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015905 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053015906 (fForce || (!vos_mem_compare( &pModProfileFields,
15907 &pSession->connectedProfile.modifyProfileFields,
15908 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 {
15910 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
15911 if(pRoamId)
15912 {
15913 *pRoamId = roamId;
15914 }
15915
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
15917 eCsrSmeIssuedReassocToSameAP, roamId,
15918 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015920 return status;
15921}
Jeff Johnson295189b2012-06-20 16:38:30 -070015922static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
15923{
15924 eHalStatus status = eHAL_STATUS_SUCCESS;
15925 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053015926 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015927 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
15928 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
15929 return (status);
15930}
Jeff Johnson295189b2012-06-20 16:38:30 -070015931eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15932{
15933 eHalStatus status = eHAL_STATUS_SUCCESS;
15934 tListElem *pEntry = NULL;
15935 tSmeCmd *pCommand = NULL;
15936 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 do
15938 {
15939 if(pMsg == NULL)
15940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015941 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015942 status = eHAL_STATUS_FAILURE;
15943 break;
15944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015945 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15946 if(pEntry)
15947 {
15948 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15949 if(eSmeCommandAddStaSession == pCommand->command)
15950 {
15951 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015952 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053015953 if (pRsp->status == eSIR_FAILURE) {
15954 VOS_ASSERT( 0 );
15955 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015956 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015958 //Remove this command out of the active list
15959 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15960 {
15961 //Now put this command back on the avilable command list
15962 csrReleaseCommand(pMac, pCommand);
15963 }
15964 smeProcessPendingQueue( pMac );
15965 }
15966 else
15967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015968 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 -070015969 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015970 status = eHAL_STATUS_FAILURE;
15971 break;
15972 }
15973 }
15974 else
15975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015976 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 -070015977 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 status = eHAL_STATUS_FAILURE;
15979 break;
15980 }
15981 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015982 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015983}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015984eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
15985 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070015986{
15987 tSirSmeAddStaSelfReq *pMsg;
15988 tANI_U16 msgLen;
15989 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015990 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015991 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053015992 pMsg = vos_mem_malloc(msgLen);
15993 if ( NULL == pMsg ) break;
15994 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
15996 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015998 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015999 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
16000
16001 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
16002
Arif Hussain24bafea2013-11-15 15:10:03 -080016003 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
16004 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016005 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016006 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016007 return( status );
16008}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016009eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
16010 tANI_U32 sessionId,
16011 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070016012{
16013 eHalStatus status = eHAL_STATUS_SUCCESS;
16014 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016015 pCommand = csrGetCommandBuffer(pMac);
16016 if(NULL == pCommand)
16017 {
16018 status = eHAL_STATUS_RESOURCES;
16019 }
16020 else
16021 {
16022 pCommand->command = eSmeCommandAddStaSession;
16023 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053016024 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
16025 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016026 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070016027 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
16028 if( !HAL_STATUS_SUCCESS( status ) )
16029 {
16030 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016031 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016032 }
16033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016034 return (status);
16035}
Jeff Johnson295189b2012-06-20 16:38:30 -070016036eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16037{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016038 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070016039}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016040eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
16041 csrRoamCompleteCallback callback,
16042 void *pContext, tANI_U8 *pSelfMacAddr,
16043 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070016044{
16045 eHalStatus status = eHAL_STATUS_SUCCESS;
16046 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053016047 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016048 *pbSessionId = CSR_SESSION_ID_INVALID;
16049 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16050 {
16051 if( !CSR_IS_SESSION_VALID( pMac, i ) )
16052 {
16053 pSession = CSR_GET_SESSION( pMac, i );
16054 status = eHAL_STATUS_SUCCESS;
16055 pSession->sessionActive = eANI_BOOLEAN_TRUE;
16056 pSession->sessionId = (tANI_U8)i;
16057 pSession->callback = callback;
16058 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016059 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016061 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
16062 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070016063 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016064 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016066 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016067 break;
16068 }
16069#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016070 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
16071 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070016072 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016073 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016075 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016076 break;
16077 }
16078#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070016079 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016080 break;
16081 }
16082 }
16083 if( CSR_ROAM_SESSION_MAX == i )
16084 {
16085 //No session is available
16086 status = eHAL_STATUS_RESOURCES;
16087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016088 return ( status );
16089}
Jeff Johnson295189b2012-06-20 16:38:30 -070016090eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
16091{
16092 eHalStatus status = eHAL_STATUS_SUCCESS;
16093 tListElem *pEntry = NULL;
16094 tSmeCmd *pCommand = NULL;
16095 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070016096 do
16097 {
16098 if(pMsg == NULL)
16099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016100 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016101 status = eHAL_STATUS_FAILURE;
16102 break;
16103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
16105 if(pEntry)
16106 {
16107 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16108 if(eSmeCommandDelStaSession == pCommand->command)
16109 {
16110 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016111 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016112 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016113 //This session is done.
16114 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016115 if(pCommand->u.delStaSessionCmd.callback)
16116 {
16117
16118 status = sme_ReleaseGlobalLock( &pMac->sme );
16119 if ( HAL_STATUS_SUCCESS( status ) )
16120 {
16121 pCommand->u.delStaSessionCmd.callback(
16122 pCommand->u.delStaSessionCmd.pContext);
16123 status = sme_AcquireGlobalLock( &pMac->sme );
16124 if (! HAL_STATUS_SUCCESS( status ) )
16125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016126 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016127 return status;
16128 }
16129 }
16130 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016131 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016132 }
16133 }
16134
16135 //Remove this command out of the active list
16136 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
16137 {
16138 //Now put this command back on the avilable command list
16139 csrReleaseCommand(pMac, pCommand);
16140 }
16141 smeProcessPendingQueue( pMac );
16142 }
16143 else
16144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016145 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 -070016146 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016147 status = eHAL_STATUS_FAILURE;
16148 break;
16149 }
16150 }
16151 else
16152 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016153 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 -070016154 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070016155 status = eHAL_STATUS_FAILURE;
16156 break;
16157 }
16158 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016159 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016160}
Jeff Johnson295189b2012-06-20 16:38:30 -070016161eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
16162{
16163 tSirSmeDelStaSelfReq *pMsg;
16164 tANI_U16 msgLen;
16165 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016166 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070016167 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
16168 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053016169 pMsg = vos_mem_malloc(msgLen);
16170 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16171 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016172 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
16173 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070016174 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053016175 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
16176 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016177 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016178 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016179 return( status );
16180}
Jeff Johnson295189b2012-06-20 16:38:30 -070016181eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016182 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070016183 tSirMacAddr sessionMacAddr,
16184 csrRoamSessionCloseCallback callback,
16185 void *pContext)
16186{
16187 eHalStatus status = eHAL_STATUS_SUCCESS;
16188 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070016189 pCommand = csrGetCommandBuffer(pMac);
16190 if(NULL == pCommand)
16191 {
16192 status = eHAL_STATUS_RESOURCES;
16193 }
16194 else
16195 {
16196 pCommand->command = eSmeCommandDelStaSession;
16197 pCommand->sessionId = (tANI_U8)sessionId;
16198 pCommand->u.delStaSessionCmd.callback = callback;
16199 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053016200 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
16201 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053016202 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070016203 if( !HAL_STATUS_SUCCESS( status ) )
16204 {
16205 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016206 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016207 }
16208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016209 return (status);
16210}
Jeff Johnson295189b2012-06-20 16:38:30 -070016211eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16212{
16213 return csrSendMBDelSelfStaReqMsg( pMac,
16214 pCommand->u.delStaSessionCmd.selfMacAddr );
16215}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016216static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16217 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070016218{
16219 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
16220 tListElem *pEntry, *pNext;
16221 tSmeCmd *pCommand;
16222 tDblLinkList localList;
16223
16224 vos_mem_zero(&localList, sizeof(tDblLinkList));
16225 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
16226 {
16227 smsLog(pMac, LOGE, FL(" failed to open list"));
16228 return;
16229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016230 csrLLLock(pList);
16231 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
16232 while(pEntry != NULL)
16233 {
16234 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
16235 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016236
16237 if (!flush_all &&
16238 csr_is_disconnect_full_power_cmd(pCommand)) {
16239 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
16240 pEntry = pNext;
16241 continue;
16242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016243 if(pCommand->sessionId == sessionId)
16244 {
16245 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
16246 {
16247 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
16248 }
16249 }
16250 pEntry = pNext;
16251 }
16252 csrLLUnlock(pList);
16253
16254 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
16255 {
16256 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
16257 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
16258 }
16259 csrLLClose(&localList);
16260}
16261
Jeff Johnson295189b2012-06-20 16:38:30 -070016262void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
16263{
16264 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16265 {
16266 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016267 csrRoamStop(pMac, sessionId);
16268 csrFreeConnectBssDesc(pMac, sessionId);
16269 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
16270 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016271 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070016272#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016273 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016274#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016275 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070016276 csrInitSession(pMac, sessionId);
16277 }
16278}
16279
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016280void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
16281 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053016282{
16283 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016284 &pMac->sme.smeCmdPendingList,
16285 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016286 if (pMac->fScanOffload)
16287 {
16288 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016289 &pMac->sme.smeScanCmdPendingList,
16290 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016291 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016292 purgeCsrSessionCmdList(pMac, sessionId,
16293 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053016294}
16295
Jeff Johnson295189b2012-06-20 16:38:30 -070016296eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053016297 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016298 csrRoamSessionCloseCallback callback,
16299 void *pContext )
16300{
16301 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070016302 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
16303 {
16304 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16305 if(fSync)
16306 {
16307 csrCleanupSession(pMac, sessionId);
16308 }
16309 else
mukul sharmabab477d2015-06-11 17:14:55 +053016310 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053016311 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053016312 /* If bPurgeList is FALSE, it means HDD already free all the
16313 * cmd and later queue few essential cmd. Now sme should process
16314 * the cmd in pending queue order only.Hence we should
16315 * avoid DEL_SELF_STA as high priority cmd.
16316 */
16317 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 pSession->selfMacAddr, callback, pContext);
16319 }
16320 }
16321 else
16322 {
16323 status = eHAL_STATUS_INVALID_PARAMETER;
16324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016325 return ( status );
16326}
16327
Jeff Johnson295189b2012-06-20 16:38:30 -070016328static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
16329{
16330 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016331
16332 if(!pSession)
16333 {
16334 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16335 return;
16336 }
16337
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 pSession->sessionActive = eANI_BOOLEAN_FALSE;
16339 pSession->sessionId = CSR_SESSION_ID_INVALID;
16340 pSession->callback = NULL;
16341 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16343 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
16344 csrFreeRoamProfile( pMac, sessionId );
16345 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
16346 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
16347 csrFreeConnectBssDesc(pMac, sessionId);
16348 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053016349 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
16350 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016351 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016352 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016353 pSession->pWpaRsnReqIE = NULL;
16354 }
16355 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016356 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016357 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016358 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016359 pSession->pWpaRsnRspIE = NULL;
16360 }
16361 pSession->nWpaRsnRspIeLength = 0;
16362#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053016363 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016364 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016365 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016366 pSession->pWapiReqIE = NULL;
16367 }
16368 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053016369 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070016370 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016371 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070016372 pSession->pWapiRspIE = NULL;
16373 }
16374 pSession->nWapiRspIeLength = 0;
16375#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053016376 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070016377 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053016378 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070016379 }
16380 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053016381
Kiet Lam64c1b492013-07-12 13:56:44 +053016382 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070016383 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016384 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016386 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016387 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016388}
16389
Jeff Johnson295189b2012-06-20 16:38:30 -070016390eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
16391{
16392 eHalStatus status = eHAL_STATUS_FAILURE;
16393 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070016394 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16395 {
16396 if( CSR_IS_SESSION_VALID( pMac, i ) )
16397 {
16398 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
16399 {
16400 //Found it
16401 status = eHAL_STATUS_SUCCESS;
16402 *pSessionId = i;
16403 break;
16404 }
16405 }
16406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016407 return( status );
16408}
16409
Jeff Johnson295189b2012-06-20 16:38:30 -070016410//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
16411//session because for IBSS, the bssid changes.
16412static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
16413{
16414 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
16415 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070016416 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
16417 {
16418 if( CSR_IS_SESSION_VALID( pMac, i ) )
16419 {
16420 pSession = CSR_GET_SESSION( pMac, i );
16421 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
16422 {
16423 //Found it
16424 nRet = i;
16425 break;
16426 }
16427 }
16428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 return (nRet);
16430}
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053016431void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
Jeff Johnson295189b2012-06-20 16:38:30 -070016432{
Mukul Sharma20aa6582014-08-07 21:36:12 +053016433 VOS_STATUS status = VOS_STATUS_SUCCESS;
16434
16435 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070016436 profile info from pmac global structure */
16437
Arif Hussain24bafea2013-11-15 15:10:03 -080016438 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
16439 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 /* Check for user misconfig of RSSI trigger threshold */
16441 pMac->roam.configParam.vccRssiThreshold =
16442 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
16443 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
16444 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070016445 /* Check for user misconfig of UL MAC Loss trigger threshold */
16446 pMac->roam.configParam.vccUlMacLossThreshold =
16447 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
16448 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016449#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16450 {
16451 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016452 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 /* Indicate the neighbor roal algorithm about the connect indication */
16454 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
16455 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016456
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016457 /* Making sure we are roaming force fully to 5GHz AP only once and
16458 * only when we connected to 2.4GH AP only during initial association.
16459 */
16460 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
16461 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
16462 SIR_BAND_2_4_GHZ)
16463 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053016464 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016465 status = vos_timer_start(
16466 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
16467 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016468 if ( status != VOS_STATUS_SUCCESS )
16469 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016470 smsLog(pMac, LOGE,
16471 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
16472 status);
16473 //Send RSO start because in case 5G roaming
16474 //host have not enabled at initial connection
16475 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053016476 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053016477 else
16478 {
16479 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
16480 __func__);
16481 }
16482 }
16483 /*
16484 * Making ini value to false here only so we just roam to
16485 * only once for whole driver load to unload tenure
16486 * This feature is only applicable for first connection only
16487 */
16488 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
16489 {
16490 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
16491 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016493 }
16494#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016495}
16496
Jeff Johnson295189b2012-06-20 16:38:30 -070016497static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
16498{
16499 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070016500
16501 if(!pSession)
16502 {
16503 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16504 return;
16505 }
16506
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 //Only to handle the case for Handover on infra link
16508 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16509 {
16510 return;
16511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016512 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
16513 csrRoamDeregStatisticsReq(pMac);
16514 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16515#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
16516 /* Indicate the neighbor roal algorithm about the disconnect indication */
16517 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
16518#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070016519
16520 //Remove this code once SLM_Sessionization is supported
16521 //BMPS_WORKAROUND_NOT_NEEDED
16522 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070016523 csrIsInfraApStarted( pMac ) &&
16524 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070016525 {
16526 pMac->roam.configParam.doBMPSWorkaround = 0;
16527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016528}
16529
Jeff Johnson295189b2012-06-20 16:38:30 -070016530void csrRoamTlStatsTimerHandler(void *pv)
16531{
16532 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
16533 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16535
Jeff Johnsone7245742012-09-05 17:12:55 -070016536 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
16537
Jeff Johnson295189b2012-06-20 16:38:30 -070016538#if 0
16539 // TODO Persession .???
16540 //req TL for stats
16541 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
16542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016543 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 }
16545 else
16546 {
16547 //save in SME
16548 csrRoamSaveStatsFromTl(pMac, tlStats);
16549 }
16550#endif
16551 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16552 {
16553 if(pMac->roam.tlStatsReqInfo.periodicity)
16554 {
16555 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016556 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16557 pMac->roam.tlStatsReqInfo.periodicity);
16558 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016560 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 return;
16562 }
16563 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16564 }
16565 }
16566}
Jeff Johnson295189b2012-06-20 16:38:30 -070016567void csrRoamPeStatsTimerHandler(void *pv)
16568{
16569 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
16570 eHalStatus status;
16571 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
16572 VOS_STATUS vosStatus;
16573 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070016574 pPeStatsReqListEntry->timerRunning = FALSE;
16575 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
16576 {
16577 // If we entered here, meaning the timer could not be successfully
16578 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
16579
16580 /* Destroy the timer */
16581 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
16582 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016584 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016585 }
16586
16587 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016588 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016589 pPeStatsReqListEntry = NULL;
16590 }
16591 else
16592 {
16593 if(!pPeStatsReqListEntry->rspPending)
16594 {
16595 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
16596 pPeStatsReqListEntry->staId);
16597 if(!HAL_STATUS_SUCCESS(status))
16598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016599 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016600 }
16601 else
16602 {
16603 pPeStatsReqListEntry->rspPending = TRUE;
16604 }
16605 }
16606
16607 //send down a req
16608 if(pPeStatsReqListEntry->periodicity &&
16609 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
16610 {
16611 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16612 if(ePMC_FULL_POWER == powerState)
16613 {
16614 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16615 {
16616 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16617 }
16618 }
16619 else
16620 {
16621 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16622 {
16623 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16624 }
16625 }
16626 //start timer
16627 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
16628 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016630 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 return;
16632 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016633 pPeStatsReqListEntry->timerRunning = TRUE;
16634
16635 }
16636
16637 }
16638}
Jeff Johnson295189b2012-06-20 16:38:30 -070016639void csrRoamStatsClientTimerHandler(void *pv)
16640{
16641 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070016642 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
16643 {
16644#if 0
16645 // TODO Stats fix for multisession
16646 //start the timer
16647 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
16648
16649 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016651 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016652 }
16653#endif
16654 }
16655#if 0
16656 //send up the stats report
16657 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
16658 pStaEntry->staId, pStaEntry->pContext);
16659#endif
16660}
16661
16662
16663
Jeff Johnson295189b2012-06-20 16:38:30 -070016664eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
16665{
16666 tAniGetPEStatsReq *pMsg;
16667 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016668 tSirMsgQ msgQ;
16669
Kiet Lam64c1b492013-07-12 13:56:44 +053016670 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
16671 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016672 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016673 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053016674 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016675 }
16676 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016677 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016678 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
16679 pMsg->staId = staId;
16680 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016681
16682 msgQ.type = WDA_GET_STATISTICS_REQ;
16683 msgQ.reserved = 0;
16684 msgQ.bodyptr = pMsg;
16685 msgQ.bodyval = 0;
16686 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016687 if(!HAL_STATUS_SUCCESS(status))
16688 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016689 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053016690 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016692 return status;
16693}
Jeff Johnson295189b2012-06-20 16:38:30 -070016694void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16695{
16696 tAniGetPEStatsRsp *pSmeStatsRsp;
16697 eHalStatus status = eHAL_STATUS_FAILURE;
16698 tListElem *pEntry = NULL;
16699 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16700 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16701 tANI_U32 tempMask = 0;
16702 tANI_U8 counter = 0;
16703 tANI_U8 *pStats = NULL;
16704 tANI_U32 length = 0;
16705 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016706 v_S7_t rssi = 0, snr = 0;
16707 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053016708 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016709 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016710 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
16711 if(pSmeStatsRsp->rc)
16712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016713 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 goto post_update;
16715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 tempMask = pSmeStatsRsp->statsMask;
16717 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 /* subtract all statistics from this length, and after processing the entire
16719 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
16720 * in this 'stats' message.
16721 */
16722 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070016723 //new stats info from PE, fill up the stats strucutres in PMAC
16724 while(tempMask)
16725 {
16726 if(tempMask & 1)
16727 {
16728 switch(counter)
16729 {
16730 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016731 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016732 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
16733 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016734 pStats += sizeof(tCsrSummaryStatsInfo);
16735 length -= sizeof(tCsrSummaryStatsInfo);
16736 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016738 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016739 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
16740 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016741 pStats += sizeof(tCsrGlobalClassAStatsInfo);
16742 length -= sizeof(tCsrGlobalClassAStatsInfo);
16743 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016745 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016746 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
16747 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016748 pStats += sizeof(tCsrGlobalClassBStatsInfo);
16749 length -= sizeof(tCsrGlobalClassBStatsInfo);
16750 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016751 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016752 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016753 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
16754 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016755 pStats += sizeof(tCsrGlobalClassCStatsInfo);
16756 length -= sizeof(tCsrGlobalClassCStatsInfo);
16757 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016759 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016760 if( CSR_MAX_STA > pSmeStatsRsp->staId )
16761 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016762 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053016763 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
16764 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 }
16766 else
16767 {
16768 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016769 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 VOS_ASSERT( 0 );
16771 }
16772 if(!HAL_STATUS_SUCCESS(status))
16773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016774 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 }
16776 pStats += sizeof(tCsrPerStaStatsInfo);
16777 length -= sizeof(tCsrPerStaStatsInfo);
16778 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053016779 case eCsrPerPktStats:
16780 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
16781 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
16782 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
16783 {
16784 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
16785 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
16786 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053016787 /* for reserved bytes */
16788 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
16789 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053016790 }
16791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016792 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016793 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 }
16796 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016797 tempMask >>=1;
16798 counter++;
16799 }
16800 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
16801 if (length != 0)
16802 {
16803 pRssi = (tANI_U32*)pStats;
16804 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016805 pStats += sizeof(tANI_U32);
16806 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 }
16808 else
16809 {
16810 /* If riva is not sending rssi, continue to use the hack */
16811 rssi = RSSI_HACK_BMPS;
16812 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053016813 /* send positive value of rssi to wifi_hal */
16814 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053016815 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016817
16818 if (length != 0)
16819 {
16820 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016821 pStats += sizeof(tANI_U32);
16822 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053016823 }
16824 else
16825 {
16826 linkCapacity = 0;
16827 }
16828
16829 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016830
16831 if (length != 0)
16832 {
16833 pSnr = (tANI_U32*)pStats;
16834 snr = (v_S7_t)*pSnr;
16835 }
16836 else
16837 {
16838 snr = SNR_HACK_BMPS;
16839 }
16840
16841 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016842post_update:
16843 //make sure to update the pe stats req list
16844 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
16845 if(pEntry)
16846 {
16847 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
16848 pPeStaEntry->rspPending = FALSE;
16849
16850 }
16851 //check the one timer cases
16852 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
16853 if(pEntry)
16854 {
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016856 if(pTempStaEntry->timerExpired)
16857 {
16858 //send up the stats report
16859 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16860 pTempStaEntry->staId, pTempStaEntry->pContext);
16861 //also remove from the client list
16862 csrRoamRemoveStatListEntry(pMac, pEntry);
16863 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 }
16865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016866}
Jeff Johnson295189b2012-06-20 16:38:30 -070016867tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16868{
16869 tListElem *pEntry = NULL;
16870 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016872 if(!pEntry)
16873 {
16874 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016875 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 return NULL;
16877 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 while( pEntry )
16879 {
16880 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016881 if(pTempStaEntry->statsMask == statsMask)
16882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016883 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 break;
16885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016886 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016888 return pEntry;
16889}
16890
Jeff Johnson295189b2012-06-20 16:38:30 -070016891tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
16892 tANI_BOOLEAN update)
16893{
16894 tListElem *pEntry;
16895 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016897 if(!pEntry)
16898 {
16899 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016900 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016901 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016902 return NULL;
16903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 while( pEntry )
16905 {
16906 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016907 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
16908 (pTempStaEntry->statsMask == pStaEntry->statsMask))
16909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016910 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016911 if(update)
16912 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016913 pTempStaEntry->periodicity = pStaEntry->periodicity;
16914 pTempStaEntry->callback = pStaEntry->callback;
16915 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016916 }
16917 break;
16918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 return pEntry;
16922}
Jeff Johnson295189b2012-06-20 16:38:30 -070016923tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
16924{
16925 tListElem *pEntry;
16926 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016928 if(!pEntry)
16929 {
16930 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070016931 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016932 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 return NULL;
16934 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016935 while( pEntry )
16936 {
16937 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016938 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
16939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016940 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 break;
16942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016945 return pEntry;
16946}
Jeff Johnson295189b2012-06-20 16:38:30 -070016947eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
16948 csrRoamLinkQualityIndCallback callback,
16949 void *pContext)
16950{
16951 pMac->roam.linkQualityIndInfo.callback = callback;
16952 pMac->roam.linkQualityIndInfo.context = pContext;
16953 if( NULL == callback )
16954 {
16955 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
16956 }
16957 else
16958 {
16959 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 /* do we need to invoke the callback to notify client of initial value ?? */
16961 }
16962 return eHAL_STATUS_SUCCESS;
16963}
Jeff Johnson295189b2012-06-20 16:38:30 -070016964void csrRoamVccTrigger(tpAniSirGlobal pMac)
16965{
16966 eCsrRoamLinkQualityInd newVccLinkQuality;
16967 tANI_U32 ul_mac_loss = 0;
16968 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016969 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16970 /*-------------------------------------------------------------------------
16971 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070016972 Check for a change in link quality and notify client if necessary
16973 -------------------------------------------------------------------------*/
16974 ul_mac_loss_trigger_threshold =
16975 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070016976 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016977 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070016979 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
16980 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016981 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
16983 }
16984 else
16985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016986 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070016987 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
16988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016989 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
16990 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070016991 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
16992 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016993 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016994 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016996 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 newVccLinkQuality );
16998
16999 /* we now invoke the callback once to notify client of initial value */
17000 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
17001 pMac->roam.linkQualityIndInfo.context );
17002 //event: EVENT_WLAN_VCC
17003 }
17004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017005 pMac->roam.vccLinkQuality = newVccLinkQuality;
17006
Jeff Johnson295189b2012-06-20 16:38:30 -070017007}
Jeff Johnson295189b2012-06-20 16:38:30 -070017008VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
17009 v_U8_t rssiNotification,
17010 void * context)
17011{
17012 tpAniSirGlobal pMac = PMAC_STRUCT( context );
17013 eCsrRoamLinkQualityInd newVccLinkQuality;
17014 // TODO : Session info unavailable
17015 tANI_U32 sessionId = 0;
17016 VOS_STATUS status = VOS_STATUS_SUCCESS;
17017 /*-------------------------------------------------------------------------
17018 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070017019 Check for a change in link quality and notify client if necessary
17020 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017021 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 pMac->roam.configParam.vccRssiThreshold);
17023 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
17024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017025 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070017026 return VOS_STATUS_SUCCESS;
17027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017028 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
17029 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017030 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070017031 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
17032 }
17033 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
17034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017035 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070017036 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
17037 }
17038 else
17039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017040 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070017041 //Set to this so the code below won't do anything
17042 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070017043 VOS_ASSERT(0);
17044 }
17045
Jeff Johnson295189b2012-06-20 16:38:30 -070017046 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
17047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017048 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070017049 if(NULL != pMac->roam.linkQualityIndInfo.callback)
17050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017051 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070017052 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070017053 /* we now invoke the callback once to notify client of initial value */
17054 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
17055 pMac->roam.linkQualityIndInfo.context );
17056 //event: EVENT_WLAN_VCC
17057 }
17058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070017060 return status;
17061}
Jeff Johnson295189b2012-06-20 16:38:30 -070017062tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
17063 tDblLinkList *pStaList,
17064 tCsrStatsClientReqInfo *pStaEntry)
17065{
17066 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017067 //if same entity requested for same set of stats with different periodicity &
17068 // callback update it
17069 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
17070 {
17071
Kiet Lam64c1b492013-07-12 13:56:44 +053017072 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
17073 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017074 {
17075 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017076 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070017077 return NULL;
17078 }
17079
Jeff Johnson295189b2012-06-20 16:38:30 -070017080 pNewStaEntry->callback = pStaEntry->callback;
17081 pNewStaEntry->pContext = pStaEntry->pContext;
17082 pNewStaEntry->periodicity = pStaEntry->periodicity;
17083 pNewStaEntry->requesterId = pStaEntry->requesterId;
17084 pNewStaEntry->statsMask = pStaEntry->statsMask;
17085 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
17086 pNewStaEntry->pMac = pStaEntry->pMac;
17087 pNewStaEntry->staId = pStaEntry->staId;
17088 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
17089
17090 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
17091 }
17092 return pNewStaEntry;
17093}
17094
Jeff Johnson295189b2012-06-20 16:38:30 -070017095tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
17096 tDblLinkList *pStaList,
17097 tCsrPeStatsReqInfo *pStaEntry)
17098{
17099 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053017100 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
17101 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017102 {
17103 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017104 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070017105 return NULL;
17106 }
17107
Jeff Johnson295189b2012-06-20 16:38:30 -070017108 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
17109 pNewStaEntry->numClient = pStaEntry->numClient;
17110 pNewStaEntry->periodicity = pStaEntry->periodicity;
17111 pNewStaEntry->statsMask = pStaEntry->statsMask;
17112 pNewStaEntry->pMac = pStaEntry->pMac;
17113 pNewStaEntry->staId = pStaEntry->staId;
17114 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
17115 pNewStaEntry->rspPending = pStaEntry->rspPending;
17116
17117 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017118 return pNewStaEntry;
17119}
Jeff Johnson295189b2012-06-20 16:38:30 -070017120eHalStatus csrGetRssi(tpAniSirGlobal pMac,
17121 tCsrRssiCallback callback,
17122 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17123{
17124 eHalStatus status = eHAL_STATUS_SUCCESS;
17125 vos_msg_t msg;
17126 tANI_U32 sessionId;
17127
17128 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017129 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017130 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17131 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070017132 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017133 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017134 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017136 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17137
17138 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
17139 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17140 pMsg->sessionId = sessionId;
17141 pMsg->staId = staId;
17142 pMsg->rssiCallback = callback;
17143 pMsg->pDevContext = pContext;
17144 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070017145 msg.type = eWNI_SME_GET_RSSI_REQ;
17146 msg.bodyptr = pMsg;
17147 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017148 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017150 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017151 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017152 status = eHAL_STATUS_FAILURE;
17153 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017154 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017155 return status;
17156}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017157
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017158eHalStatus csrGetSnr(tpAniSirGlobal pMac,
17159 tCsrSnrCallback callback,
17160 tANI_U8 staId, tCsrBssid bssId,
17161 void *pContext)
17162{
17163 eHalStatus status = eHAL_STATUS_SUCCESS;
17164 vos_msg_t msg;
17165 tANI_U32 sessionId;
17166
17167 tAniGetSnrReq *pMsg;
17168
17169 smsLog(pMac, LOG2, FL("called"));
17170
17171 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
17172 if (NULL == pMsg )
17173 {
17174 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
17175 return status;
17176 }
17177
17178 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
17179
17180 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
17181 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
17182 pMsg->sessionId = sessionId;
17183 pMsg->staId = staId;
17184 pMsg->snrCallback = callback;
17185 pMsg->pDevContext = pContext;
17186 msg.type = eWNI_SME_GET_SNR_REQ;
17187 msg.bodyptr = pMsg;
17188 msg.reserved = 0;
17189
17190 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17191 {
17192 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
17193 vos_mem_free((v_VOID_t *)pMsg);
17194 status = eHAL_STATUS_FAILURE;
17195 }
17196
17197 smsLog(pMac, LOG2, FL("returned"));
17198 return status;
17199}
17200
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017201#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017202eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
17203 tCsrRssiCallback callback,
17204 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
17205{
17206 eHalStatus status = eHAL_STATUS_SUCCESS;
17207 tAniGetRssiReq *pMsg;
17208
Kiet Lam64c1b492013-07-12 13:56:44 +053017209 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
17210 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017211 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017212 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017213 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017214 }
17215 // need to initiate a stats request to PE
17216 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
17217 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
17218 pMsg->staId = staId;
17219 pMsg->rssiCallback = callback;
17220 pMsg->pDevContext = pContext;
17221 pMsg->pVosContext = pVosContext;
17222 status = palSendMBMessage(pMac->hHdd, pMsg );
17223 if(!HAL_STATUS_SUCCESS(status))
17224 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017225 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070017226 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080017227 status = eHAL_STATUS_FAILURE;
17228 }
17229 return status;
17230}
17231#endif
17232
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017233
17234
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017235#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017236eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
17237 tCsrTsmStatsCallback callback,
17238 tANI_U8 staId,
17239 tCsrBssid bssId,
17240 void *pContext,
17241 void* pVosContext,
17242 tANI_U8 tid)
17243{
17244 eHalStatus status = eHAL_STATUS_SUCCESS;
17245 tAniGetTsmStatsReq *pMsg = NULL;
17246
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017247 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
17248 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017249 {
17250 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017251 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017252 }
17253 // need to initiate a stats request to PE
17254 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
17255 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
17256 pMsg->staId = staId;
17257 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017258 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017259 pMsg->tsmStatsCallback = callback;
17260 pMsg->pDevContext = pContext;
17261 pMsg->pVosContext = pVosContext;
17262 status = palSendMBMessage(pMac->hHdd, pMsg );
17263 if(!HAL_STATUS_SUCCESS(status))
17264 {
17265 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
17266 //pMsg is freed by palSendMBMessage
17267 status = eHAL_STATUS_FAILURE;
17268 }
17269 return status;
17270}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017271#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017272
17273
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053017274/* ---------------------------------------------------------------------------
17275 \fn csrGetTLSTAState
17276 \helper function to get teh TL STA State whenever the function is called.
17277
17278 \param staId - The staID to be passed to the TL
17279 to get the relevant TL STA State
17280 \return the state as tANI_U16
17281 ---------------------------------------------------------------------------*/
17282tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
17283{
17284 WLANTL_STAStateType tlSTAState;
17285 tlSTAState = WLANTL_STA_INIT;
17286
17287 //request TL for STA State
17288 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
17289 {
17290 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
17291 }
17292
17293 return tlSTAState;
17294}
17295
Jeff Johnson295189b2012-06-20 16:38:30 -070017296eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
17297 tANI_U32 statsMask,
17298 tCsrStatsCallback callback,
17299 tANI_U32 periodicity, tANI_BOOLEAN cache,
17300 tANI_U8 staId, void *pContext)
17301{
17302 tCsrStatsClientReqInfo staEntry;
17303 tCsrStatsClientReqInfo *pStaEntry = NULL;
17304 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
17305 tListElem *pEntry = NULL;
17306 tANI_BOOLEAN found = FALSE;
17307 eHalStatus status = eHAL_STATUS_SUCCESS;
17308 tANI_BOOLEAN insertInClientList = FALSE;
17309 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070017310 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017311
17312 if( csrIsAllSessionDisconnected(pMac) )
17313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017314 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070017315 return eHAL_STATUS_FAILURE;
17316 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053017317
17318 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
17319 {
17320 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
17321 return eHAL_STATUS_FAILURE;
17322 }
17323
Jeff Johnson295189b2012-06-20 16:38:30 -070017324 if((!statsMask) && (!callback))
17325 {
17326 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017327 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070017328 return eHAL_STATUS_FAILURE;
17329 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017330 //for the search list method for deregister
17331 staEntry.requesterId = requesterId;
17332 staEntry.statsMask = statsMask;
17333 //requester wants to deregister or just an error
17334 if((statsMask) && (!callback))
17335 {
17336 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
17337 if(!pEntry)
17338 {
17339 //msg
17340 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017341 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017342 return eHAL_STATUS_FAILURE;
17343 }
17344 else
17345 {
17346 //clean up & return
17347 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070017348 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070017349 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017350 pStaEntry->pPeStaEntry->numClient--;
17351 //check if we need to delete the entry from peStatsReqList too
17352 if(!pStaEntry->pPeStaEntry->numClient)
17353 {
17354 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
17355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017356 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070017357
Jeff Johnson295189b2012-06-20 16:38:30 -070017358 //check if we need to stop the tl stats timer too
17359 pMac->roam.tlStatsReqInfo.numClient--;
17360 if(!pMac->roam.tlStatsReqInfo.numClient)
17361 {
17362 if(pMac->roam.tlStatsReqInfo.timerRunning)
17363 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017364 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17365 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017367 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017368 return eHAL_STATUS_FAILURE;
17369 }
17370 }
17371 pMac->roam.tlStatsReqInfo.periodicity = 0;
17372 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17373 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017374 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070017375 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053017376 vos_timer_stop(&pStaEntry->timer);
17377 // Destroy the vos timer
17378 vosStatus = vos_timer_destroy(&pStaEntry->timer);
17379 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
17380 {
17381 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
17382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017384 csrRoamRemoveStatListEntry(pMac, pEntry);
17385 pStaEntry = NULL;
17386 return eHAL_STATUS_SUCCESS;
17387 }
17388 }
17389
17390 if(cache && !periodicity)
17391 {
17392 //return the cached stats
17393 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17394 }
17395 else
17396 {
17397 //add the request in the client req list
17398 staEntry.callback = callback;
17399 staEntry.pContext = pContext;
17400 staEntry.periodicity = periodicity;
17401 staEntry.pPeStaEntry = NULL;
17402 staEntry.staId = staId;
17403 staEntry.pMac = pMac;
17404 staEntry.timerExpired = FALSE;
17405
17406
Jeff Johnson295189b2012-06-20 16:38:30 -070017407 //if periodic report requested with non cached result from PE/TL
17408 if(periodicity)
17409 {
17410
17411 //if looking for stats from PE
17412 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17413 {
17414
17415 //check if same request made already & waiting for rsp
17416 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
17417 periodicity, &found, staId);
17418 if(!pPeStaEntry)
17419 {
17420 //bail out, maxed out on number of req for PE
17421 return eHAL_STATUS_FAILURE;
17422 }
17423 else
17424 {
17425 staEntry.pPeStaEntry = pPeStaEntry;
17426 }
17427
17428 }
17429 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
17430 if(statsMask & (1 << eCsrGlobalClassDStats))
17431 {
17432 if(cache && pMac->roam.tlStatsReqInfo.numClient)
17433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017434 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017435 }
17436 else
17437 {
17438
17439 //update periodicity
17440 if(pMac->roam.tlStatsReqInfo.periodicity)
17441 {
17442 pMac->roam.tlStatsReqInfo.periodicity =
17443 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
17444 }
17445 else
17446 {
17447 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
17448 }
17449 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
17450 {
17451 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
17452 }
17453
17454 if(!pMac->roam.tlStatsReqInfo.timerRunning)
17455 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017456 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017457 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017458 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017459 //req TL for class D stats
17460 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
17461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017462 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017463 }
17464 else
17465 {
17466 //save in SME
17467 csrRoamSaveStatsFromTl(pMac, pTlStats);
17468 }
17469 vos_mem_free(pTlStats);
17470 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017471 }
17472 else
17473 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017474 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017475 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017476
Jeff Johnson295189b2012-06-20 16:38:30 -070017477 if(pMac->roam.tlStatsReqInfo.periodicity)
17478 {
17479 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017480 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
17481 pMac->roam.tlStatsReqInfo.periodicity);
17482 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017484 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017485 return eHAL_STATUS_FAILURE;
17486 }
17487 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
17488 }
17489 }
17490 }
17491 pMac->roam.tlStatsReqInfo.numClient++;
17492 }
17493
17494 insertInClientList = TRUE;
17495 }
17496 //if one time report requested with non cached result from PE/TL
17497 else if(!cache && !periodicity)
17498 {
17499 if(statsMask & ~(1 << eCsrGlobalClassDStats))
17500 {
17501 //send down a req
17502 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17503 if(!HAL_STATUS_SUCCESS(status))
17504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017505 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017506 }
17507 //so that when the stats rsp comes back from PE we respond to upper layer
17508 //right away
17509 staEntry.timerExpired = TRUE;
17510 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017511 }
17512 if(statsMask & (1 << eCsrGlobalClassDStats))
17513 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017514 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053017515 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017516 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017517 //req TL for class D stats
17518 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
17519 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017520 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017521 }
17522 else
17523 {
17524 //save in SME
17525 csrRoamSaveStatsFromTl(pMac, pTlStats);
17526 }
17527 vos_mem_free(pTlStats);
17528 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017529 }
17530 else
17531 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017532 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017534
17535 }
17536 //if looking for stats from TL only
17537 if(!insertInClientList)
17538 {
17539 //return the stats
17540 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
17541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017542 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017543 if(insertInClientList)
17544 {
17545 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
17546 if(!pStaEntry)
17547 {
17548 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017549 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017550 return eHAL_STATUS_FAILURE;
17551 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017552 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070017553 //Init & start timer if needed
17554 if(periodicity)
17555 {
17556 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
17557 csrRoamStatsClientTimerHandler, pStaEntry );
17558 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017560 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017561 return eHAL_STATUS_FAILURE;
17562 }
17563 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
17564 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017566 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017567 return eHAL_STATUS_FAILURE;
17568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017571 }
17572 return eHAL_STATUS_SUCCESS;
17573}
17574
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017575#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17576
17577static tSirRetStatus
17578csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
17579 tANI_U8* pBD,
17580 tANI_U8 type,
17581 tANI_U8 subType,
17582 tSirMacAddr peerAddr,
17583 tSirMacAddr selfMacAddr)
17584{
17585 tSirRetStatus statusCode = eSIR_SUCCESS;
17586 tpSirMacMgmtHdr pMacHdr;
17587
17588 /* Prepare MAC management header */
17589 pMacHdr = (tpSirMacMgmtHdr) (pBD);
17590
17591 /* Prepare FC */
17592 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
17593 pMacHdr->fc.type = type;
17594 pMacHdr->fc.subType = subType;
17595
17596 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017597 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
17598 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017599
17600 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
17601
17602 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053017603 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
17604 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017605 return statusCode;
17606} /*** csrRoamScanOffloadPopulateMacHeader() ***/
17607
17608static tSirRetStatus
17609csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
17610 tANI_U8 nChannelNum,
17611 tANI_U32 dot11mode,
17612 tSirMacAddr selfMacAddr,
17613 tANI_U8 *pFrame,
17614 tANI_U16 *pusLen)
17615{
17616 tDot11fProbeRequest pr;
17617 tANI_U32 nStatus, nBytes, nPayload;
17618 tSirRetStatus nSirStatus;
17619 /*Bcast tx*/
17620 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
17621 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
17622
17623
Kiet Lam64c1b492013-07-12 13:56:44 +053017624 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017625
17626 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
17627
17628 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
17629 {
17630 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
17631 }
17632
17633
17634 if (IS_DOT11_MODE_HT(dot11mode))
17635 {
17636 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
17637 }
17638
17639
17640 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
17641 if ( DOT11F_FAILED( nStatus ) )
17642 {
17643 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17644 "Failed to calculate the packed size f"
17645 "or a Probe Request (0x%08x).\n", nStatus );
17646
17647
17648 nPayload = sizeof( tDot11fProbeRequest );
17649 }
17650 else if ( DOT11F_WARNED( nStatus ) )
17651 {
17652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17653 "There were warnings while calculating"
17654 "the packed size for a Probe Request ("
17655 "0x%08x).\n", nStatus );
17656 }
17657
17658 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
17659
17660 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053017661 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017662
17663
17664 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017665 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017666
17667 if ( eSIR_SUCCESS != nSirStatus )
17668 {
17669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17670 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
17671 nSirStatus );
17672 return nSirStatus;
17673 }
17674
17675
17676 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
17677 sizeof( tSirMacMgmtHdr ),
17678 nPayload, &nPayload );
17679 if ( DOT11F_FAILED( nStatus ) )
17680 {
17681 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17682 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
17683 return eSIR_FAILURE;
17684 }
17685 else if ( DOT11F_WARNED( nStatus ) )
17686 {
17687 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070017688 "There were warnings while packing a Probe Request (0x%08x).\n",
17689 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017690 }
17691
17692 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
17693 return eSIR_SUCCESS;
17694}
17695
Mukul Sharmad68cda62015-03-20 21:25:41 +053017696/*
17697 * Below Table describe whether RSO command can be send down to fimrware or not.
17698 * Host check it on the basis of previous RSO command sent down to firmware.
17699||===========================================================================||
17700|| New cmd | LAST SENT COMMAND ---> ||
17701||====|======================================================================||
17702|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
17703|| --------------------------------------------------------------------------||
17704|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017705|| RSO_STOP | YES | NO | YES | YES ||
17706|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053017707|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
17708||===========================================================================||
17709*/
17710
17711#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17712#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17713#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17714#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
17715
17716#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
17717#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053017718 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053017719#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17720 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053017721#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053017722 RSO_START_BIT)
17723
17724tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
17725{
17726 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
17727 tANI_U8 desiredMask = 0;
17728 switch(command)
17729 {
17730 case ROAM_SCAN_OFFLOAD_START:
17731 desiredMask = RSO_START_ALLOW_MASK;
17732 break;
17733 case ROAM_SCAN_OFFLOAD_STOP:
17734 desiredMask = RSO_STOP_ALLOW_MASK;
17735 break;
17736 case ROAM_SCAN_OFFLOAD_RESTART:
17737 desiredMask = RSO_RESTART_ALLOW_MASK;
17738 break;
17739 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17740 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17741 break;
17742 default:
17743 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17744 FL("Wrong RSO command %d, not allowed"), command);
17745 return 0;/*Cmd Not allowed*/
17746 }
17747 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
17748}
17749
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017750eCsrBand GetCurrentBand(tANI_U8 channel)
17751{
17752 tSirRFBand Rfband;
17753 eCsrBand band;
17754
17755 Rfband = GetRFBand(channel);
17756
17757 if (Rfband == SIR_BAND_5_GHZ)
17758 band = eCSR_BAND_5G;
17759 else if (Rfband == SIR_BAND_2_4_GHZ)
17760 band = eCSR_BAND_24;
17761 else if (Rfband == SIR_BAND_UNKNOWN)
17762 band = eCSR_BAND_MAX;
17763
17764 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17765 "channel %d Rfband %d band %d", channel, Rfband, band);
17766
17767 return band;
17768}
17769
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017770eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
17771{
17772 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017773 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017774 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017775 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017776 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053017777 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017778 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017779 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017780 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017781 eHalStatus status = eHAL_STATUS_SUCCESS;
17782 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070017783 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017784 tANI_U8 ChannelCacheStr[128] = {0};
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017785 eCsrBand eBand, Rfband = eCSR_BAND_ALL;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017786 tSirBssDescription *pBssDesc = NULL;
17787 tDot11fBeaconIEs *pIes = NULL;
17788 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080017789 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017790
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017791 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
17792
Abhinav Kumarb72f8ce2019-08-07 16:11:54 +053017793 pSession = CSR_GET_SESSION( pMac, sessionId );
17794 if (!pSession) {
17795 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17796 "%s:pSession is null", __func__);
17797 return eHAL_STATUS_FAILURE;
17798 }
17799
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070017800 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017801 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017802 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017803 return eHAL_STATUS_FAILURE;
17804 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017805
17806 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
17807 {
17808 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
17809 return eHAL_STATUS_FAILURE;
17810 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017811
Abhinav Kumarb72f8ce2019-08-07 16:11:54 +053017812 /* Roaming is not supported currently for SAE authentication */
17813 if (pSession->pCurRoamProfile &&
17814 CSR_IS_AUTH_TYPE_SAE(pSession->pCurRoamProfile->AuthType.authType[0])) {
17815 smsLog(pMac, LOGE, "Roaming not suppprted for SAE connection");
17816 return eHAL_STATUS_SUCCESS;
17817 }
17818
Abhinav Kumara70b3cf2019-07-22 15:13:06 +053017819 /* Roaming is not supported currently for OWE akm */
17820 if (pSession->pCurRoamProfile &&
17821 (pSession->pCurRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_OWE))
17822 {
17823 smsLog(pMac, LOGE, "Roaming not suppprted for OWE connection");
17824 return eHAL_STATUS_SUCCESS;
17825 }
17826
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017827 /*The Dynamic Config Items Update may happen even if the state is in INIT.
17828 * It is important to ensure that the command is passed down to the FW only
17829 * if the Infra Station is in a connected state.A connected station could also be
17830 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
17831 * We also have to ensure that if there is a STOP command we always have to inform Riva,
17832 * irrespective of whichever state we are in.*/
17833 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17834 (command != ROAM_SCAN_OFFLOAD_STOP))
17835 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053017836 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17837 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
17838 macTraceGetNeighbourRoamState(
17839 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017840 return eHAL_STATUS_FAILURE;
17841 }
17842
Mukul Sharmad68cda62015-03-20 21:25:41 +053017843 if (!CsrIsRSOCommandAllowed(pMac, command))
17844 {
17845 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17846 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
17847 command, pNeighborRoamInfo->lastSentCmd);
17848 return eHAL_STATUS_FAILURE;
17849 }
17850
Abhishek Singh3e915632014-11-01 17:14:50 +053017851 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
17852 * Also there are cases where pNeighborRoamInfo->currAPbssid
17853 * is set to 0 during disconnect and so we might return without stopping
17854 * the roam scan. So no need to find the session if command is
17855 * ROAM_SCAN_OFFLOAD_STOP.
17856 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053017857 status = csrRoamGetSessionIdFromBSSID(pMac,
17858 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
17859 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053017860 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017861 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017862 if ( !HAL_STATUS_SUCCESS( status ) )
17863 {
17864 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17865 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
17866 return eHAL_STATUS_FAILURE;
17867 }
Abhishek Singh3e915632014-11-01 17:14:50 +053017868 pBssDesc = pSession->pConnectBssDesc;
17869 if (pBssDesc == NULL)
17870 {
17871 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17872 "%s: pBssDesc not found for current session", __func__);
17873 return eHAL_STATUS_FAILURE;
17874 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053017875
17876 operationChannel = pSession->connectedProfile.operationChannel;
17877 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
17878 "operationChannel %d", operationChannel);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017879 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017880 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
17881 if (NULL == pRequestBuf)
17882 {
Abhishek Singh3e915632014-11-01 17:14:50 +053017883 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17884 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
17885 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017886 }
17887
Sushant Kaushikb97a0082015-08-31 12:36:45 +053017888#ifdef FEATURE_WLAN_DIAG_SUPPORT
17889 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
17890 eSIR_SUCCESS, eSIR_SUCCESS);
17891#endif
17892
Abhishek Singh3e915632014-11-01 17:14:50 +053017893 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
17894 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
17895 * host driver reloads, but Riva still up and running*/
17896 pRequestBuf->Command = command;
17897 if(command == ROAM_SCAN_OFFLOAD_STOP)
17898 {
17899 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053017900 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053017901 /*For a STOP Command, there is no need to
17902 * go through filling up all the below parameters
17903 * since they are not required for the STOP command*/
17904 goto send_roam_scan_offload_cmd;
17905 }
17906 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017907 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053017908 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
17909 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017910 sizeof(tCsrBssid));
17911 pRequestBuf->ConnectedNetwork.ssId.length =
17912 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
17913 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
17914 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
17915 pRequestBuf->ConnectedNetwork.ssId.length);
17916 pRequestBuf->ConnectedNetwork.authentication =
17917 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17918 pRequestBuf->ConnectedNetwork.encryption =
17919 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
17920 pRequestBuf->ConnectedNetwork.mcencryption =
17921 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017922 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
17923 {
17924 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017925 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017926 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
17927 }
17928 else
17929 {
17930 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017931
17932 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
17933 {
17934 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17935 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
17936 vos_mem_free(pRequestBuf);
17937 return eHAL_STATUS_FAILURE;
17938 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017939 if(NULL == pIes)
17940 {
17941 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17942 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053017943 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053017944 return eHAL_STATUS_FAILURE;
17945 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017946 if (pIes->SuppRates.present)
17947 {
17948 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
17949 /*Check for both basic rates and extended rates.*/
17950 for (i = 0; i < pIes->SuppRates.num_rates; i++)
17951 {
17952 /*Check if the Rate is Mandatory or Not*/
17953 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
17954 && (pIes->SuppRates.rates[i] & 0x80))
17955 {
17956 /*Retrieve the actual data rate*/
17957 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
17958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17959 if (minRate == 0)
17960 minRate = dataRate;
17961 else
17962 minRate = (minRate < dataRate) ? minRate:dataRate;
17963 }
17964 }
17965
17966 if (pIes->ExtSuppRates.present)
17967 {
17968 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
17969 {
17970 /*Check if the Rate is Mandatory or Not*/
17971 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
17972 && (pIes->ExtSuppRates.rates[i] & 0x80))
17973 {
17974 /*Retrieve the actual data rate*/
17975 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
17976 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
17977 if (minRate == 0)
17978 minRate = dataRate;
17979 else
17980 minRate = (minRate < dataRate) ? minRate:dataRate;
17981 }
17982 }
17983 }
17984 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
17985 }
17986 else
17987 {
17988 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17989 "%s: Supp Rates not present in pIes", __func__);
17990 vos_mem_free(pRequestBuf);
17991 return eHAL_STATUS_FAILURE;
17992 }
17993 if (NULL != pIes)
17994 {
17995 vos_mem_free(pIes);
17996 pIes = NULL;
17997 }
17998 switch (minRate)
17999 {
18000 case 1:
18001 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
18002 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
18003 break;
18004 case 2:
18005 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
18006 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
18007 break;
18008 case 5:
18009 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
18010 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
18011 break;
18012 case 6:
18013 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
18014 {
18015 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
18016 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
18017 }
18018 else
18019 {
18020 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
18021 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
18022 }
18023 break;
18024 case 11:
18025 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
18026 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
18027 break;
18028 case 12:
18029 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
18030 {
18031 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
18032 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
18033 }
18034 else
18035 {
18036 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
18037 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
18038 }
18039 break;
18040 case 24:
18041 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
18042 {
18043 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
18044 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
18045 }
18046 else
18047 {
18048 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
18049 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
18050 }
18051 break;
18052 default:
18053 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
18054 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
18055 break;
18056 }
18057 }
18058 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18059 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
18060 operationChannel, minRate,
18061 pRequestBuf->RxSensitivityThreshold,
18062 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018063 pRequestBuf->RoamRssiDiff =
18064 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018065 pRequestBuf->StartScanReason = reason;
18066 pRequestBuf->NeighborScanTimerPeriod =
18067 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
18068 pRequestBuf->NeighborRoamScanRefreshPeriod =
18069 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
18070 pRequestBuf->NeighborScanChannelMinTime =
18071 pNeighborRoamInfo->cfgParams.minChannelScanTime;
18072 pRequestBuf->NeighborScanChannelMaxTime =
18073 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
18074 pRequestBuf->EmptyRefreshScanPeriod =
18075 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080018076 /* MAWC feature */
18077 pRequestBuf->MAWCEnabled =
18078 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018079
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018080#ifdef FEATURE_WLAN_ESE
18081 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018082#endif
18083 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018084#ifdef FEATURE_WLAN_ESE
18085 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018086 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
18087 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018088 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
18089#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018090 currChannelListInfo->numOfChannels == 0)
18091 {
18092
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018093 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
18094 * Give Preference to INI Channels.*/
18095 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
18096 {
18097 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
18098 /*The INI channels need to be filtered with respect to the current
18099 * band that is supported.*/
18100 eBand = pMac->roam.configParam.bandCapability;
18101 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018102 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018103 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18104 "Invalid band, No operation carried out (Band %d)", eBand);
18105 vos_mem_free(pRequestBuf);
18106 return eHAL_STATUS_FAILURE;
18107 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018108
18109 if (pMac->roam.configParam.nRoamIntraBand)
18110 {
18111 eBand = GetCurrentBand(operationChannel);
18112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18113 "Current Band %d", eBand);
18114 }
18115
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018116 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
18117 {
18118 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18119 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18120 (eCSR_BAND_ALL == eBand))
18121 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018122 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
18123 ((pMac->roam.configParam.allowDFSChannelRoam) ||
18124 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
18125 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018126 {
18127 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
18128 }
18129 }
18130 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018131 }
18132 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18133 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018134 }
18135 else
18136 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018137 ChannelList = pMac->scan.occupiedChannels.channelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018138
18139 if (pMac->roam.configParam.nRoamIntraBand)
18140 {
18141 Rfband = GetCurrentBand(operationChannel);
18142 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18143 "Current Band %d", Rfband);
18144 }
18145
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018146 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
18147 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018148 if(((eCSR_BAND_24 == Rfband) &&
18149 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18150 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18151 || (eCSR_BAND_ALL == Rfband))
18152 {
18153 /* Allow DFS channels only if the DFS channel roam flag is
18154 * enabled
18155 */
18156 if(*ChannelList && ((pMac->roam.configParam.
18157 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList)))
18158 && (num_channels < SIR_ROAM_MAX_CHANNELS))
18159 {
18160 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++]
18161 = *ChannelList;
18162 }
18163 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018164 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018165 }
18166 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
18167 /* If the profile changes as to what it was earlier, inform the FW through
18168 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
18169 * for the earlier profile and try to learn them afresh.*/
18170 if (reason == REASON_FLUSH_CHANNEL_LIST)
18171 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18172 else {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018173 if ((csrNeighborRoamIsNewConnectedProfile(pMac)) ||
18174 (pMac->roam.configParam.nRoamIntraBand))
18175 pRequestBuf->ChannelCacheType =
18176 CHANNEL_LIST_DYNAMIC_INIT;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018177 else
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018178 pRequestBuf->ChannelCacheType =
18179 CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018180 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018181 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018182 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018183#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018184 else
18185 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018186 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018187 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018188 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018189 if (currChannelListInfo->numOfChannels != 0)
18190 {
18191 ChannelList = currChannelListInfo->ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018192
18193 if (pMac->roam.configParam.nRoamIntraBand)
18194 {
18195 Rfband = GetCurrentBand(operationChannel);
18196 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
18197 "Current Band %d", Rfband);
18198 }
18199
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018200 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018201 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018202 if(((eCSR_BAND_24 == Rfband) &&
18203 CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18204 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList))
18205 || (eCSR_BAND_ALL == Rfband))
18206 {
18207 if(*ChannelList && ((pMac->roam.configParam.
18208 allowDFSChannelRoam) || (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18209 {
18210 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018211 *ChannelList;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018212 }
18213 }
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018214 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018215 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018216 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018217 if (pMac->roam.configParam.nRoamIntraBand)
18218 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18219 else
18220 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018221 }
18222 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018223#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053018224 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
18225 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018226 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018227 if (j < sizeof(ChannelCacheStr))
18228 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018229 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
18230 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053018231 }
18232 else
18233 {
18234 break;
18235 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070018236 }
18237 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18238 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
18239 pRequestBuf->ChannelCacheType,
18240 pRequestBuf->ConnectedNetwork.ChannelCount,
18241 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018242 num_channels = 0;
18243 ChannelList = NULL;
18244
18245 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070018246 host_channels = sizeof(pMac->roam.validChannelList);
18247 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018248 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070018249 ChannelList = pMac->roam.validChannelList;
18250 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018251 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018252 else
18253 {
18254 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18255 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070018256 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070018257 return eHAL_STATUS_FAILURE;
18258 }
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018259
18260 if (pMac->roam.configParam.nRoamIntraBand)
18261 {
18262 Rfband = GetCurrentBand(operationChannel);
18263 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Current Band %d",
18264 Rfband);
18265 }
18266
Srinivas Girigowda56076852013-08-20 14:00:50 -070018267 for(i=0; i<pMac->roam.numValidChannels; i++)
18268 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018269 if(((eCSR_BAND_24 == Rfband) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
18270 ((eCSR_BAND_5G == Rfband) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
18271 (eCSR_BAND_ALL == Rfband))
Srinivas Girigowda56076852013-08-20 14:00:50 -070018272 {
Nishank Aggarwal54f40012017-05-08 18:47:07 +053018273 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
18274 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
18275 {
18276 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
18277 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070018278 }
18279 ChannelList++;
18280 }
18281 pRequestBuf->ValidChannelCount = num_channels;
18282
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018283 pRequestBuf->MDID.mdiePresent =
18284 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
18285 pRequestBuf->MDID.mobilityDomain =
18286 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018287 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
18288
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018289 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080018290 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18291 * where RFS is the RF Switching time. It is twice RFS to consider the
18292 * time to go off channel and return to the home channel. */
18293 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
18294 {
18295 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
18296 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
18297 " Hence enforcing home away time to disable (0)",
18298 __func__, pRequestBuf->HomeAwayTime,
18299 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18300 pRequestBuf->HomeAwayTime = 0;
18301 }
18302 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070018303
Sreelakshmi Konamki70bfdaf2017-05-29 18:47:29 +053018304 pRequestBuf->WeakZoneRssiThresholdForRoam =
18305 pMac->roam.configParam.neighborRoamConfig.nWeakZoneRssiThresholdForRoam;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018306 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
18307 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
18308 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
18309 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18310 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
18311
18312 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
18313 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080018314send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070018315 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018316 msg.reserved = 0;
18317 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053018318 MTRACE(vos_trace(VOS_MODULE_ID_SME,
18319 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018320 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
18321 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018322 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
18323 vos_mem_free(pRequestBuf);
18324 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018325 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018326 else
18327 {
18328 if (ROAM_SCAN_OFFLOAD_START == command)
18329 bRoamScanOffloadStarted = VOS_TRUE;
18330 else if (ROAM_SCAN_OFFLOAD_STOP == command)
18331 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053018332
18333 /*update the last sent cmd*/
18334 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070018335 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018336
18337 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 +053018338
18339 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053018340 (command != ROAM_SCAN_OFFLOAD_STOP) &&
18341 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053018342 {
18343
18344 /* PER ROAM SCAN */
18345 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
18346 if (!PERRoamReqBuf)
18347 {
18348 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18349 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
18350 return eHAL_STATUS_FAILURE;
18351 }
18352 /* PER Roam Config */
18353 PERRoamReqBuf->rateUpThreshold =
18354 pMac->roam.configParam.rateUpThreshold;
18355 PERRoamReqBuf->rateDownThreshold =
18356 pMac->roam.configParam.rateDownThreshold;
18357 PERRoamReqBuf->waitPeriodForNextPERScan =
18358 pMac->roam.configParam.waitPeriodForNextPERScan;
18359 PERRoamReqBuf->PERtimerThreshold =
18360 pMac->roam.configParam.PERtimerThreshold;
18361 PERRoamReqBuf->isPERRoamCCAEnabled =
18362 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053018363 PERRoamReqBuf->PERRoamFullScanThreshold =
18364 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053018365 PERRoamReqBuf->PERroamTriggerPercent =
18366 pMac->roam.configParam.PERroamTriggerPercent;
18367 PERRoamReqBuf->sessionId = sessionId;
18368
18369 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
18370 PERroamScanConfigMsg.reserved = 0;
18371 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
18372 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
18373 &PERroamScanConfigMsg))) {
18374 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
18375 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
18376 vos_mem_free(PERRoamReqBuf);
18377 return eHAL_STATUS_FAILURE;
18378 }
18379 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
18380 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
18381 PERRoamReqBuf->rateUpThreshold,
18382 PERRoamReqBuf->rateDownThreshold,
18383 PERRoamReqBuf->waitPeriodForNextPERScan,
18384 PERRoamReqBuf->PERtimerThreshold);
18385 }
18386
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018387 return status;
18388}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018389
18390eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
18391{
18392 switch(reason)
18393 {
18394 case 0:
18395 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
18396 break;
18397 case REASON_OS_REQUESTED_ROAMING_NOW:
18398 csrNeighborRoamProceedWithHandoffReq(pMac);
18399 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053018400 case REASON_INITIAL_FORCED_ROAM_TO_5G:
18401 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
18402 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018403 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070018404 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 -070018405 }
18406 return eHAL_STATUS_SUCCESS;
18407}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018408#endif
18409
Jeff Johnson295189b2012-06-20 16:38:30 -070018410tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
18411 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
18412{
18413 tANI_BOOLEAN found = FALSE;
18414 eHalStatus status = eHAL_STATUS_SUCCESS;
18415 tCsrPeStatsReqInfo staEntry;
18416 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
18417 tListElem *pStaEntry = NULL;
18418 VOS_STATUS vosStatus;
18419 tPmcPowerState powerState;
18420 *pFound = FALSE;
18421
18422 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
18423 if(pStaEntry)
18424 {
18425 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
18426 if(pTempStaEntry->periodicity)
18427 {
18428 pTempStaEntry->periodicity =
18429 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
18430 }
18431 else
18432 {
18433 pTempStaEntry->periodicity = periodicity;
18434 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018435 pTempStaEntry->numClient++;
18436 found = TRUE;
18437 }
18438 else
18439 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018440 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070018441 staEntry.numClient = 1;
18442 staEntry.periodicity = periodicity;
18443 staEntry.pMac = pMac;
18444 staEntry.rspPending = FALSE;
18445 staEntry.staId = staId;
18446 staEntry.statsMask = statsMask;
18447 staEntry.timerRunning = FALSE;
18448 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
18449 if(!pTempStaEntry)
18450 {
18451 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018452 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070018453 return NULL;
18454 }
18455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018456 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
18457 if(ePMC_FULL_POWER == powerState)
18458 {
18459 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
18460 {
18461 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
18462 }
18463 }
18464 else
18465 {
18466 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
18467 {
18468 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
18469 }
18470 }
18471 if(!pTempStaEntry->timerRunning)
18472 {
18473 //send down a req in case of one time req, for periodic ones wait for timer to expire
18474 if(!pTempStaEntry->rspPending &&
18475 !pTempStaEntry->periodicity)
18476 {
18477 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
18478 if(!HAL_STATUS_SUCCESS(status))
18479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018480 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018481 }
18482 else
18483 {
18484 pTempStaEntry->rspPending = TRUE;
18485 }
18486 }
18487 if(pTempStaEntry->periodicity)
18488 {
18489 if(!found)
18490 {
18491
18492 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
18493 csrRoamPeStatsTimerHandler, pTempStaEntry );
18494 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018496 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018497 return NULL;
18498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018499 }
18500 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018501 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070018502 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
18503 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018505 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018506 return NULL;
18507 }
18508 pTempStaEntry->timerRunning = TRUE;
18509 }
18510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018511 *pFound = found;
18512 return pTempStaEntry;
18513}
18514
Jeff Johnson295189b2012-06-20 16:38:30 -070018515/*
18516 pStaEntry is no longer invalid upon the return of this function.
18517*/
18518static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
18519{
18520 if(pEntry)
18521 {
18522 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
18523 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018524 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070018525 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018526 }
18527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018528
18529void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
18530{
18531 tListElem *pEntry;
18532 tCsrPeStatsReqInfo *pTempStaEntry;
18533 VOS_STATUS vosStatus;
18534 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018535 if(!pEntry)
18536 {
18537 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018538 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018539 return;
18540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018541 while( pEntry )
18542 {
18543 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018544 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
18545 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018546 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018547 if(pTempStaEntry->timerRunning)
18548 {
18549 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
18550 /* If we are not able to stop the timer here, just remove
18551 * the entry from the linked list. Destroy the timer object
18552 * and free the memory in the timer CB
18553 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018554 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070018555 {
18556 /* the timer is successfully stopped */
18557 pTempStaEntry->timerRunning = FALSE;
18558
18559 /* Destroy the timer */
18560 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
18561 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018563 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018564 }
18565 }
18566 else
18567 {
18568 // the timer could not be stopped. Hence destroy and free the
18569 // memory for the PE stat entry in the timer CB.
18570 pTempStaEntry->timerStopFailed = TRUE;
18571 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018573
18574 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
18575 {
18576 // Only free the memory if we could stop the timer successfully
18577 if(!pTempStaEntry->timerStopFailed)
18578 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018579 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070018580 pTempStaEntry = NULL;
18581 }
18582 break;
18583 }
18584
18585 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
18586 }
18587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018588 return;
18589}
18590
18591
Jeff Johnsone7245742012-09-05 17:12:55 -070018592void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070018593{
18594
Jeff Johnsone7245742012-09-05 17:12:55 -070018595 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
18596 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
18597 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
18598 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
18599 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
18600 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
18601 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070018602 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018603 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
18604 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
18605 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
18606 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
18607 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
18608 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018609 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070018610 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
18611 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070018612
18613}
18614
Jeff Johnson295189b2012-06-20 16:38:30 -070018615void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
18616 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
18617{
18618 tANI_U8 stats[500];
18619 tANI_U8 *pStats = NULL;
18620 tANI_U32 tempMask = 0;
18621 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018622 if(!callback)
18623 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018624 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018625 return;
18626 }
18627 if(!statsMask)
18628 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018629 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018630 return;
18631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018632 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070018633 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070018634 while(tempMask)
18635 {
18636 if(tempMask & 1)
18637 {
18638 //new stats info from PE, fill up the stats strucutres in PMAC
18639 switch(counter)
18640 {
18641 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018642 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018643 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
18644 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018645 pStats += sizeof(tCsrSummaryStatsInfo);
18646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018647 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018648 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018649 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
18650 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018651 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018653 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018654 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018655 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
18656 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018657 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018658 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018659 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018660 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018661 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
18662 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018663 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018664 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018665 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018666 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018667 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
18668 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018669 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018670 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018671 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018672 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053018673 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
18674 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070018675 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070018676 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053018677 case eCsrPerPktStats:
18678 smsLog( pMac, LOG2, FL("PerPkt stats"));
18679 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
18680 sizeof(tPerTxPacketFrmFw));
18681 pStats += sizeof(tPerTxPacketFrmFw);
18682 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018683 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018684 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070018685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018686 }
18687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018688 tempMask >>=1;
18689 counter++;
18690 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018691 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070018692}
18693
Jeff Johnson295189b2012-06-20 16:38:30 -070018694eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
18695{
18696 tListElem *pEntry = NULL;
18697 tListElem *pPrevEntry = NULL;
18698 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
18699 eHalStatus status = eHAL_STATUS_SUCCESS;
18700 VOS_STATUS vosStatus;
18701 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070018702 if(!pEntry)
18703 {
18704 //list empty
18705 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018706 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070018707 return status;
18708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018709 while( pEntry )
18710 {
18711 if(pPrevEntry)
18712 {
18713 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18714 //send up the stats report
18715 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18716 pTempStaEntry->staId, pTempStaEntry->pContext);
18717 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18718 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018719 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070018720 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
18721 {
Jeff Johnsone7245742012-09-05 17:12:55 -070018722 pTempStaEntry->pPeStaEntry->numClient--;
18723 //check if we need to delete the entry from peStatsReqList too
18724 if(!pTempStaEntry->pPeStaEntry->numClient)
18725 {
18726 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
18727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018729 //check if we need to stop the tl stats timer too
18730 pMac->roam.tlStatsReqInfo.numClient--;
18731 if(!pMac->roam.tlStatsReqInfo.numClient)
18732 {
18733 if(pMac->roam.tlStatsReqInfo.timerRunning)
18734 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018735 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
18736 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018738 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070018739 //we will continue
18740 }
18741 }
18742 pMac->roam.tlStatsReqInfo.periodicity = 0;
18743 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
18744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018745 if (pTempStaEntry->periodicity)
18746 {
18747 //While creating StaEntry in csrGetStatistics,
18748 //Initializing and starting timer only when periodicity is set.
18749 //So Stop and Destroy timer only when periodicity is set.
18750
Jeff Johnsone7245742012-09-05 17:12:55 -070018751 vos_timer_stop( &pTempStaEntry->timer );
18752 // Destroy the vos timer...
18753 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
18754 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
18755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018756 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070018757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018758 }
Jeff Johnsone7245742012-09-05 17:12:55 -070018759
Jeff Johnson295189b2012-06-20 16:38:30 -070018760
18761 pPrevEntry = pEntry;
18762 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
18763 }
18764 //the last one
18765 if(pPrevEntry)
18766 {
18767 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
18768 //send up the stats report
18769 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
18770 pTempStaEntry->staId, pTempStaEntry->pContext);
18771 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
18772 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018773 return status;
18774
18775}
18776
Jeff Johnson295189b2012-06-20 16:38:30 -070018777eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
18778 tRequestFullPowerReason *pReason,
18779 tANI_BOOLEAN *pfNeedPower )
18780{
18781 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18782 tRequestFullPowerReason reason = eSME_REASON_OTHER;
18783 tPmcState pmcState;
18784 eHalStatus status = eHAL_STATUS_SUCCESS;
18785 // TODO : Session info unavailable
18786 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070018787 if( pfNeedPower )
18788 {
18789 *pfNeedPower = eANI_BOOLEAN_FALSE;
18790 }
18791 //We only handle CSR commands
18792 if( !(eSmeCsrCommandMask & pCommand->command) )
18793 {
18794 return eHAL_STATUS_SUCCESS;
18795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018796 //Check PMC state first
18797 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018798 switch( pmcState )
18799 {
18800 case REQUEST_IMPS:
18801 case IMPS:
18802 if( eSmeCommandScan == pCommand->command )
18803 {
18804 switch( pCommand->u.scanCmd.reason )
18805 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018806#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18807 case eCsrScanGetLfrResult:
18808#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018809 case eCsrScanGetResult:
18810 case eCsrScanBGScanAbort:
18811 case eCsrScanBGScanEnable:
18812 case eCsrScanGetScanChnInfo:
18813 //Internal process, no need for full power
18814 fNeedFullPower = eANI_BOOLEAN_FALSE;
18815 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018816 default:
18817 //Other scans are real scan, ask for power
18818 fNeedFullPower = eANI_BOOLEAN_TRUE;
18819 break;
18820 } //switch
18821 }
18822 else
18823 {
18824 //ask for power for roam and status change
18825 fNeedFullPower = eANI_BOOLEAN_TRUE;
18826 }
18827 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018828 case REQUEST_BMPS:
18829 case BMPS:
18830 case REQUEST_START_UAPSD:
18831 case UAPSD:
18832 //We treat WOWL same as BMPS
18833 case REQUEST_ENTER_WOWL:
18834 case WOWL:
18835 if( eSmeCommandRoam == pCommand->command )
18836 {
18837 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
18838 tCsrScanResult *pScanResult;
18839 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070018840 switch ( pCommand->u.roamCmd.roamReason )
18841 {
18842 case eCsrForcedDisassoc:
18843 case eCsrForcedDisassocMICFailure:
18844 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18845 fNeedFullPower = eANI_BOOLEAN_TRUE;
18846 break;
18847 case eCsrSmeIssuedDisassocForHandoff:
18848 case eCsrForcedDeauth:
18849 case eCsrHddIssuedReassocToSameAP:
18850 case eCsrSmeIssuedReassocToSameAP:
18851 fNeedFullPower = eANI_BOOLEAN_TRUE;
18852 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018853 case eCsrCapsChange:
18854 fNeedFullPower = eANI_BOOLEAN_TRUE;
18855 break;
Kapil Guptad7690482017-01-10 16:21:35 +053018856 case eCsrForcedDisassocSta:
18857 case eCsrForcedDeauthSta:
18858 fNeedFullPower = eANI_BOOLEAN_FALSE;
18859 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018860 default:
18861 //Check whether the profile is already connected. If so, no need for full power
18862 //Note: IBSS is ignored for now because we don't support powersave in IBSS
18863 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
18864 {
18865 //Only need to check the first one
18866 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
18867 if( pEntry )
18868 {
18869 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
18870#if 0
18871 // TODO : Session Specific info pConnectBssDesc
18872 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
18873 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
18874 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
18875 {
18876 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
18877 // with Authenticating first. To force this, stop the current association (Disassociate) and
18878 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
18879 // a new Association.
18880 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
18881 {
18882 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
18883 {
18884 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
18885 //No need for full power
18886 //Set the flag so the code later can avoid to do the above
18887 //check again.
18888 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
18889 break;
18890 }
18891 }
18892 }
18893#endif
18894 }
18895 }
18896 //If we are here, full power is needed
18897 fNeedFullPower = eANI_BOOLEAN_TRUE;
18898 break;
18899 }
18900 }
18901 else if( eSmeCommandWmStatusChange == pCommand->command )
18902 {
18903 //need full power for all
18904 fNeedFullPower = eANI_BOOLEAN_TRUE;
18905 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
18906 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080018907#ifdef FEATURE_WLAN_TDLS
18908 else if( eSmeCommandTdlsAddPeer == pCommand->command )
18909 {
18910 //TDLS link is getting established. need full power
18911 fNeedFullPower = eANI_BOOLEAN_TRUE;
18912 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
18913 }
18914#endif
mukul sharmabab477d2015-06-11 17:14:55 +053018915 else if (eSmeCommandDelStaSession == pCommand->command)
18916 {
18917 //need full power for all
18918 fNeedFullPower = eANI_BOOLEAN_TRUE;
18919 }
18920
Jeff Johnson295189b2012-06-20 16:38:30 -070018921 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018922 case REQUEST_STOP_UAPSD:
18923 case REQUEST_EXIT_WOWL:
18924 if( eSmeCommandRoam == pCommand->command )
18925 {
18926 fNeedFullPower = eANI_BOOLEAN_TRUE;
18927 switch ( pCommand->u.roamCmd.roamReason )
18928 {
18929 case eCsrForcedDisassoc:
18930 case eCsrForcedDisassocMICFailure:
18931 reason = eSME_LINK_DISCONNECTED_BY_HDD;
18932 break;
18933 default:
18934 break;
18935 }
18936 }
18937 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018938 case STOPPED:
18939 case REQUEST_STANDBY:
18940 case STANDBY:
18941 case LOW_POWER:
18942 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053018943 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
18944 " stopped/standby state %s (%d)" ),
18945 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070018946 status = eHAL_STATUS_FAILURE;
18947 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018948 case FULL_POWER:
18949 case REQUEST_FULL_POWER:
18950 default:
18951 //No need to ask for full power. This has to be FULL_POWER state
18952 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070018953 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070018954 if( pReason )
18955 {
18956 *pReason = reason;
18957 }
18958 if( pfNeedPower )
18959 {
18960 *pfNeedPower = fNeedFullPower;
18961 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018962 return ( status );
18963}
18964
Jeff Johnson295189b2012-06-20 16:38:30 -070018965static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
18966{
18967 eHalStatus status = eHAL_STATUS_SUCCESS;
18968 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
18969 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070018970 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070018971 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
18972 {
18973 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
18974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018975 return ( status );
18976}
18977
Jeff Johnson295189b2012-06-20 16:38:30 -070018978tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
18979{
18980 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070018981 if( pCmd )
18982 {
18983 pMac->roam.sPendingCommands++;
18984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018985 return ( pCmd );
18986}
18987
Jeff Johnson295189b2012-06-20 16:38:30 -070018988void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18989{
18990 if (pMac->roam.sPendingCommands > 0)
18991 {
18992 //All command allocated through csrGetCommandBuffer need to
18993 //decrement the pending count when releasing.
18994 pMac->roam.sPendingCommands--;
18995 smeReleaseCommand( pMac, pCommand );
18996 }
18997 else
18998 {
18999 smsLog(pMac, LOGE, FL( "no pending commands"));
19000 VOS_ASSERT(0);
19001 }
19002}
19003
Jeff Johnson295189b2012-06-20 16:38:30 -070019004//Return SUCCESS is the command is queued, failed
19005eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
19006{
19007 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053019008
19009 if (!SME_IS_START(pMac))
19010 {
19011 smsLog( pMac, LOGE, FL("Sme in stop state"));
19012 return eHAL_STATUS_FAILURE;
19013 }
19014
Jeff Johnson295189b2012-06-20 16:38:30 -070019015 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
19016 {
19017 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
19018 pCommand->u.scanCmd.reason);
19019 return eHAL_STATUS_CSR_WRONG_STATE;
19020 }
19021
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019022 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
19023 {
19024 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
19025 &pCommand->Link, LL_ACCESS_LOCK);
19026 // process the command queue...
19027 smeProcessPendingQueue(pMac);
19028 status = eHAL_STATUS_SUCCESS;
19029 goto end;
19030 }
19031
Jeff Johnson295189b2012-06-20 16:38:30 -070019032 //We can call request full power first before putting the command into pending Q
19033 //because we are holding SME lock at this point.
19034 status = csrRequestFullPower( pMac, pCommand );
19035 if( HAL_STATUS_SUCCESS( status ) )
19036 {
19037 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070019038 //make sure roamCmdPendingList is not empty first
19039 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
19040 if( fNoCmdPending )
19041 {
19042 smePushCommand( pMac, pCommand, fHighPriority );
19043 }
19044 else
19045 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019046 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070019047 //no list lock is needed since SME lock is held
19048 if( !fHighPriority )
19049 {
19050 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19051 }
19052 else {
19053 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19054 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019056 }
19057 else if( eHAL_STATUS_PMC_PENDING == status )
19058 {
19059 //no list lock is needed since SME lock is held
19060 if( !fHighPriority )
19061 {
19062 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19063 }
19064 else {
19065 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
19066 }
19067 //Let caller know the command is queue
19068 status = eHAL_STATUS_SUCCESS;
19069 }
19070 else
19071 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019072 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070019073 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019074 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070019075 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053019076end:
Jeff Johnson295189b2012-06-20 16:38:30 -070019077 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070019078}
Jeff Johnson295189b2012-06-20 16:38:30 -070019079eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
19080{
19081 eHalStatus status = eHAL_STATUS_SUCCESS;
19082 tSirUpdateAPWPSIEsReq *pMsg;
19083 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
19084
19085 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19086 if (NULL == pSession)
19087 {
19088 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
19089 return eHAL_STATUS_FAILURE;
19090 }
19091
Jeff Johnson295189b2012-06-20 16:38:30 -070019092 do
19093 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019094 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
19095 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19096 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070019097 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
19098
19099 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070019100 VOS_ASSERT(pBuf);
19101
Jeff Johnson295189b2012-06-20 16:38:30 -070019102 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070019103 // transactionId
19104 *pBuf = 0;
19105 *( pBuf + 1 ) = 0;
19106 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070019107 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019108 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19109 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019110 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019111 //sessionId
19112 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019113 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019114 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070019115 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070019116 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019117 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019118 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019119 return ( status );
19120}
Jeff Johnson295189b2012-06-20 16:38:30 -070019121eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
19122{
19123 eHalStatus status = eHAL_STATUS_SUCCESS;
19124 tSirUpdateAPWPARSNIEsReq *pMsg;
19125 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070019126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19127 if (NULL == pSession)
19128 {
19129 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
19130 return eHAL_STATUS_FAILURE;
19131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019132 do
19133 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019134 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
19135 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19136 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070019137 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070019138 pBuf = (tANI_U8 *)&pMsg->transactionId;
19139 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070019140 // transactionId
19141 *pBuf = 0;
19142 *( pBuf + 1 ) = 0;
19143 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070019144 VOS_ASSERT(pBuf);
19145
Jeff Johnson295189b2012-06-20 16:38:30 -070019146 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053019147 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
19148 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019149 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070019150 // sessionId
19151 *pBuf++ = (tANI_U8)sessionId;
19152
19153 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053019154 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070019155 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070019156 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070019157 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070019158 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070019159 return ( status );
19160}
Jeff Johnson295189b2012-06-20 16:38:30 -070019161
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019162tANI_U32 csrGetdot11Mode(tHalHandle hHal, tANI_U32 sessionId,
19163 tpSirBssDescription pBssDescription)
19164{
19165 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19166 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19167 eCsrCfgDot11Mode uCfgDot11Mode, cfgDot11Mode;
19168 eHalStatus status;
19169 tDot11fBeaconIEs *ies_local = NULL;
19170 tANI_U32 dot11mode = 0;
19171
19172 smsLog(pMac, LOG1, FL("phyMode %d"), pSession->pCurRoamProfile->phyMode);
19173
19174 /* Get IE's */
19175 status = csrGetParsedBssDescriptionIEs(pMac, pBssDescription, &ies_local);
19176 if (!HAL_STATUS_SUCCESS(status)) {
19177 smsLog(pMac, LOGE,
19178 FL("csrGetParsedBssDescriptionIEs failed"));
19179 return 0;
19180 }
19181 if(ies_local == NULL) {
19182 smsLog(pMac, LOGE,
19183 FL("ies_local is NULL"));
19184 return 0;
19185 }
19186
19187 if(csrIsPhyModeMatch(pMac, pSession->pCurRoamProfile->phyMode,
19188 pBssDescription, pSession->pCurRoamProfile, &cfgDot11Mode, ies_local))
19189 uCfgDot11Mode = cfgDot11Mode;
19190 else
19191 {
19192 smsLog(pMac, LOGE, "Can not find match phy mode");
19193 if(CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId))
19194 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
19195 else
19196 uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
19197 }
19198
19199 /* dot11mode */
19200 dot11mode = csrTranslateToWNICfgDot11Mode(pMac, uCfgDot11Mode);
19201 smsLog(pMac, LOG1,
19202 FL("dot11mode %d uCfgDot11Mode %d"), dot11mode, uCfgDot11Mode);
19203
19204 if (pBssDescription->channelId <= 14 &&
19205 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
19206 WNI_CFG_DOT11_MODE_11AC == dot11mode)
19207 {
19208 /* Need to disable VHT operation in 2.4 GHz band */
19209 dot11mode = WNI_CFG_DOT11_MODE_11N;
19210 }
19211 vos_mem_free(ies_local);
19212 return dot11mode;
19213}
19214
Jeff Johnson295189b2012-06-20 16:38:30 -070019215#ifdef WLAN_FEATURE_VOWIFI_11R
19216//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
19217eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
19218{
19219 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19220 tpSirFTPreAuthReq pftPreAuthReq;
19221 tANI_U16 auth_req_len = 0;
19222 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019223 auth_req_len = sizeof(tSirFTPreAuthReq);
19224 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053019225 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070019226 {
19227 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
19228 return eHAL_STATUS_RESOURCES;
19229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019230 // Save the SME Session ID here. We need it while processing the preauth response
19231 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070019232 vos_mem_zero(pftPreAuthReq, auth_req_len);
19233
19234 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
19235 sizeof(pBssDescription->length) + pBssDescription->length);
19236
19237 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
19238
19239 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +053019240 pftPreAuthReq->dot11mode =
19241 csrGetdot11Mode(hHal, sessionId, pBssDescription);
19242 if (!pftPreAuthReq->dot11mode)
19243 {
19244 smsLog(pMac, LOGE, FL("pftPreAuthReq->dot11mode is zero"));
19245 vos_mem_free(pftPreAuthReq);
19246 return eHAL_STATUS_FAILURE;
19247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019248
Kiet Lam64c1b492013-07-12 13:56:44 +053019249 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
19250 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
19251 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
19252 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070019253
Jeff Johnson295189b2012-06-20 16:38:30 -070019254#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080019255 if (csrRoamIs11rAssoc(pMac) &&
19256 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070019257 {
19258 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053019259 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
19260 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070019261 }
19262 else
19263#endif
19264 {
19265 pftPreAuthReq->ft_ies_length = 0;
19266 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070019267 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
19268 sizeof(pBssDescription->length) + pBssDescription->length);
19269 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070019270 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
19271}
Jeff Johnson295189b2012-06-20 16:38:30 -070019272/*--------------------------------------------------------------------------
19273 * This will receive and process the FT Pre Auth Rsp from the current
19274 * associated ap.
19275 *
19276 * This will invoke the hdd call back. This is so that hdd can now
19277 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
19278 ------------------------------------------------------------------------*/
19279void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
19280{
19281 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
19282 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019283#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019284 tCsrRoamInfo roamInfo;
19285#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019286 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070019287
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019288#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080019289 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019290 if (status != eHAL_STATUS_SUCCESS) {
19291 /*
19292 * Bail out if pre-auth was not even processed.
19293 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053019294 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
19295 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070019296 return;
19297 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019299 /* The below function calls/timers should be invoked only if the pre-auth is successful */
19300 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
19301 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070019302 // Implies a success
19303 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070019304 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
19305 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053019306 /* No need to notify qos module if this is a non 11r & ESE roam*/
19307 if (csrRoamIs11rAssoc(pMac)
19308#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
19309 || csrRoamIsESEAssoc(pMac)
19310#endif
19311 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070019312 {
19313 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
19314 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053019315 if (pMac->roam.configParam.roamDelayStatsEnabled)
19316 {
19317 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
19318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019319 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
19320 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019321 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
19322 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053019323 if (pMac->roam.configParam.roamDelayStatsEnabled)
19324 {
19325 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
19326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019327 if (eHAL_STATUS_SUCCESS != status)
19328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019329 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019330 return;
19331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070019332 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019333 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
19334 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070019335 if (csrRoamIs11rAssoc(pMac))
19336 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
19337 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
19338
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019339#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
19340 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019341 {
19342 /* read TSF */
19343 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
19344
19345 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080019346 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019347 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
19348 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019349#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019350#ifdef FEATURE_WLAN_LFR
19351 // If Legacy Fast Roaming is enabled, signal the supplicant
19352 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053019353 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019354 {
19355 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053019356 vos_mem_copy((void *)&roamInfo.bssid,
19357 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070019358 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
19359 }
19360
19361#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070019362
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019363 // If its an Open Auth, FT IEs are not provided by supplicant
19364 // Hence populate them here
19365 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
19366 pMac->ft.ftSmeContext.addMDIE = FALSE;
19367 if( csrRoamIs11rAssoc(pMac) &&
19368 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
19369 {
19370 tANI_U16 ft_ies_length;
19371 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
19372
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019373 if (pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].
19374 connectedProfile.MDID.mdiePresent)
19375 pMac->ft.ftSmeContext.addMDIE = TRUE;
19376
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019377 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
19378 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
19379 {
19380 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
19381 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
19382 }
19383
Sreelakshmi Konamki099089f2017-04-17 11:45:37 +053019384 if (!ft_ies_length)
19385 {
19386 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19387 return;
19388 }
19389
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019390 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
19391 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
19392 {
19393 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
19394 }
19395 else
19396 {
19397 // Copy the RIC IEs to reassoc IEs
19398 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
19399 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
19400 pFTPreAuthRsp->ric_ies_length);
19401 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
19402 pMac->ft.ftSmeContext.addMDIE = TRUE;
19403 }
19404 }
19405
Jeff Johnson295189b2012-06-20 16:38:30 -070019406 // Done with it, init it.
19407 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
19408}
19409#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053019410
Jeff Johnson295189b2012-06-20 16:38:30 -070019411#ifdef FEATURE_WLAN_BTAMP_UT_RF
19412void csrRoamJoinRetryTimerHandler(void *pv)
19413{
19414 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
19415 tpAniSirGlobal pMac = pInfo->pMac;
19416 tANI_U32 sessionId = pInfo->sessionId;
19417 tCsrRoamSession *pSession;
19418
19419 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019421 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070019422 pSession = CSR_GET_SESSION( pMac, sessionId );
19423 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
19424 {
19425 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
19426 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019427 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070019428 }
19429 }
19430 }
19431}
Jeff Johnson295189b2012-06-20 16:38:30 -070019432eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
19433{
19434 eHalStatus status = eHAL_STATUS_FAILURE;
19435 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
19436
19437 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
19438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019439 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070019440 pSession->maxRetryCount--;
19441 pSession->joinRetryTimerInfo.pMac = pMac;
19442 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019443 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
19444 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070019445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019446 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070019447 }
19448 }
19449 else
19450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019451 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070019452 pSession->maxRetryCount);
19453 }
19454
19455 return (status);
19456}
Jeff Johnson295189b2012-06-20 16:38:30 -070019457eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
19458{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080019459 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070019460 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
19461 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053019462 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070019463 }
19464
19465 return eHAL_STATUS_SUCCESS;
19466}
19467#endif
19468
19469
19470/*
19471 pBuf points to the beginning of the message
19472 LIM packs disassoc rsp as below,
19473 messageType - 2 bytes
19474 messageLength - 2 bytes
19475 sessionId - 1 byte
19476 transactionId - 2 bytes (tANI_U16)
19477 reasonCode - 4 bytes (sizeof(tSirResultCodes))
19478 peerMacAddr - 6 bytes
19479 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
19480*/
19481static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
19482{
19483 if(pBuf && pRsp)
19484 {
19485 pBuf += 4; //skip type and length
19486 pRsp->sessionId = *pBuf++;
19487 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
19488 pBuf += 2;
19489 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
19490 pBuf += 4;
19491 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
19492 }
19493}
19494
Jeff Johnsond13512a2012-07-17 11:42:19 -070019495eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19496{
19497 static uNvTables nvTables;
19498 eHalStatus status = eHAL_STATUS_SUCCESS;
19499 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
19500
19501 /* read the country code from NV and use it */
19502 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
19503 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019504 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
19505 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019506 return status;
19507 }
19508 else
19509 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019510 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019511 status = eHAL_STATUS_FAILURE;
19512 return status;
19513 }
19514}
19515
19516eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
19517{
Kiet Lam64c1b492013-07-12 13:56:44 +053019518 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070019519 return eHAL_STATUS_SUCCESS;
19520}
schang86c22c42013-03-13 18:41:24 -070019521
19522eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
19523{
19524 tSirSetTxPowerReq *pMsg = NULL;
19525 eHalStatus status = eHAL_STATUS_SUCCESS;
19526 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19527
19528 if (!pSession)
19529 {
19530 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19531 return eHAL_STATUS_FAILURE;
19532 }
19533
Kiet Lam64c1b492013-07-12 13:56:44 +053019534 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
19535 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
19536 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
19537 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
19538 pMsg->length = sizeof(tSirSetTxPowerReq);
19539 pMsg->mwPower = mW;
19540 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
19541 sizeof(tSirMacAddr));
19542 status = palSendMBMessage(pMac->hHdd, pMsg);
19543 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070019544 {
Kiet Lam64c1b492013-07-12 13:56:44 +053019545 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
19546 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070019547 }
19548 return status;
19549}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019550
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019551eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
19552{
19553 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
19554 eHalStatus status = eHAL_STATUS_SUCCESS;
19555 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19556
19557 if (!pSession)
19558 {
19559 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19560 return eHAL_STATUS_FAILURE;
19561 }
19562 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
19563 {
19564 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053019565
19566 if( NULL == pMsg )
19567 {
19568 smsLog(pMac, LOGE, FL("PMsg is NULL "));
19569 return eHAL_STATUS_FAILURE;
19570 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019571 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
19572 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019573 pMsg->length =
19574 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019575 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053019576 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
19577 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053019578 status = palSendMBMessage(pMac->hHdd, pMsg);
19579 if (!HAL_STATUS_SUCCESS(status))
19580 {
19581 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
19582 //pMsg is freed by palSendMBMessage
19583 }
19584 }
19585 else
19586 {
19587 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
19588 status = eHAL_STATUS_FAILURE;
19589 }
19590 return status;
19591}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070019592/* Returns whether a session is in VOS_STA_MODE...or not */
19593tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
19594{
19595 tCsrRoamSession *pSession = NULL;
19596 pSession = CSR_GET_SESSION ( pMac, sessionId );
19597 if(!pSession)
19598 {
19599 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
19600 return eANI_BOOLEAN_FALSE;
19601 }
19602 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
19603 {
19604 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
19605 return eANI_BOOLEAN_FALSE;
19606 }
19607 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
19608 {
19609 return eANI_BOOLEAN_FALSE;
19610 }
19611 /* There is a possibility that the above check may fail,because
19612 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
19613 * when it is connected.So,we may sneak through the above check even
19614 * if we are not a STA mode INFRA station. So, if we sneak through
19615 * the above condition, we can use the following check if we are
19616 * really in STA Mode.*/
19617
19618 if ( NULL != pSession->pCurRoamProfile )
19619 {
19620 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
19621 {
19622 return eANI_BOOLEAN_TRUE;
19623 } else {
19624 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
19625 return eANI_BOOLEAN_FALSE;
19626 }
19627 }
19628
19629 return eANI_BOOLEAN_FALSE;
19630}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019631
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019632/**
19633 * csr_set_src_handoff_request() - Set handoff source to
19634 * SME handoff request
19635 * @pHandoffInfo: Pointer to Handoff info
19636 * @pMsg: Pointer to SME handoff request message
19637 *
19638 * Return: None
19639 */
19640#ifndef QCA_WIFI_ISOC
19641static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19642 tCsrHandoffRequest *pHandoffInfo)
19643{
19644 pMsg->handoff_src = pHandoffInfo->src;
19645}
19646#else
19647static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
19648 tCsrHandoffRequest *pHandoffInfo)
19649{
19650}
19651#endif
19652
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019653#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
19654eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
19655 tCsrHandoffRequest *pHandoffInfo)
19656{
19657 eHalStatus status = eHAL_STATUS_SUCCESS;
19658 vos_msg_t msg;
19659
19660 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053019661 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
19662 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019663 {
19664 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019665 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019666 }
19667 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
19668 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
19669 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
19670 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053019671 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053019672 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019673 pHandoffInfo->bssid,
19674 6);
19675 msg.type = eWNI_SME_HANDOFF_REQ;
19676 msg.bodyptr = pMsg;
19677 msg.reserved = 0;
19678 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
19679 {
19680 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053019681 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070019682 status = eHAL_STATUS_FAILURE;
19683 }
19684 return status;
19685}
19686#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019687
Abhishek Singh00b71972016-01-07 10:51:04 +053019688#ifdef WLAN_FEATURE_RMC
19689eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19690{
19691 tSirSetRMCReq *pMsg = NULL;
19692 eHalStatus status = eHAL_STATUS_SUCCESS;
19693 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19694
19695 if (!pSession)
19696 {
19697 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19698 return eHAL_STATUS_FAILURE;
19699 }
19700
19701 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19702 if (NULL != pMsg)
19703 {
19704 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19705 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
19706 pMsg->msgLen = sizeof(tSirSetRMCReq);
19707 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19708 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19709
19710 status = palSendMBMessage(pMac->hHdd, pMsg);
19711 if (!HAL_STATUS_SUCCESS(status))
19712 {
19713 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
19714 //pMsg is freed by palSendMBMessage
19715 }
19716 }
19717 else
19718 {
19719 return eHAL_STATUS_FAILURE;
19720 }
19721 return status;
19722}
19723
19724eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
19725{
19726 tSirSetRMCReq *pMsg = NULL;
19727 eHalStatus status = eHAL_STATUS_SUCCESS;
19728 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19729
19730 if (!pSession)
19731 {
19732 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19733 return eHAL_STATUS_FAILURE;
19734 }
19735
19736 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
19737 if (NULL != pMsg)
19738 {
19739 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
19740 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
19741 pMsg->msgLen = sizeof(tSirSetRMCReq);
19742 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
19743 &pSession->selfMacAddr, sizeof(tSirMacAddr));
19744
19745 status = palSendMBMessage(pMac->hHdd, pMsg);
19746 if (!HAL_STATUS_SUCCESS(status))
19747 {
19748 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
19749 //pMsg is freed by palSendMBMessage
19750 }
19751 }
19752 else
19753 {
19754 return eHAL_STATUS_FAILURE;
19755 }
19756 return status;
19757}
19758
19759#endif /* WLAN_FEATURE_RMC */
19760
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019761
19762#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019763/* ---------------------------------------------------------------------------
19764 \fn csrSetCCKMIe
19765 \brief This function stores the CCKM IE passed by the supplicant in a place holder
19766 data structure and this IE will be packed inside reassociation request
19767 \param pMac - pMac global structure
19768 \param sessionId - Current session id
19769 \param pCckmIe - pointer to CCKM IE data
19770 \param ccKmIeLen - length of the CCKM IE
19771 \- return Success or failure
19772 -------------------------------------------------------------------------*/
19773VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
19774 const tANI_U8 *pCckmIe,
19775 const tANI_U8 ccKmIeLen)
19776{
19777 eHalStatus status = eHAL_STATUS_SUCCESS;
19778 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
19779
19780 if (!pSession)
19781 {
19782 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
19783 return eHAL_STATUS_FAILURE;
19784 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053019785 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019786 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
19787 return status;
19788}
19789
19790/* ---------------------------------------------------------------------------
19791 \fn csrRoamReadTSF
19792 \brief This function reads the TSF; and also add the time elapsed since last beacon or
19793 probe response reception from the hand off AP to arrive at the latest TSF value.
19794 \param pMac - pMac global structure
19795 \param pTimestamp - output TSF timestamp
19796 \- return Success or failure
19797 -------------------------------------------------------------------------*/
19798VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
19799{
19800 eHalStatus status = eHAL_STATUS_SUCCESS;
19801 tCsrNeighborRoamBSSInfo handoffNode;
19802 tANI_U32 timer_diff = 0;
19803 tANI_U32 timeStamp[2];
19804 tpSirBssDescription pBssDescription = NULL;
19805
19806 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
19807 pBssDescription = handoffNode.pBssDescription;
19808
19809 // Get the time diff in milli seconds
19810 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
19811 // Convert msec to micro sec timer
19812 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
19813
19814 timeStamp[0] = pBssDescription->timeStamp[0];
19815 timeStamp[1] = pBssDescription->timeStamp[1];
19816
19817 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
19818
Kiet Lamf2f201e2013-11-16 21:24:16 +053019819 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019820 sizeof (tANI_U32) * 2);
19821 return status;
19822}
19823
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080019824#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070019825
Agarwal Ashish738843c2014-09-25 12:27:56 +053019826/* ---------------------------------------------------------------------------
19827 \fn csrDisableDfsChannel
19828 \brief This function will call csrApplyChannelPowerCountryInfo to
19829 \ to trim the list on basis of NO_DFS flag.
19830 \param pMac - pMac global structure
19831 \- return void
19832 -------------------------------------------------------------------------*/
19833void csrDisableDfsChannel(tpAniSirGlobal pMac)
19834{
19835 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
19836 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
19837}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019838
19839/* ---------------------------------------------------------------------------
19840 \fn csrGetStaticUapsdMask
19841 \brief This function will get the static uapsd settings for an existing
19842 \ Infra session.
19843 \param pMac - pMac global structure
19844 \- return void
19845 -------------------------------------------------------------------------*/
19846void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
19847{
19848 tANI_S8 sessionId;
19849 tCsrRoamSession *pSession = NULL;
19850
19851 *staticUapsdMask = 0;
19852 sessionId = csrGetInfraSessionId(pMac);
19853 if(sessionId == -1)
19854 smsLog(pMac, LOGE, FL("Valid session not present."));
19855 else
19856 pSession = CSR_GET_SESSION(pMac, sessionId);
19857
19858 if(!pSession || !pSession->pCurRoamProfile)
19859 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
Jeff Johnson89477502017-09-19 08:35:23 -070019860 " pSession:%pK"), pSession);
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053019861 else
19862 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
19863}
19864
Abhishek Singh02605092017-10-25 14:06:12 +053019865VOS_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19866 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode)
19867{
19868 VOS_STATUS status = VOS_STATUS_SUCCESS;
19869 struct sir_ecsa_ie_req *msg;
19870
19871 msg = vos_mem_malloc(sizeof(*msg));
19872 if (!msg) {
19873 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19874 return VOS_STATUS_E_NOMEM;
19875 }
19876
19877 msg->type = eWNI_SME_SET_CHAN_SW_IE_REQ;
19878 msg->len = sizeof(*msg);
19879
19880 msg->new_chan = new_chan;
19881 msg->cb_mode = cb_mode;
19882 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19883
19884 status = palSendMBMessage(mac_ctx->hHdd, msg);
19885 if (!VOS_IS_STATUS_SUCCESS(status))
19886 smsLog(mac_ctx, LOGE,
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019887 FL(" channel switch IE req failed status %d "), status);
Abhishek Singh02605092017-10-25 14:06:12 +053019888 return status;
19889}
19890
Abhishek Singh550aa8c2017-10-30 17:34:53 +053019891VOS_STATUS csr_roam_channel_change_req(tpAniSirGlobal mac_ctx,
19892 tCsrBssid bssid, uint8_t new_chan, uint8_t cb_mode, tCsrRoamProfile *profile)
19893{
19894 VOS_STATUS status = VOS_STATUS_SUCCESS;
19895 struct sir_channel_chanege_req *msg;
19896 tCsrRoamStartBssParams param;
19897
19898 vos_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
19899
19900 csrRoamGetBssStartParms(mac_ctx, profile, &param);
19901
19902 msg = vos_mem_malloc(sizeof(*msg));
19903 if (!msg) {
19904 smsLog(mac_ctx, LOGE, FL(" Memory alloc failed "));
19905 return VOS_STATUS_E_NOMEM;
19906 }
19907
19908 msg->type = eWNI_SME_ECSA_CHAN_CHANGE_REQ;
19909 msg->len = sizeof(*msg);
19910
19911 msg->new_chan = new_chan;
19912 msg->cb_mode = cb_mode;
19913 vos_mem_copy(msg->bssid, bssid, VOS_MAC_ADDR_SIZE);
19914 msg->dot11mode = csrTranslateToWNICfgDot11Mode(mac_ctx,
19915 mac_ctx->roam.configParam.uCfgDot11Mode);
19916 if (IS_24G_CH(msg->new_chan) &&
19917 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
19918 (WNI_CFG_DOT11_MODE_11AC == msg->dot11mode ||
19919 WNI_CFG_DOT11_MODE_11AC_ONLY == msg->dot11mode))
19920 msg->dot11mode = WNI_CFG_DOT11_MODE_11N;
19921
19922 vos_mem_copy(&msg->operational_rateset,
19923 &param.operationalRateSet, sizeof(msg->operational_rateset));
19924 vos_mem_copy(&msg->extended_rateset,
19925 &param.extendedRateSet, sizeof(msg->extended_rateset));
19926
19927 status = palSendMBMessage(mac_ctx->hHdd, msg);
19928 if (!VOS_IS_STATUS_SUCCESS(status))
19929 smsLog(mac_ctx, LOGE,
19930 FL(" channel switch req fauiled status %d "), status);
19931 return status;
19932}